/* ─── Variables (ACTotal Theme) ─── */
:root {
    --bg: #050506;
    --surface: #111827;
    --surface-light: #1f2937;
    --surface-hover: #374151;
    --accent: #00A7E1;
    --accent-glow: rgba(0, 167, 225, 0.35);
    --text: #ffffff;
    --text-dim: #9ca3af;
    --radius: 20px;
    --radius-sm: 12px;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

/* ─── Base Reset ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* ─── Layout ─── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: 1.5rem;
    max-width: 500px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #007bb5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, .08);
    background: var(--surface);
    color: var(--text-dim);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all .2s;
}

.btn-icon:hover {
    background: var(--surface-light);
    color: var(--text);
}

.text-muted {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #007bb5);
    color: #fff;
    box-shadow: 0 5px 20px var(--accent-glow);
    margin-top: 1rem;
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:active {
    transform: scale(0.96);
}

/* ─── Views ─── */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
    flex: 1;
    flex-direction: column;
}

.view-section.active {
    display: flex;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Setup View ─── */
.setup-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 2rem;
    text-align: center;
}

.setup-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.tables-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
    margin: 1.5rem 0;
}

.table-label {
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.table-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.table-label span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    background: var(--surface-light);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dim);
    transition: all 0.2s;
}

.table-label input:checked~span {
    background: rgba(0, 167, 225, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 4px 15px var(--accent-glow);
    transform: translateY(-2px);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* ─── Game View ─── */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin: 1.5rem 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.center-badge {
    flex: 1;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0 10px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.stat-badge strong {
    font-size: 1.4rem;
}

.game-board {
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-bottom: 2rem;
}

.operation-card {
    background: linear-gradient(145deg, var(--surface), var(--surface-light));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    width: 100%;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Animations for feedback */
.operation-card.success-pulse {
    animation: successPulse 0.5s ease-out;
}

.operation-card.error-shake {
    animation: errorShake 0.5s ease-in-out;
}

@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
        border-color: var(--success);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(16, 185, 129, 0);
        border-color: var(--success);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes errorShake {

    0%,
    100% {
        transform: translateX(0);
        border-color: var(--danger);
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.factor {
    font-size: 4.5rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.operator {
    font-size: 3rem;
    font-weight: 600;
    color: var(--accent);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
}

.option-btn {
    background: var(--surface-light);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    padding: 1.5rem 0;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.option-btn:active {
    transform: scale(0.95);
}

.option-btn.correct {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.option-btn.wrong {
    background: var(--danger);
    border-color: var(--danger);
    opacity: 0.8;
}

.feedback-toast {
    position: absolute;
    top: -20px;
    background: var(--success);
    color: #fff;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.feedback-toast.show {
    opacity: 1;
    transform: translateY(-10px);
}

.bottom-actions {
    margin-top: auto;
    padding-top: 1rem;
}

/* ─── Results View ─── */
.results-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: auto 0;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.final-score {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-light);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    width: 45%;
}

.score-title {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.score-box strong {
    font-size: 2.5rem;
}

.results-msg {
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 2rem;
}

/* ─── Footer ─── */
.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: auto;
    padding-top: 2rem;
}