:root {
  color-scheme: dark;
  --background: #0c1723;
  --panel: #13222f;
  --text: #e0e9ef;
  --muted: #9fb1bf;
  --accent: #65d7b4;
  --button: #1d3445;
  --button-hover: #27465c;
}

* { box-sizing: border-box; }

/* A phone's page does not bounce or chain its scroll to the browser (web player ADR-0039). */
html, body { overscroll-behavior: none; }

body {
  margin: 0;
  /* The height a phone shows now: 100vh is the height without the browser's bars and so runs past the screen. */
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text);
  font: 16px/1.5 system-ui, "Noto Sans KR", "Malgun Gothic", sans-serif;
}

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

[hidden] { display: none !important; }

.panel { padding: 8px 0; }

h1 { margin: 0 0 8px; font-size: 32px; font-weight: 600; }
#screen.title h1 { font-size: 64px; }

p { margin: 0 0 12px; color: var(--muted); white-space: pre-line; }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }

button {
  min-width: 140px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #2c4a5e;
  border-radius: 6px;
  background: var(--button);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--button-hover); }
button:disabled { opacity: 0.45; cursor: default; }
button.armed { border-color: #b4edff; color: #b4edff; }

#status { margin: 0 0 8px; color: var(--text); }
#hud { margin: 0 0 8px; color: var(--text); font-size: 20px; font-weight: 600; }
#canvas-host { position: relative; width: 100%; }
/* A direct game's field takes touches for its stick (web player ADR-0024). */
#canvas-host.stick { touch-action: none; }
#canvas-host canvas { display: block; border-radius: 6px; }
/* The editor's canvas takes touches and the right button for itself. */
#canvas-host.editing canvas { touch-action: none; cursor: crosshair; }
/* A drop game's canvas takes touches to aim and drop, and sits in the middle. */
#canvas-host.dropping canvas { touch-action: none; margin: 0 auto; }
#hud .hud-value { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; }
#hud .hud-value img { height: 28px; image-rendering: pixelated; }
#palette button, #settings button { min-width: 0; }
#stage-name {
  width: min(100%, 420px);
  min-height: 40px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border: 1px solid #2c4a5e;
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
/* The stage list: a row per stage, its name first. */
#buttons.stages { flex-direction: column; align-items: stretch; }
#buttons .stage-row, #buttons .stage-actions { display: flex; flex-wrap: wrap; gap: 10px; }
#buttons .stage-row button:first-child { flex: 1 1 240px; text-align: left; }
#settings .setting { display: flex; align-items: center; gap: 8px; }
#outcome {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 12, 0.55);
  color: var(--text);
  text-align: center;
}
#outcome .ending { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 22px;
  background: rgba(45, 33, 80, 0.94); border: 4px solid #0d0820; box-shadow: 0 0 0 3px #6b5b95, 8px 8px 0 3px #0d0820; }
#outcome .ending strong { font-size: 40px; }
#outcome .ending .totals { font-size: 26px; font-weight: 700; color: #ffd43b; }
#outcome .ending dl { display: grid; grid-template-columns: auto auto; gap: 4px 14px; margin: 0; font-size: 17px; text-align: left; }
#outcome .ending dt { color: var(--muted); }
#outcome .ending dd { margin: 0; display: flex; align-items: center; gap: 6px; font-weight: 600; }
#outcome .ending dd img { height: 26px; image-rendering: pixelated; }
#outcome .ending .hint { font-size: 15px; color: var(--muted); }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 8, 12, 0.85);
}
.overlay .panel { max-width: 640px; width: 100%; padding: 24px; border-radius: 8px; background: var(--panel); }

/* The license link sits under the page while loading and on the title screen. */
#site-notices { max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; font-size: 14px; }
#site-notices a { color: var(--muted); }
/* The notices in the page: a scrolling text over the screen, closed by its button or Escape. */
#notices-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 16px; border: 0; border-radius: 8px;
  background: var(--panel); color: inherit; display: none; flex-direction: column; gap: 12px; }
#notices-dialog[open] { display: flex; }
#notices-dialog::backdrop { background: rgba(4, 8, 12, 0.85); }
#notices-dialog h2 { margin: 0; font-size: 18px; }
#notices-dialog pre { flex: 1 1 auto; min-height: 0; margin: 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }

/* The frame readout (?perf in the address, page/perf.js). */
/* The playtest log's button (?log, playlog.js): small, in the bottom-right corner, clear of a skin's hud along the top and
   of the frame readout (?perf) at the bottom left. */
.playlog-button { position: fixed; right: max(6px, env(safe-area-inset-right)); bottom: max(6px, env(safe-area-inset-bottom)); z-index: 101;
  min-height: 0; padding: 4px 8px; font-size: 12px; opacity: 0.85; }
.perf-readout {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 100;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgb(0 0 0 / 70%);
  color: #fff;
  font: 12px/1.4 ui-monospace, monospace;
  white-space: pre;
  pointer-events: none;
}

/* A hud bar (engine ADR-0022): a track and its fill. */
.hud-bar { display: inline-block; width: 6em; height: 0.7em; vertical-align: middle; border: 1px solid currentColor; border-radius: 0.35em; overflow: hidden; }
.hud-bar > span { display: block; height: 100%; background: currentColor; }

/* The open choice over the field (engine ADR-0022): a title and a button per option. */
#choice { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1em; background: rgba(0, 0, 0, 0.55); color: #fff; padding: 1em; text-align: center; }
#choice[hidden] { display: none; }
#choice .choice-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75em; }
#choice button { min-width: 8em; min-height: 3em; padding: 0.75em 1em; font-size: 1.05em; }

/* A fullscreen skin (web player ADR-0029) while a game is played: the field fills the window; the hud, the buttons, the
   choice and the ending lie over it, and once the game is over its way on (a new game) comes over the ending. The skin's
   stylesheet gives them their look. */
body.layout-fullscreen.playing { overflow: hidden; }
body.layout-fullscreen.playing main { max-width: none; padding: 0; }
body.layout-fullscreen.playing #heading, body.layout-fullscreen.playing #detail, body.layout-fullscreen.playing #status,
body.layout-fullscreen.playing #commands, body.layout-fullscreen.playing #site-notices { display: none; }
body.layout-fullscreen.playing #canvas-host { position: fixed; inset: 0; width: 100%; height: 100%; }
body.layout-fullscreen.playing #canvas-host canvas { border-radius: 0; }
body.layout-fullscreen.playing #hud { position: fixed; top: 0; left: 0; right: 0; z-index: 5; margin: 0; pointer-events: none; }
body.layout-fullscreen.playing #buttons { position: fixed; top: 0; right: 0; z-index: 6; margin: 0; }
body.layout-fullscreen.playing #buttons button:not([data-action="Pause"]) { display: none; }
body.layout-fullscreen.playing.ended #buttons { inset: auto 0 10% 0; justify-content: center; z-index: 12; }
body.layout-fullscreen.playing.ended #buttons button[data-action="Pause"] { display: none; }
body.layout-fullscreen.playing.ended #buttons button[data-action="NewGame"] { display: inline-block; }
body.layout-fullscreen.playing #choice, body.layout-fullscreen.playing #outcome { position: fixed; z-index: 10; }

/* The sound button over a played field (engine ADR-0027): a speaker, crossed out while off. */
#sound-toggle { position: fixed; z-index: 6; top: 8px; left: 8px; min-width: 0; width: 40px; height: 40px; padding: 0; font-size: 20px; }
#sound-toggle::before { content: "🔊"; }
#sound-toggle[data-on="false"]::before { content: "🔇"; }

/* The touch stick (web player ADR-0024): a ring where the press began and its knob, over the field. */
#stick { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.15); pointer-events: none; }
#stick[hidden] { display: none; }
#stick > div { position: absolute; left: 32px; top: 32px; width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, 0.7); }

/* The keyboard's pick (web player ADR-0043): a thick yellow line around the picked button or card, clear of its edge so
   it shows on any button; a skin may draw it its own way. */
button.picked { outline: 4px solid #ffd54a; outline-offset: 3px; }
