/* ==========================================================================
   Bergland — "alpine dusk / topographic field guide"
   Night sky over layered ridgelines, contour-map texture, enamel-sign buttons,
   and a cable-car ticket for the room code.
   ========================================================================== */

@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/space-grotesk-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/space-grotesk-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('/fonts/space-mono-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  /* sky */
  --night-0: #060c14;
  --night-1: #0a1424;
  --night-2: #0d1e33;

  /* surfaces */
  --surface:   #101d2e;
  --surface-2: #16273d;
  --line:      #24405f;
  --line-soft: #1a2e46;

  /* ink */
  --text:  #e9f2fc;
  --muted: #8ba3bf;
  --dim:   #7d93ae;   /* lightened to clear 4.5:1 on the night sky at 11px */

  /* accents */
  --amber:      #ffb703;   /* lantern glow — primary action */
  --amber-deep: #c98703;
  --glacier:    #5fd3c4;   /* meltwater — positive */
  --alpenglow:  #ff6b5e;   /* last light on rock — danger / the spy */

  --sans: 'Space Grotesk', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 14px;
  --pad: clamp(16px, 4.5vw, 28px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night-1);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

/* --- the landscape: contour map in the sky, ridgeline on the horizon ------ */
/* Both are position:fixed elements rather than background-attachment:fixed,
   which iOS Safari handles badly. Earlier layers paint on top, so the contour
   map is listed before the sky gradient it sits on. */
body::before,
body::after {
  content: '';
  position: fixed;
  pointer-events: none;
  z-index: 0;
}
body::before {
  inset: 0;
  background:
    url('/topo.svg') center top / cover no-repeat,
    linear-gradient(180deg, var(--night-0) 0%, var(--night-1) 45%, var(--night-2) 100%);
}
body::after {
  left: 0; right: 0; bottom: 0;
  height: min(48vh, 400px);
  background:
    linear-gradient(180deg, transparent, rgba(6, 12, 20, .45) 72%),
    url('/ridge.svg') center bottom / cover no-repeat;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) var(--pad) calc(48px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: clamp(30px, 8.5vw, 42px); }
h2 { font-size: clamp(22px, 5.5vw, 27px); }
h3 { font-size: 17px; letter-spacing: 0; }
p { margin: 0; }

.muted { color: var(--muted); font-size: 15px; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* Field-guide section label: small caps mono with a rule trailing off. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}
.eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.brand-name {
  font-weight: 700; font-size: 20px; letter-spacing: .04em; text-transform: uppercase;
}
.brand-sub {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--dim); margin-top: 1px;
}

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(22, 39, 61, .9), rgba(16, 29, 46, .9));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(6px);
}
.card-tap {
  display: block; width: 100%; text-align: left;
  color: inherit; font: inherit; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  transition: transform .12s ease, border-color .12s ease;
}
.card-tap:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); border-color: var(--amber); }

.game-card { display: flex; gap: 15px; align-items: flex-start; }
/* Game icon framed like a trail blaze. */
.game-emoji {
  font-size: 24px; line-height: 1; flex: none;
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255, 183, 3, .09);
  border: 1px solid rgba(255, 183, 3, .28);
}
.game-title { font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.game-blurb { color: var(--muted); font-size: 14.5px; margin-top: 4px; }
.game-meta {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--amber); margin-top: 10px;
}

/* ---------- controls ---------- */
button, input { font: inherit; border-radius: 12px; border: 1px solid transparent; }
button { cursor: pointer; font-family: var(--sans); }
button:disabled { opacity: .4; cursor: not-allowed; }

/* Enamel sign: solid colour, hard bottom edge, presses down when tapped. */
.btn {
  background: var(--amber);
  color: #0a1523;
  border: none;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .01em;
  width: 100%;
  box-shadow: 0 3px 0 var(--amber-deep), 0 8px 20px rgba(0, 0, 0, .3);
  transition: transform .1s ease, box-shadow .1s ease;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--amber-deep); }

.btn.secondary {
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.btn.secondary:active:not(:disabled) { box-shadow: 0 0 0 rgba(0, 0, 0, .35); }

.btn.ghost {
  background: transparent; color: var(--muted);
  border: 1px dashed var(--line); box-shadow: none;
}
.btn.ghost:active:not(:disabled) { transform: translateY(2px); }

.btn.danger { background: var(--alpenglow); color: #2a0b08; box-shadow: 0 3px 0 #c2483d, 0 8px 20px rgba(0, 0, 0, .3); }
.btn.danger:active:not(:disabled) { box-shadow: 0 0 0 #c2483d; }

.btn.small { padding: 11px 15px; font-size: 14px; width: auto; }

input[type="text"] {
  background: rgba(6, 12, 20, .6);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 15px 16px;
  width: 100%;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 183, 3, .15);
}
input::placeholder { color: var(--dim); }

.code-input {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .4em;
  text-align: center;
  font-size: 28px;
  padding-left: .4em;
}

label.field { display: flex; flex-direction: column; gap: 8px; }
label.field > span {
  font-family: var(--mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--dim);
}

/* ---------- room code: a cable-car ticket ---------- */
.ticket {
  position: relative;
  background: linear-gradient(180deg, #16293f, #0e1e31);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px 18px;
  text-align: center;
  overflow: hidden;
}
/* dashed inner rule = perforated edge */
.ticket::before {
  content: '';
  position: absolute; inset: 7px;
  border: 1px dashed rgba(255, 183, 3, .22);
  border-radius: 11px;
  pointer-events: none;
}
.ticket .label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .28em;
  text-transform: uppercase; color: var(--amber); opacity: .85;
}
.ticket .code {
  font-family: var(--mono);
  font-size: clamp(42px, 15vw, 62px);
  line-height: 1.1;
  letter-spacing: .22em;
  padding-left: .22em;
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 183, 3, .3);
  margin-top: 2px;
}
.ticket .hint {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim); margin-top: 4px;
}

/* ---------- players ---------- */
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(6, 12, 20, .5);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 15px;
  display: inline-flex; align-items: center; gap: 7px;
}
/* .host is listed last so the crown wins when you are both host and "me". */
.chip.me { border-color: rgba(95, 211, 196, .55); }
.chip.host { border-color: rgba(255, 183, 3, .55); }
.chip.away { opacity: .4; }
.chip .crown { font-size: 11px; }

/* ---------- timer ---------- */
.timer {
  font-family: var(--mono);
  font-size: clamp(46px, 16vw, 66px);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  text-align: center;
  line-height: 1;
  color: #fff;
}
.timer.low { color: var(--alpenglow); }
.bar {
  height: 5px;
  background: rgba(6, 12, 20, .7);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--glacier), var(--amber));
  transition: width .3s linear;
}
.bar.low > i { background: var(--alpenglow); }

/* ---------- role card: a field-guide specimen card ---------- */
.role-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 20px 26px;
  text-align: center;
  background: linear-gradient(180deg, #14283f, #0d1c2e);
  overflow: hidden;
}
.role-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--glacier), var(--amber));
}
/* The spy gets a hazard stripe and alpenglow. */
.role-card.spy {
  background: linear-gradient(180deg, #2c1220, #190c17);
  border-color: rgba(255, 107, 94, .45);
}
.role-card.spy::before {
  background: repeating-linear-gradient(45deg, var(--alpenglow) 0 9px, #35121a 9px 18px);
}
.role-card .kicker {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .24em;
  text-transform: uppercase; color: var(--dim);
}
.role-card .headline {
  font-size: clamp(27px, 8.5vw, 38px);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 10px 0 6px;
}
.role-card .sub { color: var(--muted); font-size: 15px; }

/* sealed until you tap */
.hider { position: relative; }
.hider-veil {
  position: absolute; inset: 0;
  display: grid; place-items: center; align-content: center; gap: 8px;
  background: linear-gradient(180deg, #16273d, #0f1e30);
  border: 1px dashed var(--line);
  border-radius: 16px;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}
.hider-veil strong { font-size: 17px; font-weight: 700; }
.hider-veil .muted {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
}

/* ---------- location checklist ---------- */
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 6px; }
.loc {
  background: rgba(6, 12, 20, .45);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13.5px;
  font-family: var(--sans);
  text-align: left;
  color: var(--text);
}
.loc.struck { opacity: .28; text-decoration: line-through; text-decoration-color: var(--alpenglow); }

/* ---------- answers / voting ---------- */
.answer-btn {
  position: relative;
  width: 100%;
  text-align: left;
  background: linear-gradient(180deg, rgba(22, 39, 61, .85), rgba(16, 29, 46, .85));
  border: 1px solid var(--line-soft);
  color: var(--text);
  padding: 16px;
  font-size: 17px;
  line-height: 1.35;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  transition: transform .1s ease, border-color .1s ease;
}
.answer-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
/* Answers stay fully legible when they can't be tapped — during the reveal, and
   on your own prompt. Dimming them here would hide the actual result. */
.answer-btn:disabled { opacity: 1; cursor: default; }
.answer-btn.chosen { border-color: var(--amber); background: rgba(255, 183, 3, .08); }
.answer-btn.winner { border-color: var(--glacier); background: rgba(95, 211, 196, .08); }
.answer-attr {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--line-soft);
  font-size: 13px; color: var(--muted);
}
.answer-attr .who { font-weight: 700; color: var(--text); }
.votes-pill {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--glacier); white-space: nowrap;
}
.votes-pill.none { color: var(--dim); }

/* ---------- prompt: a trail signpost ---------- */
.prompt-box {
  border-left: 4px solid var(--amber);
  background: linear-gradient(90deg, rgba(255, 183, 3, .1), rgba(255, 183, 3, .02));
  border-radius: 0 14px 14px 0;
  padding: 18px;
  font-size: clamp(19px, 5vw, 23px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* ---------- scores ---------- */
.score-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: rgba(6, 12, 20, .45);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
}
.score-row.first {
  border-color: rgba(255, 183, 3, .5);
  background: rgba(255, 183, 3, .07);
}
/* Amber means "leader", so the unmasked spy gets alpenglow instead. */
.score-row.spy {
  border-color: rgba(255, 107, 94, .55);
  background: rgba(255, 107, 94, .08);
}
.score-row .rank {
  font-family: var(--mono); font-size: 13px; color: var(--dim);
  width: 22px; flex: none; font-variant-numeric: tabular-nums;
}
.score-row .name { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .pts { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(6, 12, 20, .55);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.badge.gold { border-color: rgba(255, 183, 3, .55); color: var(--amber); }

/* ---------- messaging ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--alpenglow);
  color: #2a0b08;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
}

.conn-warn {
  background: rgba(255, 183, 3, .1);
  border: 1px dashed rgba(255, 183, 3, .5);
  color: #ffd775;
  border-radius: 10px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
}

.divider {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

.wait-note {
  color: var(--muted); font-size: 14px; text-align: center;
  font-family: var(--mono); letter-spacing: .06em;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
