:root {
    --primary: #FF8C00;
    --secondary: #6B4EE0;
    --beginner: #4CAF50;
    --intermediate: #FFD700;
    --advanced: #F44336;
    --bg-color: #F8F9FE;
    --card-bg: #FFFFFF;
    --text-color: #2D3436;
}

* { box-sizing: border-box; }

.main-btn, .mode-card, .key, .stop-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Segoe UI', sans-serif;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: -webkit-fill-available;
    padding: 15px;
}

.game-container {
    width: 100%;
    max-width: 450px;
    background: var(--card-bg);
    border-radius: 40px;
    padding: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    border: 8px solid #EEE;
    text-align: center;
}

h1 { color: var(--secondary); font-size: 2rem; margin-bottom: 5px; }
h2 { color: var(--text-color); font-size: 1.4rem; }

.screen {
    animation: fadeIn 0.5s ease;
}

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

.emoji-float { font-size: 4rem; margin-bottom: 20px; animation: bounce 3s infinite; }
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

input {
    padding: 15px;
    border-radius: 15px;
    border: 3px solid #EEE;
    font-size: 1.1rem;
    text-align: center;
}

input:focus { border-color: var(--secondary); outline: none; }

.main-btn {
    padding: 18px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 10px 0 #4B369F;
    transition: 0.1s;
}

.main-btn:active { transform: translateY(5px); box-shadow: 0 5px 0 #4B369F; }

.mode-grid { display: grid; gap: 15px; grid-template-columns: 1fr; margin-top: 20px; }

.mode-card {
    padding: 15px 10px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    transition: transform 0.2s;
}

.mode-card:hover { transform: scale(1.02); }

.mode-card:focus-visible {
    outline: 3px solid var(--secondary);
    outline-offset: 3px;
    transform: scale(1.02);
}

@media (prefers-reduced-motion: reduce) {
    .mode-card, .main-btn, .new-digit, .emoji-float {
        transition: none !important;
        animation: none !important;
    }
    .mode-card:hover {
        transform: none !important;
    }
}

.mode-emoji { font-size: 1.8rem; flex-shrink: 0; }
.mode-info { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-title { font-size: 1.05rem; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-desc { font-size: 0.7rem; opacity: 0.8; line-height: 1.2; }
.high-score {
    flex-shrink: 0;
    font-weight: bold;
    font-size: 0.8rem;
    color: #ffd700;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    background: rgba(0,0,0,0.15);
    padding: 4px 6px;
    border-radius: 10px;
    margin-left: 4px;
    text-align: center;
    min-width: 70px;
}

.beginner { background: #E8F5E9; color: #2E7D32; border-bottom: 6px solid #C8E6C9; }
.intermediate { background: #FFF3E0; color: #EF6C00; border-bottom: 6px solid #FFE0B2; }
.advanced { background: #FFEBEE; color: #C62828; border-bottom: 6px solid #FFCDD2; }

.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.hud-item { background: #EEE; padding: 10px; border-radius: 15px; min-width: 90px; text-align: center; }
.label { font-size: 0.7rem; font-weight: bold; display: block; color: #888; }
.value { font-size: 1.1rem; font-weight: bold; color: var(--text-color); }

.timer-hud {
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 5px solid var(--secondary);
    background: white;
    padding: 0; min-width: 60px;
}

.pi-board {
    background: #333;
    padding: 20px;
    border-radius: 20px;
    color: #FFF;
    font-family: 'Courier New', monospace;
    font-size: 1.6rem;
    min-height: 80px;
    margin-bottom: 20px;
    word-break: break-all;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    transition: background-color 0.3s ease;
}

.pi-board.flash-red {
    background-color: #8B0000;
}

.new-digit {
    display: inline-block;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #0F0;
}

.new-digit.auto {
    color: #FFD700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

@keyframes popIn {
    0% { transform: scale(3); opacity: 0; filter: brightness(2); }
    100% { transform: scale(1); opacity: 1; filter: brightness(1); }
}

.pi-fixed { color: var(--primary); }
.cursor { color: #0F0; font-weight: bold; }

.keyboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.key {
    padding: 15px; background: #FFF; border: 3px solid #EEE;
    border-radius: 15px; font-size: 1.5rem; font-weight: bold;
    cursor: pointer; box-shadow: 0 5px 0 #EEE;
}
.key:active { transform: translateY(3px); box-shadow: none; }
.key:nth-child(10) { grid-column: span 3; }

.feedback-area { min-height: 40px; margin-bottom: 10px; }
#game-message { color: var(--secondary); font-weight: bold; font-size: 1.1rem; }

.stop-btn {
    border: none; background: transparent; color: #888;
    text-decoration: underline; cursor: pointer;
}

.classic { background: #E3F2FD; color: #1976D2; border-bottom: 6px solid #BBDEFB; }
.mode-separator { 
    margin: 15px 0 5px; 
    font-size: 0.9rem; 
    font-weight: bold; 
    color: #888; 
    text-transform: uppercase;
}

.hidden { display: none; }

.blink { animation: blinker 1s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }

