:root {
    --primary-color: #2196F3;
    --bg-color: #E3F2FD;
    --key-bg: #FFFFFF;
    --key-shadow: #90A4AE;
    --text-color: #333;
}

* { box-sizing: border-box; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0; padding: 0;
    font-family: "Hiragino Kaku Gothic ProN", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app {
    width: 100%; max-width: 600px; height: 100%;
    position: relative;
    background: white;
}

.screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; }}

h1 { font-size: 3rem; margin-bottom: 30px; line-height: 1.2; text-align: center; color: #1976D2; }

.primary-btn {
    background-color: var(--primary-color); color: white;
    font-size: 2rem; padding: 15px 40px;
    border: none; border-radius: 50px;
    box-shadow: 0 4px #1565C0;
    cursor: pointer; margin-top: 20px;
}
.primary-btn:active { box-shadow: 0 0 #1565C0; transform: translateY(4px); }

.secondary-btn {
    background: #607D8B; color: white; border: none; padding: 10px 20px;
    border-radius: 20px; font-size: 1.2rem; cursor: pointer;
    text-decoration: none;
    margin-top: 20px;
}

/* Start Screen */
.settings { font-size: 1.5rem; margin-bottom: 40px; text-align: center; }
.radio-group { display: flex; flex-direction: column; gap: 15px; align-items: flex-start; margin-top: 10px; }
.radio-group label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
input[type=radio] { transform: scale(1.5); }

/* Game Screen */
#game-screen { justify-content: space-between; padding-bottom: 0; }
.back-link {
    position: absolute; top: 15px; left: 15px;
    font-size: 1rem; color: white; background: #90A4AE;
    padding: 8px 12px; border-radius: 20px; text-decoration: none;
    box-shadow: 0 2px #546E7A;
}
.back-link:active { box-shadow: 0 0; transform: translateY(2px); }

.progress { font-size: 1.5rem; margin-top: 20px; color: #555; }

.problem-area {
    font-size: 5rem; font-weight: bold;
    flex-grow: 1; display: flex; align-items: center; justify-content: center;
    font-family: monospace; /* For alignment */
}
#answer-box {
    display: inline-block; min-width: 1.5em; border-bottom: 4px solid #333;
    text-align: center; color: #1976D2;
}

.input-area {
    width: 100%; background-color: #CFD8DC;
    padding: 20px; border-radius: 20px 20px 0 0;
}
.keypad {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px;
    max-width: 500px; margin: 0 auto;
}
.key {
    background: var(--key-bg); border: none; border-radius: 10px;
    font-size: 2.5rem; padding: 15px 0;
    box-shadow: 0 4px var(--key-shadow);
    color: #333; cursor: pointer;
}
.key:active { box-shadow: 0 0; transform: translateY(4px); }
.action-ac { background-color: #FFCDD2; color: #D32F2F; box-shadow: 0 4px #E57373; font-size: 2rem; }
.action-ok { background-color: #C8E6C9; color: #2E7D32; box-shadow: 0 4px #81C784; font-size: 2rem; }

/* Result Screen */
.result-box {
    background: #FFF9C4; padding: 30px; border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin: 30px 0;
    text-align: center; width: 100%;
}
.result-box p { font-size: 2rem; margin: 15px 0; }
.highlight { font-weight: bold; color: #D84315; font-size: 3rem; }

/* Feedback Overlay */
.feedback-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 15rem; font-weight: bold;
    opacity: 0; transition: opacity 0.2s;
    z-index: 100;
}
.feedback-overlay.correct::after { content: "\2B55"; color: #E91E63; }
.feedback-overlay.incorrect::after { content: "\274C"; color: #3F51B5; }

.feedback-overlay.show { opacity: 0.8; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}
