/* SimSchoolAI play page. Entry v4 (2026-10-24): a minimal "download the world" page in the style of the in-game Scenario
   Selection screen (start flow v3, Figma qpgZvzE21YgysiB9SXOuli): sand background, ink text, ink wordmark pill with
   yellow lettering, yellow primary button with ink label. No photo, no card - the text sits on the sand like the
   scenario screen's title.
   "SSAI Sans" = page-text subset of Pretendard 1.3.9 (SIL OFL 1.1, Reserved Font Name "Pretendard" -> renamed; made by
   web/tools/subset_fonts.sh, license text in fonts/Pretendard-OFL.txt). */
@font-face {
  font-family: "SSAI Sans";
  src: url("fonts/SSAISans-Medium.subset.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "SSAI Sans";
  src: url("fonts/SSAISans-Bold.subset.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #24344D;
  --ink-soft: #3A4962;      /* 8.0:1 on sand */
  --muted: #4F5B70;         /* 5.6:1 on sand */
  --sand: #E9D7B9;          /* scenario screen floor */
  --sand-light: #F4E9D6;
  --sand-deep: #DEC59C;
  --paper: #FFFAF2;
  --row: #EADCC3;
  --yellow: #F5C542;        /* Figma primary button / selected ring */
  --yellow-hover: #F8D267;
  --yellow-press: #E9B52C;
  --fade: #101621;
  --radius-plate: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "SSAI Sans", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
  overflow: hidden;
}
::selection { background: var(--yellow); color: var(--ink); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; border-radius: 8px; }
h1, h2 { font-weight: 700; margin: 0; }
h1:focus { outline: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ stage: soft sand, lighter in the middle */
.stage {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, var(--sand-light) 0%, rgba(244, 233, 214, 0) 70%),
    linear-gradient(180deg, var(--sand) 0%, var(--sand-deep) 100%);
}

.game { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .45s var(--ease-out); background: var(--fade); }
.game canvas { display: block; width: 100%; height: 100%; outline: none; }
.is-playing .game { opacity: 1; pointer-events: auto; }
/* name step (start flow): transparent input over the game's name field - the game draws the text, the browser composes Hangul */
.name-input {
  position: absolute; z-index: 3; margin: 0; padding: 0 0 0 67px; border: 0; outline: none; border-radius: 999px;
  background: transparent; color: transparent; caret-color: transparent; font: 700 17px/1 sans-serif; -webkit-text-fill-color: transparent;
  opacity: 0;   /* Chrome paints the IME composition marker (yellow box) even on transparent text; the game draws the composition */
}
.name-input::selection { background: transparent; }
.name-input[hidden] { display: none; }

/* ------------------------------------------------------------------ panel: centred column on the sand */
.panel {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto;
  padding: 8px 4px;
  text-align: center;
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
  scrollbar-width: thin; scrollbar-color: var(--row) transparent;
}
.is-playing .panel { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .3s var(--ease-out), visibility 0s .3s; }

/* wordmark = the scenario screen's logo pill */
.wordmark {
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px; margin: 0 0 28px;
  border-radius: 999px; background: var(--ink); color: var(--yellow);
  font-weight: 700; font-size: 19px; letter-spacing: -0.01em; line-height: 1;
}
.view h1 { font-size: clamp(30px, 1.6vw + 16px, 44px); line-height: 1.22; letter-spacing: -0.03em; text-wrap: balance; }
.lede { margin: 14px 0 0; font-size: 18px; color: var(--ink-soft); }
.note { margin: 16px auto 0; max-width: 34em; font-size: 16px; color: var(--ink-soft); text-wrap: balance; }
.note strong { font-weight: 700; color: var(--ink); }
.note--soft { margin-top: 6px; font-size: 14px; color: var(--muted); }

/* plate = the Figma primary button: yellow fill, ink label */
.plate {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 32px; min-height: 64px; padding: 0 36px; min-width: 240px;
  font: inherit; font-weight: 700; font-size: 21px; letter-spacing: -0.01em;
  color: var(--ink); background: var(--yellow);
  border-radius: var(--radius-plate);
  box-shadow: 0 10px 24px -10px rgba(120, 82, 10, .55), inset 0 -2px 0 rgba(36, 52, 77, .12);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background-color .18s var(--ease-out);
}
.plate:hover { background: var(--yellow-hover); transform: translateY(-1px); box-shadow: 0 14px 28px -12px rgba(120, 82, 10, .6), inset 0 -2px 0 rgba(36, 52, 77, .12); }
.plate:active { background: var(--yellow-press); transform: translateY(0) scale(.98); }
.plate:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; border-radius: var(--radius-plate); }
.plate:disabled { cursor: progress; opacity: .55; transform: none; }
.plate__icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.plate--quiet { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(36, 52, 77, .18); min-width: 0; font-size: 18px; padding: 0 24px; min-height: 56px; }
.plate--quiet:hover { background: #fff; box-shadow: inset 0 0 0 1.5px rgba(36, 52, 77, .3); }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 28px; }
.actions .plate { margin-top: 0; }

/* error mark */
.mark { width: 48px; height: 48px; margin: 0 auto 18px; display: block; }
.mark circle:first-child { fill: var(--yellow); }
.mark path { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.mark .dot { fill: var(--ink); }
#error-detail { margin-top: 16px; font-size: 13px; word-break: break-all; }
.steps { margin: 20px auto 0; padding: 0; max-width: 30em; list-style: none; counter-reset: step; display: grid; gap: 10px; text-align: left; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 15px; color: var(--ink-soft); }
.steps li::before {
  content: counter(step); display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: var(--yellow);
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 1px;
}
.steps code { font: 700 14px/1 ui-monospace, Menlo, monospace; padding: 2px 6px; border-radius: 6px; background: var(--paper); color: var(--ink); white-space: nowrap; }

/* progress: paper track + ink fill + yellow knob */
.progress { position: relative; margin: 32px auto 0; max-width: 440px; height: 12px; border-radius: 999px; background: var(--paper); box-shadow: inset 0 0 0 1px rgba(36, 52, 77, .1); }
.progress__fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  border-radius: inherit; background: var(--ink);
  transition: width .25s linear;
}
.progress__fill::after {
  content: ""; position: absolute; right: -11px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px var(--ink);
}
.progress.is-finishing .progress__fill::after { animation: knob 1.1s ease-in-out infinite; }
@keyframes knob { 50% { box-shadow: 0 0 0 4px var(--ink), 0 0 0 10px rgba(245, 197, 66, .45); } }
.progress__text { display: flex; justify-content: space-between; gap: 16px; margin: 14px auto 0; max-width: 440px; font-size: 15px; color: var(--ink-soft); }
.progress__text .num { color: var(--ink); font-weight: 700; white-space: nowrap; }

.stats {
  position: absolute; left: 12px; bottom: 12px; z-index: 7; padding: 6px 10px; border-radius: 8px;
  background: rgba(16, 22, 33, .72); color: #fff; font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre; pointer-events: none;
}
.qa-clean .stats { display: none !important; }   /* ?qa=1&clean=1: comparison captures */
.noscript { position: fixed; inset: auto 0 0 0; margin: 0; padding: 16px; background: var(--paper); text-align: center; }

/* ------------------------------------------------------------------ narrow / short windows */
@media (max-width: 600px) {
  .panel { padding: 8px 0; }
  .wordmark { margin-bottom: 22px; height: 36px; font-size: 17px; }
  .plate { width: 100%; min-width: 0; }
  .actions .plate { width: auto; flex: 1 1 auto; }
}
@media (max-height: 600px) {
  .wordmark { margin-bottom: 16px; }
  .plate { margin-top: 22px; min-height: 56px; }
  .progress { margin-top: 22px; }
}

@media (min-width: 2200px) and (min-height: 1250px) {   /* 2560x1440-class: the column grows with the screen */
  .panel { zoom: 1.3; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .plate, .game { transition-duration: .01s; }
  .plate:hover { transform: none; }
  .progress.is-finishing .progress__fill::after { animation: none; }
}
