/* ============================================
   TIMES TABLE TREK - GAME STYLES
   ============================================ */

:root {
    --space-dark: #0a0a1a;
    --space-purple: #1a1a3a;
    --accent-orange: #fb923c;
    --accent-red: #dc2626;
    --accent-gold: #ffd166;
    --accent-cyan: #4ecdc4;
    --font-main: 'Nunito', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: radial-gradient(
        ellipse at 50% 50%,
        #3a1a1a 0%,
        #1a1a2e 30%,
        var(--space-dark) 70%,
        #050510 100%
    );
}

/* Background Canvas */
#game-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Game Container */
.game-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 30px;
    background: rgba(10, 10, 30, 0.7);
    border-bottom: 2px solid rgba(251, 146, 60, 0.3);
    position: relative;
}

.question-box {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.score-box {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
}

.question-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 2px;
}

#question-text {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 900;
    color: white;
    text-shadow: 0 0 15px rgba(251, 146, 60, 0.5);
}

.score-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.fuel-meter {
    position: relative;
    padding: 4px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.45);
}

.fuel-meter::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -7px;
    width: 5px;
    height: 14px;
    transform: translateY(-50%);
    border-radius: 0 3px 3px 0;
    background: rgba(255, 255, 255, 0.55);
}

.fuel-segments {
    display: flex;
    gap: 2px;
}

.fuel-segment {
    width: 10px;
    height: 20px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.fuel-segment.filled {
    background: linear-gradient(to top, #dc2626, #fb923c, var(--accent-gold));
    box-shadow: 0 0 8px rgba(251, 146, 60, 0.8);
    transform: scaleY(1.08);
}

.score-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Race Track */
.race-track {
    order: 2;
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 40px;
    overflow: hidden;
}

/* Floating stars in track background */
.track-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.track-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    animation: twinkle 2s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* The Track Path */
.track-path {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 60px;
    display: flex;
    align-items: center;
    z-index: 2;
}

.track-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, rgba(251, 146, 60, 0.3), rgba(251, 146, 60, 0.6), rgba(251, 146, 60, 0.3));
    border-radius: 2px;
    transform: translateY(-50%);
}

/* Waypoints along track */
.waypoint {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(251, 146, 60, 0.5);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.waypoint.reached {
    background: var(--accent-orange);
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(251, 146, 60, 0.5);
}

.waypoint-finish {
    width: 24px;
    height: 24px;
    background: rgba(255, 209, 102, 0.2);
    border-color: var(--accent-gold);
}

/* Player Rocket */
.player-rocket {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    z-index: 3;
    transition: left 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-rocket img {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transform: rotate(45deg) translateY(4px); /* Rocket image is 45° right; rotate 45° more to point straight right */
}

.rocket-flame {
    display: none;
}

/* Finish Planet */
.finish-planet {
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.finish-planet img {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 0 15px rgba(255, 209, 102, 0.4));
}

/* Answer Options */
.options-area {
    order: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(10, 10, 30, 0.6);
    border-bottom: 2px solid rgba(251, 146, 60, 0.2);
    min-height: 100px;
}

.option-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid rgba(251, 146, 60, 0.3);
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15), rgba(220, 38, 38, 0.1));
    color: white;
    font-family: var(--font-main);
    font-size: 2rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.option-btn:hover {
    transform: scale(1.1);
    border-color: var(--accent-orange);
    box-shadow: 0 0 25px rgba(251, 146, 60, 0.3);
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.25), rgba(220, 38, 38, 0.2));
}

.option-btn.correct {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: #4ade80;
    box-shadow: 0 0 30px rgba(74, 222, 128, 0.4);
    animation: correctPop 0.4s ease-out;
}

.option-btn.wrong {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: #f87171;
    animation: wrongShake 0.4s ease-in-out;
}

@keyframes correctPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-8px); }
}

/* Message */
.message {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message.show {
    opacity: 1;
}

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 16, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s ease;
}

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

.overlay-content {
    text-align: center;
    padding: 30px 20px;
    width: min(520px, calc(100vw - 32px));
    max-height: 92vh;
    overflow-y: auto;
}

.overlay-rocket {
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
    animation: floatRocket 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(251, 146, 60, 0.4));
}

.overlay h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: var(--accent-orange);
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(251, 146, 60, 0.3);
}

.overlay p {
    font-size: 1.2rem;
    color: white;
    margin-bottom: 10px;
    line-height: 1.5;
}

.game-desc {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto 20px;
}

.launch-btn {
    display: inline-block;
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 900;
    font-family: var(--font-main);
    color: var(--space-dark);
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-red));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(251, 146, 60, 0.4);
    transition: all 0.3s ease;
}

.launch-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(251, 146, 60, 0.6);
}

.home-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-cyan);
    text-decoration: none;
    border: 2px solid var(--accent-cyan);
    border-radius: 50px;
    transition: all 0.3s ease;
}

.home-btn:hover {
    background: var(--accent-cyan);
    color: var(--space-dark);
}

/* Win Screen */
.win-rocket {
    margin: 20px 0;
    animation: launchWin 2s ease-in-out infinite;
}

.win-rocket img {
    width: 80px;
    height: 80px;
}

@keyframes launchWin {
    0%, 100% { transform: translateY(6px) rotate(15deg); }
    50% { transform: translateY(-20px) rotate(15deg); }
}

@keyframes floatRocket {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Age Group Selection Buttons */
.choose-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-top: 15px;
    letter-spacing: 1px;
}

.table-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin: 10px auto 0;
    width: 100%;
    max-width: 480px;
}

.table-btn {
    padding: 14px 10px;
    border-radius: 14px;
    border: 2px solid rgba(129, 140, 248, 0.5);
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    background: rgba(129, 140, 248, 0.15);
    box-shadow: 0 0 15px rgba(129, 140, 248, 0.2);
}

.table-btn:hover {
    transform: scale(1.08);
    background: rgba(129, 140, 248, 0.3);
    box-shadow: 0 0 25px rgba(129, 140, 248, 0.4);
}

.table-mixed {
    grid-column: 1 / -1;
    border-color: var(--accent-gold);
    background: rgba(255, 209, 102, 0.15);
    box-shadow: 0 0 15px rgba(255, 209, 102, 0.2);
    font-size: 1.3rem;
}

.table-mixed:hover {
    background: rgba(255, 209, 102, 0.3);
    box-shadow: 0 0 25px rgba(255, 209, 102, 0.4);
}

.table-btn.selected {
    background: rgba(74, 222, 128, 0.35);
    border-color: #4ade80;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.5);
    transform: scale(1.05);
}

.table-mixed.selected {
    background: rgba(255, 209, 102, 0.35);
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(255, 209, 102, 0.5);
}

.selected-tables {
    margin-top: 12px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    min-height: 1.5em;
}

.start-game-btn {
    margin-top: 16px;
    padding: 14px 36px;
    border-radius: 30px;
    border: none;
    font-family: var(--font-main);
    font-size: 1.3rem;
    font-weight: 900;
    color: #0a0a1e;
    background: var(--accent-gold);
    box-shadow: 0 0 25px rgba(255, 209, 102, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
}

.start-game-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 0 35px rgba(255, 209, 102, 0.6);
}

.start-game-btn:disabled {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.4);
    box-shadow: none;
    cursor: not-allowed;
}

/* Exit Button */
.exit-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    padding: 8px 16px;
    border-radius: 24px;
    background: rgba(10, 10, 30, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.exit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Responsive */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 15px;
    }

    .question-box {
        text-align: center;
    }

    .score-box {
        position: static;
        transform: none;
        order: -1;
    }

    .score-label {
        font-size: 0.68rem;
    }

    .fuel-meter {
        padding: 3px;
    }

    .fuel-segment {
        width: 8px;
        height: 16px;
    }

    .options-area {
        gap: 12px;
        min-height: 110px;
        padding: 14px 15px;
    }

    .option-btn {
        width: 80px;
        height: 80px;
        font-size: 1.6rem;
    }

    .player-rocket img {
        width: 45px;
        height: 45px;
    }

    .finish-planet img {
        width: 40px;
        height: 40px;
    }

    .overlay-content {
        padding: 24px 16px;
    }

    .table-buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        max-width: 320px;
    }

    .table-btn {
        padding: 12px 4px;
        font-size: clamp(0.85rem, 4vw, 1rem);
    }

    .table-mixed {
        grid-column: 1 / -1;
    }

    .selected-tables {
        font-size: 0.9rem;
    }

    .start-game-btn {
        padding: 12px 28px;
        font-size: 1.1rem;
    }

    .exit-btn {
        bottom: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .table-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .table-btn {
        padding: 10px 2px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .overlay h1 {
        font-size: 1.8rem;
    }

    .game-desc {
        font-size: 0.9rem;
    }

    .start-game-btn {
        padding: 10px 24px;
        font-size: 1rem;
    }
}



/* Short landscape screens (Nest Hub, landscape phones, small tablets) */
@media (max-width: 1050px) {
    .game-header {
        flex-direction: column;
        gap: 6px;
        padding: 12px 18px;
    }

    .score-box {
        position: static;
        transform: none;
        order: -1;
        justify-content: center;
    }

    #question-text {
        font-size: clamp(1.35rem, 4vw, 2.25rem);
        line-height: 1.15;
    }
}

@media (max-height: 640px) {
    .game-container {
        padding: 8px;
    }

    .game-header {
        padding: 8px 14px;
        margin-bottom: 8px;
    }

    .message {
        margin-bottom: 6px;
        min-height: 22px;
        font-size: 0.95rem;
    }
}

.game-level {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-purple, #a855f7);
    letter-spacing: 1px;
}
