* { box-sizing: border-box; }
:root { color-scheme: dark; --white: #f4f5ef; --muted: #8c9388; --ink: #080a08; }
html, body { width: 100%; height: 100%; margin: 0; background: #000; color: var(--white); }
body { display: grid; place-items: center; font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif; touch-action: none; overflow: hidden; }
#stage { position: relative; width: min(100vw, 100dvh, 600px); height: min(100vw, 100dvh, 600px); min-width: 280px; min-height: 280px; overflow: hidden; background: #000; }
.screen { width: 100%; height: 100%; }
#menu { display: flex; flex-direction: column; min-height: 0; padding: 20px 24px; }
.menu-tools { display: flex; justify-content: flex-end; flex: 0 0 32px; margin-bottom: 12px; }
.settings-button { appearance: none; display: grid; width: 36px; height: 32px; padding: 5px; place-items: center; border: 1px solid #30372d; border-radius: 7px; background: #050705; color: #d5ff5e; cursor: pointer; }
.settings-button svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.settings-button:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.game-window { position: relative; flex: 1; min-height: 0; max-height: calc(2 * clamp(100px, calc((100dvh - 132px) / 2), 240px) + 12px); overflow: hidden; }
.game-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: clamp(100px, calc((100dvh - 132px) / 2), 240px); gap: 12px; transform: translate3d(0, 0, 0); transition: transform 180ms cubic-bezier(.2, .7, .2, 1); }
.game-choice { appearance: none; position: relative; display: grid; place-items: center; min-width: 0; padding: 16px; border: 1px solid #30372d; border-radius: 12px; background: #050705; color: var(--white); font: inherit; cursor: pointer; overflow: hidden; transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease; }
.game-choice[aria-pressed="true"] { border: 2px solid var(--accent); background: #10140e; box-shadow: none; }
.game-choice:active { transform: scale(.986); }
.game-choice:focus-visible { outline: 2px solid var(--white); outline-offset: -7px; }
.game-choice:focus-visible[aria-pressed="true"] { outline: none; }
.game-symbol { display: grid; width: 100%; min-height: 0; place-items: center; color: var(--accent); }
.game-symbol svg { display: block; width: min(100%, 132px); height: min(100%, 112px); overflow: visible; }
.game-symbol svg * { vector-effect: non-scaling-stroke; }
.settings-screen { display: flex; flex-direction: column; justify-content: center; gap: 20px; padding: 38px 42px; background: #050705; }
.settings-screen h1 { margin: 0; color: #d5ff5e; font-size: 24px; line-height: 1; letter-spacing: .1em; }
.settings-list { display: grid; gap: 12px; }
.setting-choice { appearance: none; display: flex; align-items: center; justify-content: space-between; min-height: 94px; width: 100%; padding: 16px 20px; border: 1px solid #384033; border-radius: 8px; background: #10130e; color: var(--white); text-align: left; font: inherit; cursor: pointer; }
.setting-choice[aria-pressed="true"] { border-color: #d5ff5e; box-shadow: inset 3px 0 #d5ff5e; }
.setting-choice:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.setting-copy { display: grid; gap: 6px; }
.setting-copy strong { font-size: 15px; letter-spacing: .045em; }
.setting-copy small { color: #aab0a4; font-size: 12px; }
.setting-value { min-width: 52px; color: #d5ff5e; font-size: 14px; font-weight: 800; text-align: right; }
.settings-return { min-height: 74px; border-color: #69705f; }
.settings-return .setting-value { color: var(--white); font-size: 18px; }
.settings-note { margin: 0; color: #8c9388; font-size: 12px; text-align: center; }
#stage.high-contrast canvas.game-board { filter: contrast(1.3) brightness(1.08); }
#stage.high-contrast .game-help-overlay { border-color: #d5ff5e; background: #000; color: #fff; }
#stage.high-contrast .game-choice,
#stage.high-contrast .setting-choice { border-color: #b9c2ae; background: #000; color: #fff; }
#stage.high-contrast .game-choice[aria-pressed="true"],
#stage.high-contrast .setting-choice[aria-pressed="true"] { border-color: #eaff9d; box-shadow: inset 0 0 0 2px #eaff9d; }
#stage.high-contrast .game-choice[aria-pressed="true"] { border: 2px solid #eaff9d; box-shadow: none; }
#stage.high-contrast .setting-copy small { color: #e0e5dc; }
.game-screen { position: relative; display: grid; grid-template: 1fr / 1fr; place-items: center; overflow: hidden; }
#stage.game-active { width: min(100vw, 100dvh, 600px); height: min(100vw, 100dvh, 600px); }
#game-canvas { display: block; grid-area: 1 / 1; width: 100%; height: 100%; max-width: 600px; max-height: 600px; aspect-ratio: 1 / 1; margin: 0; image-rendering: auto; }
#game-canvas:focus { outline: none; }
.game-help-overlay { grid-area: 1 / 1; z-index: 2; justify-self: center; align-self: end; width: calc(100% - 48px); max-width: 460px; margin: 0 0 3px; padding: 2px 10px; border: 1px solid #526248; border-radius: 4px; background: rgba(12, 15, 11, .94); color: var(--white); font-size: 12px; font-weight: 700; line-height: 1.1; text-align: center; letter-spacing: .025em; white-space: nowrap; opacity: 0; transform: translate3d(0, 5px, 0); pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.game-help-overlay.is-visible { opacity: 1; transform: translate3d(0, 0, 0); }
.game-help-overlay.is-fading { opacity: 0; transform: translate3d(0, 5px, 0); transition: opacity 600ms ease, transform 600ms ease; }
.game-readout { max-width: 450px; width: 100%; margin: 0 auto 5px; padding: 6px 10px; border: 1px solid #69705f; border-radius: 3px; background: #252a21; color: var(--white); font-size: 12px; line-height: 1.4; text-align: center; }
.game-readout p { margin: 0; }
.game-readout p + p { margin-top: 3px; color: #b8e762; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
#live-message { font-size: 18px; }
@media (max-height: 460px) {
  #menu { padding: 14px; }
  .menu-tools { margin-bottom: 8px; }
  .settings-screen { gap: 12px; padding: 18px 22px; }
  .settings-screen h1 { font-size: 20px; }
  .setting-choice { min-height: 76px; padding: 12px 14px; }
  .settings-return { min-height: 62px; }
  .game-list { grid-auto-rows: clamp(92px, calc((100dvh - 100px) / 2), 180px); gap: 10px; }
  .game-choice { padding: 10px; }
  .game-symbol svg { width: min(100%, 94px); height: min(100%, 78px); }
}
@media (prefers-reduced-motion: reduce) {
  .game-list, .game-choice, .game-help-overlay { transition: none; }
}
