.games-page { position: relative; z-index: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 72px 20px 24px; flex: 1; }
.games-page .back { display: inline-block; margin-bottom: 20px; font-size: 15px; color: var(--muted); text-decoration: none; }
.games-page .back:hover { color: var(--ink); }
.games-page h1 { font-weight: 800; font-size: clamp(2rem, 5vw, 2.75rem); margin-bottom: 8px; }
.games-page .lead { margin: 0 0 28px; }

/* Hub */
.game-search { max-width: 420px; margin: 0 0 22px; }
.game-search label { display: block; margin-bottom: 8px; }
.game-search input { width: 100%; }
.game-grid li[hidden] { display: none; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }
.game-tile { display: block; height: 100%; padding: 24px; background: rgba(18, 18, 28, 0.9); border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-decoration: none; transition: border-color 0.2s ease, transform 0.2s ease; }
.game-tile:hover { border-color: var(--accent); transform: translateY(-3px); }
.game-tile svg { width: 56px; height: 56px; margin-bottom: 14px; }
.game-tile h2 { font-size: 1.4rem; margin-bottom: 6px; }
.game-tile p { margin: 0 0 14px; font-size: 15px; }
.tile-top { display: block; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.tile-play { display: inline-block; padding: 8px 20px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 500; font-size: 15px; }

/* Game page */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.game-card, .board { background: rgba(18, 18, 28, 0.92); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.hud { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 15px; color: var(--muted); }
.hud b { color: var(--ink); font-family: "Sora", sans-serif; }
.hud { align-items: center; }
.pause-btn { min-height: 34px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 14px; touch-action: manipulation; }
.pause-btn:hover { border-color: var(--accent); }
.pause-btn[hidden] { display: none; }
.hud { flex-wrap: wrap; }
.vol { width: 90px; min-width: 70px; padding: 0; height: 24px; background: transparent; border: 0; accent-color: var(--accent); touch-action: manipulation; }
.vol:focus { box-shadow: none; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; min-height: 36px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 14px; }
.tab.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.board-note { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.canvas-wrap { position: relative; width: 100%; max-width: var(--cw, 480px); margin: 0 auto; }
.canvas-wrap canvas { display: block; width: 100%; height: auto; background: #05050a; border: 1px solid var(--line); border-radius: 12px; touch-action: none; }
.canvas-wrap canvas.brick3d { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; border-color: transparent; pointer-events: none !important; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; background: rgba(7, 7, 11, 0.84); border-radius: 12px; }
.overlay h2 { font-size: 1.6rem; }
.overlay p { margin: 0 0 6px; font-size: 15px; }
.boss-bar { position: absolute; top: 8px; left: 10px; right: 10px; z-index: 3; pointer-events: none; display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: #fecaca; }
.boss-bar[hidden] { display: none; }
.boss-bar i { display: block; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.boss-bar b { display: block; height: 100%; width: 100%; background: #dc2626; transition: width 0.12s linear; }
.hint { margin: 14px 0 0; font-size: 14px; color: var(--muted); text-align: center; }

.pad { display: none; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: var(--cw, 480px); margin: 14px auto 0; }
.pad button { min-height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); font-size: 14px; touch-action: manipulation; user-select: none; }
.pad button:active { background: var(--accent); }
@media (pointer: coarse), (max-width: 820px) { .pad { display: grid; } }
.canvas-wrap, .pad, .overlay { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body[data-game] { touch-action: manipulation; }
@media (pointer: coarse), (max-width: 820px) {
  .canvas-wrap { max-width: min(var(--cw, 480px), max(220px, calc((100vh - 330px) * var(--ar, 1)))); }
}

.game-card:fullscreen, .game-card:-webkit-full-screen { display: flex; flex-direction: column; justify-content: center; width: 100%; height: 100%; padding: 12px 16px; border: 0; border-radius: 0; background: #07070b; overflow: auto; }
.game-card:fullscreen .canvas-wrap { max-width: min(var(--cw, 480px), max(220px, calc((100vh - 170px) * var(--ar, 1)))); }
.game-card:fullscreen .hint { margin-top: 8px; }

.board h2 { font-size: 1.2rem; margin-bottom: 12px; }
.board ol { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.board li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; counter-increment: rank; }
.board li::before { content: counter(rank); width: 22px; color: var(--muted); font-size: 13px; }
.board li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.board li .sc { font-family: "Sora", sans-serif; color: #c4b5fd; }
.board li.empty { color: var(--muted); border-bottom: 0; }
.board li.empty::before { content: none; }

dialog.dlg { margin: auto; width: calc(100% - 32px); max-width: 400px; padding: 24px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
dialog.dlg::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog.dlg h2 { font-size: 1.4rem; margin-bottom: 6px; }
dialog.dlg p { margin: 0 0 14px; }
dialog.dlg label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }
dialog.dlg .row { display: flex; gap: 10px; margin-top: 16px; }
dialog.dlg .row .btn { flex: 1; }

@media (max-width: 820px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .games-page { padding-top: 72px; }
}
