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

body {
    background: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 1024px;
    height: 768px;
    background: #000;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.3);
}

#gameCanvas {
    display: block;
    border-radius: 8px;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border-radius: 8px;
    z-index: 10;
}

.screen.hidden {
    display: none;
}

.screen h1 {
    font-size: 4rem;
    color: #f1c40f;
    text-shadow: 3px 3px 0 #c0392b, 6px 6px 0 rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: 4px;
}

.screen h2 {
    font-size: 2rem;
    color: #e74c3c;
    margin-bottom: 30px;
}

.screen p {
    font-size: 1.2rem;
    color: #ecf0f1;
    margin-bottom: 15px;
}

.controls-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px 40px;
    border-radius: 10px;
    margin: 20px 0;
}

.controls-info p {
    margin: 8px 0;
    font-size: 1rem;
}

.game-btn {
    background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    border: none;
    padding: 15px 50px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 4px 0 #962d22, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #962d22, 0 8px 15px rgba(0, 0, 0, 0.4);
}

.game-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #962d22, 0 3px 5px rgba(0, 0, 0, 0.3);
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

#health-bar {
    width: 200px;
    height: 25px;
    background: #2c3e50;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid #f1c40f;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#health-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
    transition: width 0.3s ease;
}

#score-display, #level-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: #f1c40f;
    text-shadow: 2px 2px 0 #000;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 8px;
}

/* Secondary button style */
.game-btn.secondary {
    background: linear-gradient(180deg, #3498db 0%, #2980b9 100%);
    box-shadow: 0 4px 0 #1f6391, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.game-btn.secondary:hover {
    box-shadow: 0 6px 0 #1f6391, 0 8px 15px rgba(0, 0, 0, 0.4);
}

.game-btn.secondary:active {
    box-shadow: 0 2px 0 #1f6391, 0 3px 5px rgba(0, 0, 0, 0.3);
}

.game-btn.small {
    padding: 10px 25px;
    font-size: 1rem;
}

/* Leaderboard styles */
#leaderboard-screen {
    overflow-y: auto;
}

#leaderboard-list {
    width: 90%;
    max-width: 500px;
    max-height: 350px;
    overflow-y: auto;
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 10px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.leaderboard-entry:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.15);
}

.leaderboard-entry.top-1 {
    background: linear-gradient(90deg, rgba(241, 196, 15, 0.3) 0%, rgba(241, 196, 15, 0.1) 100%);
    border: 1px solid #f1c40f;
}

.leaderboard-entry.top-2 {
    background: linear-gradient(90deg, rgba(189, 195, 199, 0.3) 0%, rgba(189, 195, 199, 0.1) 100%);
    border: 1px solid #bdc3c7;
}

.leaderboard-entry.top-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.3) 0%, rgba(205, 127, 50, 0.1) 100%);
    border: 1px solid #cd7f32;
}

.leaderboard-entry .rank {
    width: 40px;
    text-align: center;
}

.leaderboard-entry .medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.9rem;
    background: #7f8c8d;
    color: #fff;
}

.leaderboard-entry .medal.gold {
    background: linear-gradient(135deg, #f1c40f 0%, #d4ac0d 100%);
    box-shadow: 0 2px 8px rgba(241, 196, 15, 0.5);
}

.leaderboard-entry .medal.silver {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
    box-shadow: 0 2px 8px rgba(189, 195, 199, 0.5);
}

.leaderboard-entry .medal.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #a0522d 100%);
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.5);
}

.leaderboard-entry .name {
    flex: 1;
    font-weight: bold;
    color: #ecf0f1;
    margin-left: 10px;
}

.leaderboard-entry .level {
    color: #95a5a6;
    font-size: 0.9rem;
    margin-right: 15px;
}

.leaderboard-entry .score {
    font-weight: bold;
    color: #f1c40f;
    font-size: 1.1rem;
    min-width: 80px;
    text-align: right;
}

.leaderboard-empty {
    text-align: center;
    padding: 40px 20px;
    color: #95a5a6;
    font-size: 1.2rem;
}

#score-submit-section {
    background: rgba(46, 204, 113, 0.2);
    padding: 20px 30px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 1px solid #2ecc71;
}

#score-submit-section p {
    margin-bottom: 15px;
    font-size: 1.3rem;
}

#score-submit-section #pending-score {
    color: #f1c40f;
    font-weight: bold;
}

.name-input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#player-name-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    outline: none;
}

#player-name-input:focus {
    box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.5);
}

#player-name-input::placeholder {
    color: #95a5a6;
}

/* Time Runner button */
.game-btn.timerunner {
    background: linear-gradient(180deg, #9b59b6 0%, #8e44ad 100%);
    box-shadow: 0 4px 0 #6c3483, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.game-btn.timerunner:hover {
    box-shadow: 0 6px 0 #6c3483, 0 8px 15px rgba(0, 0, 0, 0.4);
}

.game-btn.timerunner:active {
    box-shadow: 0 2px 0 #6c3483, 0 3px 5px rgba(0, 0, 0, 0.3);
}

/* Timer display */
#timer-display {
    font-size: 1.8rem;
    font-weight: bold;
    color: #9b59b6;
    text-shadow: 2px 2px 0 #000;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 20px;
    border-radius: 8px;
    border: 2px solid #9b59b6;
    font-family: 'Courier New', monospace;
}

#timer-display.hidden {
    display: none;
}

/* Time display on screens */
#final-time, #level-time, #total-time {
    font-size: 1.5rem;
    color: #9b59b6;
    font-weight: bold;
}

#final-time.hidden, #level-time.hidden, #total-time.hidden {
    display: none;
}

/* Leaderboard tabs */
#leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #95a5a6;
    border: 2px solid transparent;
    padding: 10px 25px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ecf0f1;
}

.tab-btn.active {
    background: linear-gradient(180deg, #f1c40f 0%, #d4ac0d 100%);
    color: #2c3e50;
    border-color: #f1c40f;
}

/* Time score styling in leaderboard */
.leaderboard-entry .score.time-score {
    color: #9b59b6;
    font-family: 'Courier New', monospace;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 15;
    pointer-events: none;
}

#mobile-controls.hidden {
    display: none;
}

#mobile-left-controls,
#mobile-right-controls {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.mobile-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-btn:active,
.mobile-btn.pressed {
    background: rgba(241, 196, 15, 0.7);
    border-color: #f1c40f;
}

#btn-jump {
    background: rgba(46, 204, 113, 0.5);
    border-color: rgba(46, 204, 113, 0.7);
    font-size: 1rem;
}

#btn-jump:active,
#btn-jump.pressed {
    background: rgba(46, 204, 113, 0.8);
}

#btn-attack {
    background: rgba(231, 76, 60, 0.5);
    border-color: rgba(231, 76, 60, 0.7);
    font-size: 1rem;
}

#btn-attack:active,
#btn-attack.pressed {
    background: rgba(231, 76, 60, 0.8);
}

/* Rotate Screen Prompt */
#rotate-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.rotate-content {
    text-align: center;
    color: #fff;
    padding: 20px;
}

.rotate-icon {
    font-size: 80px;
    margin-bottom: 30px;
    display: inline-block;
    animation: rotate-phone 2s ease-in-out infinite;
}

.rotate-phone-svg {
    width: 100px;
    height: 100px;
    fill: #f1c40f;
    animation: rotate-phone 2s ease-in-out infinite;
}

@keyframes rotate-phone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rotate-content h2 {
    font-size: 1.8rem;
    color: #f1c40f;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.rotate-content p {
    font-size: 1.2rem;
    color: #ecf0f1;
    max-width: 280px;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 1100px) {
    #game-container {
        width: 90vw;
        height: calc(90vw * 0.75);
    }

    .screen h1 {
        font-size: 2.5rem;
    }

    .screen h2 {
        font-size: 1.5rem;
    }
}

/* Mobile portrait mode - show rotation prompt */
@media (max-width: 900px) and (orientation: portrait) {
    #rotate-prompt {
        display: flex;
    }

    #game-container {
        display: none;
    }
}

/* Mobile landscape mode */
@media (max-width: 900px) and (orientation: landscape) {
    body {
        overflow: hidden;
    }

    #game-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    #gameCanvas {
        border-radius: 0;
        width: 100%;
        height: 100%;
    }

    .screen h1 {
        font-size: 2rem;
    }

    .screen h2 {
        font-size: 1.2rem;
    }

    .screen p {
        font-size: 1rem;
    }

    .controls-info {
        padding: 10px 20px;
        margin: 10px 0;
        display: none;
    }

    .game-btn {
        padding: 10px 30px;
        font-size: 1rem;
        margin: 5px;
    }

    #hud {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    #health-bar {
        width: 120px;
        height: 20px;
    }

    #score-display, #level-display {
        font-size: 1rem;
        padding: 5px 10px;
    }

    #timer-display {
        font-size: 1.2rem;
        padding: 5px 10px;
    }

    #leaderboard-list {
        max-height: 200px;
    }
}

/* Fullscreen mode */
:fullscreen {
    background: #000;
}

:fullscreen #game-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
}

:-webkit-full-screen {
    background: #000;
}

:-webkit-full-screen #game-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
}
