/* ==========================================================================
   EarnZone — shared stylesheet for the web portal and all games.
   Palette mirrors the Android app (ui/theme/Color.kt): Indigo + Gold + Slate.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    /* Brand — same values the app's Material theme is built from */
    --ez-indigo: #4f46e5;
    --ez-indigo-light: #818cf8;
    --ez-indigo-bright: #6366f1;
    --ez-gold: #f59e0b;
    --ez-coin: #ffd700;

    /* Surfaces (app BackgroundDark / SurfaceDark) */
    --ez-bg: #0f172a;
    --ez-surface: #1e293b;
    --ez-surface-2: #273449;
    --ez-elevated: #33415a;

    /* Text */
    --ez-text: #f1f5f9;
    --ez-muted: #94a3b8;
    --ez-faint: #64748b;

    /* Semantic (app SuccessGreen / ErrorRed) */
    --ez-success: #10b981;
    --ez-danger: #dc2626;
    --ez-mint: #3edca0;
    --ez-coral: #ff6b7a;
    --ez-sky: #5ac8fa;

    --ez-border: rgba(255, 255, 255, 0.09);
    --ez-border-strong: rgba(255, 255, 255, 0.16);

    --ez-radius: 18px;
    --ez-radius-sm: 12px;
    --ez-radius-lg: 26px;

    --ez-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --ez-glow: 0 0 24px rgba(99, 102, 241, 0.45);

    /* Notch / gesture-bar insets, so HUD never sits under system UI */
    --ez-safe-top: env(safe-area-inset-top, 0px);
    --ez-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ez-safe-left: env(safe-area-inset-left, 0px);
    --ez-safe-right: env(safe-area-inset-right, 0px);

    --ez-font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    background: var(--ez-bg);
    color: var(--ez-text);
    font-family: var(--ez-font);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    /* Kill pull-to-refresh + rubber-banding inside the app WebView */
    overscroll-behavior: none;
}

button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--ez-indigo-light); text-decoration: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.ez-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 30px;
    border-radius: var(--ez-radius);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: var(--ez-surface-2);
    color: var(--ez-text);
    border: 1px solid var(--ez-border);
    transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}
.ez-btn:active { transform: scale(0.96); }
.ez-btn:disabled { opacity: 0.55; pointer-events: none; }

.ez-btn-primary {
    background: linear-gradient(135deg, var(--ez-indigo-bright), var(--ez-indigo));
    border-color: transparent;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.4);
}
.ez-btn-gold {
    background: linear-gradient(135deg, var(--ez-coin), var(--ez-gold));
    color: #2b1a00;
    border-color: transparent;
    box-shadow: 0 8px 22px rgba(245, 158, 11, 0.38);
}
.ez-btn-ghost { background: rgba(255, 255, 255, 0.06); }
.ez-btn-block { width: 100%; }
.ez-btn-lg { padding: 18px 40px; font-size: 18px; }
.ez-btn-sm { padding: 10px 18px; font-size: 14px; border-radius: var(--ez-radius-sm); }

/* ==========================================================================
   Cards / surfaces
   ========================================================================== */

.ez-card {
    background: var(--ez-surface);
    border: 1px solid var(--ez-border);
    border-radius: var(--ez-radius);
    box-shadow: var(--ez-shadow);
}
.ez-glass {
    background: rgba(30, 41, 59, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--ez-border);
}
.ez-coin-text { color: var(--ez-coin); font-weight: 800; }

/* ==========================================================================
   GAME SHELL — the DOM the SDK injects into every game page
   ========================================================================== */

body.ez-game {
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    /* Radial lift so canvas games don't read as a flat black rectangle */
    background:
        radial-gradient(circle at 50% 0%, #1e2a4a 0%, var(--ez-bg) 55%, #080d18 100%);
}

.ez-stage {
    position: fixed;
    inset: 0;
    /* No viewport units here, deliberately.
       `inset: 0` on a fixed element already fills the viewport, and it is the
       only method that survives an Android WebView whose height is indefinite:
       in that case `100vh` AND `100dvh` both resolve to ZERO — measured, not
       guessed — which collapsed the stage, the canvas and every game to nothing
       and rendered a blank screen with no error to show for it.
       Percentages resolve against the initial containing block for a fixed
       element, so height/width below are a belt-and-braces fallback that also
       reads 100% of the viewport. */
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Canvas games. Sized by JS at devicePixelRatio so it is never blurry. */
.ez-canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    z-index: 1;
}

/* DOM games (grids, cards, boards) mount here instead of the canvas. */
.ez-board {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: calc(var(--ez-safe-top) + 78px) calc(var(--ez-safe-right) + 16px)
             calc(var(--ez-safe-bottom) + 20px) calc(var(--ez-safe-left) + 16px);
    overflow: hidden;
}
.ez-board.ez-scroll { overflow-y: auto; justify-content: flex-start; touch-action: pan-y; }

/* ---- HUD ---- */

.ez-hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(var(--ez-safe-top) + 12px) calc(var(--ez-safe-right) + 14px) 12px
             calc(var(--ez-safe-left) + 14px);
    pointer-events: none;
}
.ez-hud > * { pointer-events: auto; }
.ez-hud-spacer { flex: 1; pointer-events: none; }

.ez-back {
    width: 42px; height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    background: rgba(30, 41, 59, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
    color: var(--ez-text);
}
.ez-back:active { transform: scale(0.92); }

.ez-mute {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
    color: var(--ez-text);
}
.ez-mute:active { transform: scale(0.92); }
.ez-mute.ez-muted { opacity: 0.5; }

.ez-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 74px;
    padding: 7px 16px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
}
.ez-stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--ez-muted);
}
.ez-stat-value {
    font-size: 21px;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.ez-stat-score .ez-stat-value { color: var(--ez-coin); }
.ez-stat-timer .ez-stat-value { color: var(--ez-text); }
.ez-stat-timer.ez-urgent .ez-stat-value { color: var(--ez-coral); }
.ez-stat-timer.ez-urgent { animation: ez-pulse 1s ease-in-out infinite; }

@keyframes ez-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

/* ---- Full-screen overlay screens (start / game over / paused) ---- */

.ez-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: calc(var(--ez-safe-top) + 24px) 24px calc(var(--ez-safe-bottom) + 24px);
    text-align: center;
    background: rgba(8, 13, 24, 0.86);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.ez-screen.ez-active { display: flex; animation: ez-fade 0.22s ease; }

@keyframes ez-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ez-pop {
    0%   { transform: scale(0.86); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ---- FX layer ----
   Sits above the play surface but below the HUD and the overlay screens, so
   confetti can spill over a game-over card without ever eating a tap. */
.ez-fx {
    position: absolute;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ---- Diamonds ----
   The collectible a round is actually paid for. Layered above the game but
   below the HUD (12) and the screens (20+), so one can never cover a control
   or land on top of the game-over card. Deliberately a button: it needs to be
   tappable in the canvas games, the DOM board games and the WebGL ones alike,
   and none of them share a hit-testing story. */
.ez-stat-gems .ez-stat-value { color: #7dd3fc; }

.ez-over-gems {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: rgba(226, 232, 240, 0.72);
    margin-top: 2px;
}

.ez-game-icon { font-size: 60px; line-height: 1; margin-bottom: 2px; }

/* The 3D game art replaces the emoji when a sprite exists for the game. The
   drop-shadow does the work the emoji's own shading used to. */
.ez-game-icon.ez-game-icon-img {
    width: 104px;
    height: 104px;
    margin: 0 auto 2px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.5));
    animation: ez-float 3.4s ease-in-out infinite;
}

@keyframes ez-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-7px); }
}

@media (prefers-reduced-motion: reduce) {
    .ez-game-icon.ez-game-icon-img { animation: none; }
}

.ez-title {
    font-size: clamp(28px, 8vw, 42px);
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--ez-indigo-light), var(--ez-coin));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.ez-subtitle {
    font-size: 15px;
    font-weight: 500;
    color: var(--ez-muted);
    max-width: 340px;
    line-height: 1.55;
    margin-bottom: 12px;
}

.ez-actions {
    display: flex;
    flex-direction: column;
    gap: 11px;
    width: 100%;
    max-width: 290px;
}

/* Difficulty picker */
.ez-diff {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 22px;
    border-radius: var(--ez-radius);
    font-size: 16px;
    font-weight: 700;
    background: var(--ez-surface-2);
    border: 1px solid var(--ez-border);
    transition: transform 0.14s ease, border-color 0.2s ease;
}
.ez-diff:active { transform: scale(0.96); }
.ez-diff-easy   { border-left: 4px solid var(--ez-success); }
.ez-diff-medium { border-left: 4px solid var(--ez-gold); }
.ez-diff-hard   { border-left: 4px solid var(--ez-coral); }
.ez-diff-meta { font-size: 12px; font-weight: 600; color: var(--ez-muted); }

/* ---- Game over ---- */

.ez-over-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 30px 34px;
    width: 100%;
    max-width: 340px;
    border-radius: var(--ez-radius-lg);
    background: linear-gradient(160deg, var(--ez-surface), #16203a);
    border: 1px solid var(--ez-border-strong);
    box-shadow: var(--ez-shadow);
    animation: ez-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.ez-over-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ez-muted);
}
.ez-over-title { font-size: 26px; font-weight: 800; margin-bottom: 10px; }
.ez-over-score {
    font-size: 60px;
    font-weight: 800;
    line-height: 1;
    color: var(--ez-text);
    font-variant-numeric: tabular-nums;
}
.ez-coin-icon {
    display: block;
    flex: none;
    width: 22px;
    height: 22px;
}
/* Same mark, sized to the line it sits on — for coin amounts inside a sentence. */
.ez-coin-inline {
    display: inline-block;
    width: 1.05em;
    height: 1.05em;
    vertical-align: -0.16em;
}
.ez-over-coins {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 22px;
    padding: 11px 22px;
    border-radius: 999px;
    font-size: 19px;
    font-weight: 800;
    color: var(--ez-coin);
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.ez-over-best { font-size: 13px; font-weight: 600; color: var(--ez-muted); }
.ez-over-card .ez-actions { max-width: none; }

/* Toast — used for the browser fallback when no native bridge is present */
.ez-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--ez-safe-bottom) + 28px);
    transform: translate(-50%, 20px);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 13px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    background: var(--ez-elevated);
    border: 1px solid var(--ez-border-strong);
    box-shadow: var(--ez-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.24s ease;
}
.ez-toast.ez-show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Reusable game primitives (grids, tiles, cells) used by the DOM games
   ========================================================================== */

.ez-grid { display: grid; gap: 8px; touch-action: manipulation; }

.ez-cell {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: var(--ez-radius-sm);
    background: var(--ez-surface-2);
    border: 1px solid var(--ez-border);
    font-size: clamp(16px, 5vw, 26px);
    font-weight: 800;
    transition: transform 0.12s ease, background 0.18s ease;
}
.ez-cell:active { transform: scale(0.95); }
.ez-cell-flat { border-radius: 8px; border-color: transparent; }

.ez-panel {
    width: 100%;
    max-width: 420px;
    padding: 22px;
    border-radius: var(--ez-radius);
    background: var(--ez-surface);
    border: 1px solid var(--ez-border);
}

.ez-prompt {
    font-size: clamp(22px, 7vw, 34px);
    font-weight: 800;
    line-height: 1.3;
    text-align: center;
}
.ez-hint {
    font-size: 13px;
    font-weight: 600;
    color: var(--ez-muted);
    text-align: center;
}

.ez-option {
    display: block;
    width: 100%;
    padding: 16px 20px;
    margin-bottom: 10px;
    border-radius: var(--ez-radius-sm);
    font-size: 16px;
    font-weight: 600;
    text-align: left;
    background: var(--ez-surface-2);
    border: 1px solid var(--ez-border);
    transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}
.ez-option:active { transform: scale(0.98); }
.ez-option.ez-correct {
    background: rgba(16, 185, 129, 0.18);
    border-color: var(--ez-success);
}
.ez-option.ez-wrong {
    background: rgba(220, 38, 38, 0.18);
    border-color: var(--ez-danger);
}

/* Progress bar */
.ez-bar {
    width: 100%;
    max-width: 420px;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    overflow: hidden;
}
.ez-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ez-indigo-bright), var(--ez-coin));
    transition: width 0.2s linear;
}

/* On-screen D-pad for games that need directional input on touch */
.ez-dpad {
    position: absolute;
    bottom: calc(var(--ez-safe-bottom) + 22px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 14;
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(2, 56px);
    gap: 8px;
}
.ez-dpad button {
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 22px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
    color: var(--ez-text);
}
.ez-dpad button:active { background: var(--ez-indigo); transform: scale(0.93); }
.ez-dpad .ez-dpad-up    { grid-area: 1 / 2; }
.ez-dpad .ez-dpad-left  { grid-area: 2 / 1; }
.ez-dpad .ez-dpad-down  { grid-area: 2 / 2; }
.ez-dpad .ez-dpad-right { grid-area: 2 / 3; }

@media (min-width: 860px) and (pointer: fine) {
    /* Desktop testing: keyboard works, so the D-pad is just noise */
    .ez-dpad { display: none; }
}

/* Respect users who ask for less motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   3D games — asset loading card (see assets/js/ez3d.js)
   The 2D games paint instantly; a WebGL game has a few hundred KB of geometry
   to fetch first, so it gets a real progress card instead of a blank stage.
   ========================================================================== */

.ez3d-load {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: radial-gradient(120% 120% at 50% 0%, #1e293b 0%, var(--ez-bg) 60%);
}
.ez3d-load-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 0 32px;
    text-align: center;
}
.ez3d-load-spin {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--ez-indigo-bright);
    animation: ez3d-spin 0.85s linear infinite;
}
@keyframes ez3d-spin { to { transform: rotate(360deg); } }

.ez3d-load-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--ez-muted);
    letter-spacing: 0.2px;
}
.ez3d-load-bar {
    width: min(240px, 62vw);
    height: 5px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.09);
}
.ez3d-load-bar i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ez-indigo-bright), var(--ez-coin));
    transition: width 0.25s ease;
}
.ez3d-load-error .ez3d-load-label { color: var(--ez-coral); max-width: 300px; line-height: 1.5; }

/* Touch controls shared by the 3D games: steering on the left, pedals on the
   right, both thumbs resting where they already are. */
.ez3d-controls {
    position: absolute;
    left: 0; right: 0;
    bottom: calc(var(--ez-safe-bottom) + 22px);
    z-index: 14;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 calc(var(--ez-safe-right) + 16px) 0 calc(var(--ez-safe-left) + 16px);
    /* The container spans the screen so the two clusters can sit in opposite
       corners, but only the buttons themselves may take a pointer — otherwise
       it would swallow every drag meant for the stage behind it. */
    pointer-events: none;
}
.ez3d-cluster { display: flex; flex-direction: column; gap: 9px; align-items: center; }
.ez3d-row { display: flex; gap: 12px; pointer-events: auto; }

.ez3d-pedal {
    width: 78px;
    height: 78px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 25px;
    background: rgba(30, 41, 59, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border-strong);
    color: var(--ez-text);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.ez3d-pedal:active { background: var(--ez-indigo); transform: scale(0.94); }
.ez3d-steer { font-size: 27px; background: rgba(51, 65, 90, 0.82); }

@media (max-width: 360px) {
    .ez3d-pedal { width: 66px; height: 66px; font-size: 22px; }
    .ez3d-row { gap: 9px; }
}

/* Small readout strip (lap counter, shots left) under the HUD. */
.ez3d-readout {
    position: absolute;
    top: calc(var(--ez-safe-top) + 68px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 13;
    display: flex;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.3px;
    white-space: nowrap;
    color: var(--ez-text);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
}
.ez3d-readout b { color: var(--ez-coin); }
.ez3d-readout .ez3d-sep { color: var(--ez-faint); font-weight: 600; }

/* Race start countdown. */
.ez3d-countdown {
    position: absolute;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    font-size: clamp(64px, 22vw, 130px);
    font-weight: 800;
    letter-spacing: -3px;
    color: var(--ez-text);
    text-shadow: 0 8px 34px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    animation: ez3d-pulse 1s ease-out infinite;
}
@keyframes ez3d-pulse {
    0%   { transform: translate(-50%, -50%) scale(1.18); opacity: 0.35; }
    35%  { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.85; }
}

/* Nitro charge meter — a child of the right cluster, so it tracks the pedals. */
.ez3d-nitro {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--ez-border);
}
.ez3d-nitro i {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--ez-sky), #b6ecff);
}

/* Circuit minimap. pointer-events:none matters — it sits over the stage, and
   the stage is where drag-steering is picked up. */
.ez3d-minimap {
    position: absolute;
    top: calc(var(--ez-safe-top) + 108px);
    left: calc(var(--ez-safe-left) + 14px);
    z-index: 13;
    width: 104px;
    height: 104px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.66);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
    pointer-events: none;
}
@media (max-width: 360px) {
    .ez3d-minimap { width: 86px; height: 86px; top: calc(var(--ez-safe-top) + 100px); }
}

/* ---- Landscape on a phone ----
   Keyed off viewport HEIGHT rather than orientation: what actually breaks the
   3D HUD is a short viewport, and a small tablet held upright can be just as
   short as a phone on its side. Everything stacked down the screen — HUD,
   readout, minimap, pedals — has to give up room at once, or the minimap ends
   up sitting on top of the controls. */
@media (max-height: 480px) {
    .ez3d-minimap {
        width: 78px;
        height: 78px;
        top: calc(var(--ez-safe-top) + 54px);
        border-radius: 12px;
    }
    .ez3d-readout {
        top: calc(var(--ez-safe-top) + 50px);
        font-size: 11.5px;
        padding: 5px 11px;
    }
    .ez3d-aim { top: calc(var(--ez-safe-top) + 50px); }
    .ez3d-controls { bottom: calc(var(--ez-safe-bottom) + 12px); }
    .ez3d-pedal { width: 60px; height: 60px; font-size: 20px; }
    .ez3d-steer { font-size: 22px; }
    .ez3d-row { gap: 10px; }
    .ez3d-cluster { gap: 6px; }
    .ez3d-nitro { height: 6px; }
    .ez3d-countdown { font-size: clamp(44px, 18vh, 88px); }
    .ez3d-load-card { gap: 11px; }
    .ez3d-load-spin { width: 34px; height: 34px; }
}

/* Very short — landscape on a small phone. Pull the minimap in tighter still
   so it clears the steering thumb. */
@media (max-height: 380px) {
    .ez3d-minimap { width: 66px; height: 66px; top: calc(var(--ez-safe-top) + 46px); }
    .ez3d-pedal { width: 54px; height: 54px; font-size: 18px; }
    .ez3d-controls { bottom: calc(var(--ez-safe-bottom) + 8px); }
}

/* Slingshot power/angle read-out while dragging. */
.ez3d-aim {
    position: absolute;
    top: calc(var(--ez-safe-top) + 68px);
    right: calc(var(--ez-safe-right) + 16px);
    z-index: 13;
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 800;
    color: var(--ez-text);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ez-border);
}

/* ==========================================================================
   First-person HUD (games/strike-arena.html)

   A shooter needs its readouts in the player's peripheral vision and nothing
   in the middle of the screen, which is the opposite of every other game here
   — so it gets its own block rather than bending the shared HUD.

   Everything below is pointer-events:none by default. Only the two thumb
   controls opt back in; a stray transparent panel over the stage would eat the
   drag that aims the camera, and the bug reads as "the game ignored my swipe".
   ========================================================================== */

.ez3d-fps { position: absolute; inset: 0; z-index: 13; pointer-events: none; }

/* ---- crosshair ----
   Four ticks around a dot. --sp is the current spread in pixels, written every
   frame by the game: it opens while moving or firing and closes when you stand
   still, which is the only honest way to show accuracy. */
.ez3d-cross {
    position: absolute;
    left: 50%; top: 50%;
    width: 0; height: 0;
    --sp: 7px;
}
.ez3d-cross i {
    position: absolute;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
    transition: transform 0.06s ease-out;
}
.ez3d-cross i:nth-child(1),
.ez3d-cross i:nth-child(2) { width: 2px;  height: 8px; margin-left: -1px; margin-top: -4px; }
.ez3d-cross i:nth-child(3),
.ez3d-cross i:nth-child(4) { width: 8px;  height: 2px; margin-left: -4px; margin-top: -1px; }
.ez3d-cross i:nth-child(1) { transform: translateY(calc(-1 * var(--sp) - 4px)); }
.ez3d-cross i:nth-child(2) { transform: translateY(calc(var(--sp) + 4px)); }
.ez3d-cross i:nth-child(3) { transform: translateX(calc(-1 * var(--sp) - 4px)); }
.ez3d-cross i:nth-child(4) { transform: translateX(calc(var(--sp) + 4px)); }
.ez3d-cross b {
    position: absolute;
    width: 3px; height: 3px;
    margin: -1.5px 0 0 -1.5px;
    border-radius: 50%;
    background: var(--ez-coin);
}
.ez3d-cross.ez3d-onTarget i { background: var(--ez-coral); }

/* Hit confirmation. Deliberately a separate element from the crosshair: it has
   to be able to flash while the crosshair is mid-spread-animation. */
.ez3d-hitmark {
    position: absolute;
    left: 50%; top: 50%;
    width: 26px; height: 26px;
    margin: -13px 0 0 -13px;
    opacity: 0;
}
.ez3d-hitmark i {
    position: absolute;
    width: 9px; height: 2px;
    background: #fff;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}
.ez3d-hitmark i:nth-child(1) { top: 3px;  left: 1px;  transform: rotate(45deg); }
.ez3d-hitmark i:nth-child(2) { top: 3px;  right: 1px; transform: rotate(-45deg); }
.ez3d-hitmark i:nth-child(3) { bottom: 3px; left: 1px;  transform: rotate(-45deg); }
.ez3d-hitmark i:nth-child(4) { bottom: 3px; right: 1px; transform: rotate(45deg); }
.ez3d-hitmark.ez3d-show { animation: ez3d-hit 0.22s ease-out; }
.ez3d-hitmark.ez3d-kill i { background: var(--ez-coin); }
@keyframes ez3d-hit {
    0%   { opacity: 1; transform: scale(0.7); }
    100% { opacity: 0; transform: scale(1.35); }
}

/* ---- health ---- */
.ez3d-hp {
    position: absolute;
    left: calc(var(--ez-safe-left) + 18px);
    bottom: calc(var(--ez-safe-bottom) + 22px);
    width: 132px;
}
.ez3d-hp-bar {
    height: 9px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--ez-border-strong);
}
.ez3d-hp-bar i {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ez-mint), var(--ez-sky));
    transition: width 0.18s ease-out;
}
.ez3d-hp-low .ez3d-hp-bar i { background: linear-gradient(90deg, var(--ez-danger), var(--ez-coral)); }
.ez3d-hp-label {
    margin-top: 5px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: var(--ez-muted);
}

/* ---- ammo / weapon ---- */
.ez3d-ammo {
    position: absolute;
    right: calc(var(--ez-safe-right) + 18px);
    bottom: calc(var(--ez-safe-bottom) + 130px);
    text-align: right;
}
.ez3d-ammo-count { font-size: 30px; font-weight: 800; line-height: 1; color: var(--ez-text); }
.ez3d-ammo-count.ez3d-empty { color: var(--ez-coral); }
.ez3d-ammo-name {
    margin-top: 3px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 1.4px;
    color: var(--ez-coin);
}
.ez3d-reloading {
    margin-top: 5px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}
.ez3d-reloading i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--ez-coin);
}

/* ---- damage vignette ---- */
.ez3d-hurt {
    position: absolute;
    inset: 0;
    opacity: 0;
    background: radial-gradient(115% 95% at 50% 50%, rgba(220, 38, 38, 0) 42%, rgba(220, 38, 38, 0.85) 100%);
}

/* ---- banners and score pops ---- */
.ez3d-banner {
    position: absolute;
    left: 50%; top: 27%;
    transform: translateX(-50%);
    font-size: clamp(26px, 8vw, 46px);
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    white-space: nowrap;
    color: var(--ez-text);
    text-shadow: 0 6px 26px rgba(0, 0, 0, 0.75);
    opacity: 0;
}
.ez3d-banner.ez3d-show { animation: ez3d-banner 1.7s ease-out; }
@keyframes ez3d-banner {
    0%   { opacity: 0; transform: translateX(-50%) scale(0.82); }
    18%  { opacity: 1; transform: translateX(-50%) scale(1); }
    72%  { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scale(1.05); }
}

.ez3d-pop {
    position: absolute;
    left: 50%; top: 41%;
    transform: translateX(-50%);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.6px;
    white-space: nowrap;
    color: var(--ez-coin);
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.8);
    opacity: 0;
}
.ez3d-pop.ez3d-show { animation: ez3d-pop 0.75s ease-out; }
@keyframes ez3d-pop {
    0%   { opacity: 0; transform: translate(-50%, 8px) scale(0.9); }
    22%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -22px) scale(1); }
}

/* ---- desktop hint ---- */
.ez3d-hint {
    position: absolute;
    left: 50%; bottom: 16%;
    transform: translateX(-50%);
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--ez-text);
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid var(--ez-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ---- thumb controls ----
   The stick is drawn where the thumb lands rather than pinned to a corner: a
   fixed pad forces the hand to a spot the phone's size chose, and every size of
   hand picks a different one. */
.ez3d-stick {
    position: absolute;
    width: 116px; height: 116px;
    margin: -58px 0 0 -58px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.34);
    border: 1.5px solid var(--ez-border-strong);
    opacity: 0;
    transition: opacity 0.12s;
}
.ez3d-stick.ez3d-show { opacity: 1; }
.ez3d-stick i {
    position: absolute;
    left: 50%; top: 50%;
    width: 52px; height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.62);
    border: 1.5px solid rgba(255, 255, 255, 0.32);
}

.ez3d-fire {
    position: absolute;
    right: calc(var(--ez-safe-right) + 20px);
    bottom: calc(var(--ez-safe-bottom) + 24px);
    width: 92px; height: 92px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 30px;
    color: var(--ez-text);
    background: rgba(220, 38, 38, 0.28);
    border: 2px solid rgba(255, 107, 122, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.ez3d-fire:active { background: rgba(220, 38, 38, 0.5); transform: scale(0.95); }

/* Secondary thumb buttons — jump, reload, scope — stacked inboard of FIRE. */
.ez3d-side {
    position: absolute;
    right: calc(var(--ez-safe-right) + 124px);
    bottom: calc(var(--ez-safe-bottom) + 26px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}
.ez3d-mini {
    width: 58px; height: 58px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 21px;
    color: var(--ez-text);
    background: rgba(30, 41, 59, 0.74);
    border: 1px solid var(--ez-border-strong);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.ez3d-mini:active { background: var(--ez-indigo); transform: scale(0.94); }
.ez3d-mini.ez3d-on { background: var(--ez-indigo); border-color: var(--ez-indigo-light); }

/* Mode picker on the start screen. */
.ez-diff-wave { border-left: 4px solid var(--ez-coral); }
.ez-diff-gun  { border-left: 4px solid var(--ez-sky); }

@media (max-width: 380px) {
    .ez3d-fire { width: 78px; height: 78px; font-size: 26px; }
    .ez3d-side { right: calc(var(--ez-safe-right) + 106px); }
    .ez3d-mini { width: 50px; height: 50px; font-size: 18px; }
    .ez3d-ammo { bottom: calc(var(--ez-safe-bottom) + 116px); }
    .ez3d-hp { width: 108px; }
}

/* Landscape on a phone: the same squeeze the rest of the 3D HUD takes. */
@media (max-height: 480px) {
    .ez3d-fire { width: 72px; height: 72px; font-size: 24px; bottom: calc(var(--ez-safe-bottom) + 14px); }
    .ez3d-side { right: calc(var(--ez-safe-right) + 100px); bottom: calc(var(--ez-safe-bottom) + 16px); }
    .ez3d-mini { width: 46px; height: 46px; font-size: 17px; }
    .ez3d-stick { width: 96px; height: 96px; margin: -48px 0 0 -48px; }
    .ez3d-stick i { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
    .ez3d-ammo { bottom: calc(var(--ez-safe-bottom) + 96px); }
    .ez3d-ammo-count { font-size: 25px; }
    .ez3d-hp { bottom: calc(var(--ez-safe-bottom) + 14px); }
    .ez3d-banner { top: 20%; font-size: clamp(22px, 6.5vh, 38px); }
    .ez3d-hint { bottom: 11%; }
}
