:root {
  color-scheme: dark; --bg: #0b1526; --panel: #121f34; --raised: #1b2c46; --ink: #eaf1ff;
  --muted: #9aaec9; --line: #293d59; --accent: #71edd3; --accent-ink: #07251f; --shadow: #02081466;
  font-family: "Segoe UI", system-ui, sans-serif; font-synthesis: none;
}
:root[data-theme="light"] {
  color-scheme: light; --bg: #f3f6fb; --panel: #fff; --raised: #e8eff8; --ink: #182c46;
  --muted: #506680; --line: #d1ddeb; --accent: #137a68; --accent-ink: #fff; --shadow: #20385412;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: -1; background: radial-gradient(ellipse at 80% 10%, #586de520, transparent 45%), radial-gradient(ellipse at 0 40%, #23b9a713, transparent 45%); }
.site-header, main, footer, .notice { width: min(1200px, calc(100% - 48px)); margin-inline: auto; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 26px 0; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-size: 20px; font-weight: 650; }
.brand img { object-fit: contain; }
.brand strong { display: block; font-size: 10px; letter-spacing: .3em; color: var(--accent); margin-top: 3px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.site-header { position: sticky; top: 0; z-index: 20; background: var(--bg); flex-wrap: wrap; padding-block: 14px; }
.arcade-return { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 6px; color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 650; white-space: nowrap; }
.arcade-return:hover { background: var(--raised); }
.text-link { font-size: 13px; margin-right: 12px; text-decoration: none; color: var(--muted); }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); font-size: 23px; }
.icon-button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.hero { padding: 64px 0 40px; max-width: 760px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .2em; }
h1 { font-size: clamp(34px, 6vw, 64px); line-height: 1.1; letter-spacing: -.055em; margin: 20px 0; }
.hero h1 span { color: var(--accent); }
.hero > p:not(.eyebrow) { color: var(--muted); max-width: 540px; font-size: 16px; line-height: 1.7; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 28px; color: var(--muted); font-size: 11px; }
.catalog-toolbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin: 20px 0 26px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { padding: 10px 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); color: var(--muted); font-size: 12px; }
.filter.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.search input { width: 220px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--panel); }
.game-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.game-card { overflow: hidden; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); transition: transform .25s ease, box-shadow .25s ease; }
.game-card:hover { transform: translateY(-6px); box-shadow: 0 16px 40px var(--shadow); }
.game-preview { height: 190px; position: relative; display: grid; place-items: center; overflow: hidden; }
.game-preview small { position: absolute; bottom: 14px; left: 18px; letter-spacing: .17em; font-size: 9px; color: #ffffffa0; }
.preview-snake { background: radial-gradient(ellipse at 60% 20%, #245c50, #142c30); }
.snake-art { color: #85f2c9; font-size: 32px; line-height: .72; letter-spacing: -1px; transform: rotate(-16deg); text-shadow: 0 0 28px #61e0aa70; }
.food-art { position: absolute; top: 55px; right: 48px; font-size: 20px; color: #f0ba77; }
.preview-tetris { background: radial-gradient(ellipse at 60% 30%, #4c3d79, #25243f); }
.blocks-art { font-size: 43px; color: #bfa0fb; line-height: .65; letter-spacing: 2px; transform: rotate(10deg); }
.preview-chess { background: repeating-conic-gradient(#6f5c3b22 0% 25%, transparent 0% 50%) 50% / 50px 50px, #313144; }
.chess-art { font-family: "DejaVu Sans", serif; font-size: 64px; color: #f4dbaf; transform: rotate(-10deg); text-shadow: 0 10px 15px #0006; }
.preview-puzzle { background: radial-gradient(ellipse at 40% 20%, #4c526b, #252a43); }
.tiles-art { border: 1px solid #a8c4ff55; border-radius: 12px; padding: 12px; color: #bad3ff; font: 600 25px/1.25 monospace; letter-spacing: .2em; transform: rotate(12deg); }
.preview-memory { background: radial-gradient(ellipse at 55% 25%, #47877a, #16363d); }.memory-art { color: #e7f2c7; font: 700 31px/1.4 monospace; transform: rotate(-8deg); }
.preview-pong { background: radial-gradient(ellipse at 50% 40%, #22575c, #122737); }.pong-art { color: #80ffe1; font: 700 35px monospace; text-shadow: 0 0 22px #71edd388; }
.preview-2048 { background: radial-gradient(ellipse at 60% 25%, #785b48, #32283a); }.number-art { color: #ffe0a4; font: 700 38px/1.15 monospace; transform: rotate(-8deg); }
.preview-mines { background: radial-gradient(ellipse at 50% 25%, #405b6b, #1c2c3d); }.mine-art { color: #f2c1a0; font: 700 28px/1.4 monospace; }
.preview-flappy { background: radial-gradient(ellipse at 40% 20%, #4a7081, #21374d); }.flappy-art { color: #ffe08b; font: 700 34px/1.05 monospace; }
.preview-breakout { background: radial-gradient(ellipse at 50% 30%, #67513f, #29253d); }.breakout-art { color: #ffc477; font: 700 28px/1.2 monospace; text-shadow: 0 0 18px #ffb46a88; }
.preview-pacman { background: radial-gradient(ellipse at 45% 40%, #263778, #111c39); }.pacman-art { color: #ffe46a; font: 700 33px/1.1 monospace; text-shadow: 0 0 18px #ffe46a88; }
.preview-runner { background: radial-gradient(ellipse at 50% 25%, #31536a, #17273b); }.runner-art { color: #8fe9db; font: 700 25px/1.4 monospace; }
.preview-gomoku { background: repeating-linear-gradient(0deg, #c4a770 0 1px, transparent 1px 25px), repeating-linear-gradient(90deg, #c4a770 0 1px, transparent 1px 25px), #38364a; }.gomoku-art { color: #f1e5c9; font: 700 27px/1.2 monospace; text-shadow: 0 1px 5px #101828; }
.preview-hangman { background: radial-gradient(ellipse at 50% 25%, #526273, #202b40); }.hangman-art { color: #d5e4f3; font: 700 30px/1.2 monospace; }
.preview-clicker { background: radial-gradient(ellipse at 50% 35%, #385d75, #17263e); }.clicker-art { color: #8de9ff; font: 700 34px/1 monospace; text-shadow: 0 0 20px #4bb9ff99; }
.card-body { padding: 22px 18px; }
.card-category { color: var(--accent); font-size: 8px; letter-spacing: .13em; min-height: 20px; }
.card-body h2 { margin: 10px 0; font-size: 23px; }
.card-body > p:not(.card-category) { color: var(--muted); font-size: 13px; line-height: 1.6; min-height: 64px; }
.play-link { display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: var(--ink); font-size: 13px; padding-top: 18px; margin-top: 14px; border-top: 1px solid var(--line); }
.play-link span { color: var(--accent); font-size: 22px; }
.records { margin: 48px 0 24px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; display: grid; grid-template-columns: 1fr 1.5fr; gap: 24px; }
.records h2 { margin: 8px 0; }.records p:not(.eyebrow), .external-catalog { color: var(--muted); font-size: 13px; line-height: 1.6; }
.score-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.score-list h3 { font-size: 14px; margin: 0 0 10px; }.score-list ol { margin: 0; padding-left: 24px; color: var(--muted); font-size: 13px; }.score-list li { padding: 4px 0; }
.empty { padding: 40px 0; color: var(--muted); }
.notice { color: #e0a16f; font-size: 13px; min-height: 0; }.notice:not(:empty) { padding-block: 12px; }
footer { margin-block: 44px 24px; color: var(--muted); font-size: 11px; }footer span { padding: 0 12px; }
#gameScreen { padding: 30px 0; animation: enter-game .25s ease; }
.game-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; }.back-link { font-size: 13px; text-decoration: none; }
.game-header .secondary { min-height: 40px; }
#gameTitle { font-size: 38px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 24px; align-items: start; max-width: 940px; margin: auto; }
.game-stage { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; min-width: 0; }
.board-wrap { position: relative; margin: auto; max-width: 520px; }
.game-canvas { display: block; width: 100%; background: #0b1526; border-radius: 12px; touch-action: none; }
.game-canvas.tall { max-height: 65dvh; width: auto; max-width: 100%; margin: auto; }
.game-overlay { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; padding: 20px; border-radius: 12px; background: #081427dc; color: #eaf1ff; backdrop-filter: blur(4px); }
.game-overlay h2 { font-size: 26px; margin: 0; }.game-overlay p { margin: 0; line-height: 1.6; }
.game-sidebar { display: grid; gap: 16px; }
.stats-panel, .help-panel { padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.stat strong { color: var(--ink); font-size: 23px; font-variant-numeric: tabular-nums; }.stat:last-child { border: 0; }
.game-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.primary, .secondary { min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); color: var(--ink); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.help-panel h3 { margin: 0 0 12px; font-size: 14px; }.help-panel p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 6px 0; }
.game-status { min-height: 1.7em; margin: 16px 0 0; font-size: 14px; line-height: 1.6; color: var(--accent); }
.touch-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.touch-controls button { min-width: 52px; min-height: 48px; background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; font-size: 20px; touch-action: none; user-select: none; }
.hangman-keys { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.hangman-keys button { min-width: 0; min-height: 42px; padding: 4px; font-weight: 700; }
.hangman-keys button.letter-miss { opacity: .45; }
.clicker-upgrades { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.clicker-upgrades button { flex: 1 1 150px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--raised); }
.next-canvas { width: 100px; height: 100px; display: block; margin: 8px auto; background: #0b1526; border-radius: 10px; }
.tiles-2048 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(100%, 520px); aspect-ratio: 1; margin-inline: auto; padding: 8px; border-radius: 14px; background: #263447; touch-action: none; }
.tile-2048 { display: grid; place-items: center; min-width: 0; border-radius: 9px; background: #34465a; color: transparent; font-size: clamp(22px, 6vw, 42px); font-weight: 750; font-variant-numeric: tabular-nums; animation: tile-enter .18s ease-out; }
.tile-2048.value-2 { background: #e9e0cd; color: #283446; }.tile-2048.value-4 { background: #e9d5ad; color: #283446; }.tile-2048.value-8 { background: #e7ad76; color: #fff; }
.tile-2048.value-16 { background: #df895d; color: #fff; }.tile-2048.value-32 { background: #d96a55; color: #fff; }.tile-2048.value-64 { background: #c94742; color: #fff; }
.tile-2048.value-128, .tile-2048.value-256, .tile-2048.value-512, .tile-2048.value-1024, .tile-2048.value-2048 { background: #d4ae55; color: #fff; font-size: clamp(18px, 5vw, 34px); }
.mines-board { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); width: min(100%, 520px); margin-inline: auto; gap: 3px; padding: 5px; background: #263447; border-radius: 10px; }
.mine-cell { aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--accent); background: #34465a; font-weight: 700; font-size: clamp(12px, 3vw, 21px); }
.mine-cell.open { background: var(--raised); }.mine-cell.mine { background: #713f49; color: #fff; }
.game-stage > select { width: 100%; max-width: 260px; padding: 10px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--raised); }
#gameScreen:fullscreen { overflow: auto; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: var(--bg); }
#gameScreen:fullscreen .game-layout { width: min(100%, 1480px); max-width: none; }
#gameScreen:fullscreen .game-stage { min-height: 70dvh; display: grid; align-content: center; }
#gameScreen:fullscreen .board-wrap { max-width: min(90vw, 90dvh); }
#gameScreen:fullscreen .game-canvas.tall { max-height: 72dvh; }
@keyframes tile-enter { from { opacity: .5; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
.chess-board, .puzzle-board { display: grid; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 10px; }
.chess-board { grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); }
.chess-square { position: relative; border: 0; padding: 0; font-family: "DejaVu Sans", "Segoe UI Symbol", serif; font-size: clamp(22px, 4vw, 46px); display: grid; place-items: center; background: #e4e8de; color: #101d30; min-width: 0; }
.chess-square.dark { background: #648c86; }
.chess-square.white-piece { color: #fff; text-shadow: 1px 1px 1px #14233a, -1px -1px 1px #14233a, 1px -1px 1px #14233a, -1px 1px 1px #14233a; }
.chess-square.selected { box-shadow: inset 0 0 0 4px #f7c76c; }
.chess-square.legal::after { content: ""; position: absolute; width: 22%; height: 22%; border-radius: 50%; background: #152b6280; pointer-events: none; }
.chess-square small { position: absolute; bottom: 2px; left: 3px; font: 9px system-ui; color: #122e39; text-shadow: none; }
.chess-square:focus-visible { outline-offset: -4px; z-index: 1; }
.puzzle-board { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 8px; background: var(--bg); }
.puzzle-tile { border: 1px solid var(--line); background: var(--raised); color: var(--ink); font-size: clamp(22px, 4vw, 40px); border-radius: 12px; transition: background .15s ease, transform .15s ease; }
.puzzle-tile.correct { color: var(--accent); }.puzzle-tile.empty-tile { visibility: hidden; }
.puzzle-tile:not(:disabled):hover { background: var(--panel); transform: scale(.96); }
.memory-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(100%, 520px); aspect-ratio: 1; margin-inline: auto; }
.memory-card { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); background: repeating-linear-gradient(135deg, var(--raised) 0 8px, var(--panel) 8px 16px); font-size: 32px; font-weight: 700; touch-action: manipulation; }
.memory-card.revealed { background: #e7f0df; color: #20394a; }.memory-card.matched { background: #8bd1ad; color: #183c33; }
.promotion-select { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 12px; }
.promotion-select select { background: var(--raised); color: var(--ink); border: 1px solid var(--line); padding: 8px; border-radius: 8px; max-width: 100%; }
.move-list { max-height: 180px; overflow: auto; padding-left: 24px; font: 12px/1.8 monospace; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes enter-game { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1000px) { .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }.game-layout { grid-template-columns: minmax(0, 1fr) 230px; } }
@media (max-width: 680px) {
  .site-header, main, footer, .notice { width: calc(100% - 28px); }.site-header { padding: 18px 0; }.brand { font-size: 17px; gap: 8px; }.brand img { width: 32px; height: 32px; }.header-actions { gap: 6px; }.text-link { display: none; }
  .hero { padding: 36px 0 24px; }.hero-tags { gap: 12px; font-size: 9px; }.catalog-toolbar { flex-direction: column; align-items: stretch; gap: 14px; }.search input { width: 100%; }.filter { padding: 9px 12px; font-size: 11px; }
  .records { grid-template-columns: 1fr; padding: 20px; }.game-grid { gap: 12px; }.game-preview { height: 145px; }.card-body { padding: 16px 12px; }.card-body h2 { font-size: 20px; }.card-body > p:not(.card-category) { min-height: 82px; font-size: 12px; }.card-category { font-size: 7px; min-height: 24px; }
  .game-layout { grid-template-columns: 1fr; }.game-sidebar { grid-template-columns: 1fr; gap: 12px; }.game-stage { padding: 12px; }.game-canvas.tall { max-height: 55dvh; }.stats-panel, .help-panel { padding: 14px; }.stat strong { font-size: 20px; }#gameTitle { font-size: 30px; }
  .game-header { flex-wrap: wrap; }.game-header .eyebrow { flex: 1; text-align: right; }.game-header .secondary { width: 100%; }
  .chess-square { font-size: clamp(25px, 7vw, 44px); }.puzzle-board { gap: 5px; }.puzzle-tile { border-radius: 8px; }
  .memory-board { gap: 5px; }.memory-card { font-size: 26px; }
  .hangman-keys { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }.hangman-keys button { min-height: 40px; }
}
@media (max-width: 370px) { .game-grid { grid-template-columns: 1fr; }.card-body > p:not(.card-category) { min-height: 0; }.card-category { min-height: 0; }.game-sidebar { grid-template-columns: 1fr; }.score-list { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
