*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root { --bg: #111; --card: #1f2937; --text: #e5e7eb; --muted: #9ca3af; --accent: #facc15; }
body { min-height: 100vh; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; padding: 32px 16px 64px; }
[data-l] { display: none; }
html[data-lang="en"] [data-l="en"], html[data-lang="zh-TW"] [data-l="zh-TW"] { display: revert; }
.lang-switch { position: absolute; top: 12px; right: 16px; display: flex; gap: 6px; }
button { background: var(--card); color: var(--text); border: 1px solid #374151; border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; }
header { text-align: center; margin-bottom: 24px; }
h1 { font-size: 2rem; }
.tagline { color: var(--muted); margin-top: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; max-width: 1100px; margin: 0 auto; }
.card { display: block; background: var(--card); border-radius: 12px; overflow: hidden; color: inherit; text-decoration: none; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.card[hidden] { display: none; }
.card img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; }
.card .icon { font-size: 3rem; text-align: center; padding: 28px 0 8px; }
.card h2 { font-size: 1.1rem; padding: 12px 14px 4px; }
.card p { font-size: .9rem; color: var(--muted); padding: 0 14px 12px; }
.card .best { color: var(--accent); }
.game-header { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.back { color: var(--muted); text-decoration: none; align-self: flex-start; }
.frame { margin: 0 auto; max-width: 100%; background: #000; border-radius: 12px; overflow: hidden; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.frame.portrait { aspect-ratio: 9 / 16; height: min(80vh, 900px); }
.frame.landscape { aspect-ratio: 16 / 9; width: min(100%, 1100px); }
.frame.any { aspect-ratio: 4 / 3; width: min(100%, 900px); }
.about { max-width: 720px; margin: 24px auto 0; line-height: 1.6; }
.about h2 { font-size: 1.1rem; margin: 16px 0 4px; }

.site-footer { text-align: center; margin: 32px auto 8px; }
.support { display: inline-block; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--muted); color: var(--muted); text-decoration: none; font-size: .95rem; }
.support:hover { color: #fff; border-color: #fff; }

/* Game page on phones/tablets: the game owns the whole first screen, no page scroll. */
@media (max-width: 820px), (pointer: coarse) {
  html.game-page, html.game-page body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  html.game-page body { padding: 0; min-height: 0; touch-action: none; }
  html.game-page .lang-switch, html.game-page .game-header h1, html.game-page .about, html.game-page .site-footer { display: none; }
  html.game-page .game-header { margin: 0; display: block; }
  html.game-page .frame.portrait, html.game-page .frame.landscape, html.game-page .frame.any {
    position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; aspect-ratio: auto; border-radius: 0; margin: 0;
  }
  html.game-page .back {
    position: fixed; z-index: 10; display: flex; align-items: center; justify-content: center;
    top: calc(env(safe-area-inset-top, 0px) + 8px); left: calc(env(safe-area-inset-left, 0px) + 8px);
    width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, .35); color: #fff; font-size: 22px; line-height: 1;
    -webkit-tap-highlight-color: transparent;
  }
  html.game-page .back [data-l] { display: none !important; }
  html.game-page .back::before { content: '←'; }
}

/* Visually hidden but available to screen readers (game page title: the game shows its own). */
.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; }
