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

body {
    background: #0a0a12;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    z-index: 1;
}
.screen.active { display: flex; }

/* ---- Landing Screen ---- */
#screen-landing {
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
#bg-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}
.landing-content {
    position: relative;
    z-index: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.title {
    font-size: 72px;
    font-weight: 800;
    letter-spacing: 4px;
    color: #fff;
    text-shadow: 0 0 40px rgba(0, 245, 255, 0.5), 0 0 80px rgba(0, 245, 255, 0.2);
}
.title-dot {
    color: #00f5ff;
}
.subtitle {
    font-size: 16px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.play-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
#name-input, #room-input {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 14px 20px;
    font-size: 18px;
    color: #fff;
    width: 280px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}
#name-input:focus, #room-input:focus {
    border-color: #00f5ff;
}
#name-input::placeholder, #room-input::placeholder {
    color: rgba(255,255,255,0.3);
}
.btn-play {
    background: linear-gradient(135deg, #00f5ff, #0088ff);
    border: none;
    border-radius: 8px;
    padding: 16px 64px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    letter-spacing: 3px;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 0 30px rgba(0, 245, 255, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}
.btn-play:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(0, 245, 255, 0.5);
}
.btn-play:active {
    transform: scale(0.98);
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 30px rgba(0, 245, 255, 0.3); }
    50% { box-shadow: 0 0 50px rgba(0, 245, 255, 0.5); }
}
.player-count {
    font-size: 14px;
    color: rgba(255,255,255,0.4);
}
.room-join {
    margin-top: 4px;
}
#room-input {
    width: 220px;
    font-size: 14px;
    padding: 10px 16px;
}
.room-sliders {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    width: 260px;
}
.slider-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.slider-row label {
    font-size: 14px;
    color: rgba(255,255,255,0.5);
}
.slider-row label span {
    color: #00f5ff;
    font-weight: 600;
}
.slider-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00f5ff;
    cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00f5ff;
    border: none;
    cursor: pointer;
}
.slider-hints {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 11px;
    color: rgba(255,255,255,0.25);
}
.cosmetics-preview {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    opacity: 0.5;
}
.cosmetic-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    position: relative;
}
.cosmetic-item.locked::after {
    content: '🔒';
    position: absolute;
    top: 4px;
    font-size: 14px;
}
.cosmetic-orb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
}

/* ---- Game Screen ---- */
#screen-game.active {
    display: block !important;
}
#game-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* ---- HUD ---- */
#hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}
.hud-element {
    position: absolute;
    pointer-events: auto;
}
.hud-top-left {
    top: 16px;
    left: 16px;
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.hud-top-left.urgent {
    color: #ff4444;
    animation: timer-pulse 1s ease-in-out infinite;
}
@keyframes timer-pulse {
    50% { transform: scale(1.1); }
}
.hud-top-right {
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 12px 16px;
    min-width: 180px;
    backdrop-filter: blur(4px);
}
.lb-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
}
.lb-entry {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 2px 0;
    transition: background 0.3s;
}
.lb-entry.me {
    color: #00f5ff;
    font-weight: 600;
}
.hud-bottom-center {
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.hud-bottom-left {
    bottom: 16px;
    left: 16px;
}
#minimap-canvas {
    border-radius: 8px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
}
.hud-top-center {
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.kill-msg {
    font-size: 13px;
    padding: 4px 12px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    white-space: nowrap;
    animation: feed-fade 3s forwards;
}
@keyframes feed-fade {
    0% { opacity: 1; transform: translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* ---- Overlays ---- */
.overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(4px);
}
.overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.overlay-content h2 {
    font-size: 48px;
    font-weight: 800;
    text-shadow: 0 0 30px rgba(255,0,100,0.5);
}
.death-stats, .round-stats {
    display: flex;
    gap: 24px;
    font-size: 16px;
    color: rgba(255,255,255,0.7);
}
.respawn-countdown, #round-next {
    font-size: 20px;
    color: #00f5ff;
    margin-top: 8px;
}

/* ---- Mobile ---- */
.mobile-btn {
    position: absolute;
    bottom: 80px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    z-index: 15;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}
.mobile-btn:active {
    background: rgba(255,255,255,0.3);
}

/* ---- Settings ---- */
.settings-gear {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 50;
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}
.settings-gear:hover {
    color: rgba(255,255,255,0.8);
}
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 32px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
}
.modal-content label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    cursor: pointer;
}
.quality-select {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}
.quality-select select {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
}
.btn-secondary {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px 24px;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    margin-top: 8px;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.15);
}

/* ---- Landscape Hint ---- */
#landscape-hint {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #0a0a12;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.landscape-hint-content {
    text-align: center;
    color: rgba(255,255,255,0.6);
}
.rotate-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: rotate-hint 2s ease-in-out infinite;
}
@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* ---- Round overlay extras ---- */
.round-gems {
    font-size: 22px;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}
#share-btn {
    cursor: pointer;
}

/* ---- Ad zones ---- */
.ad-zone {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 25;
}
.locked-label {
    color: rgba(255,255,255,0.4);
    font-size: 14px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .title { font-size: 42px; }
    .subtitle { font-size: 12px; letter-spacing: 4px; }
    #name-input { width: 240px; font-size: 16px; padding: 12px 16px; }
    .btn-play { padding: 14px 48px; font-size: 18px; }
    .hud-top-right { min-width: 140px; padding: 8px 12px; }
    .lb-entry { font-size: 12px; }
    .hud-top-left { font-size: 22px; }
    .death-stats, .round-stats { flex-direction: column; gap: 6px; }
    .cosmetics-preview { display: none; }
}

/* ---- Stun Overlay ---- */
.stun-overlay {
    background: rgba(255, 50, 50, 0.4);
}
.stun-content {
    background: rgba(0, 0, 0, 0.8);
    padding: 40px 60px;
    border-radius: 16px;
    border: 3px solid #ff4444;
    box-shadow: 0 0 60px rgba(255, 68, 68, 0.6);
}
.stun-content h2 {
    color: #ff4444;
    text-shadow: 0 0 30px rgba(255, 68, 68, 0.8);
    animation: stun-shake 0.2s ease-in-out infinite;
    font-size: 56px;
}
.stun-content .stun-timer {
    font-size: 80px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.8);
}
.stun-content p {
    font-size: 18px;
    color: rgba(255,255,255,0.7);
}
@keyframes stun-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-6px) rotate(-2deg); }
    75% { transform: translateX(6px) rotate(2deg); }
}

/* ---- Power-up Collected Notification ---- */
.powerup-collected {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(191, 0, 255, 0.9);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 30;
    pointer-events: none;
    border: 2px solid #fff;
    box-shadow: 0 0 20px rgba(191, 0, 255, 0.8);
}
.powerup-collected.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Mode tabs + join banner ---- */
.mode-tabs {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    justify-content: center;
}
.mode-tab {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mode-tab:hover {
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.25);
}
.mode-tab.active {
    background: rgba(0, 245, 255, 0.12);
    border-color: rgba(0, 245, 255, 0.5);
    color: #fff;
}
.join-banner {
    margin: 0 0 14px;
    padding: 10px 16px;
    background: rgba(0, 245, 255, 0.08);
    border: 1px solid rgba(0, 245, 255, 0.35);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    text-align: center;
}
.join-banner #join-banner-code {
    font-weight: 600;
    color: #00f5ff;
    margin-left: 4px;
}

/* ---- In-game room share panel ---- */
.room-share {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 10, 25, 0.85);
    border: 1px solid rgba(0, 245, 255, 0.35);
    border-radius: 8px;
    padding: 8px 14px;
    z-index: 30;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
}
.room-share-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.room-share-label {
    color: rgba(255, 255, 255, 0.55);
}
.room-share-code {
    color: #00f5ff;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.room-share-btn {
    background: rgba(0, 245, 255, 0.15);
    border: 1px solid rgba(0, 245, 255, 0.4);
    color: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.room-share-btn:hover {
    background: rgba(0, 245, 255, 0.25);
}
.room-share-dismiss {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.room-share-dismiss:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* ---- Gem icon + landing shop button ---- */
.gem-icon {
    display: inline-block;
    filter: hue-rotate(0deg);
}
.landing-meta {
    margin-top: 6px;
    display: flex;
    justify-content: center;
}
.btn-link {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-link:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ---- Shop Modal ---- */
.shop-content {
    min-width: 480px;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
}
.shop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    margin-bottom: 4px;
}
.shop-balance {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 999px;
}
.shop-section h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
    margin-bottom: 8px;
}
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.shop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.shop-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}
.shop-item.locked {
    opacity: 0.65;
}
.shop-item.locked:hover {
    opacity: 0.9;
}
.shop-item.owned {
    border-color: rgba(0, 245, 255, 0.3);
    cursor: default;
}
.shop-item.owned:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.03);
}
.shop-orb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}
.shop-trail {
    width: 60px;
    height: 12px;
    border-radius: 6px;
}
.shop-trail.standard { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5)); }
.shop-trail.fire { background: linear-gradient(90deg, transparent, #ff6b35, #ffd700); }
.shop-trail.stardust { background: linear-gradient(90deg, transparent, #c878ff, #fff); }
.shop-trail.lightning { background: linear-gradient(90deg, transparent, #00f5ff, #fff); }
.shop-name {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}
.shop-price {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
}
.shop-price.owned {
    color: rgba(0, 245, 255, 0.8);
}
.shop-cta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}
.shop-cta .btn-secondary {
    flex: 1;
    margin-top: 0;
}
.shop-cta .btn-secondary[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}
.round-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
@media (max-width: 600px) {
    .shop-content { min-width: auto; width: 92vw; padding: 20px; }
    .shop-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* ---- Built By Credit ---- */
.built-by {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.5px;
    z-index: 2;
    pointer-events: auto;
}
.built-by a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: color 0.2s, border-color 0.2s;
}
.built-by a:hover {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

/* ---- Stun Power HUD Indicator ---- */
#stun-power-indicator {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 10, 25, 0.7);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 25;
    pointer-events: none;
    border: 1px solid rgba(191, 0, 255, 0.5);
}
#stun-power-indicator.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#stun-power-indicator .stun-icon {
    color: #c878ff;
    font-size: 14px;
}
#stun-power-indicator .stun-key {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    padding-left: 10px;
}
#stun-power-indicator .stun-sep {
    color: rgba(255, 255, 255, 0.3);
    margin: 0 2px;
}
