/* =============================================
   LEO SLOT MACHINE
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #ffd700;
    --gold-dark: #b8860b;
    --gold-light: #ffec80;
    --lime: #c8ff00;
    --lime-dark: #90c000;
    --lime-glow: rgba(200, 255, 0, 0.45);
    --neon-red: #ff1744;
    --neon-blue: #00e5ff;
    --neon-green: #00e676;
    --neon-yellow: #ffea00;
    --bg-dark: #0f142d;
    --bg-darker: #080c1a;
    --frame-dark: #1a1e35;
    --frame-mid: #22284a;
    --reel-bg: #080c1a;
    --led-green: #00ff41;
    --led-red: #ff0040;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-dark);
    color: white;
    /* Disable selection and touch highlights */
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

/* --- Casino Background --- */
.casino-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(30, 38, 80, 0.7) 0%, transparent 70%),
        radial-gradient(ellipse at 20% 80%, rgba(200, 255, 0, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 229, 255, 0.04) 0%, transparent 50%),
        var(--bg-dark);
    z-index: -2;
}

/* =============================================
   SPLASH SCREEN
   ============================================= */
.splash-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash-screen.active {
    visibility: visible;
    opacity: 1;
}

.splash-logo {
    width: 200px;
    max-width: 40vw;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
    animation: splashLogoPulse 3s ease-in-out infinite alternate;
}

@keyframes splashLogoPulse {
    from { filter: drop-shadow(0 0 10px rgba(200, 255, 0, 0.2)); }
    to   { filter: drop-shadow(0 0 30px rgba(200, 255, 0, 0.5)); }
}

.splash-coin-wrap {
    animation: coinBounce 1.2s ease-in-out infinite alternate;
}

@keyframes coinBounce {
    from { transform: translateY(0px); }
    to   { transform: translateY(-14px); }
}

.splash-coin {
    width: 80px;
    height: auto;
}

.splash-text {
    font-family: 'Georgia', serif;
    font-size: 1.8rem;
    font-weight: bold;
    color: #5bc8f5;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(91, 200, 245, 0.6), 0 0 30px rgba(91, 200, 245, 0.3);
    text-align: center;
    padding: 0 20px;
}

.splash-hint {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
}

.splash-hint kbd {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: inherit;
    font-size: 0.85rem;
}

/* .hidden helper */
.hidden { display: none !important; }

/* Splash state container */
.splash-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

/* Splash "ready" — crediti inseriti, premi S per iniziare */
.splash-credits-box {
    text-align: center;
}

.splash-credits-label {
    display: block;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 4px;
    color: #888;
    margin-bottom: 6px;
}

.splash-credits-value {
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--led-green);
    letter-spacing: 4px;
    text-shadow: 0 0 12px var(--led-green), 0 0 30px rgba(0, 255, 65, 0.4);
}

.splash-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.splash-start-btn {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--lime);
    letter-spacing: 2px;
    text-shadow: 0 0 12px var(--lime), 0 0 25px rgba(200, 255, 0, 0.5);
    animation: startBtnPulse 1.2s ease-in-out infinite alternate;
}

.splash-start-btn kbd {
    background: rgba(200, 255, 0, 0.2);
    border: 1px solid var(--lime);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: inherit;
    font-size: 1.1rem;
    color: var(--lime);
}

@keyframes startBtnPulse {
    from { opacity: 0.7; transform: scale(1); }
    to   { opacity: 1;   transform: scale(1.04); }
}

/* =============================================
   RESULT SCREENS (WIN / LOSE) — immagine a tutto schermo
   ============================================= */
.result-screen {
    position: fixed;
    inset: 0;
    z-index: 400;
    visibility: hidden;
    opacity: 0;
    /* nessun background: l'immagine copre tutto */
    overflow: hidden;
}

.result-screen.active {
    visibility: visible;
    opacity: 1;
}

/* L'immagine copre l'intero schermo come un poster */
.result-screen img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Testo hint in basso, sopra l'immagine */
.result-hint {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 2px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9), 0 0 20px rgba(0,0,0,0.8);
    z-index: 1;
    background: rgba(0,0,0,0.45);
    padding: 8px 20px;
    border-radius: 30px;
    backdrop-filter: blur(4px);
}

.result-hint kbd {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    padding: 1px 7px;
    font-family: inherit;
}

/* Flash bianco che lampeggia all'entrata — WIN */
.result-screen#winScreen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}
.result-screen#winScreen.win-anim::after,
.result-screen#winScreen.jackpot-anim::after {
    animation: screenFlash 0.6s ease-out both;
}

@keyframes screenFlash {
    0%   { opacity: 0.9; }
    100% { opacity: 0; }
}

/* ---- WIN: rimbalzo gioioso ---- */
.result-screen.win-anim {
    animation: winEntry 0.9s cubic-bezier(0.22, 1.5, 0.36, 1) both,
               winShake  0.5s ease-in-out 1s both;
}

@keyframes winEntry {
    0%   { transform: scale(0.05) rotate(-12deg); opacity: 0; filter: brightness(3); }
    45%  { transform: scale(1.12) rotate(5deg);   opacity: 1; filter: brightness(1.4); }
    65%  { transform: scale(0.93) rotate(-3deg);               filter: brightness(1); }
    82%  { transform: scale(1.04) rotate(1.5deg); }
    100% { transform: scale(1)    rotate(0deg);   opacity: 1; filter: brightness(1); }
}

@keyframes winShake {
    0%,100% { transform: translateX(0); }
    18%     { transform: translateX(-12px) rotate(-1deg); }
    36%     { transform: translateX(12px)  rotate(1deg); }
    54%     { transform: translateX(-7px)  rotate(-0.5deg); }
    72%     { transform: translateX(7px)   rotate(0.5deg); }
}

/* ---- JACKPOT: ancora più esplosivo ---- */
.result-screen.jackpot-anim {
    animation: jackpotEntry  0.7s cubic-bezier(0.22, 1.6, 0.36, 1) both,
               jackpotPulse  0.35s ease-in-out 0.8s 8 alternate,
               winShake      0.6s ease-in-out 1.2s both;
}

@keyframes jackpotEntry {
    0%   { transform: scale(0) rotate(-20deg);    opacity: 0; filter: brightness(5) saturate(2); }
    35%  { transform: scale(1.25) rotate(10deg);  opacity: 1; filter: brightness(2) saturate(1.5); }
    58%  { transform: scale(0.88) rotate(-5deg);               filter: brightness(1.2); }
    78%  { transform: scale(1.08) rotate(3deg); }
    100% { transform: scale(1)    rotate(0deg);   opacity: 1; filter: brightness(1); }
}

@keyframes jackpotPulse {
    from { filter: brightness(1)   saturate(1); }
    to   { filter: brightness(1.4) saturate(1.6); }
}

/* ---- LOSE: sipario pesante che cade ---- */
.result-screen.lose-anim {
    animation: loseEntry 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes loseEntry {
    0%   { transform: translateY(-100%) scaleY(1.05); opacity: 0;   filter: brightness(0.3); }
    35%  { opacity: 0.5;                                             filter: brightness(0.6); }
    72%  { transform: translateY(4%)    scaleY(1.02); opacity: 1;   filter: brightness(0.9); }
    85%  { transform: translateY(-1.5%) scaleY(0.99); }
    93%  { transform: translateY(0.8%); }
    100% { transform: translateY(0)     scaleY(1);    opacity: 1;   filter: brightness(1); }
}

/* =============================================
   SLOT MACHINE CONTAINER
   ============================================= */
.slot-machine {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(1080px, 96vw);
    user-select: none;
    -webkit-user-select: none;
}

/* =============================================
   LOGO LEO
   ============================================= */
.logo {
    text-align: center;
    margin-bottom: 12px;
}

.logo-image {
    width: clamp(160px, 18vw, 280px);
    height: auto;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.25));
    animation: logoPulse 3s ease-in-out infinite alternate;
}

@keyframes logoPulse {
    from { filter: drop-shadow(0 0 8px rgba(200, 255, 0, 0.15)); }
    to   { filter: drop-shadow(0 0 22px rgba(200, 255, 0, 0.4)); }
}

/* =============================================
   MACHINE FRAME (Lime/Yellow glow border)
   ============================================= */
.machine-frame {
    width: 100%;
    background: linear-gradient(145deg, #1e2240 0%, #151930 50%, #0f1228 100%);
    border: 3px solid var(--lime-dark);
    border-radius: 20px;
    padding: 24px 28px;
    position: relative;
    box-shadow:
        0 0 20px var(--lime-glow),
        0 0 50px rgba(200, 255, 0, 0.15),
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 20px 60px rgba(0, 0, 0, 0.8);
}

.machine-frame::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 21px;
    background: linear-gradient(145deg, var(--lime), var(--lime-dark), var(--lime), var(--lime-dark));
    z-index: -1;
    animation: framePulse 2.5s ease-in-out infinite alternate;
}

@keyframes framePulse {
    from { opacity: 0.5; }
    to   { opacity: 0.9; }
}

/* =============================================
   STARS DISPLAY (above reels)
   ============================================= */
.stars-display {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-bottom: 18px;
}

.star {
    color: rgba(200, 255, 0, 0.55);
    font-size: 1.6rem;
    text-shadow: 0 0 6px rgba(200, 255, 0, 0.3);
    animation: starTwinkle 1.5s ease-in-out infinite alternate;
}

.star.active-star {
    color: var(--lime);
    text-shadow: 0 0 10px var(--lime), 0 0 20px var(--lime);
    animation: starTwinkleActive 1.5s ease-in-out infinite alternate;
}

.star:nth-child(1) { animation-delay: 0s; }
.star:nth-child(2) { animation-delay: 0.3s; }
.star:nth-child(3) { animation-delay: 0.6s; }
.star:nth-child(4) { animation-delay: 0.9s; }
.star:nth-child(5) { animation-delay: 1.2s; }

@keyframes starTwinkle {
    from { opacity: 0.45; transform: scale(0.88); }
    to   { opacity: 0.85; transform: scale(1.12); }
}

@keyframes starTwinkleActive {
    from { opacity: 0.7; transform: scale(0.9);  text-shadow: 0 0 6px var(--lime); }
    to   { opacity: 1;   transform: scale(1.25); text-shadow: 0 0 18px var(--lime), 0 0 35px var(--lime); }
}

/* =============================================
   REELS AREA
   ============================================= */
.reels-container {
    margin-bottom: 20px;
}

.reels-frame {
    position: relative;
    background: #000;
    border: 2px solid var(--lime-dark);
    border-radius: 12px;
    padding: 4px;
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.9),
        0 0 12px rgba(200, 255, 0, 0.15);
    display: flex;
    align-items: center;
}

.reels-window {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border-radius: 8px;
    background: var(--reel-bg);
    flex: 1;
    /* L'altezza vive qui; i figli si adattano via stretch */
    height: clamp(220px, 36vh, 400px);
}

.reel-canvas {
    /* flex: 1 1 0% + min-width: 0 garantisce che tutti e 3 i rulli
       abbiano uguale larghezza senza straripare */
    flex: 1 1 0%;
    min-width: 0;
    display: block;
    /* altezza ereditata dallo stretch del parent */
}

.reel-divider {
    width: 3px;
    flex-shrink: 0;
    /* altezza ereditata dallo stretch del parent */
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--lime-dark) 20%,
        var(--lime) 50%,
        var(--lime-dark) 80%,
        transparent 100%
    );
}

/* --- Win Line --- */
.win-line {
    position: absolute;
    left: 35px; right: 35px;
    top: 50%;
    height: 3px;
    transform: translateY(-50%);
    background: var(--neon-red);
    box-shadow: 0 0 8px var(--neon-red), 0 0 15px var(--neon-red);
    opacity: 0.6;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.3s;
}

.win-line.active {
    opacity: 1;
    animation: winLineFlash 0.3s ease-in-out infinite alternate;
}

@keyframes winLineFlash {
    from { box-shadow: 0 0 8px var(--neon-red), 0 0 15px var(--neon-red); height: 3px; }
    to   { box-shadow: 0 0 15px var(--neon-red), 0 0 35px var(--neon-red), 0 0 55px var(--neon-red); height: 5px; }
}

.win-line-indicator {
    color: var(--neon-red);
    font-size: 1rem;
    text-shadow: 0 0 10px var(--neon-red);
    padding: 0 6px;
    flex-shrink: 0;
    z-index: 6;
}

/* =============================================
   BOTTOM DISPLAYS
   ============================================= */
.bottom-displays {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.display-panel {
    flex: 1;
    background: linear-gradient(180deg, #07091a 0%, #040612 100%);
    border: 1px solid #2a2f50;
    border-radius: 10px;
    padding: 12px 16px;
    text-align: center;
}

.display-label {
    display: block;
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 3px;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.led-display {
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 3px;
}

.credits-display .led-display {
    color: var(--led-green);
    text-shadow: 0 0 8px var(--led-green), 0 0 20px rgba(0, 255, 65, 0.3);
}

.bet-display .led-display {
    color: var(--neon-yellow);
    text-shadow: 0 0 8px var(--neon-yellow), 0 0 20px rgba(255, 234, 0, 0.3);
}

.win-display .led-display {
    color: var(--neon-blue);
    text-shadow: 0 0 8px var(--neon-blue), 0 0 20px rgba(0, 229, 255, 0.3);
}

.win-display.big-win .led-display {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold), 0 0 30px var(--gold);
    animation: bigWinPulse 0.3s ease-in-out infinite alternate;
}

@keyframes bigWinPulse {
    from { transform: scale(1); }
    to   { transform: scale(1.1); }
}

/* =============================================
   CONTROLS — PLAY BUTTON
   ============================================= */
.controls {
    display: flex;
    justify-content: center;
}

.btn {
    border: none;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: translateY(2px);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* The big orange PRESS TO PLAY button — solo visivo, nessun click */
.btn-play {
    pointer-events: none;
    width: 100%;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(180deg, #d45800 0%, #a03500 50%, #7a2200 100%);
    color: var(--gold);
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 2px;
    border: 3px solid #ff7700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow:
        0 5px 20px rgba(212, 88, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.btn-play:hover:not(:disabled) {
    background: linear-gradient(180deg, #e86000 0%, #b83e00 50%, #9a3000 100%);
    box-shadow:
        0 6px 28px rgba(232, 96, 0, 0.65),
        0 0 20px rgba(232, 96, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    border-color: #ff9933;
}

.btn-play:active:not(:disabled) {
    background: linear-gradient(180deg, #9a3000 0%, #6a1800 50%, #4a1000 100%);
    box-shadow: 0 2px 10px rgba(212, 88, 0, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.5);
    transform: translateY(2px);
}

.btn-play.spinning {
    opacity: 0.5;
    cursor: not-allowed;
}

.play-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 38%, #ff9a00, #cc4400);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffb84d;
    color: var(--gold);
    font-size: 0.9rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.play-text {
    letter-spacing: 2px;
    font-size: 0.9rem;
}

/* =============================================
   IN-MACHINE WIN OVERLAY (flash)
   ============================================= */
.win-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
}

.win-overlay.active {
    opacity: 1;
}

.win-text {
    font-family: 'Georgia', serif;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--gold);
    text-shadow:
        0 0 10px var(--gold),
        0 0 20px var(--gold),
        0 0 40px var(--neon-red),
        3px 3px 0 #000;
    text-align: center;
    white-space: pre-line;
    animation: winTextBounce 0.5s ease-out;
}

@keyframes winTextBounce {
    0%   { transform: scale(0.3); opacity: 0; }
    50%  { transform: scale(1.2); }
    70%  { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* =============================================
   PARTICLES CANVAS
   ============================================= */
#particlesCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 200;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 750px) {
    .slot-machine { width: 100vw; }
    .logo-image { width: 130px; }
    .machine-frame { border-radius: 12px; padding: 14px 16px; }
    .stars-display { gap: 14px; margin-bottom: 12px; }
    .star { font-size: 1.3rem; }
    .reels-container { margin-bottom: 14px; }
    .bottom-displays { gap: 10px; margin-bottom: 14px; }
    .display-panel { padding: 8px 10px; }
    .led-display { font-size: 1.4rem; }
    .btn-play { height: 48px; }
    .play-text { font-size: 0.75rem; letter-spacing: 1px; }
    .splash-text { font-size: 1.3rem; }
}

@media (max-width: 480px) {
    .logo-image { width: 100px; }
    .machine-frame { padding: 10px 12px; }
    .bottom-displays { gap: 6px; }
    .display-panel { padding: 6px 8px; }
    .led-display { font-size: 1.1rem; letter-spacing: 1px; }
    .play-text { display: none; }
    .btn-play { width: auto; padding: 0 24px; }
}

@media (max-height: 720px) {
    .logo { margin-bottom: 6px; }
    .logo-image { width: clamp(90px, 12vw, 160px); }
    .stars-display { gap: 14px; margin-bottom: 10px; }
    .star { font-size: 1.2rem; }
    .machine-frame { padding: 14px 20px; }
    .reels-container { margin-bottom: 12px; }
    .bottom-displays { margin-bottom: 12px; }
    .display-panel { padding: 8px 10px; }
    .led-display { font-size: 1.5rem; }
}
