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

body {
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    background:
        linear-gradient(135deg, rgba(15, 40, 90, 0.88) 0%, rgba(25, 60, 120, 0.88) 50%, rgba(35, 80, 150, 0.88) 100%),
        url('school-bg.jpg') center/cover fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 30, 70, 0.3);
    pointer-events: none;
    z-index: 0;
}

.container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 20px;
    max-width: 580px;
    width: 100%;
    max-height: 96vh;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

h1, h2 {
    text-align: center;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hidden {
    display: none !important;
}

/* Welcome Screen */
.welcome-screen {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 5px 0;
    flex: 1;
    justify-content: center;
}

.logo-container {
    animation: logoFloat 3s ease-in-out infinite;
    margin-bottom: 5px;
}

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

.game-logo {
    max-width: 200px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 20px rgba(37, 99, 235, 0.3));
}

.welcome-content {
    margin: 5px 0;
}

.welcome-subtitle {
    font-size: 1.6em;
    margin-bottom: 8px;
    font-weight: 800;
}

.tagline {
    font-size: 0.95em;
    color: #555;
}

.welcome-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-play {
    width: 100%;
    padding: 14px 25px;
    font-size: 1.2em;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    transition: all 0.3s;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.6);
}

.btn-icon { font-size: 1.1em; }
.btn-text { font-weight: 700; }

/* About Screen */
.about-screen {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 0;
}

.about-logo {
    max-width: 220px;
    margin: 10px auto;
    opacity: 0.9;
}

.about-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
    padding: 15px 0;
}

.about-item {
    padding: 15px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 12px;
    border: 2px solid #bfdbfe;
}

.about-label {
    font-size: 0.85em;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-weight: 600;
}

.about-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #1e40af;
}

.about-footer {
    color: #666;
    font-style: italic;
    font-size: 0.9em;
    margin-top: 10px;
}

/* Instructions Screen */
.instructions-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 0;
}

.instructions-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    padding: 15px 0;
}

.inst-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 10px;
    font-size: 0.95em;
    color: #1e40af;
    font-weight: 500;
    border: 2px solid #bfdbfe;
}

.inst-num {
    min-width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

/* Setup Screen */
.setup-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
    padding: 10px 0;
}

.setup-screen h2 { margin-bottom: 15px; }

.options-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 15px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-group label {
    font-weight: 600;
    color: #1e40af;
    font-size: 0.9em;
}

.option-group select {
    padding: 10px;
    border: 2px solid #bfdbfe;
    border-radius: 8px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
    color: #1e40af;
}

.option-group select:focus {
    outline: none;
    border-color: #2563eb;
}

/* Button Styles */
.btn-start, .btn-secondary, .btn-primary {
    width: 100%;
    padding: 12px 25px;
    font-size: 1.05em;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-start {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e40af;
    border: 2px solid #bfdbfe;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
}

/* F1 Countdown */
.countdown {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.lights {
    display: flex;
    gap: 12px;
}

.light {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #333;
    border: 3px solid #666;
    transition: all 0.3s;
}

.light.red {
    background: #ff0000;
    box-shadow: 0 0 25px #ff0000;
}

.light.orange {
    background: #ff8c00;
    box-shadow: 0 0 25px #ff8c00;
}

.light.green {
    background: #00ff00;
    box-shadow: 0 0 25px #00ff00;
}

/* Game Screen */
.game-screen {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.number-counter {
    font-size: 1em;
    color: #666;
}

.operation-display {
    font-size: 2em;
    font-weight: bold;
    color: #2563eb;
}

.number-display {
    font-size: 5em;
    font-weight: bold;
    color: #1e40af;
    margin: 30px 0;
    animation: numberPop 0.3s ease;
}

@keyframes numberPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transition: width 0.3s;
}

/* Answer Screen */
.answer-screen {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 15px;
}

.answer-screen input {
    padding: 14px;
    font-size: 1.4em;
    border: 2px solid #bfdbfe;
    border-radius: 10px;
    text-align: center;
    color: #1e40af;
}

.answer-screen input:focus {
    outline: none;
    border-color: #2563eb;
}

/* Result Screen */
.result-screen {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    overflow-y: auto;
}

.result-message {
    font-size: 1.8em;
    font-weight: bold;
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 10px;
}

.result-message.correct {
    background: #d4edda;
    color: #155724;
}

.result-message.wrong {
    background: #f8d7da;
    color: #721c24;
}

.score-display {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #bfdbfe;
}

.score-display h3 {
    color: #1e40af;
    font-size: 1.6em;
    margin-bottom: 8px;
}

.score-breakdown {
    color: #1e40af;
    font-size: 0.85em;
    line-height: 1.5;
}

.name-entry {
    background: #fff3cd;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #ffc107;
}

.name-entry h3 {
    color: #856404;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.name-entry input {
    width: 100%;
    padding: 10px;
    font-size: 1em;
    border: 2px solid #ffc107;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 8px;
}

/* Leaderboard */
.leaderboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px 0;
}

.leaderboard h2 { margin-bottom: 15px; }

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 10px;
    border: 2px solid #bfdbfe;
}

.leaderboard-item.top3 {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fbbf24;
}

.leaderboard-rank {
    font-size: 1.3em;
    font-weight: bold;
    color: #1e40af;
    min-width: 35px;
}

.leaderboard-name {
    flex: 1;
    font-size: 1em;
    font-weight: 600;
    color: #1e40af;
}

.leaderboard-score {
    font-size: 1.1em;
    font-weight: bold;
    color: #2563eb;
}

.leaderboard-empty {
    text-align: center;
    padding: 30px;
    color: #999;
}

/* Responsive */
@media (max-height: 700px) {
    .container { padding: 15px; }
    .game-logo { max-width: 160px; }
    .welcome-subtitle { font-size: 1.4em; }
    .btn-play { padding: 12px 20px; font-size: 1.1em; }
}
