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

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: #000;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: block;
}

/* Menu and non-game screens keep their centered boxes */
#menu-screen, #table-select-screen, #stats-screen, #game-over-screen {
    display: none;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a2e 100%);
}

#menu-screen.active, #table-select-screen.active, #stats-screen.active, #game-over-screen.active {
    display: flex;
    flex-direction: column;
}

#table-select-screen {
    overflow: visible;
}

#table-select-screen > * {
    background: rgba(26, 26, 46, 0.95);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 900px;
    width: auto;
    border: 1px solid rgba(255, 214, 10, 0.2);
    margin: 20px;
}

#stats-screen .stats-content {
    background: rgba(26, 26, 46, 0.95);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 900px;
    width: auto;
    border: 1px solid rgba(255, 214, 10, 0.2);
    max-height: 85vh;
    overflow-y: auto;
    margin: 20px;
}

#stats-screen .stats-content::-webkit-scrollbar {
    width: 8px;
}

#stats-screen .stats-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

#stats-screen .stats-content::-webkit-scrollbar-thumb {
    background: rgba(255, 214, 10, 0.5);
    border-radius: 4px;
}

#stats-screen .stats-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 214, 10, 0.7);
}

#menu-screen, #game-over-screen {
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0e27 100%);
}

/* Game screen is fullscreen with overlays */
#game-screen {
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a2e 50%, #0a0e27 100%);
    padding: 0;
    position: relative;
}

#game-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 214, 10, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 110, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(90, 24, 154, 0.03) 0%, transparent 60%);
    pointer-events: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Menu Screen */
.game-title {
    font-family: 'Arial Black', sans-serif;
    font-size: 5em;
    text-align: center;
    color: #ffd60a;
    text-shadow:
        0 0 10px rgba(255, 214, 10, 0.8),
        0 0 20px rgba(255, 214, 10, 0.6),
        0 0 30px rgba(255, 214, 10, 0.4),
        4px 4px 0 #ff006e,
        5px 5px 0 #7209b7;
    margin-bottom: 80px;
    margin-top: 60px;
    letter-spacing: 4px;
    font-weight: 900;
    text-transform: uppercase;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    margin-bottom: 60px;
}

.menu-btn {
    font-family: 'Arial', sans-serif;
    font-size: 1.5em;
    padding: 18px 80px;
    border: 2px solid rgba(255, 214, 10, 0.5);
    border-radius: 8px;
    background: rgba(26, 26, 46, 0.8);
    color: #ffd60a;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 214, 10, 0.1);
    width: 350px;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    overflow: hidden;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 214, 10, 0.2), transparent);
    transition: left 0.5s;
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(255, 214, 10, 0.4),
        inset 0 1px 0 rgba(255, 214, 10, 0.2);
    border-color: rgba(255, 214, 10, 0.8);
    background: rgba(26, 26, 46, 0.9);
}

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

.hotkey {
    font-size: 0.6em;
    opacity: 0.6;
    font-weight: normal;
    letter-spacing: 1px;
}

.hint {
    font-size: 0.5em;
    opacity: 0.7;
    font-weight: normal;
}

/* Table Select and Stats Screen */
.screen-title {
    font-family: 'Arial Black', sans-serif;
    font-size: 2.5em;
    text-align: center;
    color: #ffd60a;
    text-shadow:
        0 0 10px rgba(255, 214, 10, 0.6),
        0 0 20px rgba(255, 214, 10, 0.3),
        2px 2px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 30px;
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.table-btn {
    padding: 25px;
    font-size: 1.8em;
    font-weight: bold;
    border: 3px solid #5a189a;
    border-radius: 15px;
    background: linear-gradient(135deg, #ffd60a 0%, #fca311 100%);
    color: #000;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.table-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.table-btn .medal {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 1.2em;
}

.table-btn .ranking {
    font-size: 0.5em;
    display: block;
    margin-top: 5px;
}

.back-btn {
    padding: 12px 40px;
    font-size: 1em;
    border: 2px solid rgba(255, 214, 10, 0.3);
    border-radius: 8px;
    background: rgba(26, 26, 46, 0.6);
    color: rgba(255, 214, 10, 0.9);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

.back-btn:hover {
    background: rgba(26, 26, 46, 0.8);
    border-color: rgba(255, 214, 10, 0.6);
    transform: translateX(-5px);
    box-shadow: 0 4px 15px rgba(255, 214, 10, 0.2);
}

/* Stats Screen */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.stat-box {
    background: rgba(255, 214, 10, 0.05);
    padding: 20px 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 214, 10, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2em;
    color: #ffd60a;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 214, 10, 0.5);
}

.table-times-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 214, 10, 0.2);
}

.table-times-title {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 15px;
    margin-top: 0;
    text-align: center;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: normal;
}

.table-times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
}

.table-time-item {
    background: rgba(26, 26, 46, 0.6);
    padding: 12px 8px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 214, 10, 0.2);
    transition: all 0.2s ease;
}

.table-time-item:hover {
    border-color: rgba(255, 214, 10, 0.5);
    background: rgba(26, 26, 46, 0.8);
}

.table-time-item .table-num {
    font-size: 1.3em;
    font-weight: bold;
    color: #ffd60a;
    margin-bottom: 4px;
}

.table-time-item .time-value {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
}

/* Game Screen */
.game-header {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 100;
    padding: 0;
    margin: 0;
}

.game-info {
    display: flex;
    justify-content: space-between;
    background: rgba(26, 26, 46, 0.85);
    padding: 15px 20px;
    border-radius: 12px;
    border: 2px solid rgba(255, 214, 10, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
}

.info-item {
    text-align: center;
    flex: 1;
    transition: transform 0.2s ease;
}

.info-item:hover {
    transform: scale(1.05);
}

.info-label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85em;
    margin-bottom: 8px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.info-value {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #ffd60a;
    text-shadow: 0 0 15px rgba(255, 214, 10, 0.6);
}

.game-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

#phaser-game {
    grid-row: 1 / 3;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.question-area {
    grid-row: 3;
    text-align: center;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.95);
    padding: 25px 15px;
    border-top: 3px solid rgba(255, 214, 10, 0.5);
    box-shadow:
        0 -10px 40px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(255, 214, 10, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    max-height: 45vh;
    overflow-y: auto;
}

.question-answer-box {
    background: linear-gradient(135deg, #ffd60a 0%, #fca311 100%);
    border-radius: 12px;
    padding: 15px 25px;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(26, 26, 46, 0.2);
    transition: all 0.2s ease;
    min-width: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.question-answer-box:hover {
    transform: scale(1.02);
}

.question {
    font-size: 1.8em;
    color: #1a1a2e;
    font-weight: bold;
    text-align: center;
}

.answer-display {
    font-size: 2em;
    padding: 8px 15px;
    border: 2px solid rgba(26, 26, 46, 0.3);
    border-radius: 8px;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    color: #1a1a2e;
    font-weight: bold;
    min-width: 80px;
    min-height: 45px;
    line-height: 45px;
}

.feedback {
    margin-top: 6px;
    margin-bottom: 4px;
    font-size: 1em;
    font-weight: bold;
    min-height: 24px;
    text-shadow:
        0 0 20px currentColor,
        2px 2px 4px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.feedback.correct {
    color: #06d6a0;
    animation: celebrate 0.5s;
}

.feedback.wrong {
    color: #ef476f;
    animation: shake 0.5s;
}

.time-badge {
    display: inline-block;
    background: rgba(255, 214, 10, 0.2);
    border: 2px solid rgba(255, 214, 10, 0.5);
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 0.9em;
    color: #ffd60a;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 214, 10, 0.6);
    animation: pulse 0.5s ease-in-out;
}

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

/* Number Pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
    max-width: 220px;
    margin-left: auto;
    margin-right: auto;
}

.num-btn {
    font-size: 1.3em;
    font-weight: bold;
    padding: 12px;
    border: 2px solid rgba(255, 214, 10, 0.4);
    border-radius: 10px;
    background: rgba(26, 26, 46, 0.85);
    color: #ffd60a;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.num-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.num-btn:hover {
    border-color: #ffd60a;
    background: rgba(255, 214, 10, 0.1);
    box-shadow: 0 6px 20px rgba(255, 214, 10, 0.3);
}

.clear-btn {
    background: rgba(239, 71, 111, 0.2);
    border-color: rgba(239, 71, 111, 0.4);
    color: #ef476f;
}

.clear-btn:hover {
    background: rgba(239, 71, 111, 0.3);
    border-color: #ef476f;
}

.submit-btn {
    background: rgba(6, 214, 160, 0.2);
    border-color: rgba(6, 214, 160, 0.4);
    color: #06d6a0;
    font-size: 1.6em;
}

.submit-btn:hover {
    background: rgba(6, 214, 160, 0.3);
    border-color: #06d6a0;
}

/* Menu item focus/selection styles */
.menu-btn.focused,
.table-btn.focused,
.back-btn.focused {
    border-color: #ffd60a;
    box-shadow:
        0 0 20px rgba(255, 214, 10, 0.6),
        0 0 40px rgba(255, 214, 10, 0.3),
        inset 0 0 20px rgba(255, 214, 10, 0.1);
    transform: translateY(-2px) scale(1.02);
    background: rgba(255, 214, 10, 0.1);
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Game Over Screen */
.game-over-title {
    font-family: 'Arial Black', sans-serif;
    font-size: 4em;
    text-align: center;
    color: #ff006e;
    text-shadow:
        0 0 20px rgba(255, 0, 110, 0.8),
        0 0 40px rgba(255, 0, 110, 0.5),
        3px 3px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    margin-top: 60px;
    text-transform: uppercase;
    letter-spacing: 6px;
}

.game-over-image {
    font-size: 6em;
    text-align: center;
    margin-bottom: 30px;
    filter: drop-shadow(0 0 10px rgba(255, 0, 110, 0.5));
}

.game-over-message {
    font-size: 1.3em;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 40px;
    font-weight: normal;
    letter-spacing: 1px;
}

.game-over-stats {
    background: rgba(26, 26, 46, 0.6);
    border: 1px solid rgba(255, 214, 10, 0.3);
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 40px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.game-over-stat {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    font-size: 1.2em;
    border-bottom: 1px solid rgba(255, 214, 10, 0.1);
}

.game-over-stat:last-child {
    border-bottom: none;
}

.game-over-stat .stat-label {
    color: rgba(255, 255, 255, 0.8);
    font-weight: normal;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 1px;
}

.game-over-stat .stat-value {
    color: #ffd60a;
    font-weight: bold;
    font-size: 1.3em;
    text-shadow: 0 0 10px rgba(255, 214, 10, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .stats-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .table-times-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    #stats-screen .stats-content {
        padding: 25px 20px;
        margin: 10px;
    }

    .screen-title {
        font-size: 1.8em;
        margin-bottom: 20px;
    }

    .hint {
        font-size: 0.4em;
        display: block;
        margin-top: 5px;
    }

    .table-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 100%;
    }

    .table-btn {
        padding: 20px 10px;
        font-size: 1.5em;
    }

    .table-btn .ranking {
        font-size: 0.45em;
    }

    .question-area {
        padding: 20px 12px;
        max-height: 50vh;
    }

    .game-header {
        top: 5px;
        left: 8px;
        right: 8px;
    }

    .game-info {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .info-item {
        flex: 1 1 30%;
        min-width: 80px;
    }

    .info-label {
        font-size: 0.7em;
        margin-bottom: 3px;
    }

    .info-value {
        font-size: 1.4em;
    }
}

@media (max-width: 600px) {
    .game-title {
        font-size: 2em;
        margin-top: 30px;
        margin-bottom: 40px;
        padding: 0 10px;
    }

    .menu-btn {
        font-size: 1.1em;
        width: 90%;
        max-width: 300px;
        padding: 15px 30px;
    }

    .game-over-title {
        font-size: 2em;
        margin-top: 30px;
    }

    .game-over-image {
        font-size: 3.5em;
    }

    .question-area {
        padding: 18px 10px;
        max-height: 52vh;
    }

    .question-answer-box {
        min-width: 240px;
        padding: 10px 18px;
    }

    .question {
        font-size: 1.4em;
    }

    .answer-display {
        font-size: 1.5em;
        padding: 6px 10px;
        min-height: 42px;
        line-height: 42px;
    }

    .feedback {
        font-size: 0.9em;
        min-height: 18px;
    }

    .number-pad {
        gap: 5px;
        max-width: 210px;
        margin-top: 6px;
    }

    .num-btn {
        font-size: 1.1em;
        padding: 10px 8px;
        border-width: 2px;
    }

    .submit-btn {
        font-size: 1.2em;
    }

    .stat-value {
        font-size: 1.5em;
    }

    .table-time-item .table-num {
        font-size: 1.1em;
    }
}

/* Extra small phones */
@media (max-width: 400px) {
    .game-title {
        font-size: 1.5em;
        margin-top: 20px;
        margin-bottom: 30px;
    }

    .screen-title {
        font-size: 1.4em;
    }

    .table-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .table-btn {
        padding: 15px 8px;
        font-size: 1.3em;
    }

    .question-area {
        padding: 15px 8px;
        max-height: 55vh;
    }

    .question-answer-box {
        min-width: 180px;
        padding: 8px 12px;
    }

    .question {
        font-size: 1.2em;
    }

    .answer-display {
        font-size: 1.3em;
        padding: 5px 8px;
        min-height: 38px;
        line-height: 38px;
    }

    .number-pad {
        max-width: 180px;
        gap: 4px;
    }

    .num-btn {
        font-size: 0.95em;
        padding: 8px 4px;
    }

    .info-label {
        font-size: 0.55em;
    }

    .info-value {
        font-size: 1.1em;
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .game-title {
        font-size: 2em;
        margin-top: 15px;
        margin-bottom: 20px;
    }

    .menu-buttons {
        gap: 15px;
        margin-bottom: 20px;
    }

    .menu-btn {
        padding: 12px 60px;
        font-size: 1.1em;
    }

    .table-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }

    .table-btn {
        padding: 12px 8px;
        font-size: 1.3em;
    }

    .screen-title {
        font-size: 1.5em;
        margin-bottom: 15px;
    }

    #table-select-screen > * {
        padding: 20px;
        margin: 10px;
    }

    #stats-screen .stats-content {
        padding: 20px;
        max-height: 90vh;
    }

    .question-area {
        padding: 12px 8px;
        max-height: 50vh;
    }

    .game-header {
        top: 3px;
        left: 8px;
        right: 8px;
    }

    .game-info {
        padding: 5px 10px;
    }

    .info-label {
        font-size: 0.55em;
        margin-bottom: 2px;
    }

    .info-value {
        font-size: 1.1em;
    }

    .question-answer-box {
        padding: 6px 12px;
    }

    .question {
        font-size: 1.2em;
    }

    .answer-display {
        font-size: 1.3em;
        padding: 5px 8px;
        min-height: 36px;
        line-height: 36px;
    }

    .number-pad {
        max-width: 190px;
        gap: 3px;
        margin-top: 4px;
    }

    .num-btn {
        font-size: 0.95em;
        padding: 6px;
    }

    .feedback {
        font-size: 0.8em;
        margin-top: 3px;
        min-height: 14px;
    }
}
