body {
    background-color: #222;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: white;
    font-family: 'Courier New', Courier, monospace;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    width: 100%;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 640px;
    height: 480px;
    border: 4px solid #555;
    background-color: #000;
    overflow: hidden;
    touch-action: none; /* Prevent touch scrolling on game container */
}

canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none; /* Prevent touch scrolling on canvas only */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    box-sizing: border-box;
}

#ui-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#score-display,
#timer-display,
#goals-display {
    font-size: 18px;
    font-weight: bold;
    text-shadow: 2px 2px #000;
}

#timer-display {
    font-size: 24px;
    color: #FFD700;
}

#goals-display {
    color: #00FF00;
}

#shoot-prompt {
    font-size: 30px;
    color: yellow;
    text-shadow: 2px 2px #FF0000;
    display: none;
    text-align: center;
}

#celebration {
    font-size: 48px;
    color: #00FF00;
    text-shadow: 3px 3px #006600, -1px -1px #FFFFFF;
    display: none;
    text-align: center;
    animation: pulse 0.3s ease-in-out infinite;
}

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

#fail-message {
    font-size: 24px;
    color: #FF6B6B;
    text-shadow: 2px 2px #000;
    display: none;
    text-align: center;
}

#countdown-display {
    font-size: 72px;
    color: #FFD700;
    text-shadow: 4px 4px #000;
    font-weight: bold;
    display: none;
    text-align: center;
    animation: countdownPulse 1s ease-in-out;
}

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

#start-screen,
#difficulty-screen,
#pause-menu {
    position: relative;
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 20px 30px;
    border: 2px solid white;
    pointer-events: auto;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    margin: auto;
    box-sizing: border-box;
}

#start-screen,
#difficulty-screen {
    width: 420px;
}

#difficulty-screen {
    display: none;
}

#pause-menu {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

#start-screen h1,
#difficulty-screen h1,
#pause-menu h1 {
    margin-top: 0;
    color: #FFD700;
}

#game-mode-select,
#difficulty-select,
#control-mode-select {
    margin-top: 15px;
}

#game-mode-select p,
#difficulty-select p,
#control-mode-select p {
    margin-bottom: 10px;
    font-size: 14px;
}

#game-mode-select button,
#difficulty-select button,
#control-mode-select button {
    margin: 5px;
    min-width: 80px;
}

/* Control mode button active state */
.control-mode-btn.active {
    background: #FFD700;
    color: #000;
    font-weight: bold;
}

#mode-description {
    font-size: 12px;
    color: #AAAAAA;
    margin: 0 auto 10px auto;
    text-align: center;
}

#control-mode-description {
    font-size: 11px;
    color: #AAAAAA;
    margin: 5px 0 15px 0;
    min-height: 2.4em;
    text-align: center;
}

#back-btn {
    margin-top: 15px;
    background: #666;
}

#back-btn:hover {
    background: #888;
}

#pause-menu button {
    display: block;
    width: 100%;
    margin: 10px 0;
}

button {
    background: #66BD33;
    border: 2px solid white;
    color: white;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

button:hover {
    background: #3E8948;
}

button:active {
    background: #2D6B35;
}

/* Game over screen (overlay on game area) */
#game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    background-color: rgba(0, 0, 0, 0.95);
    padding: 30px;
    border: 3px solid #FFD700;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    text-align: center;
    pointer-events: auto;
    overflow-y: auto;
    box-sizing: border-box;
}

#game-over-screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #FFD700;
}

#game-over-screen p {
    font-size: 24px;
    margin: 10px 0;
}

#game-over-screen button {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 20px;
    cursor: pointer;
}

#death-reason {
    color: #FF6B6B;
    font-weight: bold;
}

#game-over-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#game-over-buttons button {
    margin-top: 20px;
    padding: 12px 24px;
    font-size: 16px;
}

#rank-display {
    color: #FFD700;
    font-size: 18px;
    font-weight: bold;
}

#new-best-indicator {
    color: #00FF00;
    font-size: 16px;
    animation: pulse 0.3s ease-in-out infinite;
}

/* ============================================
   AUTH SECTION
   ============================================ */

#auth-section {
    margin: 10px auto 5px auto;
    padding: 8px 12px;
    border: 1px solid #555;
    background: rgba(255, 255, 255, 0.05);
    max-width: 320px;
}

.auth-login-row {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

#auth-handle-input,
#initials-handle-input {
    background: #111;
    border: 1px solid #555;
    color: #FFD700;
    padding: 6px 8px;
    font-family: inherit;
    font-size: 12px;
    width: 180px;
    outline: none;
}

#auth-handle-input:focus,
#initials-handle-input:focus {
    border-color: #FFD700;
}

.auth-btn {
    padding: 6px 12px;
    font-size: 12px;
    min-width: auto;
    margin: 0;
}

.auth-hint {
    font-size: 10px;
    color: #888;
    margin: 4px 0 0 0;
    text-align: center;
}

.auth-status {
    font-size: 13px;
    color: #00FF00;
    margin: 0 0 6px 0;
}

.auth-handle {
    color: #FFD700;
    font-weight: bold;
}

.of-login-btn {
    background: #1185FE;
    border: 2px solid #4AA3FF;
    color: white;
    font-size: 13px;
    font-weight: bold;
    padding: 8px 16px;
    width: 100%;
    cursor: pointer;
    margin: 0;
}

.of-login-btn:hover {
    background: #0D6FD8;
}

.auth-create-link {
    font-size: 10px;
    color: #888;
    margin: 4px 0 0 0;
    text-align: center;
}

.auth-create-link a {
    color: #4AA3FF;
    text-decoration: none;
}

.auth-create-link a:hover {
    text-decoration: underline;
}

.auth-logout-btn {
    background: #666;
    font-size: 11px;
    padding: 4px 10px;
    margin: 0;
}

.auth-logout-btn:hover {
    background: #888;
}

/* ============================================
   AUTH MODAL
   ============================================ */

#auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.auth-modal-box {
    background: #1a1a1a;
    border: 2px solid #1185FE;
    width: 100%;
    max-width: 360px;
    color: white;
    font-family: 'Courier New', monospace;
    box-sizing: border-box;
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #333;
}

.auth-modal-tabs {
    display: flex;
    flex: 1;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #888;
    font-family: inherit;
    font-weight: bold;
    font-size: 13px;
    padding: 12px 8px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin: 0;
    min-width: auto;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab:hover {
    color: #ccc;
    background: transparent;
}

.auth-tab.active {
    color: #1185FE;
    border-bottom-color: #1185FE;
    background: transparent;
}

.auth-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 12px;
    margin: 0;
    min-width: auto;
    line-height: 1;
}

.auth-modal-close:hover {
    color: #fff;
    background: none;
}

.auth-panel {
    padding: 16px;
}

.auth-field {
    margin-bottom: 12px;
}

.auth-field label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-field input {
    width: 100%;
    background: #111;
    border: 1px solid #444;
    color: #FFD700;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.auth-field input:focus {
    border-color: #1185FE;
}

.auth-modal-submit {
    width: 100%;
    margin-top: 4px;
}

.auth-modal-error {
    color: #FF6B6B;
    font-size: 12px;
    text-align: center;
    padding: 8px 16px;
}

.auth-modal-loading {
    color: #1185FE;
    font-size: 12px;
    text-align: center;
    padding: 8px 16px;
}

/* ============================================
   LEADERBOARD SCREEN
   ============================================ */

#leaderboard-screen {
    position: relative;
    text-align: center;
    background: rgba(0, 0, 0, 0.95);
    padding: 20px 30px;
    border: 3px solid #FFD700;
    pointer-events: auto;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
    box-sizing: border-box;
    width: 420px;
}

#leaderboard-screen h1 {
    margin-top: 0;
    color: #FFD700;
    font-size: 28px;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
}

#leaderboard-table th {
    color: #FFD700;
    border-bottom: 2px solid #FFD700;
    padding: 6px 8px;
    text-align: left;
}

#leaderboard-table th:first-child {
    width: 40px;
    text-align: center;
}

#leaderboard-table th:last-child {
    text-align: right;
}

#leaderboard-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #333;
    color: #CCC;
}

#leaderboard-table td:first-child {
    text-align: center;
    color: #FFD700;
    font-weight: bold;
}

#leaderboard-table td:last-child {
    text-align: right;
    color: #FFF;
    font-weight: bold;
}

#leaderboard-table tr.lb-me td {
    color: #00FF00;
    background: rgba(0, 255, 0, 0.08);
}

#leaderboard-table tr.lb-gold td:first-child { color: #FFD700; }
#leaderboard-table tr.lb-silver td:first-child { color: #C0C0C0; }
#leaderboard-table tr.lb-bronze td:first-child { color: #CD7F32; }

#leaderboard-empty {
    color: #888;
    font-style: italic;
    font-size: 14px;
}

#leaderboard-btn {
    margin-top: 10px;
    background: #444;
    font-size: 14px;
    padding: 8px 20px;
}

#leaderboard-btn:hover {
    background: #666;
}

/* ============================================
   INITIALS ENTRY
   ============================================ */

#initials-entry {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 360px;
    background-color: rgba(0, 0, 0, 0.95);
    padding: 20px;
    border: 3px solid #FFD700;
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 1001;
    color: white;
    text-align: center;
    pointer-events: auto;
    box-sizing: border-box;
}

#initials-entry h2 {
    color: #FFD700;
    margin: 0 0 5px 0;
    font-size: 22px;
}

#initials-score {
    font-size: 18px;
    color: #00FF00;
    margin: 0 0 10px 0;
}

#initials-chars {
    display: flex;
    gap: 12px;
    margin: 10px 0 15px 0;
    justify-content: center;
}

.initial-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.initial-char {
    font-size: 36px;
    font-weight: bold;
    color: #CCC;
    width: 40px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    border: 2px solid #555;
    background: #111;
}

.initial-char.active {
    color: #FFD700;
    border-color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.initial-arrow {
    background: #333;
    border: 1px solid #555;
    color: #CCC;
    font-size: 16px;
    padding: 4px 12px;
    min-width: auto;
    margin: 0;
    cursor: pointer;
    line-height: 1;
}

.initial-arrow:hover {
    background: #555;
    color: #FFD700;
}

#initials-entry button {
    margin-top: 8px;
}

#initials-login-prompt {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #555;
}

/* ============================================
   MOBILE DEVICE SUPPORT
   ============================================ */

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Default: Show menus, hide game container */
#portrait-menu-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

#landscape-game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

/* Mobile-specific: Fullscreen game in landscape */
body.mobile-device.landscape #landscape-game-container {
    display: flex !important;
    width: 100vw;
    height: 100vh;
}

body.mobile-device.landscape #game-container {
    width: 100vw;
    height: 100vh;
    border: none;
}

body.mobile-device.landscape canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* Rotation warning (mid-game portrait rotation) */
#rotation-warning,
#rotate-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
}

.rotate-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.rotation-content h2 {
    color: #ffd700;
    margin: 20px 0;
}

.rotation-content p {
    font-size: 18px;
    color: #ccc;
}

/* Control info sections */
.control-info {
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    margin: 20px auto;
    border-radius: 10px;
    max-width: 400px;
    border: 2px solid #555;
}

.control-info h3 {
    color: #ffd700;
    margin-bottom: 15px;
    margin-top: 0;
}

.control-info p {
    margin: 8px 0;
    font-size: 16px;
}

#touch-mode-indicator {
    color: #4a9eff;
    font-weight: bold;
    margin-top: 10px;
}

.control-info button {
    margin-top: 10px;
    font-size: 14px;
}

/* Touch zone indicators */
#touch-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.touch-zone {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
    font-size: 48px;
    font-weight: bold;
    transition: opacity 1s;
}

.left-up {
    left: 0;
    top: 0;
    width: 30%;
    height: 50%;
}

.left-down {
    left: 0;
    top: 50%;
    width: 30%;
    height: 50%;
}

.right-shoot {
    left: 30%;
    top: 0;
    width: 70%;
    height: 100%;
    font-size: 32px;
}

/* Fade out animation for touch zones */
.touch-zone.fade-out {
    animation: fadeOut 1s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

/* Mobile pause menu options */
#mobile-pause-options {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #555;
}

#mobile-pause-options h3 {
    color: #ffd700;
    font-size: 16px;
    margin-top: 0;
}

#mobile-pause-options button {
    font-size: 14px;
    padding: 8px 16px;
    margin: 5px 0;
}

/* iOS Install Prompt */
#ios-install-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ios-prompt-content {
    background: #1a1a1a;
    border: 3px solid #ffd700;
    border-radius: 10px;
    max-width: 500px;
    width: 100%;
    color: white;
    font-family: 'Courier New', monospace;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.ios-prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #333;
}

.ios-prompt-header h2 {
    margin: 0;
    color: #ffd700;
    font-size: 22px;
}

.ios-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    transition: color 0.2s;
}

.ios-close-btn:hover {
    color: #fff;
    background: none;
}

.ios-prompt-body {
    padding: 20px;
}

.ios-prompt-body p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.5;
}

.ios-instructions {
    background: rgba(255, 215, 0, 0.1);
    border-left: 3px solid #ffd700;
    padding: 15px 15px 15px 35px;
    margin: 15px 0;
}

.ios-instructions li {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.6;
}

.ios-icon {
    display: inline-block;
    font-size: 20px;
    color: #4a9eff;
    font-weight: bold;
}

.ios-note {
    font-size: 14px;
    color: #888;
    font-style: italic;
}

.ios-prompt-footer {
    padding: 20px;
    border-top: 2px solid #333;
    text-align: center;
}

.ios-continue-btn {
    background: #3E8948;
    border: 2px solid #66BD33;
    color: white;
    padding: 12px 30px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.ios-continue-btn:hover {
    background: #2D6B35;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    #start-screen h1,
    #difficulty-screen h1,
    #pause-menu h1,
    #game-over-screen h1 {
        font-size: 24px;
    }

    button {
        font-size: 16px;
        padding: 12px 24px;
        min-width: 120px;
    }

    .ios-prompt-header h2 {
        font-size: 18px;
    }

    .ios-prompt-body p,
    .ios-instructions li {
        font-size: 14px;
    }
}

/* Very small screens - extra responsive */
@media (max-height: 600px) {
    #start-screen,
    #difficulty-screen,
    #pause-menu {
        padding: 15px 20px;
    }

    #start-screen h1,
    #difficulty-screen h1,
    #pause-menu h1 {
        font-size: 20px;
        margin: 10px 0;
    }

    #game-over-screen {
        padding: 20px;
    }

    #game-over-screen h1 {
        font-size: 32px;
        margin-bottom: 15px;
    }

    #game-over-screen p {
        font-size: 18px;
        margin: 8px 0;
    }

    #game-over-screen button {
        margin-top: 20px;
        padding: 12px 30px;
        font-size: 16px;
    }

    button {
        font-size: 14px;
        padding: 8px 16px;
        margin: 5px;
        min-width: 80px;
    }

    .control-info {
        padding: 15px;
        margin: 15px auto;
    }

    .control-info h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .control-info p {
        font-size: 14px;
        margin: 6px 0;
    }

    #mode-description,
    #control-mode-description {
        font-size: 11px;
        margin: 5px 0;
    }
}

/* Extra small screens */
@media (max-height: 500px) {
    #start-screen,
    #difficulty-screen,
    #pause-menu {
        padding: 10px 15px;
    }

    #start-screen h1,
    #difficulty-screen h1,
    #pause-menu h1 {
        font-size: 18px;
        margin: 8px 0;
    }

    button {
        font-size: 12px;
        padding: 6px 12px;
        margin: 3px;
        min-width: 70px;
    }

    .control-info {
        padding: 10px;
        margin: 10px auto;
    }

    .control-info h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .control-info p {
        font-size: 12px;
        margin: 4px 0;
    }

    #mode-description,
    #control-mode-description {
        font-size: 10px;
    }

    #game-mode-select p,
    #difficulty-select p,
    #control-mode-select p {
        font-size: 12px;
        margin-bottom: 5px;
    }
}

/* Handle very small width screens */
@media (max-width: 360px) {
    #start-screen,
    #difficulty-screen,
    #pause-menu {
        padding: 10px;
    }

    button {
        font-size: 12px;
        padding: 8px 12px;
        margin: 3px 2px;
    }

    #game-mode-select button,
    #difficulty-select button,
    #control-mode-select button {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}
