/* ============================================
   Roberto's Game Collection — Shared Styles
   ============================================ */

:root {
    --color-bg-primary: #092043;
    --color-text-primary: #84bc34;
    --color-text-secondary: #c3db9a;
    --color-accent: #eb5c47;
    --color-success: #e9002e;
    --card-bg: rgba(6, 14, 35, 0.96);
    --card-border: rgba(132, 188, 52, 0.35);
}

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

body {
    font-family: 'Open Sans', sans-serif;
    background: radial-gradient(circle at top, #16356a 0, #092043 45%, #050b1b 100%);
    color: var(--color-text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

body.game-active {
    overflow: hidden;
    touch-action: none;
}

/* ── Card Container ── */
.container {
    width: 100%;
    max-width: 480px;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 22px 20px 24px;
    border: 1px solid var(--card-border);
    box-shadow:
        0 18px 45px rgba(0, 0, 0, 0.6),
        0 0 24px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* ── Typography ── */
.title {
    font-size: clamp(2rem, 7vw, 2.6rem);
    font-weight: 800;
    margin-bottom: 0.2rem;
    letter-spacing: 0.03em;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.2rem;
}

/* ── Game Controls ── */
#gameControls {
    width: 100%;
    margin-bottom: 1rem;
}

#timer {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Open Sans', monospace;
    color: transparent;
    margin-bottom: 0.25rem;
    min-height: 1.8em;
}

#countdown {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
    font-weight: 700;
    margin-bottom: 0.8rem;
    min-height: 1.2em;
}

.button-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

/* ── Buttons ── */
button {
    border: none;
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    font-family: inherit;
    letter-spacing: 0.03em;
    white-space: nowrap;
    width: 100%;
    max-width: 220px;
}

#startBtn {
    background: var(--color-accent);
    color: #fff;
    box-shadow: 0 6px 14px rgba(235, 92, 71, 0.45);
}

#startBtn:hover:not(:disabled) {
    background: #f06f5c;
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 8px 20px rgba(235, 92, 71, 0.55);
}

#startBtn:disabled {
    background: rgba(235, 92, 71, 0.45);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

#backBtn {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid rgba(195, 219, 154, 0.4);
}

#backBtn:hover {
    background: rgba(195, 219, 154, 0.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* ── Difficulty Select ── */
.difficulty-select {
    background: rgba(5, 11, 27, 0.9);
    color: var(--color-text-primary);
    border: 1px solid rgba(195, 219, 154, 0.45);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 10px;
    outline: none;
    width: 100%;
    max-width: 220px;
}

.difficulty-select option {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
}

/* ── Canvas ── */
canvas {
    border-radius: 14px;
    border: 1px solid rgba(132, 188, 52, 0.65);
    background: radial-gradient(circle at top, #16356a 0, #07142c 55%, #050b1b 100%);
    display: block;
    touch-action: none;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.7),
        0 14px 24px rgba(0, 0, 0, 0.6);
}

/* ── Highscore Section ── */
#highscoreSection {
    margin-top: 1.2rem;
    width: 100%;
}

#currentScore {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.6rem;
}

#scoreDisplay {
    color: var(--color-success);
    font-size: 1.4rem;
}

#nameInput {
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(195, 219, 154, 0.45);
    background: rgba(5, 11, 27, 0.9);
    color: var(--color-text-primary);
    width: 52%;
    max-width: 220px;
    margin-right: 8px;
    outline: none;
}

#nameInput::placeholder {
    color: rgba(195, 219, 154, 0.7);
}

#nameInput:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px rgba(235, 92, 71, 0.5);
}

#submitScoreBtn {
    padding: 8px 16px;
    font-size: 0.9rem;
    background: var(--color-text-primary);
    color: #051023;
}

#submitScoreBtn:hover:not(:disabled) {
    background: #97cf42;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(151, 207, 66, 0.45);
}

#submitScoreBtn:disabled {
    background: rgba(132, 188, 52, 0.5);
    color: rgba(5, 16, 35, 0.9);
    cursor: not-allowed;
    box-shadow: none;
}

#leaderboard {
    margin-top: 1rem;
    background: rgba(5, 11, 27, 0.85);
    border-radius: 12px;
    border: 1px solid rgba(132, 188, 52, 0.2);
    padding: 10px 10px 6px;
    max-height: 190px;
    overflow-y: auto;
    text-align: left;
}

#leaderboard h3 {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.leaderboard-entry {
    font-size: 0.85rem;
    padding: 4px 0;
    border-bottom: 1px solid rgba(195, 219, 154, 0.12);
    color: var(--color-text-secondary);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

#loading {
    font-size: 0.85rem;
    color: rgba(195, 219, 154, 0.8);
    font-style: italic;
}

.error {
    color: #f44336;
    font-size: 0.8rem;
}

/* ── Game State Colors ── */
.game-ready #timer {
    color: transparent;
}

.game-running #timer {
    color: var(--color-success);
}

.game-over #timer {
    color: #f44336;
}

/* ── Mobile Responsive ── */
@media (max-width: 520px) {
    .container {
        padding: 18px 14px 20px;
    }

    #nameInput {
        width: 100%;
        max-width: none;
        margin: 0 0 8px 0;
    }

    #submitScoreBtn {
        width: 100%;
    }
}
