* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    /* Enable zoom and fit to screen */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.5s ease;
    /* Ensure body scales properly */
    overflow-x: auto;
    overflow-y: auto;
}

/* Dynamic backgrounds for game problems */
.bg-1 { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); }
.bg-2 { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }
.bg-3 { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); }
.bg-4 { background: linear-gradient(135deg, #ff8a80 0%, #ffb74d 100%); }
.bg-5 { background: linear-gradient(135deg, #81c784 0%, #aed581 100%); }
.bg-6 { background: linear-gradient(135deg, #64b5f6 0%, #42a5f5 100%); }
.bg-7 { background: linear-gradient(135deg, #ba68c8 0%, #9c27b0 100%); }
.bg-8 { background: linear-gradient(135deg, #ffb74d 0%, #ff8a65 100%); }
.bg-9 { background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%); }
.bg-10 { background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%); }

#app {
    width: 100%;
    max-width: 800px;
    padding: 20px;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease-in;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    /* Ensure screens fit properly on all devices */
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

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

/* Responsive Base Styles */
@media screen and (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    html {
        font-size: 12px;
    }
}

/* Menu Screen Styles */
.menu-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

/* Hero Image Styles */
.hero-image-container {
    margin-bottom: 20px;
    text-align: center;
}

.hero-image {
    max-width: 400px;
    width: 100%;
    height: auto;
    max-height: 300px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.hero-image:hover {
    transform: scale(1.02);
}

.menu-container h1 {
    font-size: 3em;
    color: #333;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-settings {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 30px;
    margin: 30px 0;
    text-align: left;
}

.game-settings h2 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.setting-group input[type="checkbox"] {
    margin-right: 10px;
}

.setting-group select,
.setting-group input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.setting-group select:focus,
.setting-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Player row inline layout */
.player-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-row label {
    margin-bottom: 0;
    flex-shrink: 0;
}

.player-row .user-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-grow: 1;
}

.player-row select {
    width: auto;
    min-width: 120px;
    flex-grow: 1;
}

.menu-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-large {
    padding: 20px 40px;
    font-size: 20px;
    font-weight: 900;
    border-radius: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    animation: primaryPulse 2s ease-in-out infinite;
}

.btn-large:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.5);
}

@keyframes primaryPulse {
    0%, 100% { box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3); }
    50% { box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4); }
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(240, 147, 251, 0.4);
}

.btn-abort {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 10px 20px;
    font-size: 14px;
}

.btn-danger {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
}

/* Game Screen Styles */
.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    min-height: 400px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.progress {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.problem-container {
    margin: 60px 0;
}

.math-problem {
    font-size: 4em;
    font-weight: bold;
    color: #333;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    transition: color 0.3s ease;
}

.math-problem.correct {
    color: #4caf50;
    animation: correctPulse 1s ease;
}

.math-problem.incorrect {
    color: #f44336;
    animation: incorrectShake 0.5s ease;
}

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

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

/* Division Display Styles */
.math-problem.division-standard {
    /* Standard ÷ symbol - use default styling */
    font-family: inherit;
}

.math-problem.division-slash {
    /* Inline forward slash style - use default styling */
    font-family: 'Courier New', monospace;
}

.math-problem.division-long {
    /* Long division style */
    display: flex;
    justify-content: center;
    align-items: center;
}

.long-division {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    font-family: 'Courier New', monospace;
    font-size: 1em; /* Will be scaled by parent math-problem */
}

.long-division .divisor {
    margin-right: 10px;
    padding-top: 5px;
}

.long-division .division-bar {
    position: relative;
    border-left: 3px solid #333;
    border-top: 3px solid #333;
    padding: 5px 15px;
    border-radius: 5px 0 0 0;
}

.long-division .dividend {
    min-width: 60px;
    text-align: center;
}

.math-problem.division-fraction {
    /* Fraction style */
    display: flex;
    justify-content: center;
    align-items: center;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Georgia', serif;
    font-size: 1em; /* Will be scaled by parent math-problem */
}

.fraction .numerator,
.fraction .denominator {
    padding: 5px 10px;
    min-width: 60px;
    text-align: center;
}

.fraction .fraction-bar {
    height: 3px;
    width: 100%;
    background-color: #333;
    margin: 5px 0;
    border-radius: 1px;
}

/* Responsive adjustments for division styles */
@media (max-width: 600px) {
    .long-division {
        font-size: 0.8em;
    }
    
    .fraction {
        font-size: 0.9em;
    }
    
    .long-division .division-bar {
        padding: 3px 10px;
    }
    
    .fraction .numerator,
    .fraction .denominator {
        padding: 3px 8px;
        min-width: 50px;
    }
}

.answer-input {
    font-size: 2em;
    padding: 20px;
    border: 3px solid #ddd;
    border-radius: 15px;
    text-align: center;
    width: 300px;
    max-width: 100%;
    transition: border-color 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #667eea;
}

.feedback {
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    min-height: 30px;
}

.repeat-notice {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
    border-radius: 15px;
    padding: 20px;
    margin-top: 30px;
    display: none;
    animation: bounceIn 0.5s ease;
}

.repeat-notice.active {
    display: block;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.repeat-notice p {
    margin-bottom: 10px;
    font-weight: bold;
    color: #d63031;
}

#repeat-counter {
    font-size: 1.1em;
    color: #2d3436;
}

/* Results Screen Styles */
.results-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    max-height: 90vh;
    overflow-y: auto;
}

.results-container h2 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 30px;
}

.score-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.score-item {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.score-label {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.score-value {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #333;
}

.time-stats,
.wrong-problems,
.slowest-problems {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    text-align: left;
}

.time-stats h3,
.wrong-problems h3,
.slowest-problems h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

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

.stat-item {
    text-align: center;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
}

.stat-label {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.stat-item span:last-child {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

.problem-list {
    max-height: 300px;
    overflow-y: auto;
}

/* All problems list should show more items */
#all-problems-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 0;
}

.problem-item {
    padding: 10px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

/* Game History Screen Styles */
.history-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    max-height: 90vh;
    overflow-y: auto;
}

.history-container h2 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 30px;
}

.history-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
}

.history-filter label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.history-filter select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.history-stats {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1em;
}

.history-list {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 30px;
}

.history-item {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    margin: 15px 0;
    text-align: left;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #667eea;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.history-game-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-game-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

.history-game-meta {
    font-size: 0.9em;
    color: #666;
}

.history-score {
    text-align: center;
    padding: 10px;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-radius: 10px;
    min-width: 120px;
}

.history-score-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    display: block;
}

.history-score-label {
    font-size: 0.8em;
    color: #666;
}

.history-settings {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

.history-settings-title {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.history-settings-list {
    font-size: 0.9em;
    color: #555;
}

.history-problems {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.history-problems-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-problems-toggle {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 0.9em;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.history-problems-toggle:hover {
    background: rgba(102, 126, 234, 0.1);
}

.history-problems-list {
    display: none;
    max-height: 150px;
    overflow-y: auto;
}

.history-problems-list.expanded {
    display: block;
}

.history-problem-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
}

.history-problem-item:last-child {
    border-bottom: none;
}

.history-problem-equation {
    flex: 1;
}

.history-problem-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.history-problem-status.correct {
    background: #4caf50;
    color: white;
}

.history-problem-status.incorrect {
    background: #f44336;
    color: white;
}

.history-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.no-history {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 1.1em;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    margin: 20px 0;
}

/* Statistics Screen Styles */
.stats-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.stats-container h2 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 30px;
}

.overall-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.slowest-overall {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    text-align: left;
}

.slowest-overall h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.stats-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #app {
        padding: 10px;
    }
    
    .menu-container,
    .game-container,
    .results-container,
    .stats-container {
        padding: 20px;
    }
    
    .menu-buttons,
    .results-buttons,
    .stats-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .btn-large {
        padding: 15px 20px;
        font-size: 18px;
        max-width: 350px;
    }
    
    .math-problem {
        font-size: 2.5em;
    }
    
    .answer-input,
    .remainder-input {
        font-size: 1.5em;
        width: 100%;
    }
    
    .score-summary,
    .stats-grid,
    .overall-stats {
        grid-template-columns: 1fr;
    }
    
    .operator-selection {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .operator-option label {
        padding: 10px 5px;
    }
    
    .operator-icon {
        font-size: 1.5em;
        margin-bottom: 5px;
    }
    
    .operator-text {
        font-size: 0.8em;
    }
    
    .user-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .user-controls select {
        width: 100%;
    }
    
    .game-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .motivation-text {
        font-size: 1em;
    }
    
    .remainder-prompt {
        font-size: 1em;
    }
    
    .preset-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .preset-btn {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    .preset-btn.brain-btn {
        font-size: 14px;
    }
    
    .history-container {
        padding: 20px;
        max-height: 95vh;
    }
    
    .history-controls {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .history-item-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .history-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .history-buttons .btn {
        width: 100%;
        max-width: 300px;
    }
    
    /* Hero image responsive adjustments */
    .hero-image {
        max-width: 300px;
        max-height: 200px;
    }
    
    .about-hero-image {
        max-width: 250px;
        max-height: 150px;
    }
}

/* User Controls */
.user-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-controls select {
    flex: 1;
}

.btn-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger-small {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
}

.btn-small-game {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    color: #333;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.btn-small-game:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

/* Operator Selection */
.operator-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.operator-option {
    position: relative;
}

.operator-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.operator-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 2px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    text-align: center;
    position: relative;
}

.operator-option label:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.operator-option input[type="checkbox"]:checked + label {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.operator-option input[type="checkbox"]:not(:checked) + label {
    opacity: 0.5;
    background: rgba(200, 200, 200, 0.3);
}

.operator-option input[type="checkbox"]:checked + label::after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #4caf50;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.operator-icon {
    font-size: 2em;
    margin-bottom: 8px;
    display: block;
}

.operator-text {
    font-size: 0.9em;
    font-weight: bold;
    color: #333;
}

/* Game Controls */
.game-controls {
    display: flex;
    align-items: center;
}

/* Remainder Section */
.remainder-section {
    margin-top: 20px;
    animation: slideDown 0.3s ease;
}

.remainder-prompt {
    font-size: 1.2em;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

.remainder-input {
    width: 150px;
    font-size: 1.5em;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    transition: border-color 0.3s ease;
    margin: 0 auto;
    display: block;
}

.remainder-input:focus {
    outline: none;
    border-color: #667eea;
}

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

/* Motivation Text */
.motivation-text {
    font-size: 1.2em;
    color: #667eea;
    font-weight: bold;
    margin: 20px 0;
    min-height: 30px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

/* Streak Effects */
.streak-effects {
    position: relative;
    height: 100px;
    overflow: hidden;
    margin: 20px 0;
}

.fire-effect {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #ff6b35, #f7931e, #ffeb3b);
    border-radius: 50%;
    animation: fireFlicker 0.5s ease-in-out infinite alternate;
    opacity: 0.8;
}

.rocket-effect {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    animation: rocketBoost 1s ease-out;
}

.speed-effect {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #00bcd4, transparent);
    animation: speedLines 0.8s ease-out;
}

@keyframes fireFlicker {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.1) rotate(5deg); }
}

@keyframes rocketBoost {
    0% { transform: translate(-50%, 100%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -150%) scale(0.8); opacity: 0; }
}

@keyframes speedLines {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.streak-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5em;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* Enhanced Results Sections */
.fastest-problems,
.fastest-overall,
.fastest-recent,
.all-problems {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    text-align: left;
}

.fastest-problems h3,
.fastest-overall h3,
.fastest-recent h3,
.all-problems h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.problem-item.correct {
    background: rgba(76, 175, 80, 0.1);
    border-left: 4px solid #4caf50;
}

.problem-item.incorrect {
    background: rgba(244, 67, 54, 0.1);
    border-left: 4px solid #f44336;
}

.problem-status {
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

.problem-status.correct {
    background: #4caf50;
    color: white;
}

.problem-status.incorrect {
    background: #f44336;
    color: white;
}

/* Hide elements by default */
.wrong-problems,
.fastest-problems,
.all-problems {
    display: none;
}

.wrong-problems.has-items,
.fastest-problems.has-items,
.all-problems.has-items {
    display: block;
}

/* Question Count Slider and Presets */
.question-count-container {
    margin-top: 10px;
}

.slider {
    width: 100%;
    height: 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ddd 0%, #bbb 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 15px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.preset-btn {
    padding: 12px 8px;
    border: 2px solid #ddd;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.preset-btn:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.preset-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.preset-btn.brain-btn {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border-color: #ff6b35;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    animation: brainPulse 2s ease-in-out infinite;
}

.preset-btn.brain-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(255, 107, 53, 0.4);
}

.preset-btn.brain-btn.active {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    box-shadow: 0 8px 25px rgba(255, 65, 108, 0.5);
}

.preset-btn.mega-brain {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%, #ff6b35 100%);
    animation: megaBrainPulse 1.5s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.preset-btn.mega-brain::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(45deg);
    animation: megaBrainShine 2s ease-in-out infinite;
}

.preset-btn.mega-brain:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.6);
}

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

@keyframes megaBrainPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3); }
    50% { transform: scale(1.08); box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5); }
}

@keyframes megaBrainShine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    50% { transform: translateX(-50%) translateY(-50%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

#question-count-display {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1em;
}

/* Touch Number Pad Styles - FULL SCREEN OPTIMIZED */
.number-pad {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    margin-top: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
}

.number-pad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.number-pad-header span {
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
}

.btn-toggle-pad {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.btn-toggle-pad:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 8px;
    max-width: 300px;
    margin: 0 auto;
}

.num-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 249, 250, 0.9));
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 12px;
    font-size: 20px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    min-height: 45px;
    touch-action: manipulation; /* Prevents scroll interference on touch */
    -webkit-touch-callout: none; /* Prevents iOS callout menu */
}

.num-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.num-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.2);
}

.num-btn-wide {
    grid-column: span 1;
}

.num-btn-special {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.num-btn-special:hover {
    background: linear-gradient(135deg, #ff5252 0%, #d32f2f 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.num-btn-negative {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    font-size: 18px;
    font-weight: bold;
}

.num-btn-negative:hover {
    background: linear-gradient(135deg, #f57c00 0%, #ef6c00 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.4);
}

/* Number pad hide/show animation */
.number-pad.hidden {
    max-height: 50px;
    overflow: hidden;
    padding-bottom: 8px;
}

.number-pad.hidden .number-grid {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
}

.number-pad:not(.hidden) .number-grid {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
    transition: all 0.3s ease;
}

/* Responsive adjustments for number pad - COMPACT FULL-SCREEN OPTIMIZED */
@media (max-width: 768px) {
    /* Full screen optimization */
    #app {
        padding: 5px;
        max-width: 100%;
    }
    
    .game-container {
        padding: 15px;
        min-height: auto;
    }
    
    .problem-container {
        margin: 20px 0;
    }
    
    .math-problem {
        font-size: 2.2em;
        margin-bottom: 15px;
    }
    
    .answer-input, .remainder-input {
        font-size: 1.8em;
        padding: 12px;
        margin: 10px 0;
    }
    
    .number-pad {
        padding: 4px 6px; /* Reduced padding for more math problem space */
        margin-top: 4px; /* Reduced margin */
        width: 100%;
        max-width: none;
    }
    
    .number-grid {
        gap: 4px; /* Smaller gaps between buttons */
        max-width: 100%;
        padding: 0 3px; /* Reduced padding */
    }
    
    .num-btn {
        padding: 3px 5px; /* Even more compact for maximum math problem space */
        font-size: 18px; /* Smaller but still readable */
        min-height: 14px; /* Ultra-compact for more math problem space */
        border-radius: 6px;
    }
    
    .num-btn-special {
        font-size: 10px; /* More compact special button text */
        padding: 3px 3px;
    }
    
    .num-btn-negative {
        font-size: 14px; /* More compact negative button */
        padding: 3px 5px;
    }
}

@media (max-width: 480px) {
    #app {
        padding: 2px;
    }
    
    .game-container {
        padding: 10px;
    }
    
    .math-problem {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    .answer-input, .remainder-input {
        font-size: 1.6em;
        padding: 10px;
    }
    
    .number-pad {
        padding: 3px 4px; /* Ultra-minimal padding for maximum space */
        margin-top: 2px; /* Minimal margin */
    }
    
    .number-grid {
        gap: 2px; /* Ultra-minimal gaps */
        max-width: 100%;
    }
    
    .num-btn {
        padding: 2px 3px; /* Ultra-minimal for maximum math problem space */
        font-size: 16px; /* Smaller but still readable on touch screens */
        min-height: 12px; /* Minimal height while remaining tappable */
        border-radius: 4px;
    }
    
    .num-btn-special {
        font-size: 8px; /* Ultra-compact special buttons */
        padding: 2px 2px;
    }
    
    .num-btn-negative {
        font-size: 12px; /* Ultra-compact negative button */
        padding: 2px 3px;
    }
    
    .number-pad-header span {
        font-size: 12px;
    }
    
    .btn-toggle-pad {
        padding: 4px 8px;
        font-size: 10px;
    }
}

/* Full screen mobile experience - OPTIMIZED */
@media (max-width: 768px) {
    /* Hide device keyboard for full touch experience */
    .answer-input, .remainder-input {
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        caret-color: transparent; /* Hide cursor on mobile */
        text-align: center;
    }
    
    /* Make number pad more prominent on mobile */
    .number-pad:not(.hidden) {
        position: relative;
        z-index: 10;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 -3px 20px rgba(0, 0, 0, 0.15);
        border-top: 2px solid #667eea;
    }
    
    /* Compact layout for full screen */
    .game-header {
        margin-bottom: 15px;
    }
    
    .progress {
        font-size: 16px;
    }
    
    .game-controls .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .motivation-text {
        font-size: 1em;
        margin: 10px 0;
    }
    
    .repeat-notice {
        padding: 10px;
        margin-top: 15px;
    }
}

/* Pixel 9 XL Pro and similar large mobile devices - ULTRA COMPACT + VIEWPORT FIT */
@media (max-width: 428px) and (min-height: 900px), 
       (max-width: 768px) and (orientation: portrait) {
    /* Ensure entire page fits in viewport */
    body {
        min-height: 100vh;
        max-height: 100vh;
        overflow-x: hidden;
    }
    
    #app {
        padding: 2px !important;
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .game-container {
        padding: 8px !important;
        min-height: auto !important;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .game-header {
        margin-bottom: 8px !important;
        flex-shrink: 0;
    }
    
    .problem-container {
        margin: 8px 0 !important;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .math-problem {
        font-size: 1.8em !important;
        margin-bottom: 8px !important;
        line-height: 1.2 !important;
    }
    
    .answer-input, .remainder-input {
        font-size: 1.4em !important;
        padding: 8px !important;
        margin: 5px 0 !important;
    }
    
    .number-pad {
        flex-shrink: 0;
        margin-top: 2px !important;
    }
    .num-btn {
        padding: 2px 4px !important; /* Force ultra-compact padding */
        font-size: 16px !important; /* Readable but compact */
        min-height: 8px !important; /* Ultra-minimal height for large phones */
        line-height: 1.1 !important; /* Tight line height */
        border-radius: 4px !important;
        touch-action: manipulation !important; /* Prevent scroll interference */
    }
    
    .num-btn-special {
        font-size: 8px !important; /* Ultra-compact special buttons */
        padding: 2px 2px !important;
        min-height: 8px !important;
    }
    
    .num-btn-negative {
        font-size: 12px !important; /* Ultra-compact negative button */
        padding: 2px 4px !important;
        min-height: 8px !important;
    }
    
    .number-grid {
        gap: 1px !important; /* Minimal gaps for maximum space efficiency */
    }
    
    .number-pad {
        padding: 2px 3px !important; /* Minimal padding */
        margin-top: 1px !important;
    }
    
    /* Ensure bottom buttons are always visible */
    .number-pad .number-grid {
        margin-bottom: 4px !important;
        padding-bottom: 2px !important;
    }
    
    /* Add safe area for bottom of screen */
    .game-container::after {
        content: "";
        height: 20px; /* Safe area at bottom */
        width: 100%;
        display: block;
        flex-shrink: 0;
    }
}

/* About Screen Styles */
.about-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    margin: 0 auto;
    max-height: 80vh;
    overflow-y: auto;
}

.about-hero-container {
    margin-bottom: 30px;
    text-align: center;
}

.about-hero-image {
    max-width: 350px;
    width: 100%;
    height: auto;
    max-height: 200px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.about-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.about-content {
    margin-bottom: 30px;
}

.about-section {
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.about-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.about-section p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.about-section ul, .about-section ol {
    color: #555;
    line-height: 1.6;
    padding-left: 20px;
}

.about-section li {
    margin-bottom: 8px;
}

.about-section li strong {
    color: #333;
}

.version-info {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #764ba2;
}

.terms-content {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    margin-top: 10px;
}

.terms-content h4 {
    color: #667eea;
    margin: 15px 0 10px 0;
    font-size: 1.1em;
}

.terms-content h4:first-child {
    margin-top: 5px;
}

.terms-content ul {
    margin-bottom: 15px;
}

.terms-content p {
    margin-bottom: 10px;
}

.about-buttons {
    text-align: center;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

/* Touch feedback animation */
.num-btn.touched {
    animation: touchFeedback 0.2s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    transform: scale(0.95) !important;
}

@keyframes touchFeedback {
    0% { 
        transform: scale(1); 
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 249, 250, 0.9));
    }
    50% { 
        transform: scale(0.95); 
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
    }
    100% { 
        transform: scale(1); 
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 249, 250, 0.9));
    }
}

/* Superhero Character Styles */
.superhero-character {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    z-index: 1000;
    pointer-events: none;
    transition: transform 0.1s ease-out;
}

.superhero-sprite {
    font-size: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
    animation: superheroFloat 2s ease-in-out infinite;
}



/* Floating animation for idle state */
@keyframes superheroFloat {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg); 
    }
    50% { 
        transform: translateY(-5px) rotate(1deg); 
    }
}





/* Mobile responsive adjustments */
@media (max-width: 600px) {
    .superhero-character {
        right: 15px;
        bottom: 15px;
        width: 50px;
        height: 50px;
    }
    
    .superhero-sprite {
        font-size: 40px;
    }
    

}

/* Hide superhero on non-game screens */
#menu-screen .superhero-character,
#results-screen .superhero-character,
#history-screen .superhero-character,
#about-screen .superhero-character,
#stats-screen .superhero-character {
    display: none;
}

/* Chain boost feedback animation */
@keyframes chainBoostPop {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translateX(-50%) translateY(-30px) scale(1.2);
    }
    40% {
        transform: translateX(-50%) translateY(-40px) scale(1);
    }
    80% {
        opacity: 1;
        transform: translateX(-50%) translateY(-45px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-60px) scale(0.8);
    }
}

.chain-boost-feedback {
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}
