/* Abacus Practice Application Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    padding: 20px;
    color: #1a1a2e;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
    color: white;
    text-align: center;
    padding: 28px 20px;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 6px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header p {
    font-size: 1rem;
    opacity: 0.85;
    font-weight: 400;
}

/* Screen Management */
.screen {
    display: none;
    padding: 28px 32px;
    min-height: 400px;
}

.screen.active {
    display: block;
}

/* ===== Settings Screen ===== */
#settingsScreen {
    max-width: 720px;
    margin: 0 auto;
}

#settingsScreen h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #1a1a2e;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.settings-grid > .settings-card:first-child {
    grid-column: 1 / -1;
}

/* Settings Card */
.settings-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.settings-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fafbfc;
    border-bottom: 1px solid #f0f0f5;
}

.card-icon {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    border-radius: 7px;
}

.card-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
    letter-spacing: -0.2px;
}

.card-body {
    padding: 14px 16px;
}

/* Input Row */
.input-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.input-row .input-group {
    flex: 1;
}

.range-separator {
    font-size: 1.3rem;
    color: #9ca3af;
    font-weight: 300;
    padding-bottom: 10px;
}

/* Input Group */
.input-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input[type="number"],
.input-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    color: #1a1a2e;
    background: #fff;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.input-group input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-group input[type="number"]::placeholder {
    color: #c0c5ce;
    font-weight: 400;
}

/* Display Time Row */
.display-time-row {
    display: flex;
    gap: 10px;
}

.display-time-row select {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    color: #1a1a2e;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.display-time-row select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Custom Display Time */
.custom-display-time {
    width: 100px !important;
    flex-shrink: 0;
}
.custom-display-time.hidden {
    display: none;
}

/* Operations Grid */
.ops-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.op-chip {
    cursor: pointer;
    display: block;
}

.op-chip input[type="checkbox"] {
    display: none;
}

.chip-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #6b7280;
    background: #fafbfc;
    transition: all 0.2s ease;
    text-align: center;
}

.chip-label:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
    color: #4f46e5;
}

.op-chip input[type="checkbox"]:checked + .chip-label {
    background: #eef2ff;
    border-color: #4f46e5;
    color: #4f46e5;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

/* Answer Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 10px;
}

/* ===== Game Mode Selection ===== */
.mode-select-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.mode-option {
    cursor: pointer;
    display: block;
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 6px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: #fafbfc;
    transition: all 0.25s ease;
    text-align: center;
    min-height: 88px;
}

.mode-card:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
}

.mode-option input[type="radio"]:checked + .mode-card {
    background: #eef2ff;
    border-color: #4f46e5;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.15);
}

.mode-emoji {
    font-size: 1.35rem;
}

.mode-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #374151;
    line-height: 1.2;
}

.mode-option input[type="radio"]:checked + .mode-card .mode-name {
    color: #4f46e5;
}

.mode-desc {
    font-size: 0.65rem;
    color: #9ca3af;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .mode-select-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .mode-select-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .mode-option:last-child {
        grid-column: span 2;
    }
}

/* ===== Game Screen ===== */
#gameScreen {
    max-width: 640px;
    margin: 0 auto;
}

/* ===== Game Header (Mode-aware) ===== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 14px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    gap: 12px;
}

.game-header-left,
.game-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}

.mode-badge.mode-challenge { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.mode-badge.mode-practice { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
.mode-badge.mode-timeattack { background: #fdf2f8; color: #db2777; border-color: #fbcfe8; }
.mode-badge.mode-survival { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.mode-badge.mode-flash { background: #fffbeb; color: #d97706; border-color: #fde68a; }

.question-counter {
    font-size: 1rem;
    font-weight: 700;
    color: #4f46e5;
}

.timer {
    font-size: 1.1rem;
    font-weight: 700;
    color: #374151;
    font-family: 'Courier New', monospace;
}

.timer-countdown {
    color: #db2777;
}

.timer-danger {
    color: #dc2626 !important;
    animation: pulse-danger 0.5s ease-in-out infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.survival-lives {
    font-size: 0.85rem;
    font-weight: 700;
    color: #dc2626;
    padding: 4px 10px;
    background: #fef2f2;
    border-radius: 16px;
    border: 1px solid #fecaca;
}

.lives-dead {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* ===== Ready Overlay ===== */
.ready-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px;
}

.ready-overlay.hidden {
    display: none;
}

.ready-content {
    text-align: center;
    padding: 40px;
}

.ready-emoji {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.ready-content h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.ready-content p {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 28px;
}

.btn-ready {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 48px;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
    transition: all 0.25s ease;
    min-width: 180px;
    height: 48px;
}

.btn-ready:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.4);
}

.btn-ready:active {
    transform: translateY(0);
}

/* ===== Countdown ===== */
.countdown-number {
    font-size: 5rem;
    font-weight: 800;
    color: #1a1a2e;
    animation: countdownPop 0.9s ease-out;
}

.countdown-go {
    font-size: 3.5rem;
    color: #1a1a2e;
    animation: countdownPop 0.4s ease-out;
}

@keyframes countdownPop {
    0% { transform: scale(1.8); opacity: 0; }
    40% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Practice Message (inside number display) ===== */
.practice-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.practice-msg .ready-emoji {
    font-size: 3rem;
    margin-bottom: 4px;
}

.practice-msg-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1a1a2e;
}

.practice-msg-sub {
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
}

/* ===== Inline Answer Area (inside number display) ===== */
.inline-answer-area {
    margin-top: 12px;
}

.inline-answer-input {
    width: 220px;
    padding: 12px 16px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid #d1d5db;
    border-radius: 14px;
    background: #f9fafb;
    color: #1a1a2e;
    outline: none;
    font-family: inherit;
    transition: all 0.3s ease;
}

.inline-answer-input::placeholder {
    color: #9ca3af;
}

.inline-answer-input:focus {
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Hide spinner buttons in number input */
.inline-answer-input::-webkit-outer-spin-button,
.inline-answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.inline-answer-input[type=number] {
    -moz-appearance: textfield;
}

.inline-answer-input.feedback-correct-input {
    border-color: #16a34a;
    background: #f0fdf4;
}

.inline-answer-input.feedback-correct-input::placeholder {
    color: #16a34a;
    font-weight: 700;
}

.inline-answer-input.feedback-incorrect-input {
    border-color: #dc2626;
    background: #fef2f2;
}

.inline-answer-input.feedback-incorrect-input::placeholder {
    color: #dc2626;
    font-weight: 700;
}

.inline-button-group {
    margin-top: 12px;
}

.inline-button-group .btn-primary {
    padding: 10px 36px;
    border-radius: 12px;
    font-size: 1rem;
}

.inline-choice-grid {
    gap: 8px;
}

.inline-choice-grid .choice-btn {
    padding: 10px 14px;
    font-size: 1rem;
    background: #f9fafb;
    border: 2px solid #d1d5db;
    color: #1a1a2e;
}

.inline-choice-grid .choice-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.inline-choice-grid .choice-btn.selected {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
}

/* ===== Answer Feedback Overlay ===== */
.answer-feedback {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.answer-feedback.hidden {
    display: none;
}

.feedback-correct {
    background: #dcfce7;
    color: #16a34a;
    border: 1.5px solid #a7f3d0;
}

.feedback-incorrect {
    background: #fee2e2;
    color: #dc2626;
    border: 1.5px solid #fecaca;
}

/* ===== Results Mode Badge ===== */
.results-mode-badge {
    text-align: center;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 700;
    margin: -10px auto 20px;
    display: inline-block;
    width: auto;
}

#resultsScreen h2 + .results-mode-badge {
    display: block;
    text-align: center;
}

.results-mode-badge.mode-challenge { background: #fffbeb; color: #b45309; }
.results-mode-badge.mode-practice { background: #ecfdf5; color: #059669; }
.results-mode-badge.mode-timeattack { background: #fdf2f8; color: #db2777; }
.results-mode-badge.mode-survival { background: #fef2f2; color: #dc2626; }
.results-mode-badge.mode-flash { background: #fffbeb; color: #d97706; }

.toggle-option {
    flex: 1;
    cursor: pointer;
}

.toggle-option input[type="radio"] {
    display: none;
}

.toggle-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: #fafbfc;
    transition: all 0.2s ease;
    text-align: center;
}

.toggle-label:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
}

.toggle-icon {
    font-size: 1.3rem;
}

.toggle-text {
    font-size: 0.82rem;
    font-weight: 500;
    color: #6b7280;
}

.toggle-option input[type="radio"]:checked + .toggle-label {
    background: #eef2ff;
    border-color: #4f46e5;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

.toggle-option input[type="radio"]:checked + .toggle-label .toggle-text {
    color: #4f46e5;
    font-weight: 600;
}

/* Start Button */
.btn-start {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    grid-column: 1 / -1;
    width: 60%;
    margin: 20px auto 0;
    padding: 14px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
}

.btn-start:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* Responsive - Settings */
@media (max-width: 480px) {
    .input-row {
        gap: 10px;
    }
    .range-separator {
        display: none;
    }
}

/* Buttons */
.btn {
    padding: 15px 25px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 180px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn:focus {
    outline: 2px solid rgba(79, 70, 229, 0.5);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    display: block;
    min-width: 160px;
    margin: 20px auto 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
}

.btn-outline {
    background: transparent;
    color: #6b7280;
    border: 1.5px solid #d1d5db;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: none;
    height: 44px;
    min-width: 180px;
}

.btn-outline:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
    transform: none;
    box-shadow: none;
}

/* Game Screen - Number Display */
.number-display {
    text-align: center;
    padding: 80px 40px 40px 40px;
    background: #ffffff;
    color: #1a1a2e;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    position: relative;
    height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes slide-in {
    0% { 
        transform: translateY(-30px);
        opacity: 0;
        scale: 0.8;
    }
    50% { 
        transform: translateY(10px);
        opacity: 0.7;
        scale: 1.05;
    }
    100% { 
        transform: translateY(0);
        opacity: 1;
        scale: 1;
    }
}

@keyframes bounce-in {
    0% { 
        transform: scale(0.3);
        opacity: 0;
    }
    50% { 
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% { 
        transform: scale(1);
        opacity: 1;
    }
}

.number-position {
    font-size: 1rem;
    opacity: 0.7;
    font-weight: bold;
    background: #f3f4f6;
    color: #6b7280;
    padding: 6px 15px;
    border-radius: 15px;
    display: inline-block;
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
}

.back-to-answer {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.8;
    display: none;
}

.back-to-answer:hover {
    background: #e5e7eb;
    opacity: 1;
    transform: scale(1.05);
}

.replay-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.8;
    display: none;
}

.replay-btn:hover {
    background: #e5e7eb;
    opacity: 1;
    transform: scale(1.05);
}

.replay-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f9fafb;
}

.replay-btn:disabled:hover {
    transform: none;
}

/* Answer Modes */
.answer-mode.hidden {
    display: none;
}

.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    max-width: 450px;
    margin: 0 auto 20px;
}

.choice-btn {
    padding: 12px 8px;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    border: 2px solid #4f46e5;
    border-radius: 8px;
    background: white;
    color: #4f46e5;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}



.choice-btn:hover {
    background: #4f46e5;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(79, 70, 229, 0.3);
}

.choice-btn.selected {
    background: #667eea;
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    transform: scale(1.05);
    animation: pulse-selected 0.5s ease-in-out;
}

@keyframes pulse-selected {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1.05); }
}

/* Ensure clean reset of choice buttons */
.choice-btn:not(.selected) {
    background: white !important;
    color: #667eea !important;
    transform: none !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1) !important;
}

.choice-btn:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .choice-grid {
        grid-template-columns: 1fr 1fr 1fr;
        max-width: 380px;
        gap: 8px;
    }
    
    .choice-btn {
        font-size: 1rem;
        padding: 10px 6px;
        min-height: 45px;
    }
}

@media (max-width: 480px) {
    .choice-grid {
        grid-template-columns: 1fr 1fr;
        max-width: 280px;
    }
    
    .choice-btn {
        font-size: 1rem;
        padding: 10px;
        min-height: 45px;
    }
}

.operation {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

.current-number {
    font-size: 7rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #1a1a2e;
    text-shadow: none;
    min-height: 150px;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

.current-number.repeated-number {
    color: #ff6b6b;
    animation: shake 0.5s ease-in-out;
    text-shadow: none;
}

.current-number.number-changing {
    transform: scale(0.8);
    opacity: 0.3;
    transition: all 0.1s ease-in;
}

.current-number.number-entering {
    animation: slide-in 0.4s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Answer Area */
.answer-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    margin-bottom: 30px;
}

.answer-area.hidden {
    display: none;
}

.button-group.hidden {
    display: none;
}

.answer-area h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5rem;
}

#answerInput {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
}

#answerInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 20px 0;
    padding: 15px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    width: 0%;
}

/* ===== Results Screen ===== */
#resultsScreen {
    max-width: 800px;
    margin: 0 auto;
}

#resultsScreen h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #1a1a2e;
    font-size: 1.6rem;
    font-weight: 700;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 10px;
    text-align: center;
    transition: all 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9ca3af;
}

.stat-total {
    border-color: #c7d2fe;
    background: linear-gradient(135deg, #eef2ff, #fff);
}
.stat-total .stat-value { color: #4f46e5; }

.stat-correct {
    border-color: #a7f3d0;
    background: linear-gradient(135deg, #ecfdf5, #fff);
}
.stat-correct .stat-value { color: #059669; }

.stat-incorrect {
    border-color: #fecaca;
    background: linear-gradient(135deg, #fef2f2, #fff);
}
.stat-incorrect .stat-value { color: #dc2626; }

.stat-percent {
    border-color: #fbcfe8;
    background: linear-gradient(135deg, #fdf2f8, #fff);
}
.stat-percent .stat-value { color: #db2777; }

.stat-time {
    border-color: #fde68a;
    background: linear-gradient(135deg, #fffbeb, #fff);
}
.stat-time .stat-value { color: #d97706; }

.stat-totaltime {
    border-color: #c4b5fd;
    background: linear-gradient(135deg, #f5f3ff, #fff);
}
.stat-totaltime .stat-value { color: #7c3aed; }

/* Details Section */
.details-section {
    margin-bottom: 24px;
}

.details-section h3 {
    margin-bottom: 14px;
    color: #374151;
    font-size: 1.05rem;
    font-weight: 600;
}

.details-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.9rem;
}

.details-table th {
    background: #f9fafb;
    padding: 12px 14px;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6b7280;
    border-bottom: 1.5px solid #e5e7eb;
}

.details-table td {
    padding: 12px 14px;
    text-align: center;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.details-table tbody tr {
    transition: background 0.15s ease;
}

.details-table tr.correct {
    background: #f0fdf4;
}

.details-table tr.correct:hover {
    background: #dcfce7;
}

.details-table tr.incorrect {
    background: #fef2f2;
}

.details-table tr.incorrect:hover {
    background: #fee2e2;
}

.numbers-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.number-chip {
    background: #4f46e5;
    color: white;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.op-chip {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 600;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
}

.correct .status-icon {
    background: #dcfce7;
    color: #16a34a;
}

.incorrect .status-icon {
    background: #fee2e2;
    color: #dc2626;
}

/* Results Action Buttons */
.results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-top: 8px;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 160px;
}

.btn-replay {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-replay:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

.btn-settings {
    background: #fff;
    color: #374151;
    border: 1.5px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.btn-settings:hover {
    transform: translateY(-2px);
    border-color: #c7d2fe;
    background: #f9fafb;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Results Responsive */
@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .stat-card:nth-child(4),
    .stat-card:nth-child(5) {
        grid-column: span 1;
    }
    .stat-value {
        font-size: 1.3rem;
    }
    .results-actions {
        flex-direction: column;
        align-items: center;
    }
    .btn-action {
        width: 100%;
        max-width: 280px;
    }
    .details-table th,
    .details-table td {
        padding: 8px 6px;
        font-size: 0.82rem;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-card:last-child {
        grid-column: span 2;
    }
}

/* ===== Responsive Design ===== */

/* Tablet */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    header {
        padding: 20px 16px;
    }
    
    .container {
        border-radius: 16px;
    }
    
    .screen {
        padding: 20px;
    }
    
    .current-number {
        font-size: 5.5rem;
    }
    
    .number-display {
        padding: 50px 24px 30px 24px;
        height: 280px;
        border-radius: 16px;
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        margin: 15px 0;
        padding: 10px;
    }
    
    .game-header {
        padding: 12px 16px;
        margin-bottom: 20px;
    }
    
    .details-table,
    .summary-table {
        font-size: 0.9rem;
    }
    
    .details-table th,
    .details-table td,
    .summary-table th,
    .summary-table td {
        padding: 8px 6px;
    }
    
    .answer-area {
        padding: 0 16px;
        margin-bottom: 20px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    body {
        padding: 6px;
    }
    
    .container {
        border-radius: 12px;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    header {
        padding: 16px 12px;
    }
    
    .screen {
        padding: 16px 12px;
    }
    
    .current-number {
        font-size: 4rem;
        min-height: 100px;
    }
    
    .number-display {
        padding: 35px 16px 25px 16px;
        height: 230px;
        border-radius: 14px;
        margin-bottom: 16px;
    }
    
    .inline-answer-input {
        width: 180px;
        padding: 10px 12px;
        font-size: 1.3rem;
    }
    
    .back-to-answer,
    .replay-btn {
        font-size: 0.78rem;
        padding: 6px 10px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 10px 12px;
        margin-bottom: 16px;
    }
    
    .game-header-left,
    .game-header-right {
        justify-content: center;
    }
    
    .btn {
        min-width: 160px;
        max-width: 280px;
        width: 100%;
        font-size: 0.95rem;
        height: 46px;
    }
    
    .btn-ready {
        min-width: 160px;
        height: 44px;
        font-size: 0.95rem;
        padding: 12px 36px;
    }
    
    .btn-outline {
        height: 40px;
        font-size: 0.82rem;
        min-width: 160px;
    }
    
    .answer-area {
        padding: 0 12px;
        margin-bottom: 16px;
        gap: 8px;
    }
    
    .progress-bar {
        margin-top: 12px;
    }
    
    .question-counter {
        font-size: 0.9rem;
    }
    
    .timer {
        font-size: 1rem;
    }
    
    .mode-badge {
        font-size: 0.72rem;
        padding: 4px 10px;
    }
    
    .numbers-display {
        flex-direction: column;
        gap: 2px;
    }
    
    .number-chip {
        font-size: 0.8rem;
    }
    
    .settings-card {
        border-radius: 12px;
    }
    
    .card-body {
        padding: 12px 14px;
    }
    
    .card-header {
        padding: 10px 14px;
    }
    
    .btn-start {
        padding: 14px;
        font-size: 0.95rem;
        margin-top: 20px;
    }
}
