@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Space+Mono:wght@400;700&display=swap');

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

body {
    font-family: 'Space Mono', monospace;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.game-container {
    width: 90%;
    max-width: 900px;
    background: rgba(20, 20, 35, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5),
                inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    animation: fadeIn 0.5s ease-out;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        align-items: flex-start;
        padding: 10px 0;
    }
    
    .game-container {
        width: 95%;
        padding: 15px;
        margin: 10px auto;
        border-radius: 15px;
        min-height: auto;
    }
    
    .title {
        font-size: 1.8em;
        margin-bottom: 15px;
    }
    
    .title.compact {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .audio-controls {
        top: 10px;
        right: 10px;
        gap: 5px;
    }
    
    .audio-btn {
        width: 35px;
        height: 35px;
        font-size: 1em;
    }
    
    .stats.compact {
        padding: 6px 10px;
        gap: 5px;
    }
    
    .stat-icon.compact {
        font-size: 1em;
        margin-right: 3px;
    }
    
    .stat-value.compact {
        font-size: 0.8em;
    }
    
    .timer-bar {
        height: 35px;
        margin-bottom: 8px;
    }
    
    .timer-text {
        font-size: 1em;
    }
    
    .code-container {
        padding: 15px;
        font-size: 12px;
        line-height: 20px;
    }
    
    .code-line {
        min-height: 25px;
        padding: 3px 0;
    }
    
    .line-number {
        width: 30px;
        padding-right: 10px;
    }
    
    .button {
        padding: 12px 25px;
        font-size: 1em;
        margin: 8px;
    }
    
    .button-group {
        gap: 10px;
    }
    
    .rules {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .rules h2 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    .rules li {
        font-size: 0.9em;
        margin: 8px 0;
    }
    
    .input-group input {
        width: 250px;
        padding: 8px 15px;
        font-size: 1em;
    }
    
    .final-score {
        font-size: 2.2em;
        margin: 15px 0;
    }
    
    .message {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    
    .leaderboard {
        padding: 20px;
        height: 350px;
    }
    
    .leaderboard h2 {
        font-size: 1.6em;
        margin-bottom: 15px;
    }
    
    .leaderboard-entry {
        padding: 6px 10px;
        min-height: 45px;
        gap: 8px;
    }
    
    .rank {
        font-size: 1em;
        min-width: 30px;
        margin-right: 8px;
    }
    
    .player-name {
        font-size: 0.9em;
    }
    
    .player-date {
        font-size: 0.7em;
    }
    
    .score {
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .game-container {
        width: 98%;
        padding: 12px;
        margin: 5px auto;
    }
    
    .title {
        font-size: 1.5em;
    }
    
    .title.compact {
        font-size: 0.9em;
        margin-bottom: 6px;
    }
    
    .stats.compact {
        padding: 5px 8px;
        gap: 3px;
    }
    
    .stat-icon.compact {
        font-size: 0.9em;
        margin-right: 2px;
    }
    
    .stat-value.compact {
        font-size: 0.75em;
    }
    
    .code-container {
        padding: 12px;
        font-size: 11px;
        line-height: 18px;
    }
    
    .line-number {
        width: 25px;
        padding-right: 8px;
    }
    
    .button {
        padding: 10px 20px;
        font-size: 0.9em;
        margin: 5px;
    }
    
    .input-group input {
        width: 200px;
        padding: 6px 12px;
        font-size: 0.9em;
    }
    
    .final-score {
        font-size: 1.8em;
    }
    
    .message {
        font-size: 1em;
    }
}

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

@keyframes fire {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.stat-icon.fire-animation {
    animation: fire 0.5s ease-in-out infinite, flicker 0.2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px #ff6b6b);
}

.points-popup {
    position: fixed;
    font-size: 2em;
    font-weight: 700;
    color: #4caf50;
    pointer-events: none;
    z-index: 1000;
    animation: pointsFloat 2s ease-out forwards;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

@keyframes pointsFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.audio-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.audio-btn {
    background: rgba(30, 30, 46, 0.8);
    border: 1px solid rgba(78, 205, 196, 0.3);
    color: #4ecdc4;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.audio-btn:hover {
    background: rgba(78, 205, 196, 0.2);
    transform: scale(1.1);
}

.audio-btn.muted {
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3);
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5em;
    font-weight: 900;
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #ffd93d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(78, 205, 196, 0.5);
    transition: all 0.3s ease;
}

.title.compact {
    font-size: 1.2em;
    margin-bottom: 10px;
    font-weight: 700;
}

.start-screen, .game-screen, .end-screen, .leaderboard-screen {
    display: none;
}

.start-screen.active, .game-screen.active, .end-screen.active, .leaderboard-screen.active {
    display: block;
}

.rules {
    background: rgba(30, 30, 46, 0.8);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.rules h2 {
    color: #4ecdc4;
    margin-bottom: 12px;
    font-size: 1.5em;
}

.rules ul {
    list-style: none;
    padding-left: 0;
}

.rules li {
    margin: 1px 0;
    font-size: 1.0em;
    display: flex;
    align-items: center;
}

.rules li span {
    margin-right: 10px;
    font-size: 1.3em;
}

.button {
    background: linear-gradient(45deg, #4caf50, #45a049);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
    display: inline-block;
    margin: 10px;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.5);
}

.button:active {
    transform: translateY(0);
}

.button.secondary {
    background: linear-gradient(45deg, #4ecdc4, #44a3aa);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.3);
}

.button.secondary:hover {
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.5);
}

.button:disabled {
    background: linear-gradient(45deg, #666, #555);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats.compact {
    background: rgba(30, 30, 46, 0.8);
    border-radius: 10px;
    padding: 8px 15px;
    margin-bottom: 15px;
    border: 1px solid rgba(78, 205, 196, 0.3);
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
}

.stat {
    background: rgba(30, 30, 46, 0.8);
    padding: 10px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    margin: 5px;
    border: 1px solid rgba(78, 205, 196, 0.3);
    transition: all 0.3s ease;
}

.stat.compact {
    background: transparent;
    padding: 0;
    margin: 0;
    border: none;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.2);
}

.stat.compact:hover {
    transform: none;
    box-shadow: none;
}

.stat-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

.stat-icon.compact {
    font-size: 1.1em;
    margin-right: 4px;
}

.stat-value {
    font-weight: 700;
    font-size: 1.2em;
    color: #ffd93d;
}

.stat-value.compact {
    font-size: 0.9em;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(30, 30, 46, 0.8);
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #4caf50);
    width: 0%;
    transition: width 0.5s ease;
}

.code-container {
    background: #1e1e1e;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    font-family: 'Courier New', Consolas, 'Lucida Console', monospace;
    font-size: 14px;
    line-height: 24px;
    overflow-x: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(78, 205, 196, 0.2);
    transition: all 0.4s ease-in-out;
}

.code-container.transitioning-out {
    opacity: 0;
    transform: translateX(-30px) scale(0.95);
}

.code-container.transitioning-in {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
    animation: slideInFromRight 0.5s ease-out forwards;
}

@keyframes slideInFromRight {
    0% {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.code-line {
    display: flex;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    padding: 5px 0;
    min-height: 30px;
    align-items: center;
}

.code-line:hover:not(.disabled) {
    background: rgba(78, 205, 196, 0.1);
}

.code-line.selected {
    background: rgba(255, 215, 61, 0.2);
    border-left: 3px solid #ffd93d;
}

.code-line.disabled {
    cursor: not-allowed;
    opacity: 0.5;
    background: rgba(100, 100, 100, 0.2);
}

.code-line.disabled:hover {
    background: rgba(100, 100, 100, 0.2);
}

.line-number {
    width: 35px;
    text-align: right;
    padding-right: 15px;
    color: #676e95;
    user-select: none;
    flex-shrink: 0;
}

.code-content {
    flex: 1;
    white-space: pre;
    text-align: left;
    color: #e0e0e0;
}

.timer {
    font-size: 1.5em;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.timer-display {
    position: relative;
    z-index: 2;
    font-weight: 700;
    color: #fff;
}

.timer-bar {
    width: 100%;
    height: 40px;
    background: rgba(30, 30, 46, 0.8);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(78, 205, 196, 0.3);
    margin-bottom: 10px;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #4caf50);
    transition: width 1s linear;
    position: absolute;
    left: 0;
    top: 0;
}

.timer-fill.warning {
    background: linear-gradient(90deg, #ff6b6b, #ff4757);
    animation: pulse 1s infinite;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 1.2em;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

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

.feedback {
    text-align: center;
    font-size: 1.2em;
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    display: none;
}

.feedback.correct {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid #4caf50;
}

.feedback.incorrect {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}

.feedback.show {
    display: block;
    animation: slideIn 0.3s ease;
}

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

.button-group {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.leaderboard {
    background: rgba(30, 30, 46, 0.8);
    border-radius: 15px;
    padding: 25px;
    border: 1px solid rgba(255, 215, 61, 0.3);
    height: 400px;
    display: flex;
    flex-direction: column;
}

.leaderboard h2 {
    color: #ffd93d;
    text-align: center;
    margin-bottom: 20px;
    font-size: 2em;
    flex-shrink: 0;
}

#leaderboardList {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

#leaderboardList::-webkit-scrollbar {
    width: 8px;
}

#leaderboardList::-webkit-scrollbar-track {
    background: rgba(20, 20, 35, 0.6);
    border-radius: 4px;
}

#leaderboardList::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 61, 0.6);
    border-radius: 4px;
}

#leaderboardList::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 61, 0.8);
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 5px 0;
    background: rgba(20, 20, 35, 0.6);
    border-radius: 8px;
    transition: all 0.3s ease;
    gap: 10px;
    min-height: 50px;
}

.leaderboard-entry:hover {
    transform: translateX(5px);
    background: rgba(30, 30, 46, 0.8);
}

.leaderboard-entry.gold {
    border: 2px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.silver {
    border: 2px solid #c0c0c0;
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.3);
}

.leaderboard-entry.bronze {
    border: 2px solid #cd7f32;
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.3);
}

.leaderboard-entry.highlighted {
    border: 2px solid #4ecdc4;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
    background: rgba(78, 205, 196, 0.1);
    animation: highlightPulse 2s ease-in-out 3;
}

@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(78, 205, 196, 0.8);
    }
}

.rank {
    font-size: 1.2em;
    font-weight: 700;
    margin-right: 10px;
    min-width: 35px;
}

.player-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.player-name {
    font-size: 1em;
    margin-bottom: 2px;
}

.player-date {
    font-size: 0.75em;
    color: #676e95;
}

.score {
    font-size: 1.1em;
    color: #ffd93d;
    font-weight: 700;
}

.input-group {
    margin: 20px 0;
    text-align: center;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.2em;
    color: #4ecdc4;
}

.input-group input {
    background: rgba(30, 30, 46, 0.8);
    border: 2px solid rgba(78, 205, 196, 0.5);
    color: white;
    padding: 10px 20px;
    font-size: 1.1em;
    border-radius: 10px;
    width: 300px;
    max-width: 100%;
    text-align: center;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #4ecdc4;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
}

.final-score {
    text-align: center;
    font-size: 3em;
    color: #ffd93d;
    margin: 20px 0;
    font-weight: 700;
    text-shadow: 0 0 30px rgba(255, 215, 61, 0.5);
}

.message {
    text-align: center;
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #4ecdc4;
}
