/* Scan Rush mini game ------------------------------------------------- */

body.game-page {
    min-height: 100svh;
    background: linear-gradient(180deg, #23c7a6 0%, #14a1d6 18%, #0a6cff 45%, #0847b3 100%);
    background-attachment: fixed;
}

body.game-page .language-switcher a {
    opacity: 0.85;
}

body.game-page .language-switcher a.current {
    font-weight: 700;
    opacity: 1;
    text-decoration: none;
    pointer-events: none;
}

.game-main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 68px clamp(8px, 2.5vw, 24px) max(10px, env(safe-area-inset-bottom));
}

.game-shell {
    width: 100%;
    max-width: 980px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.hud {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
}

.hud-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 999px;
    padding: 6px 14px;
    font: inherit;
    font-size: 1rem;
    color: white;
    font-variant-numeric: tabular-nums;
    transition: transform 0.25s var(--ease-spring), background-color 0.25s;
}

.hud-chip b {
    font-size: 1.15rem;
    min-width: 1.4em;
    text-align: left;
}

/* stacked chips, all the same size: small label on top, value below */
.hud-chip {
    flex-direction: column;
    justify-content: center;
    gap: 0;
    padding: 4px 10px 5px;
    border-radius: 18px;
    width: 96px;
}

.hud-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
    line-height: 1.2;
    white-space: nowrap;
}

.hud-val {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.15;
}

.hud-sound {
    cursor: pointer;
}

.hud-sound .snd-state {
    min-width: 0;
}

.hud-sound.off {
    opacity: 0.75;
}

/* Timer inside the game area */
.stage-timer {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 22px 5px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #0a6cff;
    box-shadow: 0 6px 18px rgba(90, 50, 10, 0.25);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    transition: transform 0.25s var(--ease-spring), background-color 0.25s, color 0.25s;
}

.stage-timer .hud-label {
    color: #3a3a3c;
}

.stage-timer .hud-val {
    font-size: 1.2rem;
}

.stage-timer b {
    font-size: 2.1rem;
    font-weight: 900;
    line-height: 1.05;
    min-width: 1.2em;
    text-align: left;
}

.stage-timer.bump {
    transform: translateX(-50%) scale(1.15);
    background: #24c9a7;
    color: white;
}

.stage-timer.bump .hud-label,
.stage-timer.low .hud-label {
    color: white;
}

.stage-timer.low {
    background: #ff453a;
    color: white;
    animation: timer-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes timer-pulse {
    from { transform: translateX(-50%) scale(1); }
    to { transform: translateX(-50%) scale(1.1); }
}

.hud-chip.bump {
    transform: scale(1.18);
    background: rgba(36, 201, 167, 0.55);
}

/* Stage ------------------------------------------------------------------ */

.stage {
    position: relative;
    width: 100%;
    height: calc(100svh - 68px - 62px - max(10px, env(safe-area-inset-bottom)));
    min-height: 240px;
    max-height: 760px;
    border-radius: 28px;
    overflow: hidden;
    background: #e7c493;
    box-shadow: 0 24px 60px rgba(2, 18, 56, 0.35), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.stage.playing {
    cursor: none;
}

.stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Overlays ------------------------------------------------------------- */

.overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(6, 46, 112, 0.42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0s 0.3s;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s;
}

.ov-card {
    width: min(420px, 100%);
    max-height: 100%;
    background: white;
    color: #1c1c1e;
    border-radius: 28px;
    padding: 18px 22px 22px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(2, 18, 56, 0.35);
    transform: translateY(16px) scale(0.96);
    transition: transform 0.45s var(--ease-spring);
}

.overlay.show .ov-card {
    transform: none;
}

.ov-small {
    width: min(320px, 100%);
}

.ov-mascot {
    display: block;
    width: 108px;
    height: auto;
    margin: -4px auto 2px;
    animation: bob 4s ease-in-out infinite;
}

.ov-card h1,
.ov-card h2 {
    font-size: clamp(1.7rem, 6vw, 2.2rem);
    line-height: 1.1;
    margin: 0 0 6px;
    color: #0a6cff;
    letter-spacing: -0.01em;
}

.ov-lead {
    margin: 0 0 12px;
    font-size: 1rem;
    line-height: 1.45;
    color: #3a3a3c;
}

.ov-big {
    font-size: 2.6rem;
    margin: 0 0 4px;
}

.how {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    text-align: left;
    font-size: 0.92rem;
    line-height: 1.35;
    color: #3a3a3c;
}

.how li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 7px;
}

.how-ico {
    flex: none;
    width: 30px;
    height: 22px;
    border-radius: 6px;
    display: inline-grid;
    place-items: center;
    font-size: 1rem;
    background: #eef4ff;
}

.how-red {
    background: linear-gradient(0deg, rgba(255, 59, 48, 0.75) 55%, #5b4a3a 55%);
    box-shadow: inset 0 0 0 2px white, 0 0 0 1px #5b4a3a;
}

.how-white {
    background: linear-gradient(0deg, #e9eef5 55%, #5b4a3a 55%);
    box-shadow: inset 0 0 0 2px white, 0 0 0 1px #5b4a3a;
}

/* "Put your finger here" target */
.start-target {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 0;
    background: none;
    font: inherit;
    color: #0a6cff;
    font-weight: 800;
    font-size: 1.02rem;
    cursor: pointer;
    padding: 4px 8px;
    touch-action: none;
}

.start-ring {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: radial-gradient(circle, #24c9a7 0 34%, rgba(36, 201, 167, 0.25) 36% 100%);
    box-shadow: 0 0 0 4px rgba(10, 108, 255, 0.2);
    animation: ring-pulse 1.3s ease-in-out infinite;
}

@keyframes ring-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(10, 108, 255, 0.2); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 14px rgba(10, 108, 255, 0.06); }
}

/* Countdown and banner ---------------------------------------------------- */

.countdown,
.banner {
    position: absolute;
    z-index: 2;
    left: 50%;
    pointer-events: none;
    color: white;
    font-weight: 900;
    text-align: center;
    white-space: nowrap;
    -webkit-text-stroke: 0;
    text-shadow: 0 4px 0 #0a6cff, 0 10px 24px rgba(2, 18, 56, 0.4);
}

.countdown {
    top: 50%;
    font-size: clamp(7rem, 36vmin, 15rem);
    transform: translate(-50%, -50%);
    opacity: 0;
}

.countdown.pop {
    animation: count-pop 0.6s var(--ease-out) both;
}

@keyframes count-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(2); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(0.95); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
}

.banner {
    top: 84px;
    font-size: clamp(1.3rem, 5vmin, 2rem);
    transform: translateX(-50%);
    opacity: 0;
    background: #ff8a2a;
    border-radius: 999px;
    padding: 6px 20px;
    text-shadow: none;
    box-shadow: 0 8px 20px rgba(2, 18, 56, 0.3);
}

.banner.show {
    animation: banner-in 1.8s var(--ease-out) both;
}

@keyframes banner-in {
    0% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.8); }
    15% { opacity: 1; transform: translateX(-50%) scale(1.06); }
    25% { transform: translateX(-50%) scale(1); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* Big first-item instructions, near the top of the game area */
.tutorial-tip {
    position: absolute;
    z-index: 2;
    top: 92px;
    left: 50%;
    max-width: calc(100% - 24px);
    transform: translateX(-50%);
    padding: 8px 22px 9px;
    border-radius: 999px;
    background: rgba(70, 55, 45, 0.82);
    color: white;
    font-size: clamp(1.35rem, 5.5vmin, 2.3rem);
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 8px 22px rgba(60, 35, 10, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
}

.tutorial-tip.show {
    opacity: 1;
    animation: tip-in 0.45s var(--ease-spring) both;
}

@keyframes tip-in {
    from { transform: translateX(-50%) scale(0.7); }
    to { transform: translateX(-50%) scale(1); }
}

/* Game over --------------------------------------------------------------- */

.ov-score {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.4;
}

.ov-score b {
    color: #0a6cff;
    font-size: 1.6em;
}

.ov-best {
    margin: 0 0 14px;
    color: #6b6b70;
    font-weight: 600;
}

.ov-best.record {
    color: #ff8a2a;
    font-weight: 800;
}

.ov-cta {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e5e5ea;
    font-size: 0.9rem;
    color: #3a3a3c;
}

.ov-cta p {
    margin: 0 0 10px;
}

.ov-cta .store-cta .app-store-badge {
    height: 46px;
    margin: 0 auto;
}

/* Small screens ------------------------------------------------------------- */

@media (max-width: 420px) {
    .hud-chip {
        padding: 5px 10px;
        font-size: 0.92rem;
    }

    .hud-chip {
        width: 84px;
        padding: 3px 8px 4px;
    }

    .stage-timer b {
        font-size: 1.8rem;
    }

    #hud-time b {
        font-size: 1.75rem;
    }
}

@media (max-height: 640px) {
    .ov-card .how {
        display: none;
    }

    .ov-mascot {
        width: 80px;
    }
}

@media (max-height: 470px) {
    .ov-mascot,
    .ov-cta p {
        display: none;
    }

    .ov-card {
        padding: 12px 18px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ov-mascot,
    .start-ring,
    .stage-timer.low,
    .tutorial-tip.show {
        animation: none;
    }
}
