@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@400;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow: hidden;
    width: 100%;
    height: 100%;
    background: #0a0a14;
    font-family: 'Inter', sans-serif;
}

#renderCanvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
    display: block;
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: linear-gradient(180deg, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
    z-index: 10;
}

.hud-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: rgba(255,255,255,0.45);
    margin-bottom: 2px;
    text-transform: uppercase;
}

#score-block, #timer-block {
    min-width: 140px;
}
#timer-block { text-align: right; }

#score-value {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(123,47,247,0.9), 0 0 40px rgba(123,47,247,0.5);
    line-height: 1;
    letter-spacing: 0.05em;
}

#center-block {
    text-align: center;
}
#center-block .hud-label {
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    color: rgba(255,255,255,0.25);
}

#multiplier-value {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255,215,0,0.9), 0 0 40px rgba(255,165,0,0.5);
    line-height: 1;
    letter-spacing: 0.05em;
    transition: color 0.5s, text-shadow 0.5s;
}

#timer-bar-wrap {
    margin-top: 5px;
    height: 4px;
    width: 140px;
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

#timer-bar {
    height: 100%;
    width: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #7b2ff7, #00d2ff);
    transition: width 0.8s linear, background 0.5s;
}

/* ===== Score Popup ===== */
#score-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', monospace;
    font-size: 2.8rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255,215,0,0.9), 0 0 60px rgba(255,165,0,0.6);
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    white-space: nowrap;
}

#score-popup.pop {
    animation: scoreFloat 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes scoreFloat {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
    25%  { opacity: 1; transform: translate(-50%, -70%) scale(1.4); }
    100% { opacity: 0; transform: translate(-50%, -130%) scale(1); }
}

/* ===== Win Overlay ===== */
#winUI {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#win-card {
    background: linear-gradient(145deg, rgba(20,10,40,0.97), rgba(10,5,20,0.97));
    border: 1px solid rgba(123,47,247,0.5);
    border-radius: 24px;
    padding: 3rem 4rem;
    text-align: center;
    box-shadow: 0 0 60px rgba(123,47,247,0.4), 0 30px 60px rgba(0,0,0,0.6);
    animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardIn {
    from { opacity: 0; transform: scale(0.8) translateY(30px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

#win-emoji {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: spin 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes spin {
    from { transform: rotateY(0deg) scale(0); }
    to   { transform: rotateY(360deg) scale(1); }
}

#win-card h1 {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
}

#win-final-score-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 4px;
}

#win-score {
    font-family: 'Orbitron', monospace;
    font-size: 3.5rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255,215,0,0.8);
    margin-bottom: 0.75rem;
}

#win-rating {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    margin-bottom: 2rem;
    letter-spacing: 0.05em;
}

#restartButton {
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #fff;
    background: linear-gradient(135deg, #7b2ff7, #4400aa);
    border: none;
    padding: 14px 40px;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.3s;
    box-shadow: 0 4px 20px rgba(123,47,247,0.5);
    pointer-events: auto;
}

#restartButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(123,47,247,0.7);
}

#restartButton:active {
    transform: scale(0.97);
}

/* ===== Initials Entry ===== */
#initials-box {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 1rem 0;
}

#hs-new-label {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 14px #ffd700, 0 0 30px rgba(255,215,0,0.5);
    animation: pulse 1s ease-in-out infinite;
}

#hs-enter-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    color: rgba(255,255,255,0.5);
}

#initials-display {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.initial-slot {
    width: 56px; height: 68px;
    border: 2px solid rgba(123,47,247,0.6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-size: 2.2rem;
    font-weight: 900;
    color: rgba(123,47,247,0.8);
    background: rgba(123,47,247,0.08);
    box-shadow: 0 0 12px rgba(123,47,247,0.2);
    transition: all 0.15s;
}

.initial-slot.active {
    border-color: #ffd700;
    color: #ffd700;
    text-shadow: 0 0 12px #ffd700;
    box-shadow: 0 0 20px rgba(255,215,0,0.4);
    animation: cursorBlink 0.7s step-end infinite;
}

.initial-slot.filled {
    border-color: #00d2ff;
    color: #00d2ff;
    text-shadow: 0 0 10px #00d2ff;
    box-shadow: 0 0 14px rgba(0,210,255,0.3);
    animation: none;
}

@keyframes cursorBlink {
    50% { opacity: 0.3; }
}

/* ===== High Scores Leaderboard ===== */
#high-scores {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 1rem 0;
    width: 100%;
}

#hs-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
}

#score-list {
    background: rgba(123,47,247,0.06);
    border: 1px solid rgba(123,47,247,0.2);
    border-radius: 10px;
    padding: 8px 20px;
    width: 320px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    animation: rowIn 0.3s ease both;
}
.score-row:last-child { border-bottom: none; }

@keyframes rowIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.score-rank {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    width: 28px;
    font-weight: 700;
}

.score-name {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    font-weight: 700;
    color: #00d2ff;
    text-shadow: 0 0 8px rgba(0,210,255,0.7);
    width: 80px;
    text-align: center;
}

.score-val {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #c77dff;
    text-shadow: 0 0 8px rgba(199,125,255,0.7);
    flex: 1;
    text-align: right;
}

.score-row.top .score-name { color: #ffd700; text-shadow: 0 0 10px rgba(255,215,0,0.8); }
.score-row.top .score-val  { color: #ffd700; text-shadow: 0 0 10px rgba(255,215,0,0.8); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
