/**
 * Countdown Numbers Game - Styling
 * MathsVault Design System
 */

:root {
    --primary: #0EA5E9;
    --secondary: #38BDF8;
    --light: #FFFFFF;
    --dark: #1D1D1B;
    --gray: #6c757d;
    --light-gray: #f8f9fa;
    --border: #dee2e6;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
    
    /* Dark mode defaults */
    --card-bg: #1E293B;
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --card-border: rgba(148, 163, 184, 0.2);
}

/* Background image for menu screen */
body.game-menu-active {
    --menu-bg-image: url('/interactive/shared/backgrounds/countdown.png');
}

body.countdown-page {
    color: var(--light);
}

body.countdown-page.game-menu-active {
    --menu-bg-start: #0B1120;
    --menu-bg-end: #0F172A;
    --game-primary: #0EA5E9;
    --game-primary-dark: #0284C7;
    --game-secondary: #38BDF8;
    --menu-card-bg: rgba(11, 19, 34, 0.75);
    --menu-card-border: rgba(148, 163, 184, 0.2);
    --menu-text-light: #E2E8F0;
}

.countdown-menu {
    position: relative;
    z-index: 2;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    color: #E2E8F0;
}

.countdown-menu-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.countdown-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(56, 189, 248, 0.35), rgba(14, 116, 144, 0.15));
    box-shadow: 0 18px 42px rgba(2, 6, 23, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.countdown-icon {
    font-size: 3.2rem;
    color: #38BDF8;
    filter: drop-shadow(0 12px 28px rgba(56, 189, 248, 0.4));
}

.countdown-menu h1 {
    font-size: 3.5rem;
    letter-spacing: 0.08em;
    margin: 0;
    text-align: center;
}

.countdown-menu .game-menu-subtitle {
    margin: 0 auto;
    max-width: 640px;
    font-size: 1.1rem;
    text-align: center;
    color: rgba(226, 232, 240, 0.8);
}

.countdown-daily-card {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    padding: 24px;
    border-radius: 20px;
    background: rgba(8, 14, 30, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 32px rgba(2, 6, 23, 0.5);
}

.daily-card-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.daily-card-right {
    display: flex;
    align-items: center;
    justify-content: center;
}

.daily-badge {
    padding: 10px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.9) 0%, rgba(14, 165, 233, 0.9) 100%);
    color: #0B1120;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.daily-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}

.daily-info .daily-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: #FFFFFF;
}

.daily-info .daily-date {
    font-size: 0.95rem;
    color: rgba(226, 232, 240, 0.75);
}

.daily-info .daily-countdown {
    font-size: 0.95rem;
    color: rgba(250, 183, 25, 0.9);
    font-weight: 600;
}

.daily-status-tag {
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #38BDF8;
    background: rgba(56, 189, 248, 0.15);
    text-align: center;
}

.daily-status-tag.status-completed {
    color: #22d3ee;
    background: rgba(34, 211, 238, 0.18);
}

.daily-status-tag.status-playing {
    color: #facc15;
    background: rgba(250, 204, 21, 0.2);
}

.countdown-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}

.countdown-stats .stat-card {
    background: rgba(11, 19, 34, 0.8);
    border-radius: 18px;
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 14px 32px rgba(2, 6, 23, 0.5);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.countdown-stats .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 44px rgba(2, 6, 23, 0.6);
}

.countdown-stats .stat-value {
    display: block;
    font-size: 2.1rem;
    font-weight: 700;
    color: #38BDF8;
    margin-bottom: 6px;
}

.countdown-stats .stat-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: rgba(226, 232, 240, 0.75);
}

.countdown-stats .stat-card.highlight .stat-value {
    color: #FACC15;
}

.countdown-stats .stat-card.highlight .stat-label {
    color: rgba(250, 204, 21, 0.85);
}

.countdown-highlight-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.25) 0%, rgba(14, 116, 144, 0.25) 100%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 20px 48px rgba(2, 6, 23, 0.55);
    order: 32; /* After preview (30), before actions (40) */
}

.countdown-highlight-card .highlight-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.highlight-badge {
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.2);
    color: #38BDF8;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.highlight-status {
    font-size: 0.95rem;
    color: rgba(226, 232, 240, 0.8);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.countdown-highlight-card .highlight-body h2 {
    margin: 0 0 10px;
    font-size: 1.8rem;
    color: #E2E8F0;
}

.countdown-highlight-card .highlight-body p {
    margin: 0;
    font-size: 1rem;
    color: rgba(226, 232, 240, 0.78);
}

.highlight-meta {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.highlight-meta .meta-item {
    flex: 1;
    min-width: 160px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(8, 14, 30, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.18);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(226, 232, 240, 0.65);
}

.meta-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #38BDF8;
}

.countdown-menu-options {
    gap: 18px;
}

.countdown-menu-options .game-menu-button {
    text-align: left;
    align-items: flex-start;
}

@media (max-width: 768px) {
    /* Compact mobile layout - match game-menu.css mobile styles */
    .countdown-menu {
        padding: clamp(24px, 4vw, 32px) clamp(16px, 4vw, 24px);
        gap: var(--menu-spacing-md, 1.25rem);
        min-height: auto;
        max-height: 100vh;
        overflow-y: auto;
    }

    /* Hide icon on mobile */
    .countdown-menu-title .countdown-icon-wrapper {
        display: none !important;
    }

    .countdown-menu-title h1 {
        font-size: clamp(2rem, 5vw, 2.5rem);
        margin: 0;
    }

    /* Hide subtitle on mobile */
    .game-menu-subtitle {
        display: none;
    }

    /* Hide daily card on mobile */
    .countdown-daily-card {
        display: none !important;
    }

    /* Compact horizontal stats - one line */
    .countdown-stats {
        display: flex;
        flex-direction: row;
        gap: var(--menu-spacing-xs, 0.5rem);
        flex-wrap: nowrap;
    }

    .countdown-stats .stat-card {
        flex: 1;
        min-width: 0;
        padding: var(--menu-spacing-sm, 0.85rem);
        gap: 0.25rem;
    }

    .countdown-stats .stat-value {
        font-size: clamp(1.5rem, 4vw, 1.8rem);
        line-height: 1.2;
    }

    .countdown-stats .stat-label {
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    .countdown-stats .stat-label i {
        font-size: 0.7rem;
    }

    /* Hide highlight card on mobile - it's in customSections */
    .countdown-highlight-card {
        display: none !important;
    }
    
    /* Ensure custom sections respect mobile layout */
    .game-menu-container .countdown-highlight-card {
        display: none !important;
    }

    /* Full width buttons in single column */
    .countdown-menu-options,
    .game-menu-options {
        display: flex;
        flex-direction: column;
        gap: var(--menu-spacing-xs, 0.5rem);
    }

    .countdown-menu-options .game-menu-button,
    .game-menu-options .game-menu-button {
        width: 100%;
        max-width: 100%;
        grid-template-columns: auto 1fr;
        text-align: left;
        align-items: center;
        padding: 0.85rem 1rem;
    }

    .game-menu-button-icon {
        margin: 0;
        flex-shrink: 0;
    }

    .game-menu-button-text {
        justify-self: flex-start;
        text-align: left;
    }

    /* Badge dropdown - use same styles as game-menu.css */
    .badge-display-section {
        order: 40;
        margin-top: 0;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        width: 100%;
    }

    .badge-display-section h3 {
        display: none;
    }

    .badge-display-section > #game-badge-display {
        display: none;
    }

    .badge-dropdown-toggle {
        display: grid;
        width: 100%;
        border: 2px solid var(--game-primary, #0EA5E9);
        border-radius: var(--menu-radius-lg, 24px);
        background: #0F172A;
        color: var(--game-primary, #0EA5E9);
        padding: 0.85rem 1rem;
        grid-template-columns: auto 1fr auto;
        gap: 0.85rem;
        align-items: center;
        cursor: pointer;
        transition: transform 0.26s ease, box-shadow 0.26s ease, border-color 0.26s ease;
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.4);
        position: relative;
        z-index: 10001;
    }

    .badge-dropdown-toggle:hover {
        transform: translateY(-2px);
        border-color: rgba(14, 165, 233, 0.5);
        box-shadow: 0 25px 70px rgba(37, 99, 235, 0.22);
    }

    .badge-dropdown-toggle-icon {
        display: grid;
        place-items: center;
        width: 48px;
        height: 48px;
        border-radius: 16px;
        background: rgba(148, 163, 184, 0.12);
        border: 2px solid rgba(14, 165, 233, 0.4);
        font-size: 1.25rem;
        color: var(--game-primary, #0EA5E9);
        flex-shrink: 0;
    }

    .badge-dropdown-toggle-text {
        font-size: 1.1rem;
        font-weight: 600;
        text-align: left;
    }

    .badge-dropdown-toggle-chevron {
        font-size: 0.9rem;
        color: var(--game-primary, #0EA5E9);
        transition: transform 0.26s ease;
        flex-shrink: 0;
    }

    .badge-dropdown-toggle.open .badge-dropdown-toggle-chevron {
        transform: rotate(180deg);
    }

    .badge-dropdown-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.42s ease, padding 0.42s ease;
        padding: 0;
        margin-top: var(--menu-spacing-xs, 0.5rem);
        background: rgba(15, 23, 42, 0.88);
        border: 2px solid rgba(14, 165, 233, 0.35);
        border-radius: 18px;
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.4);
    }

    .badge-dropdown-content.open {
        max-height: 60vh;
        padding: var(--menu-spacing-md, 1.25rem);
        overflow-y: auto;
    }

    .badge-dropdown-content .badge-display-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }

    .badge-dropdown-content .badge-display-image {
        width: 60px;
        height: 60px;
    }

    .badge-dropdown-content .badge-display-item {
        max-width: 100px;
    }

    .badge-dropdown-content .badge-display-name {
        font-size: 0.7rem;
    }
}

@media (max-width: 540px) {
    .countdown-icon-wrapper {
        width: 80px;
        height: 80px;
    }
    .countdown-icon {
        font-size: 2.8rem;
    }
    .countdown-menu .game-menu-subtitle {
        font-size: 1rem;
    }
    .daily-info {
        min-width: 0;
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background: radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.12), transparent 55%),
                radial-gradient(circle at 85% 25%, rgba(56, 189, 248, 0.12), transparent 50%),
                linear-gradient(180deg, #0B1120 0%, #0F172A 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    color: var(--light);
}

/* Prevent mobile viewport scrolling */
@media (max-width: 576px) {
    body {
        position: fixed;
        width: 100%;
        height: 100vh;
        overflow: hidden;
    }
    
    body.game-menu-active {
        position: static; /* Allow menu to scroll if needed */
        overflow-x: hidden;
        overflow-y: auto;
    }
}

/* Game Container */
.game-container {
    height: 100vh;
    overflow: hidden;
    padding-top: 80px; /* Space for fixed header */
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.countdown-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem 1rem 1rem 1rem;
    padding-top: 2.5rem; /* Extra padding for game header */
    max-width: 100%;
    pointer-events: auto;
    min-height: 0; /* Allows flex child to shrink */
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */

.game-screen {
    display: none;
    animation: fadeIn 0.4s ease;
    flex: 1;
    overflow: hidden;
    pointer-events: auto;
}

.game-screen.active {
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

/* Center selection screen vertically */
#number-selection-screen.game-screen.active {
    justify-content: center;
    align-items: center;
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
}

#number-selection-screen.game-screen.active * {
    pointer-events: auto !important;
}

#number-selection-screen.game-screen.active .number-choice-btn {
    pointer-events: auto !important;
    z-index: 1000 !important;
}

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

/* ============================================
   GAME PLAY LAYOUT - VERTICAL STACK
   ============================================ */

/* Vertical flex layout: Target > Two Column Content > Controls */
.game-play-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    gap: 1rem;
    padding: 0;
    min-height: 0; /* Allows flex child to shrink */
}

/* 1) Target card - full width at top, centered target */
.target-card {
    flex-shrink: 0;
    width: 100%;
    margin-top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 2rem;
}

.target-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.target-label {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* 2) Main Content Area - Three Column Layout */
.game-main-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    overflow: hidden;
    min-height: 0;
}

/* Left Column: All Control Buttons */
.game-left-column {
    flex: 0 0 180px; /* Fixed width for buttons */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.control-buttons-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
}

.control-buttons-column .btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Middle Column: Number Pad and Operations Pad */
.game-middle-column {
    flex: 0 0 400px; /* Fixed width */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Right Column: Current Calculation, History, Stats */
.game-right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.current-calc-card {
    flex-shrink: 0;
}

.history-card {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.calculation-history {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    align-content: start;
}

.stats-card {
    flex-shrink: 0;
}

.stats-row-container {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
}

.stats-card .stat-row {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.5rem;
    border-bottom: none;
    border-right: 1px solid var(--card-border);
}

.stats-card .stat-row:last-child {
    border-right: none;
}

.stats-card .stat-label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.stats-card .stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.numbers-section {
    flex-shrink: 0;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.operations-section {
    flex-shrink: 0;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

/* Legacy support - calc-action-buttons may still exist in some contexts */
.calc-action-buttons {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.calc-action-buttons .btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.numbers-section h3,
.operations-section h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    text-align: center;
}

/* 5) Control Buttons - Hidden on desktop (moved to left column), shown on mobile */
.game-controls-bottom {
    display: none; /* Hidden on desktop - buttons are in left column */
    flex-shrink: 0;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 1rem;
    width: 100%;
    border-top: 2px solid var(--card-border);
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    margin-top: auto;
}

.game-controls-bottom .btn {
    flex: 1;
    min-width: 80px;
    max-width: 140px;
    min-height: 40px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
}

/* Submit button - stands out with different color */
.btn-submit {
    background: #FAB719 !important; /* Gold/Bathurst gold */
    border-color: #FAB719 !important;
    color: #1f2937 !important; /* Dark text */
    font-weight: 700 !important;
    box-shadow: 0 4px 15px rgba(250, 183, 25, 0.4) !important;
    min-width: 120px !important;
    max-width: 180px !important;
}

.btn-submit:hover:not(:disabled) {
    background: #e0a517 !important;
    border-color: #e0a517 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(250, 183, 25, 0.5) !important;
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Legacy class support (for backwards compatibility) */
.game-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}


/* ============================================
   NUMBER SELECTION SCREEN
   ============================================ */

.selection-card {
    background: var(--card-bg);
    border: 4px solid var(--secondary);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 900px;
    margin: 0 auto;
    color: var(--text-primary);
    pointer-events: auto !important;
    position: relative;
    z-index: 100 !important;
}

.selection-card h2 {
    color: var(--primary);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.instruction-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.large-number-selector {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.number-choice-btn {
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    width: 120px;
    cursor: pointer;
    transition: var(--transition);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: var(--text-primary);
    pointer-events: auto !important;
    position: relative;
    z-index: 100 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(14, 165, 233, 0.3);
    user-select: none;
    -webkit-user-select: none;
}

.number-choice-btn:hover {
    transform: translateY(-5px);
    border-color: var(--secondary);
    box-shadow: 0 8px 20px rgba(250, 183, 25, 0.3);
}

.number-choice-btn.selected {
    background: var(--secondary);
    border-color: var(--secondary);
    color: var(--text-primary);
    font-weight: bold;
}

.choice-number {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.5rem;
    pointer-events: none;
}

.number-choice-btn.selected .choice-number {
    color: var(--text-primary);
}

.choice-label {
    display: none;
}

.number-choice-btn.selected .choice-label {
    color: var(--text-primary);
}

/* ============================================
   GAME PLAY SCREEN
   ============================================ */

/* Target Display - Centered at top (desktop) */
.target-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark, #0284C7) 100%);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-shrink: 0;
    position: relative;
}

.target-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
}

.target-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.target-number {
    color: var(--light);
    font-size: 3rem;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
    line-height: 1;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.target-number.exact-match-flash {
    animation: exactMatchFlash 0.5s ease 3;
}

@keyframes exactMatchFlash {
    0%, 100% {
        color: var(--secondary);
        text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
    }
    50% {
        color: var(--success);
        text-shadow: 0 0 20px rgba(40, 167, 69, 0.8), 3px 3px 6px rgba(0,0,0,0.3);
        transform: scale(1.1);
    }
}

/* Timer Display */
.timer-display {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    position: relative;
}

.timer-circle {
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
}

.timer-background {
    fill: none;
    stroke: rgba(255,255,255,0.2);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: var(--secondary);
    stroke-width: 8;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
    stroke-linecap: round;
}

.timer-progress.warning {
    stroke: var(--warning);
}

.timer-progress.danger {
    stroke: var(--danger);
    animation: timerPulse 0.5s ease infinite;
}

@keyframes timerPulse {
    0%, 100% {
        stroke-width: 8;
    }
    50% {
        stroke-width: 10;
    }
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--light);
    font-size: 1.5rem;
    font-weight: 800;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Cards */
.numbers-card,
.operations-card,
.current-calc-card,
.history-card,
.stats-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.numbers-card h3,
.operations-card h3,
.current-calc-card h3,
.history-card h3,
.stats-card h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    text-align: center;
}

/* Number Tiles */
.number-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.number-tile {
    background: var(--primary);
    color: var(--light);
    border: none;
    border-radius: 12px;
    padding: 1.25rem 0.5rem;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    position: relative;
}

.number-tile:hover:not(:disabled) {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(201, 12, 15, 0.4);
}

.number-tile:active:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
}

.number-tile:disabled {
    background: var(--gray);
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.number-tile.selected {
    background: var(--secondary);
    color: var(--text-primary);
    animation: tileSelect 0.3s ease;
}

@keyframes tileSelect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Operation Buttons */
.operation-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.bracket-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--secondary);
}

.bracket-btn:hover:not(:disabled) {
    background: var(--light-gray);
    border-color: var(--primary);
}

.operation-btn {
    background: var(--secondary);
    color: var(--text-primary);
    border: none;
    border-radius: 10px;
    padding: 0.75rem 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.operation-btn:hover:not(:disabled) {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(250, 183, 25, 0.4);
}

.operation-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.operation-btn.selected {
    background: var(--primary);
    color: var(--light);
    animation: tileSelect 0.3s ease;
}

/* Calculation Display */
.calculation-display {
    background: var(--light-gray);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 1rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    font-family: 'Gloria Hallelujah', cursive;
}

.calc-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1.2rem;
}

.calc-expression {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.calc-number {
    color: var(--primary);
}

.calc-operation {
    color: var(--secondary);
    font-size: 2rem;
}

.calc-equals {
    color: var(--text-secondary);
}

.calc-result {
    color: var(--success);
    font-size: 1.8rem;
}

.calc-error {
    color: var(--danger);
}

.calc-bracket {
    color: var(--text-primary);
    font-weight: bold;
}

.calc-action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.75rem;
}

.game-container .btn-sm,
.modal .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.game-container .btn-success,
.modal .btn-success {
    background: var(--success);
    color: var(--light);
}

.game-container .btn-success:hover:not(:disabled),
.modal .btn-success:hover:not(:disabled) {
    background: #218838;
}

/* Calculation Controls */
.calculation-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Calculation History - Legacy rule (overridden by main rule above) */
.calculation-history {
    max-height: 300px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    align-content: start;
}

.history-empty {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.history-step {
    background: rgba(30, 41, 59, 0.6); /* Darker background for better contrast */
    border-left: 4px solid var(--secondary);
    border-radius: 8px;
    padding: 0.85rem;
    margin-bottom: 0; /* No margin-bottom since grid handles spacing */
    font-size: 1rem;
    animation: slideInRight 0.3s ease;
    font-family: 'Gloria Hallelujah', cursive;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 80px;
    justify-content: center;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-step-expression {
    color: #E2E8F0; /* Light text for better contrast on dark background */
    font-weight: bold;
}

.history-step-result {
    color: #38BDF8; /* Bright secondary color for results */
    font-weight: bold;
    font-size: 1.15em; /* Slightly larger for emphasis */
}

/* Stats Card */
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    color: var(--primary);
    font-weight: bold;
}

/* ============================================
   RESULTS SCREEN
   ============================================ */

.results-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 1rem;
    gap: 1rem;
}

.results-title {
    color: var(--primary);
    font-size: 2rem;
    margin: 0;
    text-align: center;
    font-weight: bold;
    flex-shrink: 0;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
}

.results-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.results-card {
    background: rgba(30, 41, 59, 0.95);
    border: 2px solid var(--card-border);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    text-align: center;
}

.results-card h3 {
    color: var(--light);
    font-size: 1.2rem;
    margin: 0 0 0.75rem 0;
    text-align: center;
    font-weight: bold;
    flex-shrink: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.results-middle .results-card {
    border-color: var(--primary);
}

.results-comparison {
    text-align: center;
    margin-bottom: 1rem;
}

.result-item {
    margin: 0.5rem 0;
}

.result-label {
    color: var(--light);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    opacity: 0.9;
}

.result-value {
    font-size: 2.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.target-value {
    color: var(--light);
}

.user-value {
    color: var(--secondary);
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.result-separator {
    font-size: 1.2rem;
    color: var(--light);
    font-weight: bold;
    margin: 0.5rem 0;
    opacity: 0.8;
}

.score-display {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.score-label {
    color: var(--light);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.score-value {
    color: var(--light);
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
    animation: scoreReveal 0.6s ease;
}

@keyframes scoreReveal {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    70% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Solution Tabs */
.solution-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--card-border);
    flex-shrink: 0;
}

.solution-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.solution-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.solution-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
}

.solution-tab i {
    font-size: 1rem;
}

/* Solution Tab Panels */
.solution-tab-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.solution-tab-panel.active {
    display: flex;
    flex-direction: column;
}

/* Solution Sections (user and computer) */
.solution-steps-wrapper,
.user-solution-steps {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    text-align: center;
    min-height: 0;
}

.solution-steps,
.user-solution-steps {
    max-width: 100%;
}

.solution-step {
    background: rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--light);
    animation: slideInLeft 0.5s ease forwards;
    opacity: 0;
    text-align: center;
    font-family: 'Gloria Hallelujah', cursive;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.history-empty {
    text-align: center;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.solution-step:nth-child(1) { animation-delay: 0.1s; }
.solution-step:nth-child(2) { animation-delay: 0.2s; }
.solution-step:nth-child(3) { animation-delay: 0.3s; }
.solution-step:nth-child(4) { animation-delay: 0.4s; }
.solution-step:nth-child(5) { animation-delay: 0.5s; }

.results-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    padding: 0.5rem 0;
}

/* ============================================
   BUTTONS (for game screens, not menu)
   ============================================ */

.game-container .btn,
.modal .btn {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-weight: bold;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.game-container .btn:hover:not(:disabled),
.modal .btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.game-container .btn:active:not(:disabled),
.modal .btn:active:not(:disabled) {
    transform: translateY(0);
}

.game-container .btn:disabled,
.modal .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.game-container .btn-primary,
.modal .btn-primary {
    background: var(--primary);
    color: var(--light);
}

.game-container .btn-primary:hover:not(:disabled),
.modal .btn-primary:hover:not(:disabled) {
    background: #a00a0c;
}

.game-container .btn-secondary,
.modal .btn-secondary {
    background: var(--secondary);
    color: var(--text-primary);
}

.game-container .btn-secondary:hover:not(:disabled),
.modal .btn-secondary:hover:not(:disabled) {
    background: #e6a517;
}

.game-container .btn-lg,
.modal .btn-lg {
    padding: 1rem 2rem;
    font-size: 1.2rem;
}

.game-container .btn-icon,
.modal .btn-icon {
    font-size: 1.2em;
}

.game-container .btn-danger,
.modal .btn-danger {
    background: var(--danger);
    color: var(--light);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border: 3px solid var(--primary);
    color: var(--text-primary);
    border-radius: 16px;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    margin: 5% auto;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    position: relative;
    animation: slideDown 0.3s ease;
}

.modal-large {
    max-width: 900px;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    color: var(--text-secondary);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    background: none;
    border: none;
    line-height: 1;
}

.modal-close:hover {
    color: var(--primary);
}

.modal-content h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    font-weight: bold;
}

.modal-content h3 {
    color: var(--primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: bold;
}

.modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body ul,
.modal-body ol {
    line-height: 1.8;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-label {
    display: block;
    color: var(--text-primary);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.form-select {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(201, 12, 15, 0.25);
    outline: none;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin: 1rem 0;
}

.stat-box {
    background: var(--light-gray);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.stat-box-value {
    color: var(--primary);
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-box-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Hide old desktop two-column layout if it exists */
.game-play-content,
.game-play-left,
    .game-play-right {
    display: none !important;
    }
    
@media (max-width: 992px) {
    .results-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    
    .results-column {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding-top: 70px;
        background: radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.12), transparent 55%),
                    radial-gradient(circle at 85% 25%, rgba(56, 189, 248, 0.12), transparent 50%),
                    linear-gradient(180deg, #0B1120 0%, #0F172A 100%);
    }
    
    .countdown-container {
        padding: 0.5rem 0.5rem 0.5rem 0.5rem;
        padding-top: 1.5rem; /* Extra padding for game header on mobile */
        background: radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.12), transparent 55%),
                    radial-gradient(circle at 85% 25%, rgba(56, 189, 248, 0.12), transparent 50%),
                    linear-gradient(180deg, #0B1120 0%, #0F172A 100%);
    }

    .selection-card {
        padding: 1.5rem 1rem;
    }
    
    .selection-card h2 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .instruction-text {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    /* Number selection */
    .large-number-selector {
        gap: 0.5rem;
    }

    .number-choice-btn {
        width: 60px;
        padding: 0.75rem 0.25rem;
    }

    .choice-number {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .choice-label {
        font-size: 0.75rem;
    }
    
    /* Game play layout */
    .game-play-layout {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .game-play-left,
    .game-play-right {
        gap: 0.5rem;
    }
    
    /* Target card */
    .target-card {
        padding: 1rem;
        gap: 1rem;
        flex-direction: column;
    }
    
    .target-number {
        font-size: 2.5rem;
    }
    
    .target-label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    .timer-display {
        width: 70px;
        height: 70px;
    }
    
    .timer-circle {
        width: 70px;
        height: 70px;
    }
    
    .timer-text {
        font-size: 1.5rem;
    }

    /* Number tiles */
    .number-tiles {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .number-tile {
        padding: 0.75rem 0.25rem;
        font-size: 1.3rem;
    }

    /* Operations */
    .operation-buttons {
        gap: 0.5rem;
        grid-template-columns: repeat(3, 1fr);
    }

    .operation-btn {
        padding: 0.75rem 0.5rem;
        font-size: 1.5rem;
    }

    /* Cards */
    .numbers-card h3,
    .operations-card h3,
    .current-calc-card h3,
    .history-card h3,
    .stats-card h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .numbers-card,
    .operations-card,
    .current-calc-card,
    .history-card,
    .stats-card {
        padding: 0.75rem;
    }

    /* Calculation display */
    .calculation-display {
        font-size: 1rem;
        padding: 0.75rem;
        min-height: 50px;
    }
    
    .calc-placeholder {
        font-size: 0.9rem;
    }

    /* Control buttons */
    .game-controls {
        gap: 0.5rem;
    }
    
    .game-container .btn,
    .modal .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .calc-action-buttons {
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    /* Stats */
    .stats-row-container {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .stats-card .stat-row {
        flex: none;
        min-width: auto;
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 0.5rem 0;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }
    
    .stats-card .stat-row:last-child {
        border-bottom: none;
    }
    
    .stats-card .stat-label {
        margin-bottom: 0;
    }
    
    .stats-card .stat-value {
        font-size: 1rem;
    }
    
    .stat-row {
        padding: 0.5rem 0;
        font-size: 0.9rem;
    }

    /* History */
    .calculation-history {
        max-height: 150px;
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 0.5rem;
    }
    
    .history-step {
        padding: 0.5rem;
        font-size: 0.9rem;
        margin-bottom: 0;
        min-height: auto;
    }

    /* Results screen */
    .results-title {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .results-card {
        padding: 0.75rem;
    }
    
    .results-card h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .result-value {
        font-size: 2rem;
    }

    .score-value {
        font-size: 1.8rem;
    }
    
    .solution-step {
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
    
    .results-buttons {
        gap: 0.5rem;
    }
    
    .game-container .btn-lg,
    .modal .btn-lg {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}

/* ============================================
   MOBILE TABS - Hidden (using vertical stack layout)
   ============================================ */
.mobile-tabs,
.mobile-tab-panels,
.mobile-tab,
.mobile-tab-panel {
    display: none !important;
}

/* Smooth scrolling for mobile */
@media (max-width: 576px) {
    * {
        -webkit-tap-highlight-color: rgba(52, 152, 219, 0.2);
    }
    
    html {
        scroll-behavior: smooth;
    }
}

/* ============================================
   MOBILE OPTIMISED LAYOUT (576px and below)
   ============================================ */
@media (max-width: 576px) {
    body.with-game-header {
        padding-top: 0 !important;
    }
    
    .game-container {
        padding-top: 50px;
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        background: radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.12), transparent 55%),
                    radial-gradient(circle at 85% 25%, rgba(56, 189, 248, 0.12), transparent 50%),
                    linear-gradient(180deg, #0B1120 0%, #0F172A 100%);
    }
    
    .countdown-container {
        padding: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.12), transparent 55%),
                    radial-gradient(circle at 85% 25%, rgba(56, 189, 248, 0.12), transparent 50%),
                    linear-gradient(180deg, #0B1120 0%, #0F172A 100%);
    }

    /* Selection screen - clean and spacious */
    .selection-card {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }
    
    .selection-card h2 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }
    
    .instruction-text {
        font-size: 0.95rem;
        margin-bottom: 1rem;
        line-height: 1.4;
    }
    
    .large-number-selector {
        gap: 0.6rem;
        margin: 1.5rem 0;
    }
    
    .number-choice-btn {
        width: 60px;
        height: 70px;
        padding: 0.5rem 0.25rem;
        border-radius: 12px;
        transition: all 0.2s ease;
    }
    
    .number-choice-btn:active {
        transform: scale(0.95);
    }

    .choice-number {
        font-size: 1.5rem;
        font-weight: 700;
    }

    .choice-label {
        font-size: 0.7rem;
    }
    
    .game-container .btn-lg,
    .modal .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        border-radius: 10px;
        min-height: 48px; /* Better touch target */
    }

    /* ===== MOBILE GAME LAYOUT - VERTICAL STACK ===== */
    .game-play-layout {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
        gap: 0.75rem;
        padding: 0;
    }
    
    /* Mobile: Stack columns vertically */
    .game-main-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-left-column {
        flex: 0 0 auto;
        width: 100%;
        order: 3; /* Show last on mobile */
    }
    
    .control-buttons-column {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .game-middle-column {
        flex: 0 0 auto;
        width: 100%;
        order: 1; /* Show first on mobile */
    }
    
    .game-right-column {
        flex: 1;
        width: 100%;
        order: 2; /* Show second on mobile */
    }
    
    /* Show bottom controls on mobile */
    .game-controls-bottom {
        display: flex;
        order: 4;
    }
    
    /* Target bar - compact at top */
    .target-card {
        padding: 0.75rem 1rem;
        gap: 1rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-radius: 10px;
        margin: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        flex-shrink: 0;
    }
    
    .target-info {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        text-align: left;
    }
    
    .target-info {
        flex: 1;
        text-align: left;
    }

    .target-number {
        font-size: 2rem;
        font-weight: 800;
        line-height: 1;
    }
    
    .target-label {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.25rem;
    }
    
    .timer-display {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
    
    .timer-circle {
        width: 60px;
        height: 60px;
    }
    
    .timer-text {
        font-size: 1rem;
        font-weight: 800;
    }
    
    /* Main content - stack vertically on mobile */
    .game-main-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .game-left-column {
        flex: 0 0 auto;
        width: 100%;
        order: 2; /* Show after right column on mobile */
    }
    
    .game-right-column {
        flex: 1;
        width: 100%;
        order: 1; /* Show first on mobile */
    }
    
    /* Calculations space - scrollable (legacy support) */
    .calculations-space {
        flex: 1;
        gap: 0.75rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Combined pad - side by side on mobile too (legacy support) */
    .combined-pad {
        gap: 0.5rem;
        flex-shrink: 0;
        flex-direction: row;
    }
    
    .calc-action-buttons {
        padding: 0.75rem;
    }
    
    .calc-action-buttons .btn {
        font-size: 0.9rem;
        padding: 0.65rem 0.85rem;
    }
    
    .numbers-section {
        flex: 2;
        padding: 0.75rem;
    }
    
    .operations-section {
        flex: 1;
        padding: 0.75rem;
    }
    
    .numbers-section h3,
    .operations-section h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    /* Bottom controls - more compact */
    .game-controls-bottom {
        padding: 0.4rem 0.5rem;
        gap: 0.4rem;
        border-top: 2px solid var(--card-border);
    }
    
    .game-controls-bottom .btn {
        min-width: 70px;
        max-width: 120px;
        min-height: 40px;
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
    }
    
    .game-controls-bottom .btn i {
        font-size: 0.85em;
    }
    
    /* Mobile tab navigation */
    .mobile-tabs {
        display: flex;
        background: var(--card-bg);
        border-bottom: 2px solid var(--border);
        flex-shrink: 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    .mobile-tab {
        flex: 1;
        padding: 0.85rem 0.5rem;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;
        text-align: center;
    }
    
    .mobile-tab:active {
        transform: scale(0.98);
    }
    
    .mobile-tab.active {
        color: var(--primary);
        background: rgba(52, 152, 219, 0.08);
    }
    
    .mobile-tab.active::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 0;
        right: 0;
        height: 2px;
        background: var(--primary);
    }
    
    .mobile-tab i {
        display: block;
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }
    
    /* Tab panels container */
    .mobile-tab-panels {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        position: relative;
    }
    
    /* Tab panels */
    .mobile-tab-panel {
        display: none;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
    }
    
    .mobile-tab-panel.active {
        display: flex;
    }
    
    /* Hide desktop content wrapper on mobile (content moves to tabs) */
    .game-play-content {
        display: none !important;
    }

    /* Cards in mobile tabs - optimised spacing */
    .numbers-card,
    .operations-card,
    .current-calc-card,
    .history-card,
    .stats-card {
        padding: 0.85rem;
        border-width: 2px;
        border-radius: 12px;
        margin: 0;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    
    .numbers-card h3,
    .operations-card h3,
    .current-calc-card h3,
    .history-card h3,
    .stats-card h3 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    /* Number tiles - larger touch targets */
    .number-tiles {
        gap: 0.6rem;
        grid-template-columns: repeat(3, 1fr);
    }

    .number-tile {
        padding: 1rem 0.5rem;
        font-size: 1.4rem;
        font-weight: 700;
        min-height: 56px;
        border-radius: 10px;
        transition: all 0.2s ease;
    }
    
    .number-tile:active {
        transform: scale(0.95);
    }

    /* Operations - 2 column grid */
    .operation-buttons {
        gap: 0.5rem;
        grid-template-columns: repeat(2, 1fr);
    }

    .operation-btn {
        padding: 0.7rem 0.4rem;
        font-size: 1.3rem;
        font-weight: 700;
        min-height: 48px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }
    
    .operation-btn:active {
        transform: scale(0.95);
    }

    /* Current calculation display */
    .calculation-display {
        font-size: 1rem;
        padding: 0.75rem;
        min-height: 52px;
        border-radius: 8px;
        line-height: 1.4;
    }
    
    .calc-placeholder {
        font-size: 0.85rem;
    }
    
    .calc-action-buttons {
        margin-top: 0.75rem;
        gap: 0.5rem;
        display: flex;
    }
    
    .calc-action-buttons .btn {
        flex: 1;
        min-height: 44px;
    }

    /* Game controls - better touch targets */
    .game-controls {
        gap: 0.5rem;
        flex-wrap: nowrap;
        margin-top: 0.75rem;
    }
    
    .game-controls .btn {
        flex: 1;
        min-height: 48px;
        border-radius: 10px;
        font-weight: 600;
    }
    
    .game-container .btn,
    .modal .btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.2s ease;
    }
    
    .game-container .btn:active,
    .modal .btn:active {
        transform: scale(0.98);
    }
    
    .game-container .btn-sm,
    .modal .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    /* Stats display - cleaner layout */
    .stat-row {
        padding: 0.65rem 0;
        font-size: 0.9rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .stat-label {
        font-size: 0.85rem;
        font-weight: 500;
    }
    
    .stat-value {
        font-size: 1rem;
        font-weight: 700;
    }

    /* Calculation history - scrollable */
    .calculation-history {
        max-height: 200px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        grid-template-columns: 1fr; /* Single column on small mobile */
        gap: 0.5rem;
    }
    
    .history-step {
        padding: 0.65rem;
        font-size: 0.9rem;
        margin-bottom: 0;
        border-radius: 8px;
        border-left-width: 3px;
        min-height: auto;
    }
    
    .history-empty {
        font-size: 0.9rem;
        padding: 1.5rem 0.75rem;
        text-align: center;
        color: var(--text-secondary);
    }

    /* Results screen - mobile optimized */
    .results-layout {
        padding: 0.75rem;
        gap: 0.75rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .results-title {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
        font-weight: 800;
        text-align: center;
        color: var(--light);
    }
    
    .results-grid {
        gap: 0.75rem;
        grid-template-columns: 1fr; /* Single column on mobile for better readability */
        margin-bottom: 0.75rem;
    }
    
    /* Solution tabs on mobile */
    .solution-tabs {
        gap: 0.25rem;
        margin-bottom: 0.75rem;
    }
    
    .solution-tab {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .solution-tab i {
        font-size: 0.9rem;
    }
    
    .results-card {
        padding: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .results-card h3 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .result-label {
        font-size: 0.75rem;
        font-weight: 600;
    }

    .result-value {
        font-size: 1.8rem;
        font-weight: 800;
    }
    
    .result-separator {
        font-size: 1rem;
        margin: 0.5rem 0;
        font-weight: 700;
    }

    .score-display {
        padding: 1rem;
        margin-top: 0.75rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .score-label {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-weight: 600;
    }

    .score-value {
        font-size: 2rem;
        font-weight: 800;
    }
    
    .solution-step {
        padding: 0.65rem;
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        border-left-width: 3px;
        border-radius: 6px;
    }
    
    .solution-steps-wrapper,
    .user-solution-steps {
        max-height: 250px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .results-buttons {
        gap: 0.75rem;
        flex-direction: column;
        margin-top: 1rem;
    }
    
    .results-buttons .btn {
        width: 100%;
        min-height: 52px;
        font-size: 1rem;
        border-radius: 10px;
        font-weight: 700;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stat-box {
        padding: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    
    .stat-box-value {
        font-size: 2rem;
        font-weight: 800;
    }
    
    .stat-box-label {
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Mobile modals */
    .modal-content {
        margin: 2% auto;
        padding: 1rem;
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .modal-content h3 {
        font-size: 1rem;
        margin-top: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-body {
        max-height: 70vh;
        font-size: 0.9rem;
    }
    
    .modal-close {
        right: 0.75rem;
        top: 0.75rem;
        font-size: 1.5rem;
    }
    
    .setting-group {
        margin-bottom: 1rem;
    }
    
    .setting-label {
        font-size: 0.9rem;
    }
    
    .form-select {
        font-size: 0.9rem;
        padding: 0.4rem;
    }
    
    /* Achievements on mobile */
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .achievement-card {
        padding: 0.75rem;
    }
    
    .achievement-card .achievement-badge-img,
    .achievement-card .achievement-icon {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }
    
    .achievement-name {
        font-size: 0.85rem;
    }
    
    .achievement-description {
        font-size: 0.75rem;
    }
    
    /* Button icons smaller on mobile */
    .btn i,
    .btn-icon {
        font-size: 0.9em;
    }
    
    /* Game header on mobile */
    .game-top-bar {
        padding: 0.5rem;
    }
    
    .game-title-header {
        font-size: 1rem;
    }
    
    /* Ensure button group is hidden on mobile (burger menu shows instead) */
    .game-top-bar .button-group {
        display: none !important;
    }
    
    /* Ensure burger menu is visible on mobile */
    .game-top-bar .game-header-burger {
        display: block !important;
    }
    
    .top-bar-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus styles for keyboard navigation */
button:focus-visible,
.btn:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
    outline: 3px solid var(--secondary);
    outline-offset: 2px;
}

/* Touch-friendly mobile interactions */
@media (max-width: 576px) {
    /* Ensure all interactive elements are touch-friendly */
    .number-tile,
    .operation-btn,
    .btn {
        -webkit-tap-highlight-color: rgba(250, 183, 25, 0.3);
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* Prevent text selection during touch */
    .number-tiles,
    .operation-buttons,
    .calculation-display {
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Larger tap targets */
    .number-tile,
    .operation-btn {
        min-height: 44px; /* iOS minimum tap target */
    }
}

/* ============================================
   ANIMATIONS & EFFECTS
   ============================================ */

/* Confetti for exact matches */
@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--secondary);
    top: -10px;
    animation: confetti 3s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

