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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #f0f0f0;
    min-height: 100vh;
}

/* ========== SCREENS ========== */

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.hidden {
    display: none !important;
}

/* ========== SETTINGS SCREEN ========== */

.settings-container {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 560px;
    width: 100%;
    text-align: center;
}

h1 {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 28px;
    background: linear-gradient(135deg, #e74c3c 0%, #f39c12 35%, #2ecc71 65%, #3498db 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rules-summary {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 28px;
    text-align: left;
}

.rules-summary h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
}

.rules-summary ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rules-summary li {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.rules-summary li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: rgba(255, 255, 255, 0.4);
}

.setting-group {
    margin-bottom: 28px;
}

.setting-group label {
    display: block;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.setting-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 600;
    padding: 14px 8px;
    min-height: 52px;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-btn:hover {
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.setting-btn.active {
    background: #fff;
    border-color: #fff;
    color: #1a1a2e;
}

.primary-btn {
    display: block;
    width: 100%;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 20px;
    min-height: 70px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    margin-bottom: 12px;
    transition: all 0.2s;
    letter-spacing: 1px;
}

.primary-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

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

.secondary-btn {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: none;
    transform: none;
}

.back-btn {
    margin-bottom: 0;
}

/* ========== GAME SCREEN ========== */

#game-screen {
    padding: 0;
    justify-content: flex-start;
}

.game-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 12px;
    flex-shrink: 0;
}

.header-left h1 {
    font-size: 1.6rem;
    margin-bottom: 0;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #e74c3c 0%, #f39c12 35%, #2ecc71 65%, #3498db 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.stats-row {
    display: flex;
    gap: 24px;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.45);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 14px;
    min-height: 44px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.sound-btn {
    font-size: 1.1rem;
    min-width: 44px;
    padding: 8px 10px;
}

.sound-btn.sound-active {
    background: rgba(46, 204, 113, 0.18);
    border-color: rgba(46, 204, 113, 0.5);
    color: #2ecc71;
}

/* ========== GAME AREA ========== */

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
    width: 100%;
}

/* ========== STATUS AREA ========== */

#status-area {
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.status-msg {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #fff;
    min-height: 2.4rem;
    transition: color 0.2s;
}

.status-msg.phase-watch  { color: #f39c12; }
.status-msg.phase-input  { color: #2ecc71; }
.status-msg.phase-correct { color: #2ecc71; }
.status-msg.phase-wrong  { color: #e74c3c; }

.progress-indicator {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    letter-spacing: 3px;
    min-height: 1.4rem;
}

/* ========== COLOR GRID ========== */

.color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    max-width: 520px;
}

.color-btn {
    aspect-ratio: 1;
    min-height: 130px;
    border-radius: 20px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.color-btn:focus-visible {
    outline: 4px solid #fff;
    outline-offset: 4px;
}

/* Base colors (dim state) */
.color-red    { background: #7b2020; }
.color-green  { background: #1a5e35; }
.color-blue   { background: #1a3a6e; }
.color-yellow { background: #7a5c10; }

/* Active / lit state */
.color-btn.lit {
    transform: scale(1.06);
}

.color-red.lit    { background: #ff4444; box-shadow: 0 0 40px 12px rgba(255, 68, 68, 0.7);    filter: brightness(1.3); }
.color-green.lit  { background: #2ecc71; box-shadow: 0 0 40px 12px rgba(46, 204, 113, 0.7);  filter: brightness(1.3); }
.color-blue.lit   { background: #3498db; box-shadow: 0 0 40px 12px rgba(52, 152, 219, 0.7);  filter: brightness(1.3); }
.color-yellow.lit { background: #f1c40f; box-shadow: 0 0 40px 12px rgba(241, 196, 15, 0.7);  filter: brightness(1.3); }

/* Hover state (only when input phase) */
.color-btn:not([disabled]):hover {
    filter: brightness(1.15);
    transform: scale(1.03);
}

.color-btn:not([disabled]):active {
    transform: scale(0.97);
}

/* Disabled during watch phase */
.color-btn[disabled] {
    cursor: default;
    pointer-events: none;
}

/* Wrong flash */
.color-btn.flash-wrong {
    animation: flash-wrong 0.5s ease;
}

@keyframes flash-wrong {
    0%   { filter: brightness(1); }
    25%  { filter: brightness(2) sepia(1) hue-rotate(-30deg); }
    50%  { filter: brightness(1); }
    75%  { filter: brightness(2) sepia(1) hue-rotate(-30deg); }
    100% { filter: brightness(1); }
}

.color-symbol {
    font-size: 3.2rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.85);
    pointer-events: none;
}

.color-key-hint {
    font-size: 0.9rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 1px;
    pointer-events: none;
}

/* ========== KEYBOARD HINT ========== */

.keyboard-hint {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
}

kbd {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 0.8rem;
    font-family: inherit;
    margin: 0 2px;
}

/* ========== GAME OVER SCREEN ========== */

.result-container {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.result-icon {
    font-size: 4rem;
    line-height: 1;
}

.result-container h1 {
    font-size: 2.2rem;
    letter-spacing: 3px;
    -webkit-text-fill-color: #fff;
    background: none;
    margin-bottom: 0;
}

.result-msg {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

.win-stats {
    display: flex;
    gap: 32px;
    justify-content: center;
    margin: 8px 0;
}

.win-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.win-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.45);
}

.win-stat-value {
    font-size: 2.8rem;
    font-weight: 900;
    color: #f39c12;
    line-height: 1;
}

.new-record {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 10px 24px;
    border-radius: 50px;
    letter-spacing: 1px;
}

.new-record.hidden {
    display: none;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 600px) {
    .game-header {
        flex-wrap: wrap;
        padding: 10px 14px;
    }

    .header-left h1 {
        font-size: 1.3rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .action-btn {
        font-size: 0.78rem;
        padding: 6px 10px;
        min-height: 40px;
    }

    .status-msg {
        font-size: 1.5rem;
    }

    .color-grid {
        gap: 12px;
    }

    .color-btn {
        min-height: 110px;
        border-radius: 16px;
    }

    .color-symbol {
        font-size: 2.6rem;
    }

    .keyboard-hint {
        display: none;
    }

    .result-container {
        padding: 32px 24px;
    }

    .win-stat-value {
        font-size: 2.2rem;
    }
}

@media (max-width: 380px) {
    .color-btn {
        min-height: 90px;
    }

    .color-symbol {
        font-size: 2rem;
    }

    .setting-btn {
        font-size: 0.9rem;
        padding: 12px 6px;
    }
}
