:root { color-scheme: dark; --bg: #04060f; --panel: #0b1328; --line: #1c2b4a; --text: #dfe9ff; --muted: #8aa3c4; --accent: #55d6ff; --warm: #ffd166;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1, h2, h3, h4 { letter-spacing: -0.01em; line-height: 1.2; }
button, input, select, textarea { font-family: inherit; }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }
::selection { background: rgba(85,214,255,0.35); color: #fff; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { -webkit-tap-highlight-color: transparent; }
.card, .btn, .chip, .site-header nav a { transition: border-color .2s ease, background-color .2s ease, transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease, color .2s ease; }
.btn:active, .chip:active { transform: translateY(1px); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.site-header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 10px max(24px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid rgba(28,43,74,0.8); background: rgba(6,11,24,0.82); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.08em; font-size: 15px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 22px; height: 22px; }
.site-header nav { display: flex; gap: 4px; }
.site-header nav a { display: inline-block; padding: 7px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 500; }
.site-header nav a:hover { color: var(--text); background: rgba(255,255,255,0.06); text-decoration: none; }
.site-header nav a.current { color: #fff; background: rgba(85,214,255,0.14); }
main { max-width: 1040px; margin: 0 auto; padding: 32px 24px 48px; }
.hero { margin: 0 0 28px; }
.hero h1 { margin: 0 0 6px; font-size: 34px; font-weight: 800; }
.hero p { margin: 0; color: var(--muted); font-size: 17px; }
.columns { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
@media (max-width: 760px) { .columns { grid-template-columns: 1fr; } }
h2 { font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; font-weight: 700; }
.games { display: grid; gap: 16px; }
.card { display: grid; grid-template-columns: 160px 1fr; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; color: inherit; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 0 1px rgba(85,214,255,0.15); text-decoration: none; }
.card:active { transform: translateY(0); }
.card img { width: 160px; height: 120px; object-fit: cover; display: block; background: #060b18; }
.card .body { padding: 14px 16px 14px 0; }
.card h3 { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: #fff; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.card .play { display: inline-block; font-weight: 700; color: var(--warm); font-size: 13px; letter-spacing: 0.06em; }
.news { display: grid; gap: 14px; }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.post time { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.post h3 { margin: 4px 0 8px; font-size: 16px; color: #fff; }
.post p { margin: 0; color: var(--text); font-size: 14px; line-height: 1.5; }
.site-footer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); font-size: 12.5px; padding: 22px 24px calc(22px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.site-footer nav { display: flex; gap: 18px; }
.site-footer nav a { color: var(--muted); }
.site-footer nav a:hover { color: var(--accent); }
.legal { max-width: 720px; }
.legal h1 { margin: 0 0 4px; font-size: 26px; }
.legal .updated { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.legal h2 { margin: 26px 0 8px; }
.legal p, .legal li { color: var(--text); font-size: 15px; line-height: 1.6; }

/* ---------- catalog components ---------- */
.section { margin: 0 0 32px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head h2 a { color: inherit; }
.section-head .hint { color: var(--muted); font-size: 13px; }
.section-head .more { margin-left: auto; font-size: 13px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.section-featured { padding: 18px; border: 1px solid #244b6b; border-radius: 12px; background: linear-gradient(135deg, rgba(85,214,255,0.08), rgba(255,209,102,0.05)); }
.games { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card .body { position: relative; }
.badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; margin: 0 0 8px; }
.badge-original { background: var(--warm); color: #1a1200; }
.badge-guide { background: #1c2b4a; color: #9fd9ff; border: 1px solid #2b4470; }
.card-original { border-color: #3d5a7a; }
.card-featured { grid-template-columns: 200px 1fr; }
.card-featured img { width: 200px; height: 150px; }
.card-guide .play { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font-size: 13px; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.crumbs { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.crumbs a { color: var(--muted); }
.crumbs span { color: var(--text); }

/* ---------- game page ---------- */
.game-page { max-width: 1100px; }
.game-head { margin: 0 0 24px; }
.game-head h1 { margin: 6px 0 6px; font-size: 34px; font-weight: 800; }
.game-head .lede { margin: 0 0 14px; color: var(--muted); font-size: 16px; max-width: 760px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-block; padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 14px; border: 1px solid var(--line); color: var(--text); background: var(--panel); }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--warm); color: #1a1200; border-color: var(--warm); }
.btn-primary:hover { background: #ffe08a; }
.game-grid { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: start; }
@media (max-width: 860px) { .game-grid { grid-template-columns: 1fr; gap: 8px; } .game-aside .cover { display: none; } }
.prose { margin: 0 0 28px; }
.prose h2 { font-size: 20px; letter-spacing: 0; text-transform: none; color: #fff; margin: 0 0 10px; }
.prose p, .prose li { font-size: 16px; line-height: 1.65; color: var(--text); }
.prose p { margin: 0 0 12px; }
.prose ol, .prose ul { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin: 0 0 6px; }
.prose details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 8px; background: var(--panel); }
.prose details { transition: border-color .2s ease; }
.prose details[open] { border-color: #2b4470; }
.prose summary { cursor: pointer; font-weight: 600; color: #fff; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 2px 0; }
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after { content: ''; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-2px) rotate(45deg); transition: transform .2s ease; }
.prose details[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.prose details p { margin: 10px 0 2px; }
.edition { border-radius: 12px; padding: 18px 20px; margin: 0 0 28px; border: 1px solid #244b6b; background: linear-gradient(135deg, rgba(85,214,255,0.10), rgba(255,209,102,0.06)); }
.edition h2 { margin: 0 0 8px; font-size: 19px; color: #fff; text-transform: none; letter-spacing: 0; }
.edition p { margin: 0 0 12px; color: var(--text); font-size: 15px; line-height: 1.55; }
.edition-planned { border-style: dashed; background: var(--panel); }
.game-aside .cover { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 0 0 14px; }
.facts { display: grid; gap: 8px; margin: 0 0 14px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.facts div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--text); }
.aside-actions { margin: 0 0 14px; }
.aside-actions .btn { display: block; text-align: center; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.disclaimer { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------- playable stage ---------- */
.stage { margin: 0 0 22px; border-radius: 12px; border: 1px solid var(--line); background: #060b18; overflow: hidden; }
.stage-fill .canvas-stage { height: min(72vh, 620px); min-height: 300px; display: flex; align-items: center; justify-content: center; }
.stage canvas#game { display: block; touch-action: none; cursor: crosshair; }
.stage .help { text-align: center; color: var(--muted); font-size: 12.5px; padding: 8px 0 10px; user-select: none; }
.stage .help kbd { background: #16213a; color: #bfe9ff; border-radius: 3px; padding: 1px 5px; font-family: inherit; }
.stage-auto { padding: 8px 12px 16px; }

/* featured originals: vertical cards */
.section-featured .games { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card-featured { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; gap: 0; }
.card-featured img { width: 100%; height: auto; aspect-ratio: 16 / 10; }
.card-featured .body { padding: 14px 16px 16px; }
.news-wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* ---------- offline ---------- */
.offline-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text); user-select: none; }
.offline-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.offline-switch .track { width: 42px; height: 24px; border-radius: 12px; background: #2b3448; position: relative; flex: none; transition: background-color .15s; }
.offline-switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.offline-switch input:checked + .track { background: #2ec27e; } .offline-switch input:checked + .track::after { left: 21px; }
.offline-switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.offline-switch input:disabled + .track { opacity: 0.5; }
.offline-switch .state { color: var(--muted); font-size: 12.5px; }
.offline-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.offline-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; font-size: 14px; }
.offline-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.offline-list span { color: var(--muted); font-size: 12.5px; } .offline-list span.on { color: #2ec27e; }
.offline-page ul { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- phones ---------- */
@media (max-width: 480px) {
  main { padding: 16px 12px 36px; }
  .site-header { padding: 10px 14px; }
  .hero h1 { font-size: 28px; }
  .game-head h1 { font-size: 28px; }
  .stage-auto { padding: 8px 6px 14px; }
  .crumbs { font-size: 12px; }
}

.offline-page #offline-saved .muted { margin: 0; }
.offline-page h2 { margin-top: 8px; }

@media (max-width: 480px) {
  .site-header { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .site-header nav a { padding: 7px 11px; }
  .brand { font-size: 14px; white-space: nowrap; }
}
@media (max-width: 360px) {
  .brand { font-size: 13px; letter-spacing: 0.04em; gap: 8px; }
  .site-header nav a { padding: 6px 9px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- full-screen play ---------- */
.stage-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.stage-tools .crumbs { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-open { flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px 7px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: border-color .2s ease, background-color .2s ease; }
.fs-open:hover { border-color: var(--accent); }
.fs-open svg { width: 16px; height: 16px; }
.stage-bar { display: none; }
.stage:focus { outline: none; }
.stage-body { position: relative; }
html.rg-immersive, html.rg-immersive body { overflow: hidden; overscroll-behavior: none; }
.stage.is-immersive { position: fixed; inset: 0; z-index: 1000; margin: 0; border: 0; border-radius: 0; height: var(--rg-vh, 100vh); height: var(--rg-vh, 100dvh);
  display: flex; flex-direction: column; background: var(--bg); padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  animation: rg-fs-in .22s cubic-bezier(.2,.8,.2,1); }
@keyframes rg-fs-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.stage.is-immersive .stage-bar { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; height: 44px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); }
.stage-title { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-done { border: 0; background: transparent; color: var(--accent); font-size: 16px; font-weight: 600; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.stage-done:hover { background: rgba(85,214,255,0.1); }
.stage-done svg { display: none; width: 20px; height: 20px; }
/* full screen behaves like an app: no text selection, copy menu or double-tap zoom while playing (fields still edit) */
.stage.is-immersive { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stage.is-immersive :is(input, textarea, select, [contenteditable]) { user-select: text; -webkit-user-select: text; }
/* phone turned sideways: height is precious, so the bar becomes a slim rail down the left edge */
@media (orientation: landscape) and (max-height: 500px) {
  .stage.is-immersive { flex-direction: row; }
  .stage.is-immersive .stage-bar { flex-direction: column; justify-content: flex-start; width: 44px; height: auto; padding: 6px 0; border-bottom: 0; border-right: 1px solid var(--line); }
  .stage.is-immersive .stage-title { display: none; }
  .stage.is-immersive .stage-done { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 10px; background: rgba(255,255,255,0.06); }
  .stage.is-immersive .stage-done svg { display: block; }
  .stage.is-immersive .stage-done span { display: none; }
  .stage.is-immersive .stage-body { flex: 1 1 auto; min-width: 0; }
}
.stage.is-immersive .stage-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.stage.is-immersive .stage-body > :not(script) { flex: 1 1 auto; min-height: 0; }
.stage-auto.is-immersive { padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
@media (max-width: 480px) { .fs-open span { display: none; } .fs-open { padding: 7px 9px; } }
