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

/* Define CSS variables for colors */
:root {
    --color-primary: #1e90ff;
    --color-secondary: #70a1ff;
    --color-dark: #2c3e50;
    --color-light: #ffffff;
    --color-text-dark: #000000;
    --color-text-light: #ffffff;
    --color-tertiary: #ff7e5f;
    --color-quaternary: #feb47b;
    /* ...other variables... */
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(-45deg, var(--color-primary), var(--color-secondary), var(--color-tertiary), var(--color-quaternary));
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    transition: background 0.3s, color 0.3s;
    color: var(--color-text-dark);
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://www.transparenttextures.com/patterns/diagonal-noise.png');
    opacity: 0.05;
    pointer-events: none;
    z-index: -1;
}

@keyframes gradientAnimation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body.light-theme {
    --color-primary: #1e90ff;
    --color-secondary: #70a1ff;
    --color-text: var(--color-text-dark);
}

body.dark-theme {
    --color-primary: var(--color-dark);
    --color-secondary: #4ca1af;
    --color-text: var(--color-text-light);
}

body[class*="theme-"] {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: var(--color-text);
}

body.theme-green {
    --color-primary: #2ecc71;
    --color-secondary: #27ae60;
    --color-tertiary: #55efc4;
    --color-quaternary: #00b894;
}

body.theme-red {
    --color-primary: #e74c3c;
    --color-secondary: #c0392b;
    --color-tertiary: #ff7675;
    --color-quaternary: #d63031;
}

body.theme-purple {
    --color-primary: #9b59b6;
    --color-secondary: #8e44ad;
    --color-tertiary: #be90d4;
    --color-quaternary: #9b59b6;
}

body.theme-orange {
    --color-primary: #e67e22;
    --color-secondary: #d35400;
    --color-tertiary: #f39c12;
    --color-quaternary: #e67e22;
}

body.theme-yellow {
    --color-primary: #f1c40f;
    --color-secondary: #f39c12;
    --color-tertiary: #f1c40f;
    --color-quaternary: #f39c12;
}

body.theme-pink {
    --color-primary: #fd79a8;
    --color-secondary: #e84393;
    --color-tertiary: #ff9ff3;
    --color-quaternary: #f368e0;
}

body.theme-teal {
    --color-primary: #1abc9c;
    --color-secondary: #16a085;
    --color-tertiary: #48dbfb;
    --color-quaternary: #1dd1a1;
}

body.theme-brown {
    --color-primary: #8d6e63;
    --color-secondary: #5d4037;
    --color-tertiary: #a1887f;
    --color-quaternary: #795548;
}

body.theme-gray {
    --color-primary: #95a5a6;
    --color-secondary: #7f8c8d;
    --color-tertiary: #bdc3c7;
    --color-quaternary: #95a5a6;
}

body.theme-cyan {
    --color-primary: #00bcd4;
    --color-secondary: #0097a7;
    --color-tertiary: #00acc1;
    --color-quaternary: #00838f;
}

body.theme-lime {
    --color-primary: #cddc39;
    --color-secondary: #afb42b;
    --color-tertiary: #d4e157;
    --color-quaternary: #c0ca33;
}

body.theme-indigo {
    --color-primary: #3f51b5;
    --color-secondary: #303f9f;
    --color-tertiary: #5c6bc0;
    --color-quaternary: #3949ab;
}

body.theme-amber {
    --color-primary: #ffc107;
    --color-secondary: #ff9800;
    --color-tertiary: #ffb300;
    --color-quaternary: #ffa000;
}

body.theme-deep-orange {
    --color-primary: #ff5722;
    --color-secondary: #e64a19;
    --color-tertiary: #ff7043;
    --color-quaternary: #d84315;
}

/* ...other theme colors... */

.container {
    background: var(--color-light);
    padding: 3rem; /* Consolidated padding */
    border-radius: 1rem;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 600px; /* Set maximum width */
    transition: background 0.3s, color 0.3s;
    margin: 2rem auto; /* Center the container */
    color: var(--color-text);
}

.container.dark-theme {
    background: #333;
    color: white;
}

.screen {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.hidden {
    display: none;
}

input, select, button {
    padding: 0.8rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    background-color: var(--color-light);
    color: var(--color-text-dark);
    border: 2px solid var(--color-secondary);
}

body.dark-theme input,
body.dark-theme select {
    background-color: var(--color-dark);
    color: var(--color-text-light);
    border-color: var(--color-secondary);
}

button {
    background: var(--color-primary);
    color: var(--color-text-light);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s, color 0.3s;
    height: 2.8rem;
    padding: 0 1rem;
}

button.light-theme {
    background: #1e90ff;
    color: white;
}

button.dark-theme {
    background: #4ca1af;
    color: black;
}

button[class*="theme-"] {
    background: var(--color-primary);
}

button:hover {
    transform: scale(1.05);
}

button:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
}

#score-display {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

#score-display.light-theme {
    background: white;
    color: black;
}

#score-display.dark-theme {
    background: #333;
    color: white;
}

.success {
    animation: bounce 0.5s;
    color: green;
}

.failure {
    animation: shake 0.5s;
    color: red;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
        width: 100%;
    }

    #score-display, #back-to-menu {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    #back-to-menu {
        right: 5rem;
    }

    .top-bar .theme-controls button {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
        min-width: 0; /* Allow buttons to shrink */
    }

    .top-bar .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .game-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--color-light);
        padding: 0.5rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        transition: background 0.3s, color 0.3s;
    }

    .game-controls.dark-theme {
        background: #333;
        color: white;
    }

    .game-content {
        padding-bottom: 4rem; /* Ensure space for fixed controls */
    }
}

/* Increase font size for mobile devices */
@media (max-width: 480px) {
    body {
        font-size: 18px; /* Adjust the font size as needed */
    }
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.top-bar .left, .top-bar .right {
    display: flex;
    gap: 0.5rem;
}

.top-bar .right {
    align-items: center;
}

.top-bar .user-info {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    text-align: center;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.top-bar .difficulty {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

body.dark-theme .top-bar {
    background: rgba(51, 51, 51, 0.9);
    color: white;
}

body.light-theme .top-bar {
    background: rgba(255, 255, 255, 0.9);
    color: black;
}

@media (max-width: 480px) {
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        grid-template-columns: 1fr;
        text-align: center;
        padding: 0.5rem;
    }

    .top-bar .left, .top-bar .right {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-bar .user-info {
        align-items: flex-start;
        text-align: center;
    }

    .top-bar button {
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
    }

    #question {
        font-size: 1.5rem;
    }

    #answer {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .top-bar > div {
        width: 100%;
    }

    .theme-controls {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.3rem;
    }

    .theme-controls button {
        min-width: auto;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .user-info {
        order: 2;
        margin: 0.5rem 0;
    }
}

@media (min-width: 768px) {
    .container {
        margin-top: 5rem;
        padding: 3rem;
    }

    .top-bar {
        padding: 0.5rem 2rem;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 800px;
    }

}

@media (min-width: 1440px) {
    .container {
        max-width: 1000px;
    }
}

/* Update theme-controls styles */
.theme-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    margin-bottom: 0.5rem;
    z-index: 2;
}

.theme-controls button {
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: var(--color-text-light);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: none;
}

.theme-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Remove these overrides to keep consistent theme colors */
.theme-controls button[class*="theme-"] {
    background: var(--color-primary);
    color: var(--color-text-light);
}

body.dark-theme .theme-controls button[class*="theme-"] {
    background: var(--color-primary);
    color: var(--color-text-light);
}

.game-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 1rem 0;
}

.game-controls button {
    flex: 1;
    max-width: 200px;
}

.game-content {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

#question {
    font-size: 2rem;
    margin: 1rem 0;
}

#answer {
    font-size: 1.5rem;
    text-align: center;
    max-width: 200px;
    margin: 0 auto;
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.8rem;
    margin: 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    max-height: 500px;
    opacity: 1;
    transition: all 0.3s ease-out;
    width: 100%;
    box-sizing: border-box;
}

.stats-panel.collapsed {
    max-height: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
}

.stat-item {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem;
    border-radius: 0.3rem;
    background: rgba(255, 255, 255, 0.1);
    transition: transform 0.2s;
    min-width: 0; /* Prevent overflow */
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .stats-panel {
        grid-template-columns: repeat(2, 1fr); /* Show 2 columns on mobile */
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .stat-item {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .stat-item .label {
        font-size: 0.8rem;
    }
}

.stat-item i {
    grid-row: 1 / span 2;
    font-size: 1.2em;
    color: var(--color-primary);
}

.stat-item .label {
    grid-column: 2;
    font-size: 0.8em;
    opacity: 0.8;
    text-align: left;
}

.stat-item .value {
    grid-column: 2;
    font-weight: bold;
    text-align: left;
}

@media (max-width: 768px) {
    .stats-panel {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stat-item {
        font-size: 0.9rem;
    }
}

.stat-item i {
    margin-right: 0.5rem;
    color: var(--color-primary);
}

.stats-toggle {
    width: auto !important;
    padding: 0.5rem 1rem !important;
    margin-bottom: 0.5rem;
    background: transparent !important;
    color: var(--color-text) !important;
    border: none;
    font-size: 0.9rem;
    align-items: center;
    gap: 0.5rem;
}

.stats-toggle:hover {
    transform: none !important;
    opacity: 0.8;
}

/* Add these new styles */
.shake-wrong {
    animation: shake-animation 0.5s ease-in-out;
    background-color: rgba(255, 0, 0, 0.1);
    border-color: #ff6b6b !important;
}

@keyframes shake-animation {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Modify existing input styles */
input[type="number"] {
    transition: background-color 0.3s, border-color 0.3s;
}

/* Add progress indicator styles */
.progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    transform-origin: left;
    transition: transform 0.3s ease-out;
}

/* Add floating score animation */
.floating-score {
    position: absolute;
    animation: float-up 1s ease-out forwards;
    color: var(--color-primary);
    font-weight: bold;
    pointer-events: none;
}

@keyframes float-up {
    0% { 
        transform: translateY(0);
        opacity: 1;
    }
    100% { 
        transform: translateY(-50px);
        opacity: 0;
    }
}

/* Add pulse animation for streaks */
.pulse-streak {
    animation: pulse 0.5s ease-out;
}

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

/* Add difficulty level indicator */
.difficulty-indicator {
    position: relative;
    padding: 0.3rem 0.8rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    background: rgba(255,255,255,0.1);
    margin-left: 0.5rem;
}

.difficulty-indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
    animation: glow 1.5s ease-in-out infinite;
}

.difficulty-easy::before { background: #2ecc71; }
.difficulty-medium::before { background: #f1c40f; }
.difficulty-hard::before { background: #e74c3c; }
.difficulty-expert::before { background: #9b59b6; }

@keyframes glow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Add hover effects for interactive elements */
.stat-item {
    transform: translateY(0);
    transition: transform 0.2s, background-color 0.3s;
}

.stat-item:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.2);
}

/* Add focus state for input */
#answer:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary), 0.2);
}

/* Add timer animation */
.timer-bar {
    height: 2px;
    background: var(--color-primary);
    width: 100%;
    transform-origin: left;
}

.timer-active {
    animation: timer 5s linear;
}

@keyframes timer {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Add game info overlay styles */
.info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex; /* keeps the overlay verticaly middle */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.info-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.info-content {
    background: var(--color-light);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 1rem;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

.info-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    width: auto;
}

/* Add threshold indicators */
.threshold-indicator {
    position: relative;
    height: 4px;
    background: rgba(255,255,255,0.1);
    margin: 0.5rem 0;
    border-radius: 2px;
    overflow: hidden;
}

.threshold-fill {
    position: absolute;
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s;
}

.threshold-marker {
    position: absolute;
    height: 8px;
    width: 2px;
    background: rgba(255,255,255,0.5);
    top: -2px;
}

.threshold-label {
    position: absolute;
    top: -20px;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: rgba(255,255,255,0.7);
}

/* Add caps visualization */
.cap-indicator {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    background: rgba(255,255,255,0.1);
}

.cap-warning {
    color: #f1c40f;
    animation: pulse 1s infinite;
}

.version-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
}

.version-display {
    background: var(--color-primary);
    color: var(--color-text-light);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: default;
    opacity: 0.9;
}

body.dark-theme .version-info #version-display {
    color: var(--color-text-light);
    background-color: var(--color-secondary);
}

@media (max-width: 480px) {
    .version-info {
        justify-content: space-between;
        align-items: center;
        gap: 0.2rem; /* Reduce gap for mobile */
    }

    .version-info #version-display {
        padding: 0.3rem 0.5rem; /* Adjust padding for mobile */
        font-size: 0.8rem; /* Adjust font size for mobile */
    }

}

.version-info #version-display {
    font-size: 0.9rem;
    color: var(--color-text-light);
    background-color: var(--color-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: color 0.3s, background-color 0.3s;
}

body.dark-theme .version-info #version-display {
    color: var(--color-text-light);
    background-color: var(--color-secondary);
}

.version-overlay .info-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 1rem;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    background: var(--color-light);
    color: var(--color-text-dark);
}

/* Add these new styles */
body.dark-theme .version-overlay .info-content,
body.dark-theme .info-overlay .info-content {
    background: #333;
    color: var(--color-text-light);
}

body.light-theme .version-overlay .info-content,
body.light-theme .info-overlay .info-content {
    background: var(--color-light);
    color: var(--color-text-dark);
}

/* Add these new styles */
.button-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Add these new styles */
.name-row {
    display: flex;
    gap: 0.5rem;
}

.name-row input {
    flex: 1;
}

.icon-button {
    flex: 0 0 20%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.8rem;
}

.selected-info {
    font-size: 0.9rem;
    padding: 0.3rem 0;
    color: var(--color-text);
    background: rgba(255,255,255,0.1);
    border-radius: 0.5rem;
    padding: 0.3rem 0.8rem;
    margin-top: 0.3rem;
}

body.dark-theme .selected-info {
    background: rgba(0,0,0,0.2);
}

/* Update media query for mobile view */
@media (max-width: 480px) {
    /* ...existing code... */
    .selected-info {
        font-size: 0.8rem;
        padding: 0.2rem 0.5rem;
    }
}