:root {
  --paper: #f3f4f7;
  --surface: #ffffff;
  --ink: #161a2e;
  --muted: #545a73;
  --indigo: #2b3a8c;
  --indigo-soft: #e3e7f6;
  --seal: #b8322a;
  --line: #d6d9e4;
  --on-indigo: #ffffff;
  --banner: #2b3a8c;
  --gold: #a87b1f;
  --banner-ink: #ffffff;
  --display: "Young Serif", Georgia, serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10131f; --surface: #181c2c; --ink: #e8eaf3; --muted: #9ba1bb;
    --indigo: #8c9cff; --indigo-soft: #222a4d; --seal: #ff7a6e; --line: #2c3250; --on-indigo: #0c0f1a; --banner: #232c5c; --banner-ink: #eef0fa; --gold: #d9b25a;
  }
}
:root[data-theme="dark"] {
  --paper: #10131f; --surface: #181c2c; --ink: #e8eaf3; --muted: #9ba1bb;
  --indigo: #8c9cff; --indigo-soft: #222a4d; --seal: #ff7a6e; --line: #2c3250; --on-indigo: #0c0f1a; --banner: #232c5c; --banner-ink: #eef0fa; --gold: #d9b25a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--body); overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

.btn { display: inline-block; font: 500 0.98rem var(--body); padding: 11px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.btn.small { padding: 7px 12px; font-size: 0.9rem; }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: var(--on-indigo); }
.btn:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
input { font: 400 1rem var(--body); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

/* full-screen layout: bar, hud, stage (fills the rest), pad */
.app {
  height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { font-family: var(--display); font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.bar-actions { display: flex; gap: 8px; }

.game-hud { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.game-hud b { color: var(--ink); }
.game-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.game-frame { position: relative; width: 300px; height: 400px; }
#g-canvas { width: 100%; height: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); touch-action: none; display: block; }
.game-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; background: color-mix(in srgb, var(--banner) 82%, transparent); color: var(--banner-ink); border-radius: 12px; }
.game-overlay[hidden] { display: none; }
.game-overlay .g-title { font-family: var(--display); font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.1; }
.game-overlay p { max-width: 30ch; }
.game-overlay .btn.primary { background: var(--banner-ink); color: var(--banner); border-color: var(--banner-ink); }
.g-save { display: grid; gap: 6px; justify-items: center; }
.g-save[hidden] { display: none; }
.g-save label { font-weight: 600; }
.g-save-row { display: flex; gap: 8px; }
.g-save-row input { width: 10em; }

.game-pad { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; }
.game-pad .btn { font-size: 1.1rem; padding: 12px; text-align: center; }
.game-pad .g-fire { grid-column: 1 / -1; background: var(--seal); color: #fff; border-color: var(--seal); font-weight: 600; }
.game-pad .g-fire:disabled { opacity: 0.55; cursor: default; }
/* keyboard-and-mouse screens don't need the touch pad */
@media (hover: hover) and (pointer: fine) { .game-pad { display: none; } }

dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); padding: 18px; }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog[open] { display: grid; gap: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.board { display: grid; gap: 6px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.table-scroll[hidden] { display: none; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
td:first-child, th:first-child { width: 2.5em; }
tr.me td { background: var(--indigo-soft); font-weight: 600; }
@media (max-width: 480px) {
  th, td { padding: 8px 7px; }
  th:nth-child(6), td:nth-child(6) { display: none; }
}
.powers { margin: 4px 0 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.powers b { color: var(--ink); font-weight: 600; }
/* inside the website's Play tab: the site already has its own header */
.embed .brand, .embed #g-install { display: none !important; }
.embed .bar { justify-content: flex-end; }
