/* === CSS Variables (define per page) ===
   --primary       : main brand color
   --primary-dark  : darker shade (title, hover)
   --primary-light : lighter shade (gradient end)
   --bg-tint       : light tint (progress bg, btn bg)
   --bg-lighter    : even lighter (numpad bg, card bg)
   ======================================== */

/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex; flex-direction: column; align-items: center; padding: 20px;
}
.container { max-width: 520px; width: 100%; }

/* === Top Bar === */
.top-bar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.top-bar a { color: #888; text-decoration: none; font-size: 14px; }
.top-bar a:hover { color: #555; }
.title { font-size: 16px; font-weight: 600; color: var(--primary-dark); }

/* === Card === */
.card {
    background: #fff; border-radius: 24px; padding: 28px 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.06); text-align: center;
}

/* === Stats & Progress === */
.stats {
    display: flex; justify-content: space-between; margin-bottom: 12px;
    font-size: 14px; color: #888;
}
.stats span { display: flex; align-items: center; gap: 4px; }
.progress-bar {
    width: 100%; height: 4px; border-radius: 2px; margin-bottom: 20px;
    background: var(--bg-tint);
}
.progress-bar .fill {
    height: 100%; border-radius: 2px; width: 0%; transition: width 0.3s;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

/* === Mode Switch === */
.mode-switch { display: flex; gap: 8px; justify-content: center; margin-bottom: 24px; }
.mode-btn {
    padding: 8px 18px; border: 2px solid var(--bg-tint); border-radius: 20px;
    background: var(--bg-tint); font-size: 13px; font-weight: 500; color: #555;
    cursor: pointer; transition: all 0.15s;
}
.mode-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.mode-btn:hover:not(.active) { border-color: var(--primary-light); opacity: 1; }

/* === Multiple Choice Options === */
.options {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
    max-width: 360px; margin: 0 auto 16px;
}
.opt-btn {
    padding: 18px 12px; font-size: 20px; font-weight: 600;
    border: 3px solid #e0e0e0; border-radius: 14px;
    background: #fafafa; cursor: pointer; transition: all 0.15s;
    color: #333; font-family: inherit;
}
.opt-btn:hover { border-color: var(--primary-light); background: var(--bg-lighter); transform: translateY(-2px); }
.opt-btn:disabled { cursor: default; transform: none; }
.opt-btn.correct { border-color: #27ae60; background: #eafaf1; animation: pop 0.3s ease; }
.opt-btn.wrong { border-color: #e74c3c; background: #fdedec; animation: shake 0.3s ease; }

/* === Numpad === */
.numpad {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
    max-width: 360px; margin: 0 auto 12px;
}
.numpad button {
    padding: 16px 4px; font-size: 26px; font-weight: 700;
    border-radius: 14px; cursor: pointer; color: #333;
    transition: all 0.1s;
    border: 2px solid var(--bg-tint); background: var(--bg-lighter);
}
.numpad button:hover { background: var(--bg-tint); opacity: 1; }
.numpad button:active { transform: scale(0.94); background: var(--primary-light); }
.numpad .clear { background: #fff3e0; border-color: #ffe082; color: #e65100; }

/* === Confirm Button === */
.confirm-btn {
    padding: 14px 48px; font-size: 20px; font-weight: 600;
    border: none; border-radius: 14px; color: #fff; cursor: pointer;
    display: inline-block; margin: 0 auto 8px; transition: all 0.15s;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.confirm-btn:hover { transform: translateY(-1px); }
.confirm-btn:active { transform: translateY(0); }

/* === Feedback === */
.feedback {
    min-height: 44px; display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 600; border-radius: 12px;
    padding: 8px 16px; margin-bottom: 12px;
}
.feedback.correct { color: #27ae60; background: #eafaf1; }
.feedback.wrong { color: #e74c3c; background: #fdedec; }

/* === Next Button === */
.next-btn {
    padding: 14px 40px; font-size: 18px; font-weight: 600;
    border: none; border-radius: 14px; color: #fff; cursor: pointer;
    display: none; margin: 0 auto; transition: all 0.15s;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.next-btn.show { display: inline-block; }
.next-btn:hover { transform: translateY(-1px); }

/* === Result Page === */
.result-page { display: none; text-align: center; padding: 20px 0; }
.result-page.show { display: block; }
.result-page .emoji { font-size: 64px; margin-bottom: 12px; }
.result-page h2 { font-size: 24px; color: #333; margin-bottom: 8px; }
.result-page .score { font-size: 48px; font-weight: 700; margin: 12px 0; color: var(--primary); }
.result-page .detail { font-size: 16px; color: #888; margin-bottom: 20px; }
.result-page .restart-btn {
    padding: 14px 40px; font-size: 18px; font-weight: 600;
    border: none; border-radius: 14px; color: #fff; cursor: pointer; transition: all 0.15s;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.result-page .restart-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* === Animations === */
@keyframes pop { 0% { transform: scale(0.9); } 100% { transform: scale(1); } }
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* === Responsive === */
@media (max-width: 480px) {
    .card { padding: 20px 12px; }
    .numpad { max-width: 300px; gap: 6px; }
    .numpad button { padding: 14px 4px; font-size: 22px; }
    .opt-btn { font-size: 17px; padding: 14px 8px; }
    .options { gap: 8px; }
    .mode-btn { font-size: 12px; padding: 6px 14px; }
}
