/* Dark, warm, torch-lit. Everything is laid out for a phone held one-handed —
   that is how this gets played — and simply gets more room on a laptop. */

:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1e242e;
  --line: #2b3341;
  --ink: #e8eaf0;
  --muted: #97a0b0;
  --gold: #f6c453;
  --gold-dim: #6b5527;
  --danger: #e8654f;
  --safe: #59c39a;
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

/* The UA rule for [hidden] is `display: none`, which loses to any author
   `display:` on the same element — a "hidden" flex panel then stays painted
   forever. Making it !important is the only reliable fix. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b2130 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1.15em; height: 1.15em; vertical-align: -.2em; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.top h1 {
  margin: 0; font-size: 20px; letter-spacing: .04em; font-weight: 650;
  color: var(--gold);
}
.top-right { display: flex; align-items: center; gap: 10px; }

main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 16px; }
.foot { padding: 12px 16px; color: var(--muted); font-size: 12px; text-align: center; }

.card-panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; box-shadow: var(--shadow);
}
.lede { margin: 0 0 14px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }

/* --- controls ------------------------------------------------------------ */

button {
  font: inherit; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  cursor: pointer; transition: transform .06s ease, background .15s ease;
}
button:hover { background: #262e3a; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.primary { background: var(--gold); color: #201a09; border-color: var(--gold); font-weight: 650; }
button.primary:hover { background: #ffd777; }
button.big { flex: 1; padding: 16px; font-size: 17px; }
button.link {
  background: none; border: none; color: var(--muted);
  text-decoration: underline; padding: 4px 2px;
}
button.link:hover { color: var(--ink); background: none; }

.row { display: flex; gap: 10px; margin-top: 12px; }
.field { display: block; margin: 12px 0; color: var(--muted); font-size: 14px; }
input {
  font: inherit; width: 100%; margin-top: 6px; padding: 11px 12px;
  border-radius: 10px; border: 1px solid var(--line);
  background: #0f131a; color: var(--ink);
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.code-input {
  text-transform: uppercase; letter-spacing: .35em; font-size: 20px;
  text-align: center; margin-top: 0;
}
.or { margin: 18px 0 8px; color: var(--muted); font-size: 13px; text-align: center; }
.rules-link { margin: 16px 0 0; font-size: 13px; }
.rules-link a { color: var(--muted); }

.chip {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; font-size: 13px;
  letter-spacing: .18em; color: var(--gold);
}
.code-display {
  font-size: 44px; letter-spacing: .3em; text-align: center; color: var(--gold);
  padding: 10px 0 4px; text-indent: .3em;
}

/* --- lobby / rosters ----------------------------------------------------- */

.room-link {
  text-align: center; font-size: 13px; color: var(--muted);
  word-break: break-all; margin-bottom: 6px;
}
.chip.copyable { cursor: pointer; }
.chip.copyable:hover { color: #ffd777; border-color: var(--gold-dim); }

.roster { list-style: none; padding: 0; margin: 16px 0 0; }
.roster li {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 10px; background: var(--panel-2);
  margin-bottom: 8px;
}
.roster .host { color: var(--gold); font-size: 12px; }
.roster .name { flex: 1; }
.roster .drop { padding: 2px 9px; border-radius: 8px; line-height: 1.4; }

/* Bots are labelled everywhere they appear: a table should never wonder
   whether the explorer that just walked out was a person. */
.tag {
  font-size: 11px; letter-spacing: .04em; color: #9ec7f0;
  border: 1px solid #2f4560; background: #16202c;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
}
.botbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.botbar button { color: #9ec7f0; }

/* --- the five caves ------------------------------------------------------ */

.caves { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 14px; }
.caves li {
  flex: 1; text-align: center; padding: 7px 2px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}
.caves li.done { color: var(--ink); border-color: #3a4757; }
.caves li.now {
  color: #201a09; background: var(--gold); border-color: var(--gold);
  font-weight: 650;
}

/* --- camp + path --------------------------------------------------------- */

.expedition {
  display: flex; gap: 0; align-items: stretch;
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, #141922, #10141b);
}
.camp {
  flex: 0 0 130px; padding: 12px; border-right: 1px solid var(--line);
  background: #12171f;
}
.camp-head { color: var(--gold); font-size: 13px; margin-bottom: 8px; white-space: nowrap; }

.path-wrap { flex: 1; min-width: 0; position: relative; }
.path {
  display: flex; gap: 10px; list-style: none; margin: 0; padding: 12px 12px 20px;
  overflow-x: auto; scroll-behavior: smooth; min-height: 132px;
  align-items: center;
}
.path::-webkit-scrollbar { height: 6px; }
.path::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.cardface {
  flex: 0 0 76px; height: 104px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; position: relative;
  animation: deal .28s ease-out;
}
@keyframes deal {
  from { opacity: 0; transform: translateY(-10px) rotate(-4deg); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .cardface { animation: none; } }

.cardface .val { font-size: 24px; font-weight: 650; }
.cardface .sub { font-size: 11px; color: var(--muted); }
.cardface.treasure { color: var(--gold); border-color: var(--gold-dim); }
.cardface.hazard { color: var(--danger); border-color: #4a2b26; }
.cardface.hazard.fatal { background: #3a1c18; border-color: var(--danger); }
.cardface.relic { color: #b493f0; border-color: #40325e; background: #221c33; }
.cardface.relic.claimed { opacity: .8; }

/* A card that still has gems lying on it is lit; one that has been picked
   clean goes grey. That difference is the only way to see, at a glance, what
   is still waiting on the path for whoever walks out next. */
.cardface.treasure.holding {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(246, 196, 83, .25);
}
.cardface.treasure.spent { opacity: .5; border-color: var(--line); }
.cardface .ground {
  position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; white-space: nowrap; padding: 1px 7px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--gold-dim); color: var(--gold);
}
.cardface.spent .ground { border-color: var(--line); color: var(--muted); }

.incl {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.incl .ico { width: .95em; height: .95em; }
.cardface .ico { width: 30px; height: 30px; }

.path-gems {
  position: absolute; right: 12px; bottom: 8px; font-size: 12px;
  color: var(--gold); background: rgba(13, 15, 20, .8);
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--gold-dim);
}

/* --- who is where -------------------------------------------------------- */

.inside { margin-top: 14px; }
.inside-head {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--gold); font-size: 13px; margin-bottom: 8px;
}
.tokens { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.camp .tokens { flex-direction: column; gap: 6px; }
.tokens li {
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; white-space: nowrap;
}
.tokens li.me { border-color: var(--gold); }
.tokens li.away { opacity: .5; }
/* Two numbers per explorer, and they must never be confused: gold is banked
   and cannot be taken away, the outlined one is what this cave still owns. */
.tokens .gems { color: var(--gold); }
.tokens .risked {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--danger); border: 1px dashed #5c332c; border-radius: 999px;
  padding: 0 6px; font-variant-numeric: tabular-nums;
}
.camp-note { margin: -4px 0 8px; font-size: 11px; }

.risk { font-size: 13px; font-variant-numeric: tabular-nums; }
.risk.none { color: var(--muted); }
.risk.low { color: var(--safe); }
.risk.mid { color: var(--gold); }
.risk.high { color: var(--danger); font-weight: 650; }
.decision .risk { display: block; margin-top: 6px; font-size: 15px; }
.tokens .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--line);
}
.tokens li.decided .dot { background: var(--safe); }

/* --- decisions ----------------------------------------------------------- */

.decision {
  margin-top: 16px; padding: 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
}
.prompt { font-size: 15px; margin-bottom: 4px; }
.prompt .urgent { color: var(--danger); }
#waiting { margin-top: 10px; min-height: 1.2em; }

.hints { margin-top: 10px; text-align: center; color: var(--muted); font-size: 12px; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 1px 6px; margin: 0 1px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--panel-2); color: var(--ink);
  font: inherit; font-size: 11px; line-height: 1.5;
}

.log {
  list-style: none; padding: 0; margin: 16px 0 0;
  font-size: 13px; color: var(--muted);
}
.log li { padding: 3px 0; border-bottom: 1px dashed #1d232d; }
.log li:first-child { color: var(--ink); }

.hazard-track {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  margin-top: 16px; color: var(--muted); font-size: 12px;
}
.hazard-track span { display: inline-flex; align-items: center; gap: 4px; }
.hazard-track .gone { opacity: .3; text-decoration: line-through; }

/* --- overlay ------------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 14, .82);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  z-index: 10;
}
.overlay-inner { max-width: 420px; width: 100%; }
.overlay h2 { margin: 0 0 8px; font-size: 22px; }
.standings { list-style: none; counter-reset: rank; padding: 0; margin: 0 0 6px; }
.standings li {
  counter-increment: rank; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; background: var(--panel-2);
  margin-bottom: 7px;
}
.standings li::before {
  content: counter(rank); color: var(--muted); font-size: 13px;
  min-width: 1.2em; text-align: right;
}
.standings li.me { border: 1px solid var(--gold); }
.standings .name { flex: 1; }
.standings .score { color: var(--gold); font-weight: 650; }

@media (max-width: 560px) {
  .camp { flex: 0 0 104px; padding: 10px 8px; }
  .cardface { flex-basis: 66px; height: 92px; }
  .code-display { font-size: 34px; }
}
