* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: transparent;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    position: relative;
}

/* Background matching website */
#bg {
    -moz-transform: scale(1.0);
    -webkit-transform: scale(1.0);
    -ms-transform: scale(1.0);
    transform: scale(1.0);
    -webkit-backface-visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1;
}

#bg:before, #bg:after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#bg:before {
    -moz-transition: background-color 2.5s ease-in-out;
    -webkit-transition: background-color 2.5s ease-in-out;
    -ms-transition: background-color 2.5s ease-in-out;
    transition: background-color 2.5s ease-in-out;
    -moz-transition-delay: 0.75s;
    -webkit-transition-delay: 0.75s;
    -ms-transition-delay: 0.75s;
    transition-delay: 0.75s;
    background-image: linear-gradient(to top, rgba(19, 21, 25, 0.5), rgba(19, 21, 25, 0.5)), url("../images/overlay.png");
    background-size: auto, 256px 256px;
    background-position: center, center;
    background-repeat: no-repeat, repeat;
    z-index: 2;
}

#bg:after {
    -moz-transform: scale(1.125);
    -webkit-transform: scale(1.125);
    -ms-transform: scale(1.125);
    transform: scale(1.125);
    -moz-transition: -moz-transform 0.325s ease-in-out, -moz-filter 0.325s ease-in-out;
    -webkit-transition: -webkit-transform 0.325s ease-in-out, -webkit-filter 0.325s ease-in-out;
    -ms-transition: -ms-transform 0.325s ease-in-out, -ms-filter 0.325s ease-in-out;
    transition: transform 0.325s ease-in-out, filter 0.325s ease-in-out;
    background-image: url("../images/bg.jpg");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    z-index: 1;
}

#app {
    width: 100%;
    max-width: 800px;
    position: relative;
    z-index: 10;
}

.screen {
    width: 100%;
}

.hidden {
    display: none !important;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

/* ASCII Box Styling */
.ascii-box {
    background: rgba(19, 21, 25, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Close button - on start screen and mode selection screen */
#start-screen .close-button,
#mode-selection-screen .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    font-size: 2em;
    color: #ffffff;
    text-decoration: none;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(19, 21, 25, 0.6);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

#start-screen .close-button:hover,
#mode-selection-screen .close-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ff4444;
    transform: scale(1.1);
}

#start-screen .close-button:active,
#mode-selection-screen .close-button:active {
    transform: scale(0.95);
}

.ascii-box pre {
    margin: 0;
    color: #fff;
    font-size: 1.2em;
}

.title {
    font-size: 1.5em;
    margin-bottom: 20px;
}

.content {
    margin-top: 20px;
    line-height: 1.8;
}

.instructions {
    text-align: left;
    margin: 20px 0;
    padding: 15px;
    background: rgba(19, 21, 25, 0.6);
    border-left: 3px solid #4a9eff;
    backdrop-filter: blur(2px);
}

.high-score {
    margin: 20px 0;
    font-size: 1.2em;
    color: #ffd700;
}

.start-prompt, .restart-prompt {
    margin-top: 30px;
    font-size: 1.1em;
    color: #4a9eff;
}

/* Mode Selection */
.mode-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.mode-option {
    padding: 15px;
    background: rgba(19, 21, 25, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    backdrop-filter: blur(2px);
}

.mode-option:hover {
    border-color: #4a9eff;
    background: rgba(19, 21, 25, 0.85);
    transform: translateX(3px);
}

.mode-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #4a9eff;
    margin-bottom: 8px;
}

.mode-description {
    color: #ccc;
    margin-bottom: 8px;
    line-height: 1.4;
    font-size: 0.95em;
}

.mode-high-score {
    color: #ffd700;
    margin-bottom: 6px;
    font-size: 1em;
}

.mode-hint {
    color: #888;
    font-style: italic;
    font-size: 0.85em;
}

/* Mobile: single column for small screens */
@media (max-width: 600px) {
    .mode-selection {
        grid-template-columns: 1fr;
    }
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: rgba(19, 21, 25, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat .label {
    font-size: 0.8em;
    color: #888;
}

.stat span:last-child {
    font-size: 1.3em;
    font-weight: bold;
    color: #4a9eff;
}

#lives {
    color: #ff4444;
    font-size: 1.5em;
    letter-spacing: 5px;
}

#streak {
    color: #ffd700;
}

/* Timer */
.timer-container {
    position: relative;
    width: 100%;
    height: 40px;
    background: rgba(19, 21, 25, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
    backdrop-filter: blur(2px);
}

.timer-bar {
    height: 100%;
    background: #4a9eff;
    width: 100%;
    transition: width 0.1s linear, background 0.3s;
}

.timer-bar.warning {
    background: #ff4444;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Drill Area */
.drill-area {
    min-height: 300px;
    padding: 20px;
    background: rgba(19, 21, 25, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.drill-title {
    font-size: 1.2em;
    margin-bottom: 20px;
    text-align: center;
    color: #4a9eff;
}

/* Ordering Drill */
.ordering-drill {
    text-align: center;
}

.fractions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
}

.fraction-item {
    padding: 15px;
    background: rgba(19, 21, 25, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(2px);
}

.fraction-item:hover {
    border-color: #4a9eff;
    background: #2a2a2a;
}

.fraction-item.selected {
    border-color: #4a9eff;
    background: rgba(26, 58, 90, 0.7);
}

.fraction-item.position-1 { border-left: 5px solid #4a9eff; }
.fraction-item.position-2 { border-left: 5px solid #5abf4a; }
.fraction-item.position-3 { border-left: 5px solid #ffd700; }
.fraction-item.position-4 { border-left: 5px solid #ff8844; }
.fraction-item.position-5 { border-left: 5px solid #ff4444; }

.fraction {
    font-size: 1.5em;
    font-weight: bold;
}

.position {
    color: #4a9eff;
    font-weight: bold;
}

.hint, .submit-hint {
    margin-top: 20px;
    color: #888;
    font-style: italic;
}

/* Bigger/Smaller Drill */
.bigger-smaller-drill {
    text-align: center;
}

.comparison-area {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 30px;
    margin: 40px 0;
    flex-wrap: wrap;
}

.fraction-box {
    flex: 1;
    min-width: 200px;
    padding: 30px;
    background: rgba(19, 21, 25, 0.7);
    border: 3px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(2px);
}

.fraction-box:hover {
    border-color: #4a9eff;
    background: rgba(19, 21, 25, 0.85);
    transform: scale(1.05);
}

.fraction-box:active {
    transform: scale(0.95);
}

.fraction-large {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 10px;
}

.vs {
    font-size: 1.5em;
    color: #888;
    font-weight: bold;
}

/* Feedback */
.feedback {
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    min-height: 40px;
    padding: 10px;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.feedback.correct {
    color: #4a9eff;
    animation: flash 0.5s;
}

.feedback.wrong {
    color: #ff4444;
    animation: flash 0.5s;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Level Up Animation */
.level-up {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    font-weight: bold;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border: 3px solid #ffd700;
    z-index: 2000;
    animation: levelUpAnim 2s;
}

/* Raise level up prompt higher for Bigger/Smaller game only */
.level-up.level-up-high {
    top: 35%;
    animation: levelUpAnimHigh 2s;
}

@keyframes levelUpAnim {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

@keyframes levelUpAnimHigh {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

.help-hint {
    text-align: center;
    color: #666;
    font-size: 0.9em;
    margin-top: 20px;
}

/* Game Over Screen */
#new-high-score {
    color: #ffd700;
    font-size: 1.3em;
    margin: 15px 0;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .game-header {
        font-size: 0.9em;
    }
    
    .fraction-large {
        font-size: 2em;
    }
    
    .comparison-area {
        flex-direction: column;
        gap: 20px;
    }
    
    .fraction-box {
        width: 100%;
    }
    
    .vs {
        transform: rotate(90deg);
    }
}

/* New Drill Styles */
.fraction-display {
    font-size: 2em;
    font-weight: bold;
    margin: 20px 0;
    color: #4a9eff;
}

.input-area {
    margin: 30px 0;
}

.decimal-input, .fraction-input, .number-input {
    font-size: 1.5em;
    padding: 15px;
    background: rgba(19, 21, 25, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-family: 'Courier New', monospace;
    text-align: center;
    width: 100%;
    max-width: 300px;
    backdrop-filter: blur(2px);
}

.fraction-pair, .equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.and, .operator, .equals {
    font-size: 1.5em;
    color: #888;
    font-weight: bold;
}

.mixed-display {
    font-size: 2em;
    font-weight: bold;
    margin: 20px 0;
    color: #4a9eff;
}

.inches-display {
    font-size: 2em;
    font-weight: bold;
    margin: 20px 0;
    color: #4a9eff;
}

.feet-input, .inches-input {
    font-size: 1.5em;
    padding: 15px;
    background: rgba(19, 21, 25, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-family: 'Courier New', monospace;
    text-align: center;
    width: 100px;
    margin: 0 10px;
    backdrop-filter: blur(2px);
}

.feet-input.active, .inches-input.active {
    border-color: #4a9eff;
    background: rgba(26, 58, 90, 0.7);
}

.unit {
    font-size: 1.2em;
    margin: 0 15px;
    color: #888;
}

.hint-text {
    color: #888;
    margin: 15px 0;
    font-style: italic;
}

.mark-description {
    font-size: 1.8em;
    font-weight: bold;
    margin: 30px 0;
    color: #4a9eff;
    padding: 20px;
    background: rgba(19, 21, 25, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(2px);
}

/* Focus indicators for accessibility */
.fraction-item:focus,
.fraction-box:focus {
    outline: 3px solid #4a9eff;
    outline-offset: 2px;
}
