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

html, body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: linear-gradient(to bottom, #0d3d56 0%, #1a4d6d 30%, #2a5f7f 70%, #0d2b3d 100%);
    position: fixed;
    width: 100%;
    height: 100%;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    background: linear-gradient(to bottom, #1a4d6d 0%, #2a5f7f 50%, #0d2b3d 100%);
    cursor: pointer;
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-size: 18px;
    z-index: 10;
}

#score {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    margin-bottom: 10px;
}

#level {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#room-display {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    margin-bottom: 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

#room-code-display {
    color: #4CAF50;
    font-size: 18px;
    letter-spacing: 1px;
}

.small-btn {
    background: rgba(76, 175, 80, 0.8);
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.small-btn:hover {
    background: rgba(76, 175, 80, 1);
    transform: none;
}

#leaderboard {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 10px;
    min-width: 200px;
}

#leaderboard h3 {
    margin-bottom: 10px;
    font-size: 16px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 5px;
}

#leaderboard-list {
    list-style-position: inside;
    font-size: 14px;
}

#leaderboard-list li {
    padding: 3px 0;
}

#game-version {
    position: absolute;
    bottom: 10px;
    right: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    z-index: 10;
    pointer-events: none;
}

/* Ad Containers */
#banner-ad-container {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: rgba(0, 0, 0, 0.7);
    padding: 2px;
    text-align: center;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.2);
    max-width: 728px;
    width: auto;
    border-radius: 3px 3px 0 0;
}

#banner-ad-container .adsbygoogle {
    max-height: 90px;
    display: block;
}

#mrec-ad-container {
    margin: 15px auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    text-align: center;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#minimap-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 120px;
    height: 120px;
    background: transparent;
    border-radius: 50%;
    z-index: 10;
    pointer-events: none;
    overflow: hidden;
    transition: bottom 0.3s ease;
}

#minimap-container.ad-visible {
    bottom: 95px;
}

#minimap {
    display: block;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #banner-ad-container {
        max-width: 320px;
        padding: 1px;
        background: rgba(0, 0, 0, 0.6);
    }

    #banner-ad-container .adsbygoogle {
        width: 320px !important;
        height: 50px !important;
        max-height: 50px !important;
    }

    #minimap-container {
        width: 70px;
        height: 70px;
        bottom: 80px;
        left: 10px;
        pointer-events: auto;
        transition: all 0.3s ease;
        cursor: pointer;
    }

    #minimap-container.expanded {
        width: 120px;
        height: 120px;
    }

    #minimap-container.ad-visible {
        bottom: 55px;
    }
}

/* Chat System */
#chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: rgba(26, 77, 109, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

#chat-toggle:hover {
    background: rgba(26, 77, 109, 1);
    transform: scale(1.1);
}

#chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b30;
    color: white;
    border-radius: 10px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    padding: 0 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#chat-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 280px;
    max-height: 300px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: none;
    flex-direction: column;
    z-index: 999;
}

#chat-container.open {
    display: flex;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    max-height: 250px;
    font-size: 13px;
}

.chat-message {
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    word-wrap: break-word;
}

.chat-message .chat-name {
    font-weight: bold;
    color: #4a9eff;
    margin-right: 5px;
}

.chat-message .chat-text {
    color: #ffffff;
}

.chat-message.system {
    background: rgba(255, 200, 100, 0.15);
    font-style: italic;
}

.chat-message.system .chat-text {
    color: #ffc864;
}

#chat-input-wrapper {
    display: flex;
    padding: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

#chat-input {
    flex: 1;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px; /* Prevent iOS zoom on focus */
    -webkit-appearance: none;
    appearance: none;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#chat-send {
    margin-left: 5px;
    padding: 8px 15px;
    background: #1a4d6d;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}

#chat-send:hover {
    background: #2a5f7f;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #chat-toggle {
        width: 45px;
        height: 45px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    #chat-container {
        width: calc(100% - 30px);
        right: 15px;
        bottom: 70px;
        max-height: 250px;
    }

    #chat-messages {
        max-height: 200px;
        font-size: 12px;
    }

    #chat-input, #chat-send {
        font-size: 12px;
    }
}

#start-screen-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99;
    background: linear-gradient(to bottom, #1a4d6d 0%, #2a5f7f 50%, #0d2b3d 100%);
    display: block;
}

#start-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 250, 255, 0.95) 100%);
    backdrop-filter: blur(20px);
    padding: 30px 25px;
    border-radius: 24px;
    text-align: center;
    z-index: 100;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35),
                0 10px 30px rgba(26, 77, 109, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 3px solid rgba(255, 255, 255, 0.7);
    touch-action: auto;
    -webkit-user-select: text;
    user-select: text;
    width: 90%;
    max-width: 480px;
    box-sizing: border-box;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 248, 255, 0.85) 100%);
    backdrop-filter: blur(8px);
    padding: 30px 35px;
    border-radius: 25px;
    text-align: center;
    z-index: 100;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(26, 77, 109, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 3px solid rgba(255, 255, 255, 0.6);
    touch-action: auto;
    -webkit-user-select: text;
    user-select: text;
    max-width: 500px;
    width: 90%;
    animation: gameOverFadeIn 0.5s ease-out;
}

@keyframes gameOverFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

#start-screen h1 {
    color: #1e3a5f;
    font-size: 48px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 8px rgba(42, 130, 180, 0.25);
    animation: float 3s ease-in-out infinite;
    font-weight: 800;
    letter-spacing: 2px;
}

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

#start-screen p, #game-over p {
    color: #5a6c7d;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.instructions {
    font-size: 13px !important;
    margin-bottom: 18px !important;
    color: #6b7c8e !important;
    font-weight: 500;
}

#player-name {
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid #e0e7ef;
    border-radius: 12px;
    margin: 0 auto 20px;
    width: 100%;
    max-width: 100%;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: block;
    background: white;
    color: #2c3e50;
    font-weight: 500;
}

#player-name:focus {
    border-color: #3d6bb3;
    box-shadow: 0 4px 16px rgba(61, 107, 179, 0.2), 0 0 0 3px rgba(61, 107, 179, 0.1);
    transform: translateY(-1px);
}

button {
    background: linear-gradient(135deg, #3d6bb3 0%, #2a5298 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(42, 82, 152, 0.25);
    display: block;
    margin: 0 auto;
    width: 100%;
    letter-spacing: 0.5px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(42, 82, 152, 0.4);
    background: linear-gradient(135deg, #4a7ac4 0%, #3562a9 100%);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 3px 12px rgba(42, 82, 152, 0.3);
}

.room-options {
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.room-options h3 {
    color: #1e3a5f;
    margin-bottom: 10px;
    font-size: 17px;
}

.primary-btn {
    background: linear-gradient(135deg, #20c997 0%, #17a589 100%);
    margin-bottom: 0;
    width: 100%;
    box-shadow: 0 4px 15px rgba(32, 201, 151, 0.3);
    font-size: 16px;
    padding: 16px 32px;
    font-weight: 700;
}

.primary-btn:hover {
    box-shadow: 0 8px 25px rgba(32, 201, 151, 0.4);
    background: linear-gradient(135deg, #28d4a5 0%, #1bb896 100%);
    transform: translateY(-2px);
}

.divider {
    color: #9ca9b8;
    margin: 4px 0;
    font-size: 12px;
    text-align: center;
    font-weight: 600;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #d0d8e0, transparent);
}

.room-input-group {
    display: flex;
    gap: 8px;
    margin: 0;
    width: 100%;
    justify-content: stretch;
}

.room-input-group input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #e0e7ef;
    border-radius: 12px;
    outline: none;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: white;
    font-weight: 600;
    letter-spacing: 2px;
}

.room-input-group input:focus {
    border-color: #3d6bb3;
    box-shadow: 0 4px 16px rgba(61, 107, 179, 0.2), 0 0 0 3px rgba(61, 107, 179, 0.1);
    transform: translateY(-1px);
}

.room-input-group button {
    flex: 0 0 auto;
    padding: 14px 24px;
    width: auto;
}

.room-privacy-option {
    margin: 2px auto 6px;
    text-align: center;
    width: 100%;
}

.room-privacy-option label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #2c3e50;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    justify-content: center;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
    transition: background 0.2s;
}

.room-privacy-option label:hover {
    background: rgba(61, 107, 179, 0.05);
}

.room-privacy-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #3d6bb3;
}

#create-room-btn {
    width: 100%;
    background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
    padding: 14px 32px;
    font-weight: 600;
}

#create-room-btn:hover {
    box-shadow: 0 8px 25px rgba(255, 165, 0, 0.4);
    background: linear-gradient(135deg, #ffb520 0%, #ff9d1a 100%);
    transform: translateY(-2px);
}

#room-info {
    margin: 15px auto 0;
    padding: 18px;
    background: linear-gradient(135deg, rgba(61, 107, 179, 0.08) 0%, rgba(30, 58, 95, 0.05) 100%);
    border-radius: 14px;
    width: 100%;
    border: 2px solid rgba(61, 107, 179, 0.15);
}

#room-info p {
    margin: 5px 0;
    color: #1e3a5f;
    font-weight: bold;
}

#current-room-code {
    color: #28a745;
    font-size: 24px;
    letter-spacing: 2px;
}

.share-link {
    font-size: 12px !important;
    font-weight: normal !important;
    color: #666 !important;
    word-break: break-all;
}

#room-link {
    color: #3d6bb3;
    font-weight: bold;
}

#available-rooms {
    margin: 0 auto 15px;
    width: 100%;
}

#available-rooms h4 {
    color: #1e3a5f;
    margin-bottom: 10px;
    font-size: 16px;
}

#rooms-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.room-item {
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid #4CAF50;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.room-item:hover {
    background: rgba(76, 175, 80, 0.2);
    border-color: #45a049;
    transform: translateY(-2px);
}

.room-item-code {
    font-weight: bold;
    font-size: 18px;
    color: #2a5298;
    margin-bottom: 5px;
}

.room-item-info {
    font-size: 14px;
    color: #666;
}

.room-item-players {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

#game-over h2 {
    color: #1e3a5f;
    font-size: 44px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: 800;
    letter-spacing: -0.5px;
}

#final-score {
    font-size: 26px;
    color: #2a5298;
    font-weight: bold;
    margin: 15px 0 20px 0;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(42, 130, 180, 0.15) 0%, rgba(26, 77, 109, 0.1) 100%);
    border-radius: 15px;
    border: 2px solid rgba(42, 130, 180, 0.3);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

#game-over-leaderboard {
    margin: 20px 0;
    text-align: left;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    padding: 15px;
    border: 2px solid rgba(42, 130, 180, 0.2);
}

#game-over-leaderboard h3 {
    color: #1e3a5f;
    font-size: 20px;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

#game-over-leaderboard-list {
    list-style-position: inside;
    padding: 0;
    margin: 0;
    max-height: 280px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 8px;
}

#game-over-leaderboard-list li {
    padding: 8px 12px;
    margin: 4px 0;
    color: #2c3e50;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-weight: 600;
}

#game-over-leaderboard-list li:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateX(3px);
}

#game-over-leaderboard-list li:nth-child(1) {
    border-left-color: #FFD700;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 255, 255, 0.6) 100%);
}

#game-over-leaderboard-list li:nth-child(2) {
    border-left-color: #C0C0C0;
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.2) 0%, rgba(255, 255, 255, 0.6) 100%);
}

#game-over-leaderboard-list li:nth-child(3) {
    border-left-color: #CD7F32;
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.2) 0%, rgba(255, 255, 255, 0.6) 100%);
}

#level-up-notification {
    display: none !important; /* Now using dynamic canvas text instead */
}

@keyframes levelUpSlideIn {
    0% {
        transform: translateX(150%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateX(-10px) scale(1.05);
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Combo Display */
#combo-display {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    font-weight: bold;
    z-index: 150;
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.6);
    text-align: center;
    border: 3px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.1s ease;
}

/* Combo shake animation */
@keyframes comboShake {
    0%, 100% { transform: translateX(0) scale(1); }
    10% { transform: translateX(-8px) scale(1.15) rotate(-3deg); }
    20% { transform: translateX(8px) scale(1.15) rotate(3deg); }
    30% { transform: translateX(-8px) scale(1.15) rotate(-3deg); }
    40% { transform: translateX(8px) scale(1.15) rotate(3deg); }
    50% { transform: translateX(-6px) scale(1.12) rotate(-2deg); }
    60% { transform: translateX(6px) scale(1.12) rotate(2deg); }
    70% { transform: translateX(-4px) scale(1.08) rotate(-1deg); }
    80% { transform: translateX(4px) scale(1.08) rotate(1deg); }
    90% { transform: translateX(-2px) scale(1.04) rotate(0deg); }
}

/* Crazy shake animation for 300+ milestones */
@keyframes comboCrazyShake {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    5% { transform: translate(-15px, 10px) scale(1.3) rotate(-8deg); }
    10% { transform: translate(15px, -10px) scale(1.35) rotate(8deg); }
    15% { transform: translate(-18px, 12px) scale(1.3) rotate(-10deg); }
    20% { transform: translate(18px, -12px) scale(1.35) rotate(10deg); }
    25% { transform: translate(-20px, 15px) scale(1.4) rotate(-12deg); }
    30% { transform: translate(20px, -15px) scale(1.4) rotate(12deg); }
    35% { transform: translate(-18px, 10px) scale(1.35) rotate(-10deg); }
    40% { transform: translate(18px, -10px) scale(1.35) rotate(10deg); }
    45% { transform: translate(-15px, 8px) scale(1.3) rotate(-8deg); }
    50% { transform: translate(15px, -8px) scale(1.3) rotate(8deg); }
    55% { transform: translate(-12px, 6px) scale(1.25) rotate(-6deg); }
    60% { transform: translate(12px, -6px) scale(1.25) rotate(6deg); }
    65% { transform: translate(-10px, 5px) scale(1.2) rotate(-5deg); }
    70% { transform: translate(10px, -5px) scale(1.2) rotate(5deg); }
    75% { transform: translate(-8px, 4px) scale(1.15) rotate(-4deg); }
    80% { transform: translate(8px, -4px) scale(1.15) rotate(4deg); }
    85% { transform: translate(-5px, 2px) scale(1.1) rotate(-2deg); }
    90% { transform: translate(5px, -2px) scale(1.1) rotate(2deg); }
    95% { transform: translate(-2px, 1px) scale(1.05) rotate(-1deg); }
}

#combo-display.shake {
    animation: comboShake 0.5s ease-in-out;
}

#combo-display.crazy-shake {
    animation: comboCrazyShake 0.8s ease-in-out;
}

/* Continuous animation for 300+ combo */
@keyframes comboExcited {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        box-shadow: 0 8px 30px rgba(255, 107, 107, 0.6),
                    0 0 0 0 rgba(255, 107, 107, 0);
    }
    25% {
        transform: scale(1.08) rotate(-2deg);
        box-shadow: 0 8px 35px rgba(255, 107, 107, 0.8),
                    0 0 20px 10px rgba(255, 107, 107, 0.4);
    }
    50% {
        transform: scale(1.12) rotate(0deg);
        box-shadow: 0 8px 40px rgba(255, 107, 107, 1),
                    0 0 30px 15px rgba(255, 107, 107, 0.6);
    }
    75% {
        transform: scale(1.08) rotate(2deg);
        box-shadow: 0 8px 35px rgba(255, 107, 107, 0.8),
                    0 0 20px 10px rgba(255, 107, 107, 0.4);
    }
}

@keyframes comboGlow {
    0%, 100% {
        filter: brightness(1) saturate(1);
    }
    50% {
        filter: brightness(1.3) saturate(1.5);
    }
}

#combo-display.excited {
    animation: comboExcited 1.2s ease-in-out infinite,
               comboGlow 0.8s ease-in-out infinite;
}

.combo-text {
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 3px;
    letter-spacing: 1px;
}

.combo-multiplier {
    font-size: 16px;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.combo-pulse {
    animation: comboPulse 0.3s ease-in-out;
}

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

/* Mobile Joystick */
#joystick-container {
    position: fixed;
    z-index: 1000;
    touch-action: none;
    pointer-events: none; /* Allow touches to pass through to canvas */
    transform: translate(-50%, -50%); /* Center joystick on touch point */
}

#joystick-base {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#joystick-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: all 0.1s ease;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    #ui {
        top: 10px;
        left: 10px;
        font-size: 12px;
        max-width: calc(100vw - 20px);
    }

    #score, #level, #room-display {
        padding: 6px 12px;
        font-size: 12px;
        margin-bottom: 6px;
    }

    #leaderboard {
        padding: 8px;
        min-width: 100px;
        max-width: 150px;
        font-size: 10px;
    }

    #leaderboard h3 {
        font-size: 12px;
        margin-bottom: 5px;
    }

    #leaderboard-list {
        font-size: 10px;
    }

    #leaderboard-list li {
        padding: 2px 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #start-screen {
        padding: 25px 20px;
        max-width: none;
        max-height: 90vh;
        width: 92%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 20px;
    }

    #game-over {
        padding: 20px;
        max-width: none;
        max-height: 90vh;
        width: 92%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #start-screen h1 {
        font-size: 38px;
        margin-bottom: 8px;
        letter-spacing: 1px;
    }

    #start-screen p {
        font-size: 13px;
        margin: 6px 0;
    }

    .instructions {
        font-size: 12px !important;
        margin-bottom: 15px !important;
    }

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

    #player-name {
        padding: 12px 16px;
        font-size: 15px;
        max-width: 100%;
        width: 100%;
        margin-bottom: 16px;
    }

    button {
        padding: 13px 28px;
        font-size: 15px;
    }

    .primary-btn {
        padding: 15px 28px;
    }

    .room-options {
        margin-top: 15px;
    }

    .room-options h3 {
        font-size: 17px;
        margin-bottom: 10px;
    }

    .room-input-group {
        gap: 10px;
    }

    .room-input-group input {
        padding: 10px;
        font-size: 14px;
        flex: 1;
    }

    .room-input-group button {
        padding: 10px 15px;
        font-size: 14px;
    }

    .divider {
        margin: 10px 0;
        font-size: 12px;
    }

    #room-info {
        padding: 12px;
        font-size: 13px;
    }

    #current-room-code {
        font-size: 20px;
    }

    #combo-display {
        top: 15px;
        right: 15px;
        padding: 12px 24px;
    }

    .combo-text {
        font-size: 22px;
    }

    .combo-multiplier {
        font-size: 13px;
    }

    .small-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    #room-code-display {
        font-size: 14px;
    }

    .room-privacy-option label {
        font-size: 13px;
    }

    .room-privacy-option input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .share-link {
        font-size: 11px;
        word-break: break-all;
    }

    #game-version {
        font-size: 10px;
        bottom: 8px;
        right: 8px;
    }
}

@media (max-width: 480px) {
    body {
        overflow: hidden;
    }

    #ui {
        top: 5px;
        left: 5px;
        font-size: 10px;
        max-width: calc(100vw - 10px);
    }

    #score, #level, #room-display {
        padding: 4px 8px;
        font-size: 10px;
        margin-bottom: 4px;
    }

    #leaderboard {
        padding: 5px;
        min-width: 85px;
        max-width: 100px;
    }

    #leaderboard h3 {
        font-size: 10px;
        margin-bottom: 3px;
    }

    #leaderboard-list {
        font-size: 8px;
        max-height: 150px;
        overflow-y: auto;
    }

    #leaderboard-list li {
        padding: 1px 0;
        max-width: 90px;
    }

    /* Hide room display on very small screens to save space */
    #room-display {
        display: none !important;
    }

    #start-screen {
        padding: 20px 16px;
        max-width: none;
        max-height: 92vh;
        width: 96%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 18px;
    }

    #game-over {
        padding: 15px;
        max-width: none;
        max-height: 92vh;
        width: 96%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #start-screen h1 {
        font-size: 32px;
        margin-bottom: 6px;
        letter-spacing: 1px;
    }

    #start-screen p {
        font-size: 12px;
        margin: 5px 0;
    }

    .instructions {
        font-size: 11px !important;
        margin-bottom: 12px !important;
    }

    #game-over p {
        font-size: 11px;
        margin: 6px 0;
    }

    #player-name {
        padding: 12px 14px;
        font-size: 14px;
        max-width: 100%;
        width: 100%;
        margin-bottom: 14px;
    }

    button {
        padding: 12px 24px;
        font-size: 14px;
        width: 100%;
    }

    .primary-btn {
        padding: 14px 24px;
    }

    .room-options {
        margin-top: 10px;
    }

    .room-options h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .room-input-group {
        flex-direction: column;
        gap: 8px;
    }

    .room-input-group input {
        width: 100%;
        max-width: 280px;
        font-size: 13px;
    }

    .room-input-group button {
        width: 100%;
        max-width: 280px;
    }

    .divider {
        margin: 8px 0;
        font-size: 11px;
    }

    #room-info {
        padding: 10px;
        font-size: 11px;
    }

    #current-room-code {
        font-size: 16px;
    }

    .share-link {
        font-size: 10px;
        word-break: break-all;
    }

    #combo-display {
        top: 10px;
        right: 10px;
        padding: 10px 18px;
    }

    .combo-text {
        font-size: 18px;
    }

    .combo-multiplier {
        font-size: 11px;
    }

    #joystick-base {
        width: 90px;
        height: 90px;
    }

    #joystick-stick {
        width: 35px;
        height: 35px;
    }

    .room-privacy-option {
        font-size: 11px;
    }

    .room-privacy-option label {
        font-size: 11px;
    }

    #game-version {
        font-size: 9px;
        bottom: 5px;
        right: 5px;
    }
}

/* Legal Links */
.legal-links {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(90, 108, 125, 0.2);
    font-size: 12px;
    color: #6b7c8e;
}

.legal-links a {
    color: #1a4d6d;
    text-decoration: none;
    transition: color 0.2s ease;
}

.legal-links a:hover {
    color: #2a5f7f;
    text-decoration: underline;
}

.legal-links .separator {
    margin: 0 8px;
    color: #b0b8c1;
}
