:root {
    --bg-color: #f0f8ff;
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --accent-color: #ffe66d;
    --text-color: #2c3e50;
    --card-bg: #ffffff;
    
    --btn-012: #ff9f43;
    --btn-345: #0abde3;
    --btn-all: #1dd1a1;
    
    --correct-color: #10ac84;
    --wrong-color: #ee5253;
}

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

body {
    font-family: 'Fredoka', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(78, 205, 196, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 107, 107, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 50% 50%, rgba(255, 230, 109, 0.15) 0%, transparent 30%);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-y: auto;
}

#app {
    width: 100%;
    max-width: 700px;
    min-height: 100vh;
    position: relative;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border: 6px solid white;
    padding: 20px;
    margin: 10px;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

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

/* Header & Menu */
.header {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#logo {
    height: 130px;
    margin-bottom: 10px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    animation: logoBounce 2.5s ease-in-out infinite;
}

@keyframes logoBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    40%       { transform: translateY(-14px) scale(1.06); }
    60%       { transform: translateY(-8px) scale(1.03); }
}

.header-title-block {
    display: inline-block;
}

.header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    line-height: 1.2;
    text-shadow: 3px 3px 0px white, 5px 5px 0px rgba(0,0,0,0.05);
    text-align: center;
}

.subtitle {
    display: block;
    font-size: 1rem;
    color: #7f8c8d;
    font-weight: 400;
    margin-top: 4px;
    text-align: right;
}


.menu-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    flex: 1;
}

.btn {
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 0 rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 rgba(0,0,0,0.15);
}

.menu-btn {
    width: 85%;
    max-width: 400px;
    padding: 16px 20px;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: white;
    border: 4px solid rgba(255,255,255,0.3);
}

.menu-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 13px 0 rgba(0,0,0,0.15);
}

.menu-btn:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 rgba(0,0,0,0.15);
}

.btn-icon {
    font-size: 2rem;
}

.mode-012 { background-color: var(--btn-012); }
.mode-345 { background-color: var(--btn-345); }
.mode-all { background-color: var(--btn-all); }

.menu-footer {
    text-align: center;
    font-size: 1.1rem;
    color: #7f8c8d;
    margin-bottom: 10px;
    margin-top: 10px;
}

/* Time selection */
.time-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.selection-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.time-buttons {
    display: flex;
    gap: 8px;
}

.time-btn {
    padding: 8px 14px;
    font-size: 1rem;
    background: white;
    color: var(--text-color);
    border: 3px solid #dfe6e9;
    box-shadow: 0 4px 0 #dfe6e9;
    border-radius: 14px;
    min-width: 50px;
}

.time-btn.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 0 #c0392b;
}

.time-btn:hover {
    transform: translateY(-2px);
}

/* Timer display */
.timer-display {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    background: white;
    border: 3px solid var(--secondary-color);
    border-radius: 15px;
    padding: 8px 18px;
    min-width: 85px;
    text-align: center;
    box-shadow: 0 5px 0 rgba(0,0,0,0.1);
}

.timer-display.warning {
    border-color: var(--wrong-color);
    color: var(--wrong-color);
    animation: timerPulse 0.6s ease-in-out infinite;
}

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

.two-player-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 8px;
}

/* Game Over Overlay */
.game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.game-over-overlay.hidden {
    display: none;
}

.game-over-box {
    background: white;
    border-radius: 30px;
    padding: 40px 50px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 5px solid var(--accent-color);
    max-width: 520px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-over-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-color);
}

.game-over-scores {
    font-size: 1.6rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-over-scores .winner {
    font-size: 1.9rem;
    color: var(--correct-color);
}

.game-over-scores .loser {
    color: #aaa;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-over-buttons .menu-btn {
    width: auto;
    padding: 14px 24px;
    font-size: 1.3rem;
}

/* Player count selection */
.player-selection {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 18px;
}

.player-count-btn {
    padding: 12px 28px;
    font-size: 1.2rem;
    background: white;
    color: var(--text-color);
    border: 3px solid #dfe6e9;
    box-shadow: 0 5px 0 #dfe6e9;
}

.player-count-btn.selected {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    box-shadow: 0 5px 0 #30b5ab;
}

.player-count-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 0 #dfe6e9;
}

.player-count-btn.selected:hover {
    box-shadow: 0 8px 0 #30b5ab;
}

/* Two Player Layout */
#app.two-player-mode {
    max-width: 100%;
    border-radius: 0;
    margin: 0;
    border: none;
    padding: 10px;
    min-height: 100vh;
}


.two-player-area {
    display: flex;
    flex-direction: row;
    gap: 0;
    flex: 1;
    align-items: flex-start;
}

.player-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
}

.panel-divider {
    width: 5px;
    align-self: stretch;
    background: linear-gradient(to bottom, transparent, #dfe6e9 20%, #dfe6e9 80%, transparent);
    border-radius: 4px;
    margin: 10px 5px;
}

.panel-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    border-radius: 18px;
    margin-bottom: 5px;
}

.p1-header {
    background: rgba(100, 181, 246, 0.15);
    border: 3px solid #64b5f6;
}

.p2-header {
    background: rgba(255, 138, 101, 0.15);
    border: 3px solid #ff8a65;
}

.player-label {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-color);
}

.panel-score {
    font-size: 1.2rem;
    font-weight: 700;
    color: #b33939;
}

.player-panel .question-container {
    padding: 16px 24px;
    margin-bottom: 8px;
    gap: 12px;
}

.player-panel .question-text {
    font-size: 3rem;
}

.player-panel .equals {
    font-size: 2.6rem;
}

.player-panel .answer-display {
    font-size: 2.6rem;
    min-width: 68px;
    height: 65px;
}

.player-panel .numpad {
    max-width: 260px;
}

.player-panel .numpad-btn {
    padding: 15px;
    font-size: 1.6rem;
}

/* Game Screen */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.small-btn {
    padding: 12px 25px;
    font-size: 1.4rem;
    background-color: white;
    color: var(--primary-color);
    border: 3px solid var(--primary-color);
    box-shadow: 0 6px 0 var(--primary-color);
}

.score-container {
    background: var(--accent-color);
    padding: 12px 25px;
    border-radius: 20px;
    font-size: 1.8rem;
    font-weight: 700;
    color: #b33939;
    box-shadow: 0 6px 0 rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 3px solid white;
}

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.question-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: white;
    padding: 22px 40px;
    border-radius: 25px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    margin-bottom: 28px;
    border: 4px solid var(--secondary-color);
}

.question-text {
    font-size: 3.8rem;
    font-weight: 700;
    color: var(--text-color);
}

.equals {
    font-size: 3.2rem;
    color: var(--primary-color);
}

.answer-display {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    background: var(--secondary-color);
    min-width: 80px;
    height: 75px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.15);
    transition: background 0.2s;
}

.feedback-inline {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 10px 28px;
    border-radius: 14px;
    text-align: center;
    margin: 8px 0;
    transition: opacity 0.2s;
}

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

.feedback-inline.correct {
    color: var(--correct-color);
    background: rgba(16, 172, 132, 0.12);
}

.feedback-inline.wrong {
    color: var(--wrong-color);
    background: rgba(238, 82, 83, 0.1);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 300px;
    margin-top: 8px;
}

.numpad-btn {
    padding: 18px;
    font-size: 1.8rem;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    background: white;
    border: 4px solid #dfe6e9;
    border-radius: 18px;
    box-shadow: 0 6px 0 #dfe6e9;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.1s;
}

.numpad-btn:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 6px 0 var(--secondary-color);
}

.numpad-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #dfe6e9;
}

.numpad-del {
    background: #fff5f5;
    border-color: #fab1b1;
    box-shadow: 0 6px 0 #f08080;
    color: var(--wrong-color);
}

.numpad-del:active {
    box-shadow: 0 0 0 #f08080;
}

.numpad-ok {
    background: #f0fff8;
    border-color: #6edcb8;
    box-shadow: 0 6px 0 #058c63;
    color: var(--correct-color);
}

.numpad-ok:active {
    box-shadow: 0 0 0 #058c63;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}


@media (max-width: 600px) {
    #app {
        border-width: 0;
        border-radius: 0;
        margin: 0;
        padding: 12px;
    }
    #logo { height: 90px; }
    .header h1 { font-size: 1.7rem; }
    .header h1 span { font-size: 2.2rem; }
    .menu-btn { font-size: 1.3rem; padding: 12px; width: 100%; }
    .btn-icon { font-size: 1.6rem; }
    .question-text { font-size: 2.8rem; }
    .equals { font-size: 2.4rem; }
    .answer-display { font-size: 2.4rem; min-width: 65px; height: 65px; }
    .numpad-btn { padding: 14px; font-size: 1.5rem; }
    .numpad { max-width: 260px; gap: 10px; }
    .top-bar { flex-direction: column; gap: 10px; }
}
