:root {
  --bg: #05030e;
  --primary: #00e5ff;
  --secondary: #3d7bff;
  --accent: #ff2bd6;
  --font: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--primary);
  font-family: var(--font);
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

.panel {
  position: fixed;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 88vw);
  padding: 28px 30px 26px;
  background: rgba(5, 3, 14, 0.82);
  border: 1px solid var(--primary);
  border-radius: 10px;
  box-shadow: 0 0 18px color-mix(in srgb, var(--primary) 35%, transparent), inset 0 0 24px color-mix(in srgb, var(--primary) 10%, transparent);
  text-align: center;
  animation: panel-in 0.6s ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.panel h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.18em;
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary);
}
.panel h1 span { color: var(--accent); text-shadow: 0 0 10px var(--accent); padding: 0 0.1em; }

.subtitle {
  margin: 6px 0 22px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--secondary);
}

.panel label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 8px;
}

.panel input[type="time"] {
  font-family: var(--font);
  font-size: 28px;
  padding: 6px 12px;
  background: transparent;
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 60%, transparent);
  border-radius: 6px;
  text-align: center;
  color-scheme: dark;
  outline: none;
}
.panel input[type="time"]:focus { border-color: var(--accent); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent); }

.summary {
  min-height: 18px;
  margin: 14px 0 20px;
  font-size: 12px;
  color: var(--primary);
  opacity: 0.85;
}
.summary.error { color: #ff5577; opacity: 1; }

.panel button {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.25em;
  padding: 12px 30px;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform 0.15s, box-shadow 0.15s;
}
.panel button:hover { transform: translateY(-1px); box-shadow: 0 0 26px var(--accent); }
.panel button:disabled { opacity: 0.35; cursor: default; transform: none; }

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  margin: 0 0 24px;
  text-align: left;
  font-size: 13px;
}
.stats dt { color: var(--secondary); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; align-self: center; }
.stats dd { margin: 0; text-align: right; color: var(--primary); font-weight: 700; }

.debug {
  position: fixed;
  top: 28px;
  right: 7%;
  width: 250px;
  padding: 10px 12px;
  font-size: 11px;
  background: rgba(5, 3, 14, 0.9);
  border: 1px dashed var(--secondary);
  border-radius: 8px;
}
.debug-title { color: var(--secondary); margin-bottom: 8px; letter-spacing: 0.1em; }
.debug-title small { opacity: 0.6; }
.debug-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.debug button {
  font-family: var(--font);
  font-size: 10px;
  padding: 3px 7px;
  background: transparent;
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent);
  border-radius: 4px;
  cursor: pointer;
}
.debug button.active, .debug button:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }

.options {
  position: fixed;
  left: 3%;
  bottom: calc(max(190px, min(290px, 33vh)) + 12px);
  width: 290px;
  padding: 12px 14px 10px;
  background: rgba(5, 3, 14, 0.94);
  border: 1px solid var(--primary);
  border-radius: 8px;
  box-shadow: 0 0 14px color-mix(in srgb, var(--primary) 30%, transparent);
  animation: options-in 0.2s ease-out;
}
@keyframes options-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.options-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--secondary);
}
.options-head button {
  font: inherit;
  font-size: 16px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
}
.option-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 4px;
  font-family: var(--font);
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  cursor: pointer;
}
.option-row:last-child { border-bottom: none; }
.option-row:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.option-label { font-size: 12px; }
.option-label small { display: block; font-size: 10px; opacity: 0.55; margin-top: 2px; }
.switch {
  flex: none;
  position: relative;
  width: 34px;
  height: 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 9px;
  transition: background 0.15s, border-color 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 50%, transparent);
  transition: transform 0.15s, background 0.15s;
}
.option-row[aria-checked="true"] .switch {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.option-row[aria-checked="true"] .switch::after {
  transform: translateX(16px);
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.options-foot { margin: 8px 0 0; font-size: 10px; opacity: 0.5; }
.choice {
  flex: none;
  min-width: 64px;
  padding: 3px 8px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.position { margin: -10px 0 18px; font-size: 11px; line-height: 1.6; color: var(--primary); opacity: 0.8; }
.position b { color: var(--accent); font-weight: 700; }

/* ---------- Carte de la galaxie ---------- */
.galaxy {
  position: fixed;
  inset: 0;
  display: flex;
  background: var(--bg);
  z-index: 20;
  animation: options-in 0.25s ease-out;
}
.galaxy-map { position: relative; flex: 1; min-width: 0; }
#galaxy-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.galaxy-tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.galaxy button, .treasures button {
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 5px 9px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 5px;
  cursor: pointer;
}
.galaxy button:hover:not(:disabled), .treasures button:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.galaxy button:disabled { opacity: 0.4; cursor: default; }
.galaxy button.primary {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
}
.galaxy button.primary:hover:not(:disabled) { background: var(--accent); box-shadow: 0 0 20px var(--accent); }
.galaxy-side {
  flex: none;
  width: 310px;
  padding: 16px 16px 10px;
  overflow-y: auto;
  border-left: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
  background: color-mix(in srgb, var(--bg) 92%, black);
  font-size: 12px;
}
.galaxy-side h2 { margin: 0; font-size: 14px; letter-spacing: 0.16em; color: var(--primary); text-shadow: 0 0 8px var(--primary); }
.galaxy-side h4 { margin: 14px 0 6px; font-size: 10px; letter-spacing: 0.14em; color: var(--secondary); text-transform: uppercase; font-weight: 600; }
.galaxy-sub { margin: 4px 0 12px; font-size: 10px; color: var(--secondary); letter-spacing: 0.05em; }
.galaxy-end { display: flex; align-items: center; justify-content: space-between; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--secondary); margin-bottom: 10px; }
.galaxy-end input {
  font-family: var(--font);
  font-size: 16px;
  padding: 2px 6px;
  background: transparent;
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: 5px;
  color-scheme: dark;
}
.stats.compact { gap: 4px 12px; margin: 0 0 8px; font-size: 12px; }
.stats.compact dt { font-size: 10px; }
.galaxy-status { margin: 0; padding: 6px 8px; font-size: 11px; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 5px; }
.galaxy-status.error { color: #ff5577; border-color: #ff5577; }
.galaxy-route { margin: 0; padding: 0 0 0 22px; max-height: 190px; overflow-y: auto; }
.galaxy-route li { padding: 3px 0; cursor: pointer; color: var(--accent); }
.galaxy-route li.locked { color: var(--primary); opacity: 0.7; }
.galaxy-route li span { display: inline-block; min-width: 110px; }
.galaxy-route li small { font-size: 10px; opacity: 0.75; }
.galaxy-row { display: flex; gap: 6px; margin: 10px 0; }
.galaxy-row button { flex: 1; }
.galaxy-row.main button { padding: 8px 9px; font-size: 11px; }
.galaxy-card { padding: 10px; border: 1px solid color-mix(in srgb, var(--secondary) 45%, transparent); border-radius: 6px; min-height: 60px; }
.galaxy-card h3 { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.1em; color: var(--primary); }
.galaxy-card .meta { margin: 2px 0 6px; font-size: 10px; opacity: 0.8; }
.galaxy-card .meta.accent { color: var(--accent); opacity: 1; }
.galaxy-card button { width: 100%; margin-top: 6px; }
.hint { margin: 0; font-size: 11px; opacity: 0.6; }
.odds { margin: 6px 0; }
.odds-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 6px; font-size: 10px; padding: 1px 0; }
.odds-row i { display: block; height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) calc(var(--k) * 100%), color-mix(in srgb, var(--primary) 12%, transparent) 0); }
.odds-row b { text-align: right; color: var(--primary); }
.galaxy-foot { margin: 8px 0 0; font-size: 9px; opacity: 0.45; }

/* ---------- Trésors ---------- */
.treasures {
  position: fixed;
  inset: 4% 5%;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--bg) 95%, black);
  border: 1px solid var(--primary);
  border-radius: 10px;
  box-shadow: 0 0 22px color-mix(in srgb, var(--primary) 30%, transparent);
  z-index: 25;
  animation: options-in 0.2s ease-out;
}
.treasures header { display: flex; align-items: baseline; gap: 16px; margin-bottom: 10px; }
.treasures h2 { margin: 0; font-size: 16px; letter-spacing: 0.18em; text-shadow: 0 0 8px var(--primary); }
#treasures-count { flex: 1; font-size: 11px; color: var(--secondary); }
#treasures-close { font-size: 16px; padding: 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.chips button.active { color: var(--bg); background: var(--primary); }
.treasure-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
  align-content: start;
}
.treasure {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 8px;
  font-size: 11px;
}
.treasure.rare { border-color: color-mix(in srgb, var(--secondary) 70%, transparent); }
.treasure.legendaire { border-color: var(--accent); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 35%, transparent); }
.treasure.unknown { opacity: 0.45; box-shadow: none; }
.treasure strong { margin-top: 6px; color: var(--primary); }
.treasure small { font-size: 9px; letter-spacing: 0.08em; color: var(--secondary); margin-top: 2px; }
.treasure.legendaire small { color: var(--accent); }
.treasure p { margin: 6px 0 4px; font-size: 10px; opacity: 0.75; line-height: 1.35; }
.treasure .where { opacity: 0.6; }
.treasures, .galaxy { color-scheme: dark; }
.treasure { align-self: start; }

/* ---------- Connexion et compte ---------- */
.auth { top: 40%; z-index: 20; }
.auth form { text-align: left; }
.auth .field {
  width: 100%;
  margin-bottom: 14px;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 15px;
  background: transparent;
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 60%, transparent);
  border-radius: 6px;
  outline: none;
  user-select: text;
}
.auth .field:focus { border-color: var(--accent); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent); }
.auth .summary { text-align: center; margin: 6px 0 16px; }
.auth button[type="submit"] { display: block; width: 100%; }
.panel button.link {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 6px;
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 400;
  color: var(--secondary);
  background: transparent;
  box-shadow: none;
}
.panel button.link:hover { color: var(--accent); box-shadow: none; }

.account { margin-top: 12px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.account-email { display: block; margin-bottom: 8px; font-size: 11px; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; }
.account-row { display: flex; gap: 6px; }
.account-row button {
  flex: 1;
  padding: 6px 4px;
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--primary);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent);
  border-radius: 4px;
  cursor: pointer;
}
.account-row button:hover { border-color: var(--accent); color: var(--accent); }
