/* YoDuel — Western Duel Game */
:root {
    --bg: #0a0a0a;
    --gold: #D4A03C;
    --gold-dark: #A67C28;
    --red: #C0392B;
    --green: #27AE60;
    --text: #F0E6D2;
    --text-dim: #8B7D6B;
    --surface: #1A1A1A;
    --surface-2: #252525;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Courier New', monospace;
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Western background */
.western-bg {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background:
        linear-gradient(180deg, rgba(10,10,10,.7) 0%, rgba(30,20,10,.4) 50%, rgba(10,10,10,.8) 100%),
        url('https://images.unsplash.com/photo-1509316785289-025f5b846b35?w=1200&q=60') center/cover no-repeat;
}
.western-bg::before {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 200px;
    background: linear-gradient(to top, rgba(212,160,60,.15), transparent);
}
.western-bg::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* Container */
.game { width: 100vw; height: 100vh; display: flex; flex-direction: column; position: relative; }

/* Schermo intero con testo centrato */
.screen {
    position: absolute; inset: 0;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 32px; text-align: center;
    transition: opacity .3s;
}
.screen.active { display: flex; }
.screen > *:not(.western-bg) { position: relative; z-index: 1; }

/* Logo / Titolo */
.logo { font-size: 48px; font-weight: 900; letter-spacing: 4px; color: var(--gold); text-shadow: 0 0 40px rgba(212,160,60,.3); margin-bottom: 8px; }
.logo span { color: var(--red); }
.subtitle { font-size: 14px; color: var(--text-dim); letter-spacing: 6px; text-transform: uppercase; margin-bottom: 48px; }

/* Form */
.input-group { margin-bottom: 24px; width: 100%; max-width: 300px; }
.input-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; display: block; }
.input-field {
    width: 100%; padding: 16px 20px; background: var(--surface);
    border: 2px solid var(--gold-dark); border-radius: 8px;
    color: var(--text); font-family: inherit; font-size: 18px; font-weight: 700;
    text-align: center; outline: none;
}
.input-field:focus { border-color: var(--gold); box-shadow: 0 0 20px rgba(212,160,60,.2); }

/* Bottoni */
.btn {
    padding: 18px 48px; border: none; border-radius: 12px;
    font-family: inherit; font-size: 18px; font-weight: 900;
    cursor: pointer; text-transform: uppercase; letter-spacing: 3px;
    transition: all .2s;
}
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #000; }
.btn-gold:active { transform: scale(.95); }
.btn-red { background: var(--red); color: #fff; }
.btn-green { background: var(--green); color: #fff; }

/* Stato attesa */
.waiting-dots { display: flex; gap: 8px; margin: 24px 0; }
.waiting-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gold-dark); animation: pulse-dot 1.4s infinite; }
.waiting-dot:nth-child(2) { animation-delay: .2s; }
.waiting-dot:nth-child(3) { animation-delay: .4s; }
@keyframes pulse-dot { 0%,80%,100% { opacity: .3; transform: scale(.8); } 40% { opacity: 1; transform: scale(1.2); } }

/* Players */
.players { display: flex; gap: 32px; margin: 32px 0; }
.player-slot {
    padding: 20px 32px; background: var(--surface);
    border: 2px solid var(--surface-2); border-radius: 12px;
    min-width: 140px;
}
.player-slot.joined { border-color: var(--gold); }
.player-slot.ready { border-color: var(--green); background: rgba(39,174,96,.1); }
.player-name { font-size: 18px; font-weight: 700; }
.player-status { font-size: 11px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }

/* Preparati */
.prepare-text {
    font-size: 64px; font-weight: 900; color: var(--gold);
    text-shadow: 0 0 60px rgba(212,160,60,.5);
    animation: breathe 2s infinite;
}
@keyframes breathe { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

/* FUOCO! */
.fire-screen { background: #000 !important; }
.fire-text {
    font-size: min(30vw, 200px); font-weight: 900; color: var(--red);
    text-shadow: 0 0 80px rgba(192,57,43,.8), 0 0 160px rgba(192,57,43,.4);
    animation: fire-flash .1s ease-out;
    letter-spacing: 8px;
}
@keyframes fire-flash { from { transform: scale(2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Bottone FUOCO (sostituto volume button) */
.fire-btn {
    position: fixed; bottom: 0; left: 0; right: 0; height: 50vh;
    background: transparent; border: none; cursor: pointer;
    display: none; z-index: 100;
    -webkit-tap-highlight-color: transparent;
}
.fire-btn.visible { display: block; }
.fire-btn:active { background: rgba(192,57,43,.1); }
.fire-hint { position: fixed; bottom: 24px; left: 0; right: 0; text-align: center; font-size: 13px; color: var(--text-dim); letter-spacing: 2px; z-index: 101; }

/* Tilt indicator */
.tilt-bar {
    position: fixed; right: 16px; top: 50%; transform: translateY(-50%);
    width: 8px; height: 200px; background: var(--surface-2); border-radius: 8px;
    overflow: hidden; z-index: 50;
}
.tilt-fill { position: absolute; bottom: 0; left: 0; right: 0; background: var(--red); border-radius: 8px; transition: height .1s; }
.tilt-target { position: absolute; left: -4px; right: -4px; height: 40px; top: 10px; border: 2px solid var(--green); border-radius: 4px; }
.tilt-ok .tilt-fill { background: var(--green); }

/* Risultato */
.result-winner { font-size: 48px; font-weight: 900; color: var(--gold); margin-bottom: 8px; }
.result-time { font-size: 24px; color: var(--green); font-weight: 700; margin-bottom: 24px; }
.result-detail { font-size: 14px; color: var(--text-dim); margin-bottom: 8px; }
.result-badge { display: inline-block; padding: 8px 24px; background: var(--gold); color: #000; font-weight: 900; border-radius: 8px; font-size: 14px; letter-spacing: 2px; margin-bottom: 32px; }
.result-loser { color: var(--red); }

/* Replay lento */
.replay { margin: 24px 0; padding: 20px; background: var(--surface); border-radius: 12px; width: 100%; max-width: 320px; }
.replay-bar { height: 8px; background: var(--surface-2); border-radius: 8px; position: relative; overflow: hidden; margin-top: 12px; }
.replay-fill-1, .replay-fill-2 { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 8px; transition: width 2s ease; }
.replay-fill-1 { background: var(--gold); z-index: 2; }
.replay-fill-2 { background: var(--red); z-index: 1; }

/* Leaderboard */
.leaderboard { width: 100%; max-width: 320px; margin-top: 24px; }
.lb-row { display: flex; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--surface-2); font-size: 14px; }
.lb-row:first-child { color: var(--gold); font-weight: 700; }
.lb-rank { width: 30px; }

/* Audio enable */
.audio-btn {
    position: fixed; top: 16px; right: 16px; z-index: 200;
    background: var(--surface); border: 1px solid var(--gold-dark);
    color: var(--gold); padding: 8px 16px; border-radius: 8px;
    font-family: inherit; font-size: 12px; cursor: pointer;
}
