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

body {
    background: #0f172a;
    color: #e2e8f0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-frame {
    width: 100vw;
    height: calc(100vh - 44px);
    margin-top: 44px;
    border: none;
    display: block;
    position: relative;
    z-index: 1;
}

/* Inline name entry on game-over overlay (shown on high score) */
.name-entry {
    display: none;
    gap: 8px;
    align-items: center;
}

.name-entry.visible {
    display: flex;
}

#name-input {
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 1rem;
    color: #f8fafc;
    text-align: center;
    width: 200px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

#name-input:focus {
    border-color: #f59e0b;
}

#name-input::placeholder {
    color: #475569;
}

.btn-save {
    background: #f59e0b;
    color: #0f172a;
    padding: 10px 20px;
    font-size: 0.9rem;
}

/* Game over overlay */
#overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 100;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 24px;
    backdrop-filter: blur(6px);
}

#overlay.visible {
    display: flex;
}

#overlay h1 {
    font-size: 2.5rem;
    color: #f8fafc;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#overlay .score {
    font-size: 4rem;
    font-weight: 800;
    color: #38bdf8;
    text-shadow: 0 0 30px rgba(56, 189, 248, 0.4);
}

#overlay .game-name {
    font-size: 1.1rem;
    color: #94a3b8;
    margin-top: -12px;
}

/* High score banner */
.high-score-banner {
    display: none;
    color: #f59e0b;
    font-size: 1.4rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
    animation: pulse-gold 1.5s ease-in-out infinite;
}

.high-score-banner.visible {
    display: block;
}

@keyframes pulse-gold {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* Current high score info below game name */
.high-score-info {
    display: none;
    color: #64748b;
    font-size: 0.9rem;
    margin-top: -8px;
}

.high-score-info.visible {
    display: block;
}

.high-score-info .hs-name {
    color: #f59e0b;
    font-weight: 600;
}

.high-score-info .hs-score {
    color: #94a3b8;
    font-weight: 600;
}

.btn-row {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-play-again {
    background: #38bdf8;
    color: #0f172a;
}

.btn-next {
    background: #a78bfa;
    color: #0f172a;
}

.btn-random {
    position: fixed;
    top: 10px;
    right: 16px;
    z-index: 50;
    background: #a78bfa;
    color: #0f172a;
    padding: 8px 18px;
    font-size: 0.85rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    opacity: 0.7;
}

.btn-random:hover {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(167, 139, 250, 0.3);
}

.btn-stats {
    position: fixed;
    top: 10px;
    left: 16px;
    z-index: 50;
    background: #38bdf8;
    color: #0f172a;
    padding: 8px 18px;
    font-size: 0.85rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    opacity: 0.7;
}

.btn-stats:hover {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn-highscores {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: #f59e0b;
    color: #0f172a;
    padding: 8px 18px;
    font-size: 0.85rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    opacity: 0.7;
}

.btn-highscores:hover {
    opacity: 1;
    transform: translateX(-50%) translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

#loading {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    background: #0f172a;
    transition: opacity 0.3s;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #1e293b;
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
