/* Last One — the screens.
   Portrait-first and fixed-height throughout: the play screen never scrolls,
   and the forms scroll inside their own pane rather than moving the page. */

/* -------------------------------------------------------------------- bars */
.topbar {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 9px var(--pad); padding-top: calc(9px + var(--safe-t));
  background: rgba(14,18,10,.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: var(--step-1); }
.brand img { width: 32px; height: 32px; border-radius: 9px; }

/* --------------------------------------------------------------------- home */
.hero { display: grid; gap: 14px; place-items: center; text-align: center; padding: clamp(18px, 5vh, 48px) 0 var(--gap); }
.hero img { width: clamp(84px, 22vw, 124px); height: auto; border-radius: 26px; box-shadow: var(--shadow-lg); }
.hero h1 { font-size: var(--step-4); }
.hero .tagline { color: var(--gold); font-weight: 700; font-size: var(--step-1); }
.hero .blurb { color: var(--ink-soft); max-width: 44ch; }

.choice-grid { display: grid; gap: 12px; }
.choice {
  display: flex; gap: 15px; align-items: center; text-align: start;
  padding: 18px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--line);
  font: inherit; color: inherit; cursor: pointer; width: 100%;
  transition: border-color .16s ease, transform .12s ease, background .16s ease;
}
.choice:hover { border-color: var(--gold); background: var(--bg-raised); }
.choice:active { transform: scale(.99); }
.choice-mark { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; flex: none; background: var(--bg-sunken); border: 1px solid var(--line-strong); color: var(--gold); }
.choice-title { display: block; font-family: var(--font-display); font-size: var(--step-1); }
.choice-sub { display: block; font-size: var(--step--1); color: var(--ink-soft); line-height: 1.4; }

/* -------------------------------------------------------------------- lobby */
.code-plate { text-align: center; }
.code-value {
  font-family: var(--font-display); font-size: clamp(2.6rem, 15vw, 4.4rem);
  letter-spacing: .16em; color: var(--gold); line-height: 1;
  /* A Latin code must not flip inside an RTL document. */
  direction: ltr; unicode-bidi: isolate;
}
.qr-frame { background: #fff; border-radius: var(--radius-lg); padding: 12px; width: min(240px, 62vw); margin-inline: auto; box-shadow: var(--shadow); }
.qr-frame svg { display: block; width: 100%; height: auto; }
.join-url { direction: ltr; unicode-bidi: isolate; word-break: break-all; font-size: var(--step--1); color: var(--ink-soft); }

.tribute-grid { display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.tribute-card { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; }
.tribute-card.is-away { opacity: .45; }
.tribute-card.is-me { border-color: var(--gold); }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--bg-sunken); border: 2px solid var(--line-strong); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 74px; height: 74px; border-width: 3px; }

.sigil-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; }
@media (max-width: 430px) { .sigil-grid { grid-template-columns: repeat(4, 1fr); } }
.sigil-pick { aspect-ratio: 1; border-radius: 13px; display: grid; place-items: center; background: var(--bg-sunken); border: 2px solid var(--line); cursor: pointer; min-height: 46px; }
.sigil-pick[aria-pressed="true"] { border-color: var(--gold); background: rgba(240,185,60,.12); }

/* ================================================================== THE GAME
   One viewport. The map owns everything above the panel; the panel's height is
   driven by what the round is doing, and the map area shrinks to match rather
   than being covered by it — so the whole arena stays visible at all times. */
.play {
  position: absolute; inset: 0;
  --panel-h: 42dvh;
}
.play-map {
  position: absolute; inset: 0 0 var(--panel-h) 0;
  transition: bottom .32s cubic-bezier(.2,.8,.3,1);
}
.play-map .map {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none;
  border-radius: 0; border: none; box-shadow: none;
  background: transparent;
}

/* Floating over the map, not taking space from it. */
.play-top {
  position: absolute; inset-inline: 0; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + var(--safe-t)) 12px 8px;
  background: linear-gradient(180deg, rgba(10,13,7,.92), rgba(10,13,7,0));
  pointer-events: none;
}
.play-top > * { pointer-events: auto; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(14,18,10,.82); backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 6px 12px; font-size: var(--step--1); font-weight: 700;
}
.hud-pill .icon { color: var(--gold); }
.hud-pill.is-danger { color: var(--danger-soft); border-color: rgba(224,82,60,.5); }

/* The panel. Its height is a CSS variable the stage sets, so move / story /
   decide each get exactly the room they need and the map gets the rest. */
.play-panel {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 8;
  height: var(--panel-h);
  background: linear-gradient(180deg, rgba(23,29,16,.97), var(--bg-raised));
  border-top: 1px solid var(--line-strong);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -14px 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
  transition: height .32s cubic-bezier(.2,.8,.3,1);
}
.play[data-stage="move"]   { --panel-h: 20dvh; }
.play[data-stage="story"]  { --panel-h: 34dvh; }
.play[data-stage="decide"] { --panel-h: 52dvh; }
.play[data-stage="ended"]  { --panel-h: 0; }

.panel-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 8px auto 4px; flex: none; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px var(--pad) 12px; }

/* --------------------------------------------------------- decide: the clock */
.decide-head { display: flex; align-items: center; gap: 12px; padding: 2px 0 10px; }
.timer-ring { position: relative; width: 46px; height: 46px; flex: none; }
.timer-ring svg { transform: rotate(-90deg); display: block; }
.timer-ring .track { stroke: var(--line-strong); }
.timer-ring .bar { stroke: var(--gold); transition: stroke-dashoffset .25s linear; }
.timer-ring.is-urgent .bar { stroke: var(--danger); }
.timer-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.action-grid { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .action-grid { grid-template-columns: repeat(3, 1fr); } }
.action-btn {
  display: flex; align-items: center; gap: 10px; text-align: start;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 12px; min-height: 58px;
  font: inherit; color: inherit; cursor: pointer; width: 100%;
  transition: border-color .14s ease, background .14s ease, transform .1s ease;
}
.action-btn:active { transform: scale(.98); }
.action-btn .icon { color: var(--gold); flex: none; }
.action-btn[aria-pressed="true"] { border-color: var(--gold); background: rgba(240,185,60,.14); }
.action-name { display: block; font-weight: 700; font-size: var(--step--1); line-height: 1.25; }
.action-sub { display: block; font-size: .72rem; color: var(--ink-faint); line-height: 1.3; }
.action-group-label { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin: 12px 0 6px; }

.locked-note { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--gold); font-weight: 700; font-size: var(--step--1); padding: 8px 0; }

/* ----------------------------------------------------------- story + status */
.event-card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 15px 17px; display: grid; gap: 10px;
  animation: pop .28s cubic-bezier(.2,1.2,.4,1) both; position: relative; overflow: hidden;
}
.event-card.is-fatal { border-color: rgba(224,82,60,.55); }
.event-card.is-fatal::before { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(224,82,60,.18), transparent 60%); pointer-events: none; }
.event-card.is-mine { border-color: var(--gold); }
.event-text { font-size: var(--step-0); line-height: 1.5; position: relative; }
.event-text b { color: var(--gold); font-weight: 700; }
.event-text .who-2 { color: var(--water); }
.event-text .what { color: var(--gold-soft); }
.event-meta { display: flex; flex-wrap: wrap; gap: 6px; position: relative; }
.event-progress { display: flex; gap: 4px; }
.event-dot { width: 16px; height: 3px; border-radius: 2px; background: var(--line-strong); }
.event-dot.on { background: var(--gold); }

/* Health as three bars, because "2 of 3" is instant and a percentage is not. */
.health-bar { display: inline-flex; gap: 3px; align-items: center; }
.health-pip { width: 16px; height: 6px; border-radius: 2px; background: var(--line-strong); }
.health-pip.on { background: var(--leaf); }
.health-pip.on.hurt { background: var(--gold); }
.health-pip.on.critical { background: var(--danger); }

.status-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cond-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; background: rgba(224,82,60,.14); border: 1px solid rgba(224,82,60,.4); color: var(--danger-soft); font-size: .72rem; font-weight: 700; }
.bag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.bag-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--bg-sunken); border: 1px solid var(--line-strong); font-size: .74rem; font-weight: 700; }
.bag-item .icon { color: var(--gold); }

.fallen-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.fallen-chip { position: relative; filter: grayscale(1); opacity: .6; }
.fallen-chip::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--danger); opacity: .7; }

.projection-banner { display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(240,185,60,.14); border: 1px solid rgba(240,185,60,.4); color: var(--gold-soft); border-radius: var(--radius); padding: 9px 13px; font-size: var(--step--1); font-weight: 700; }

/* ------------------------------------------------------------------ endgame */
.crown-stage { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: var(--pad); overflow-y: auto; }
.crown-stage .trophy { color: var(--gold); filter: drop-shadow(0 0 26px rgba(240,185,60,.4)); animation: float 3.4s ease-in-out infinite; flex: none; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-9px) } }
.winner-plate { background: var(--bg-card); border: 2px solid var(--gold); border-radius: var(--radius-xl); padding: 22px; display: grid; gap: 12px; place-items: center; width: min(400px, 100%); box-shadow: var(--shadow-lg); flex: none; }
.winner-name { font-family: var(--font-display); font-size: var(--step-2); }
.recap-list { display: grid; gap: 7px; width: min(460px, 100%); }
.recap-row { display: flex; align-items: center; gap: 9px; padding: 9px 11px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); font-size: var(--step--1); }
.recap-phase { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); flex: none; }
.star-row { display: flex; gap: 6px; justify-content: center; }
.star-btn { background: none; border: none; cursor: pointer; padding: 6px; color: var(--line-strong); min-width: 44px; min-height: 44px; }
.star-btn.on { color: var(--gold); }

/* --------------------------------------------------------------- field guide */
.legend-grid { display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.legend-item { display: flex; gap: 11px; align-items: flex-start; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; text-align: start; width: 100%; font: inherit; color: inherit; cursor: pointer; }
.legend-item:hover { border-color: var(--gold); }
.legend-swatch { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; border: 1px solid rgba(0,0,0,.35); }
.legend-name { display: block; font-weight: 700; }
.legend-blurb { display: block; font-size: var(--step--1); color: var(--ink-soft); }
.danger-meter { display: inline-flex; gap: 3px; align-items: center; }
.danger-pip { width: 7px; height: 7px; border-radius: 2px; background: var(--line-strong); }
.danger-pip.on { background: var(--danger); }
