/* Turbo Scratch — FunDash neon / casino */

:root {
    --bg: #080f1e;
    --surface: #111b30;
    --neon-pink: #e879f9;
    --neon-cyan: #22d3ee;
    --neon-gold: #f59e0b;
    --text: #f0f5ff;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: Inter, Roboto, system-ui, sans-serif;
    background: radial-gradient(ellipse 100% 80% at 50% -10%, #0e1e3a 0%, var(--bg) 55%);
    color: var(--text);
    overflow: hidden;
}

body {
    padding: 0;
}

.scratch-app {
    height: 100dvh;
    max-height: 100dvh;
    display: grid;
    grid-template-rows: auto auto auto auto 1fr auto auto;
    justify-items: center;
    gap: 0.3rem;
    padding:
        calc(0.45rem + env(safe-area-inset-top))
        calc(0.55rem + env(safe-area-inset-right))
        calc(0.45rem + env(safe-area-inset-bottom))
        calc(0.55rem + env(safe-area-inset-left));
    box-sizing: border-box;
    overflow: hidden;
}

.scratch-header {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.15rem;
    position: relative;
    z-index: 120;
}

.scratch-brand {
    display: inline-flex;
    align-self: flex-start;
    line-height: 0;
    text-decoration: none;
}

.prize-strip {
    text-align: center;
    width: 100%;
    font-size: clamp(0.68rem, 2.8vw, 0.76rem);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.prize-strip strong {
    display: block;
    font-size: clamp(0.78rem, 3.2vw, 0.95rem);
    color: var(--neon-gold);
    text-shadow: 0 0 12px rgba(255, 204, 0, 0.45);
    line-height: 1.25;
}

.subtitle {
    width: 100%;
    max-width: 400px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
    font-size: clamp(0.72rem, 2.8vw, 0.8rem);
}

.cards-bar {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 46, 166, 0.12), rgba(0, 245, 255, 0.08));
    border: 1px solid var(--border);
    font-size: clamp(0.76rem, 2.8vw, 0.84rem);
}

.cards-bar strong {
    color: var(--neon-cyan);
}

.btn-more-cards {
    display: none;
    width: 100%;
    max-width: 400px;
    margin-bottom: 0.25rem;
    padding: 0.72rem 1rem;
    border: 2px solid var(--neon-pink);
    border-radius: 14px;
    background: linear-gradient(180deg, #ff3ec0 0%, #c2185b 100%);
    color: #fff;
    font-weight: 900;
    font-size: clamp(0.95rem, 4vw, 1.1rem);
    letter-spacing: 0.08em;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    box-shadow: 0 0 24px rgba(255, 46, 166, 0.45);
    min-height: 44px;
    position: relative;
    z-index: 125;
}

.btn-more-cards.visible {
    display: block;
}

/* Card sizing strategy:                                                       */
/* - Width is the smaller of 360px, (viewport - horizontal gutters), and       */
/*   the row-height of the 1fr grid cell (so the card never overflows          */
/*   vertically on short phones).                                              */
/* - align-self:center prevents the grid from stretching the wrap tall and     */
/*   breaking the aspect-ratio: 1 square shape, which had been making the      */
/*   canvas un-interactive / visually "stuck" on iPhone SE-class devices.     */
.card-stage-wrap {
    width: min(360px, 100% - 16px, 72dvh);
    max-width: 360px;
    aspect-ratio: 1;
    margin-inline: auto;
    align-self: center;
    justify-self: center;
    position: relative;
    z-index: 120;
}

.card-stage {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid var(--neon-cyan);
    box-shadow:
        0 0 0 1px rgba(0, 245, 255, 0.25),
        0 0 32px rgba(0, 245, 255, 0.2),
        inset 0 0 40px rgba(0, 0, 0, 0.5);
}

/* Moving silver sheen over scratch layer (non-interactive) */
.scratch-shimmer-sheen {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    border-radius: 14px;
    background: linear-gradient(
        118deg,
        transparent 36%,
        rgba(255, 255, 255, 0.08) 44%,
        rgba(255, 255, 255, 0.42) 50%,
        rgba(200, 220, 255, 0.18) 56%,
        transparent 64%
    );
    background-size: 240% 240%;
    mix-blend-mode: soft-light;
    animation: scratch-silver-shimmer 2.6s linear infinite;
}

@keyframes scratch-silver-shimmer {
    0% {
        background-position: 120% 40%;
    }
    100% {
        background-position: -40% 60%;
    }
}

.scratch-fx-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    z-index: 4;
}

.symbols-grid {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    background: linear-gradient(180deg, #1e1530 0%, #0f0a18 100%);
    gap: 2px;
    padding: 2px;
}

.symbol-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2rem, 11vw, 2.75rem);
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    user-select: none;
}

.symbols-grid.revealed-glitz .symbol-cell {
    animation: symbol-sparkle 1s ease-out both;
}

.symbols-grid.revealed-glitz .symbol-cell:nth-child(3n + 1) {
    animation-delay: 0.05s;
}
.symbols-grid.revealed-glitz .symbol-cell:nth-child(3n + 2) {
    animation-delay: 0.12s;
}
.symbols-grid.revealed-glitz .symbol-cell:nth-child(3n) {
    animation-delay: 0.2s;
}

@keyframes symbol-sparkle {
    0% {
        filter: brightness(1);
        transform: scale(1);
    }
    35% {
        filter: brightness(1.45) drop-shadow(0 0 10px rgba(255, 255, 255, 0.85));
        transform: scale(1.06);
    }
    100% {
        filter: brightness(1);
        transform: scale(1);
    }
}

#scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: crosshair;
    z-index: 2;
}

.status-msg {
    width: 100%;
    max-width: 400px;
    margin-top: 0.2rem;
    min-height: 2.5em;
    text-align: center;
    font-size: 0.88rem;
    color: var(--muted);
}

.status-msg.win {
    color: var(--neon-gold);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.status-msg.lose {
    color: #ff6b9d;
}

.ad-strip {
    width: min(320px, 100%);
    min-height: 50px;
    max-height: 50px;
    margin-top: 0.1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    background: rgba(17, 17, 17, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--muted);
    z-index: 90;
}

/* Ad overlays — same pattern as vault / fruit */
.ad-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
}

.ad-overlay-msg {
    color: #fff;
    font-size: clamp(1.2rem, 5vw, 1.65rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
}

.ad-overlay-btn {
    display: none;
    margin-top: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: clamp(1rem, 4vw, 1.3rem);
    font-weight: 800;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: #222;
    color: #00ff88;
}

.big-win-flash {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: radial-gradient(circle at 50% 50%, rgba(255, 204, 0, 0.35) 0%, transparent 55%);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.big-win-flash.on {
    opacity: 1;
}

/* ─── Short-phone + small-phone optimizations (Phase 2) ───────────── */
@media (max-height: 680px) {
    .card-stage-wrap { max-width: 300px; }
    .scratch-title, .scratch-header .scratch-title { font-size: clamp(0.95rem, 4vw, 1.15rem); }
}
@media (max-width: 360px) {
    .card-stage-wrap { max-width: calc(100% - 32px); }
}
