/* Font futuristici self-hosted (offline-friendly per la PWA) */
@font-face {
    font-family: 'Audiowide';
    font-weight: 400;
    font-display: swap;
    src: url('fonts/Audiowide-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Chakra Petch';
    font-weight: 400;
    font-display: swap;
    src: url('fonts/ChakraPetch-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Chakra Petch';
    font-weight: 500;
    font-display: swap;
    src: url('fonts/ChakraPetch-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Chakra Petch';
    font-weight: 700;
    font-display: swap;
    src: url('fonts/ChakraPetch-700.woff2') format('woff2');
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #060a18; touch-action: none; }
body { font-family: 'Chakra Petch', sans-serif; color: #7df9ff; user-select: none; -webkit-user-select: none; }
h1, .logo, .bigBtn, .hudCell span, .scoresTitle, #message { font-family: 'Audiowide', 'Chakra Petch', sans-serif; }
#app { position: fixed; inset: 0; }
canvas { display: block; }

/* ---------- HUD ---------- */
#hudTop {
    position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    display: flex; gap: 26px; align-items: center;
    padding: 8px 22px; border: 1px solid rgba(125, 249, 255, .35); border-radius: 10px;
    background: rgba(2, 8, 16, .55); backdrop-filter: blur(4px);
    pointer-events: none; white-space: nowrap;
}
.hudCell label { display: block; font-size: 8px; letter-spacing: 2px; opacity: .55; }
.hudCell span { font-size: 18px; text-shadow: 0 0 10px rgba(0, 255, 255, .6); }
.hudCell .lives { color: #ffd27a; text-shadow: 0 0 10px rgba(255, 180, 60, .6); letter-spacing: 3px; }
.hudCell .mult { color: #ffc23b; font-size: 13px; margin-left: 6px; }
#hudBonuses { display: flex; gap: 8px; }
.bonusIcon {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; position: relative;
}
.bonusIcon::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #04101c; }
.bonusIcon span { position: relative; z-index: 1; font-size: 13px; font-weight: 700; }

#bossBar {
    position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 62px); left: 50%; transform: translateX(-50%);
    width: min(420px, 70vw); display: none; pointer-events: none;
}
#bossBar label { font-size: 9px; letter-spacing: 3px; color: #ff3bd4; text-shadow: 0 0 8px rgba(255, 59, 212, .8); }
#bossBar .track { height: 8px; border: 1px solid rgba(255, 59, 212, .6); border-radius: 4px; overflow: hidden; margin-top: 3px; }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3bd4, #ff5a3c); transition: width .15s; }

#message {
    position: fixed; top: 34%; left: 50%; transform: translate(-50%, -50%) scale(.8);
    font-size: clamp(26px, 5vw, 52px); letter-spacing: 4px; text-align: center;
    color: #7df9ff; text-shadow: 0 0 24px rgba(0, 255, 255, .8);
    opacity: 0; pointer-events: none; white-space: nowrap;
}
#message.show { animation: msgPop 2s ease-out forwards; }
@keyframes msgPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
    12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    20% { transform: translate(-50%, -50%) scale(1); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
}

/* ---------- tag versione (sempre visibile, in ogni schermata) ---------- */
#versionTag {
    position: fixed; bottom: max(8px, env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right));
    font-size: 10px; letter-spacing: 1px; color: rgba(125, 249, 255, .45);
    pointer-events: none; z-index: 25; text-shadow: 0 0 6px rgba(0, 255, 255, .3);
}

/* ---------- barra aggiornamento disponibile ---------- */
#updateBanner {
    display: none; position: fixed; z-index: 40;
    top: max(64px, calc(env(safe-area-inset-top) + 56px)); left: 50%; transform: translateX(-50%);
    max-width: min(88vw, 520px); padding: 11px 22px;
    font-size: 12px; letter-spacing: 1px; text-align: center; line-height: 1.45;
    color: #06121f; background: linear-gradient(90deg, #35f5ff, #51ff7a);
    border-radius: 22px; cursor: pointer;
    box-shadow: 0 0 22px rgba(53, 245, 255, .55); animation: updPulse 1.8s ease-in-out infinite;
}
#updateBanner .uv { font-weight: 700; }
@keyframes updPulse {
    0%, 100% { box-shadow: 0 0 18px rgba(53, 245, 255, .45); }
    50% { box-shadow: 0 0 30px rgba(53, 245, 255, .85); }
}

/* ---------- pulsanti angolo ---------- */
.cornerBtn {
    position: fixed; top: max(10px, env(safe-area-inset-top)); width: 44px; height: 44px;
    border-radius: 50%; border: 1px solid rgba(125, 249, 255, .5);
    background: rgba(2, 8, 16, .55); color: #7df9ff; font-size: 15px;
    font-family: inherit; cursor: pointer; z-index: 20;
}
#pauseBtn { right: max(12px, env(safe-area-inset-right)); }
#muteBtn { right: calc(max(12px, env(safe-area-inset-right)) + 54px); }
.cornerBtn:active { background: rgba(0, 60, 80, .7); }

/* ---------- joystick ---------- */
#joyBase, #joyKnob { position: fixed; border-radius: 50%; pointer-events: none; display: none; z-index: 15; }
#joyBase { width: 108px; height: 108px; border: 2px solid rgba(125, 249, 255, .5); background: rgba(0, 20, 30, .25); }
#joyKnob { width: 44px; height: 44px; background: rgba(125, 249, 255, .55); box-shadow: 0 0 16px rgba(0, 255, 255, .6); }

/* ---------- overlay ---------- */
.overlay {
    position: fixed; inset: 0; z-index: 30;
    display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    background: radial-gradient(ellipse at center, rgba(2, 6, 14, .35) 0%, rgba(2, 6, 14, .82) 100%);
    text-align: center; padding: 20px;
}
.overlay h1 { font-size: clamp(34px, 7vw, 64px); letter-spacing: 6px; text-shadow: 0 0 30px rgba(0, 255, 255, .7); }
.overlay h1.danger { color: #ff4d6a; text-shadow: 0 0 30px rgba(255, 60, 90, .8); }
.logo { animation: logoPulse 3s ease-in-out infinite; }
/* nome lungo (Asteroid Swarm): il titolo scala con lo schermo anche sui telefoni in verticale */
.overlay h1.logo { font-size: clamp(20px, 6.2vw, 64px); }
.logo em { font-style: normal; color: #ff3bd4; text-shadow: 0 0 24px rgba(255, 59, 212, .8); }
@keyframes logoPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.subtitle { font-size: clamp(9px, 1.6vw, 12px); letter-spacing: 3px; opacity: .6; }

.bigBtn {
    font-family: inherit; font-size: 18px; letter-spacing: 3px;
    padding: 14px 42px; border-radius: 10px; cursor: pointer;
    border: 1px solid rgba(125, 249, 255, .8); color: #7df9ff;
    background: rgba(0, 20, 34, .6); text-shadow: 0 0 10px rgba(0, 255, 255, .7);
    box-shadow: 0 0 18px rgba(0, 255, 255, .2);
}
.bigBtn:hover, .bigBtn:active { background: rgba(0, 70, 95, .7); }
.bigBtn.dim { opacity: .6; font-size: 13px; padding: 10px 28px; }

.diffChooser { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.diffLabel { font-size: 10px; letter-spacing: 3px; opacity: .6; }
#diffChips { display: flex; gap: 8px; }
.diffChip {
    font-family: inherit; font-size: 12px; letter-spacing: 2px;
    padding: 8px 16px; border-radius: 8px; cursor: pointer;
    border: 1px solid rgba(125, 249, 255, .4); background: rgba(2, 8, 16, .5);
    color: rgba(125, 249, 255, .7);
}
.diffChip.active {
    color: #06121f; background: linear-gradient(90deg, #35f5ff, #51ff7a);
    border-color: transparent; box-shadow: 0 0 14px rgba(53, 245, 255, .5); font-weight: 700;
}

.scoresBox {
    min-width: min(320px, 80vw); padding: 14px 22px;
    border: 1px solid rgba(125, 249, 255, .25); border-radius: 10px; background: rgba(2, 8, 16, .5);
}
.scoresTitle { font-size: 11px; letter-spacing: 4px; opacity: .7; margin-bottom: 8px; }
.scoreRow { display: flex; justify-content: space-between; gap: 30px; font-size: 13px; padding: 3px 0; }
.scoreRow.dim { opacity: .5; justify-content: center; }

.hint { font-size: 10px; letter-spacing: 1px; opacity: .55; line-height: 1.8; }
.hint.clickable { cursor: pointer; pointer-events: auto; font-size: 13px; opacity: .8; }

.finalScoreBox { font-size: 20px; letter-spacing: 2px; }
.finalScoreBox span { color: #ffc23b; text-shadow: 0 0 14px rgba(255, 194, 59, .7); }
#nameEntry { display: none; flex-direction: column; align-items: center; gap: 12px; }
.entryLabel { font-size: 12px; letter-spacing: 1px; color: #ffc23b; }
#playerName {
    font-family: inherit; font-size: 20px; text-align: center; letter-spacing: 2px;
    padding: 10px 16px; width: min(280px, 70vw);
    background: #020810; color: #7df9ff; border: 1px solid rgba(125, 249, 255, .7); border-radius: 8px;
    text-transform: uppercase;
}
