/* Page chrome + overlay base + HUD chrome shared across all games. */

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-0);
    color: var(--ink-0);
    font-family: var(--font-display);
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 30%, #11131f 0%, var(--bg-0) 70%);
}

.game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.stage[data-glitch="true"] .game-canvas {
    animation: stage-glitch 0.18s steps(2) 1;
}

.stage[data-glitch="true"]::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 4px var(--danger);
    mix-blend-mode: screen;
    animation: stage-glitch-flash 0.18s ease-out 1;
}

@keyframes stage-glitch {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(-6px, 2px); }
    100% { transform: translate(0, 0); }
}

@keyframes stage-glitch-flash {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* HUD ---------------------------------------------------------------------- */

.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: start;
    padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 32px);
    gap: 12px;
    pointer-events: none;
    z-index: 2;
}

.hud__cell {
    display: flex;
    flex-direction: column;
    line-height: 1;
    background: rgba(5, 6, 10, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: var(--hud-shadow);
}

.hud__cell--score    { grid-column: 1; justify-self: start; }
.hud__cell--combo    { grid-column: 2; justify-self: center; }
.hud__cell--accuracy { grid-column: 3; justify-self: end; }

.hud__label {
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--ink-1);
    margin-bottom: 6px;
}

.hud__value {
    font-size: clamp(22px, 3.2vh, 32px);
    font-weight: 800;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.hud__icon-btn {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(5, 6, 10, 0.55);
    color: var(--ink-0);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    font-size: 18px;
    line-height: 1;
    transition: transform 120ms ease, border-color 120ms ease;
}

.hud__icon-btn:hover,
.hud__icon-btn:focus-visible {
    transform: rotate(-90deg);
    border-color: var(--neon-cyan);
    outline: 0;
}

/* Overlay ------------------------------------------------------------------ */

.overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(5, 6, 10, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 5;
    transition: opacity 240ms ease;
}

.overlay[hidden] { display: none; }

.overlay__panel {
    text-align: center;
    padding: 32px 40px;
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(0, 240, 255, 0.06), rgba(255, 43, 214, 0.06));
    box-shadow: 0 0 80px rgba(0, 240, 255, 0.15);
    max-width: 560px;
    width: min(92vw, 560px);
}

.overlay__panel--compact {
    max-width: 360px;
    width: min(92vw, 360px);
}

.overlay__title {
    margin: 0 0 8px;
    font-size: clamp(36px, 8vh, 64px);
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
    text-shadow: 0 0 24px rgba(0, 240, 255, 0.55);
}

.overlay__title--sm {
    font-size: clamp(28px, 5vh, 42px);
    margin-bottom: 16px;
}

.overlay__subtitle {
    margin: 0 0 24px;
    color: var(--ink-1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 13px;
}

.overlay__btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.18em;
    padding: 14px 36px;
    border-radius: 999px;
    color: var(--bg-0);
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-emerald));
    box-shadow: 0 0 32px rgba(0, 240, 255, 0.55);
    transition: transform 120ms ease, box-shadow 120ms ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.overlay__btn:hover,
.overlay__btn:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 0 48px rgba(0, 240, 255, 0.75);
    outline: 0;
}

.overlay__btn--secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink-0);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.10);
}

.overlay__btn--secondary:hover,
.overlay__btn--secondary:focus-visible {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.20);
}

.overlay__btn-glyph {
    display: inline-block;
    transform: translateX(-2px);
    font-size: 14px;
}

.overlay__btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 4px 0 16px;
}

.overlay__hint {
    margin: 18px 0 0;
    color: var(--ink-1);
    font-size: 13px;
    letter-spacing: 0.06em;
}

.overlay__hint kbd {
    font: inherit;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Tutorial how-to-play list. Structural styles shared by all games;
   the per-step <strong>/<em> highlight colors live in each game's CSS. */

.howto {
    list-style: none;
    margin: 20px 0 12px;
    padding: 0;
    text-align: left;
    display: grid;
    gap: 10px;
}

.howto__step {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    line-height: 1.4;
    color: var(--ink-0);
    font-size: 14px;
}

.howto__step strong {
    color: var(--neon-cyan);
    letter-spacing: 0.08em;
}

.howto__step em {
    color: var(--neon-emerald);
    font-style: normal;
}

.howto__num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: rgba(0, 240, 255, 0.10);
    border: 1px solid rgba(0, 240, 255, 0.45);
    color: var(--neon-cyan);
    font-weight: 800;
    font-size: 13px;
    display: grid;
    place-items: center;
}

/* Mobile shared adjustments. Game-specific @media rules live in each game's
   own stylesheet. */
@media (max-width: 480px) {
    .hud { padding: 10px 12px; gap: 8px; }
    .hud__cell { padding: 7px 10px; }
    .hud__value { font-size: 20px; }
    .hud__label { font-size: 9px; letter-spacing: 0.14em; margin-bottom: 4px; }
    .hud__icon-btn { width: 32px; height: 32px; font-size: 16px; }
    .overlay__panel { padding: 22px 18px; }
    .howto__step { font-size: 13px; gap: 10px; }
    .howto__num { width: 22px; height: 22px; font-size: 12px; }
}
