/* Visual-only game surface; only meta-controls carry text/icons. */
* { box-sizing: border-box; }
html, body {
  margin: 0; color: #d8dae0;
  font: 14px/1.4 Geist, "Helvetica Neue", Arial, sans-serif;
}
html { background: #f3f5f2; }
body {
  position: relative;
  min-height: 100dvh;
  padding: clamp(24px, 6vh, 64px) 0;
  background-color: #f3f5f2;
  background-image:
    radial-gradient(circle at 76% 18%, rgba(41, 81, 214, .09), transparent 31rem),
    linear-gradient(rgba(18, 23, 32, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 23, 32, .045) 1px, transparent 1px);
  background-size: auto, 72px 72px, 72px 72px;
  background-position: center, center top, center top;
}
body::before {
  content: '';
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 0;
  width: min(82vw, 1080px);
  aspect-ratio: 1.45;
  pointer-events: none;
  background: radial-gradient(ellipse, rgba(41, 81, 214, .14), rgba(38, 52, 78, .07) 42%, transparent 72%);
  filter: blur(32px);
  transform: translate(-50%, -50%) scale(1);
  animation: ambient-breathe 12s ease-in-out infinite alternate;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitchTiles'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
#app {
  position: relative;
  z-index: 2;
  max-width: 820px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(18, 23, 32, .18);
  border-radius: 20px;
  background:
    radial-gradient(circle at 86% 0, rgba(41, 81, 214, .10), transparent 34%),
    rgba(251, 252, 250, .82);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, .72),
    0 30px 72px rgba(38, 52, 78, .15),
    0 8px 22px rgba(38, 52, 78, .08);
  backdrop-filter: blur(18px) saturate(112%);
}
@keyframes ambient-breathe {
  to { opacity: .72; transform: translate(-50%, -50%) scale(1.045); }
}

@media (max-width: 860px) {
  body { padding: 14px 0; }
  #app { border-radius: 14px; box-shadow: 0 22px 52px rgba(38, 52, 78, .15); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

.ctl { display: flex; align-items: center; gap: 4px; font-size: 16px; }
select {
  background: #1a1c22; color: #d8dae0; border: 1px solid #333;
  border-radius: 6px; padding: 4px 6px; font-size: 13px;
}
#startBtn {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 7;
  display: grid;
  gap: 3px;
  min-width: 248px;
  padding: 14px 22px 13px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 12px;
  background: #f4f7ff;
  color: #101725;
  box-shadow: 0 14px 34px rgba(5, 11, 24, .34), inset 0 1px #fff;
  cursor: pointer;
  transition: transform .25s ease, background .25s ease, box-shadow .25s ease;
}
#startBtn[hidden] { display: none; }
#startBtn > span { font-size: 15px; font-weight: 750; letter-spacing: -.01em; }
#startBtn small { color: #5b6472; font-size: 11px; font-weight: 550; }
#startBtn:hover {
  transform: translateX(-50%) translateY(-3px);
  background: #fff;
  box-shadow: 0 18px 42px rgba(5, 11, 24, .42), inset 0 1px #fff;
}
#startBtn:focus-visible { outline: 3px solid #7ea5ff; outline-offset: 3px; }

/* online lobby controls (meta only; never display a rule) */
#hostBtn, #joinBtn, #joinGoBtn {
  background: #1a1c22; color: #cfe0ff; border: 1px solid #2a6df4;
  border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer;
}
#hostBtn:hover, #joinBtn:hover, #joinGoBtn:hover { background: #1f2a44; }
.netstat {
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: #16181e; border: 1px solid #2a2d36; color: #9aa0ac;
}
#lobby {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0; padding: 8px 10px; border-radius: 8px;
  background: #16181e; border: 1px solid #2a2d36; font-size: 12px;
  color: #9aa0ac;
}
#lobby code {
  background: #0e0f13; color: #cfe0ff; padding: 2px 8px; border-radius: 6px;
  font-size: 13px; letter-spacing: .5px; user-select: all;
}
#joinCode {
  background: #1a1c22; color: #d8dae0; border: 1px solid #333;
  border-radius: 6px; padding: 4px 6px; font-size: 12px; width: 200px;
}

/* STAGE PIPS — text-free: each .step renders a pure ICON via ::after (no labels).
   demo = play-triangle, play = 4-dot party, report = checkmark. .on lights the active
   stage; .done greens a completed stage (same state classes as before). */
#steps { display: flex; gap: 8px; margin: 12px 0; }
.step {
  flex: 1; text-align: center; padding: 6px; border-radius: 6px;
  background: #16181e; color: #555; font-size: 14px; line-height: 1; border: 1px solid #222;
}
.step::after { content: ''; }
.step[data-k="demo"]::after   { content: '\25B6'; }   /* ▶ play-triangle (demo) */
.step[data-k="play"]::after   { content: '\2237'; }   /* ∷ four-dot party (play) */
.step[data-k="report"]::after { content: '\2713'; }   /* ✓ checkmark (report) */
.step.on { background: #1f2a44; color: #cfe0ff; border-color: #2a6df4; }
.step.done { color: #6fbf73; }

/* VISUAL META-RAIL canvas: a single thin row of pure-visual widgets (cycle pips /
   depth rung-ladder / pursuit+deference bars / survival heart-pips / penalty flash-tick),
   all drawn by updatePanel. No text. */
#metarail {
  display: block; width: 100%; max-width: 540px;
  margin: 0 0 10px; border-radius: 8px;
  background: #16181e; border: 1px solid #2a2d36;
}

/* skippable HOW-TO / intro card (matches the lobby card style). */
#helpBtn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 6;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(207, 224, 255, .3);
  border-radius: 50%;
  background: rgba(17, 21, 29, .74);
  color: #dce7ff;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
#helpBtn:hover { background: #202a40; border-color: #7ea5ff; transform: translateY(-2px); }
/* #readguide (the readout screen's legend) rides EVERY #howto rule rather than copying them:
   cards that are supposed to look identical drift apart the moment they have two rulesets. */
#howto, #readguide {
  position: relative; margin: 10px 0; padding: 12px 14px;
  border-radius: 8px; background: #16181e; border: 1px solid #2a3a5a;
  font-size: 13px; color: #c2c8d2;
}
#howto.hidden, #readguide.hidden { display: none; }
#howto .howto-title, #readguide .howto-title {
  font-weight: 600; color: #cfe0ff; margin-bottom: 8px; font-size: 13px;
}
#howto .howto-body, #readguide .howto-body { margin: 0; padding-left: 20px; }
#howto .howto-body li, #readguide .howto-body li { margin: 4px 0; line-height: 1.5; }
#howto .howto-body b, #readguide .howto-body b { color: #e6ebf4; }
/* the bilingual gloss tail, same tone as the tutorial cards' .en */
#readguide .howto-body .en { color: #97a0b0; }
#howtoClose, #readguideClose {
  position: absolute; top: 8px; right: 8px;
  background: transparent; color: #9aa0ac; border: 0;
  font-size: 14px; cursor: pointer; line-height: 1;
}
#howtoClose:hover, #readguideClose:hover { color: #fff; }

/* HUMAN-FACING SCENARIO NARRATION card (always shown; mirrors #howto styling, no .hidden). */
#scenario { background: #16181e; border: 1px solid #2a3a5a; border-radius: 8px;
  padding: 10px 14px; margin: 10px 0; max-width: 540px; font-size: 13px; color: #c2c8d2; line-height: 1.5; }
#scenario .scen-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 6px; }
#scenario .chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #aeb6c4; }
#scenario .chip .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
#scenario #scenarioLine { margin: 4px 0; color: #e6ebf4; }
#scenario:has(#scenarioLine:empty) { display: none; }
#scenario .scen-watch { margin: 4px 0 0; font-size: 12px; color: #97a0b0; }
#scenario .scen-watch b { color: #c2c8d2; }

/* ===== TUTORIAL DOM LAYERS (P14/P15: #annot chips + §C.4 cards + handoff card) =====
   app.js computes each chip's left/top over the board (board->screen transform +
   collision-avoidance) and toggles .on for visibility; these classes supply the overlay
   base that positioning math assumes. Chips/handoff are pointer-transparent; the §C.4
   cards accept clicks (click = advance card). */
#stage { position: relative; flex: 0 0 auto; }
#bootbar {
  position: absolute; top: 0; left: 16px; right: 16px; height: 48px; z-index: 8;
  background: rgba(12, 16, 23, .88); border: 1px solid rgba(207, 224, 255, .2);
  border-radius: 12px; overflow: hidden; pointer-events: none; display: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28); backdrop-filter: blur(10px);
}
#bootbar.on { display: block; }
#bootbar > i {
  position: absolute; left: 12px; bottom: 9px;
  display: block; width: 0; max-width: calc(100% - 24px); height: 10px;
  border-radius: 999px; background: linear-gradient(90deg, #5f8cff, #a9c4ff);
  box-shadow: 0 0 16px rgba(95, 140, 255, .55); transition: width .12s linear;
}
#bootbar::before {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 9px; height: 10px;
  border-radius: 999px; background: rgba(255, 255, 255, .12);
}
#bootbar > span {
  position: absolute; left: 12px; top: 7px; color: #edf3ff;
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
}
#annot { position: absolute; inset: 0; pointer-events: none; display: none; }
#annot.on { display: block; }
.annot-chip {
  position: absolute; z-index: 4; pointer-events: none;
  background: rgba(22, 24, 30, .94); border: 1px solid #2a3a5a; border-radius: 8px;
  padding: 6px 9px; font-size: 12px; line-height: 1.35; color: #c2c8d2;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.annot-chip b { display: block; color: #e6ebf4; font-weight: 600; }
/* fork sub-caption (the 2nd line inside the same chip, one language like the first) gets a divider */
.annot-chip b + b { margin-top: 5px; padding-top: 5px; border-top: 1px solid #2a2d36; }

#tutCards { display: none; }
#tutCards.on { display: block; }
/* 카드가 게이트가 된 뒤(2026-08-05)의 스크림: 보드를 눌러 "게임이 기다린다"를 말하고,
   동시에 보드 클릭이 방향 이동으로 새는 것을 막는다. 스크림이 없으면 게이트 중의
   보드 클릭이 board 의 click 리스너를 타고 parkTutorialInput 으로 들어가, beat 0 에서
   _tutActNext() 를 불러 1막이 통째로 건너뛰어진다. */
#tutScrim {
  position: absolute; inset: 0; z-index: 4;
  background: rgba(10, 12, 16, .62); border-radius: 10px;
  pointer-events: auto; cursor: pointer;
}
.tut-card {
  display: none; position: absolute; z-index: 5; left: 50%; top: 50%;
  transform: translate(-50%, -50%); width: 440px; max-width: calc(100% - 24px);
  background: rgba(22, 24, 30, .96); border: 1px solid #2a6df4; border-radius: 10px;
  padding: 12px 14px; font-size: 13px; line-height: 1.5; color: #c2c8d2;
  cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
.tut-card.on { display: block; }
/* 카드 문구는 lang="ko" · lang="en" 한 쌍이고 한쪽만 보인다 — 둘 다 본문 색으로 쓴다. */
.tut-card [lang] { color: #e6ebf4; }
.tut-card [lang] b { color: #cfe0ff; }
.tut-card .tut-next { margin-top: 8px; text-align: right; font-size: 12px; color: #cfe0ff; }

#handoffCard {
  display: none; position: absolute; z-index: 5; left: 50%; top: 50%;
  transform: translate(-50%, -50%); width: 380px; max-width: calc(100% - 24px);
  background: rgba(22, 24, 30, .96); border: 1px solid #2a6df4; border-radius: 10px;
  padding: 14px 16px; text-align: center; font-size: 14px; color: #e6ebf4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5); pointer-events: none;
}
#handoffCard.on { display: block; }

main { display: flex; gap: 10px; align-items: flex-start; }
/* crisp-edges 픽셀 보간 지정은 뺐다(2026-08-10). fitCanvas 가 백킹스토어를 DPR 배로
   키운 뒤로는 1:1 매핑이라 보간 자체가 안 일어난다 — 이득이 없고, DPR 이 정수가 아닌
   화면(1.25 · 1.5)에서만 계단을 만든다. */
canvas {
  background: #15161b; border-radius: 14px; display: block;
}
#board { cursor: pointer; }
#side { flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  #startBtn, #helpBtn { transition: none; }
}

/* ===== KO | EN (랜딩·IRB 게이트와 같은 계약) =====
   사람용 문구는 DOM 에 lang="ko" · lang="en" 한 쌍으로 있고 <html lang> 이 한쪽을 감춘다.
   <html lang> 은 index.html 머리 스크립트가 첫 페인트 전에 정한다(?lang= > aa.lang > ko). */
html[lang="ko"] [lang="en"], html[lang="en"] [lang="ko"] { display: none !important; }
.lang-bar {
  display: flex; align-items: center; gap: 2px; margin: -6px 0 4px;
  font: 500 11px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; color: #5b6472;
}
.lang-bar button { appearance: none; border: 0; background: none; padding: 4px; font: inherit; color: inherit; cursor: pointer; }
.lang-bar button:hover { color: #101725; }
.lang-bar button[aria-pressed="true"] { color: #b7791f; font-weight: 700; }
.lang-bar .sep { opacity: .5; }

/* ===== 세로로 길거나 좁은 화면: HUD 를 보드 아래로 =====
   app.js 의 HUD_BELOW_MQ 와 **같은 쿼리**여야 한다 — 그쪽이 HUD 캔버스를 240x540 기둥에서
   540x240 띠로 다시 짓는다. 보드·HUD 캔버스는 폭에 맞춰 줄어든다(fitCanvas 가 박는 인라인 px 를
   !important 로 이긴다; 높이 auto 는 백킹스토어 비율 1:1 · 9:4 를 그대로 따른다). #app 으로 좁혀
   둔 이유: replay.html 도 style.css 와 같은 #stage/#side/#hud 이름을 쓴다. */
@media (max-aspect-ratio: 1/1), (max-width: 840px) {
  #app { max-width: 568px; }
  #app main { flex-direction: column; align-items: center; }
  #app #stage, #app #side { width: 100%; max-width: 540px; }
  #app #board, #app #hud { width: 100% !important; height: auto !important; }
  #app #scenario { max-width: none; }
}
