* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a2e;
    color: #fff;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-select: none;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#canvasLayer {
    position: absolute;
    inset: 0;
    z-index: 0;
}

#canvasLayer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#moneyPopups {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.money-popup {
    position: absolute;
    font-size: 26px;
    font-weight: bold;
    color: #22c55e;
    text-shadow: 0 0 12px rgba(34, 197, 94, 0.8), 0 1px 3px rgba(0,0,0,0.5);
    white-space: nowrap;
    animation: moneyPopup 1s ease-out forwards;
    transform: translate(-50%, -50%) scale(0.5);
}
.money-popup-negative {
    color: #ef4444;
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.8), 0 1px 3px rgba(0,0,0,0.5);
}

@keyframes moneyPopup {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.15);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(1);
    }
}

#overlayLayer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: auto; /* so Start / Play buttons and screens receive clicks */
}

#overlayLayer #ui {
    pointer-events: none; /* let clicks pass through to game when no screen is open */
}

#overlayLayer #ui #controls,
#overlayLayer #ui #moneyDisplay {
    pointer-events: auto; /* but controls and money stay clickable */
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#moneyDisplay {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    text-align: left;
    pointer-events: none;
    z-index: 20;
}

.money-label {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 4px;
}

.money-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.money-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #22c55e;
    filter: drop-shadow(0 1px 3px rgba(34, 197, 94, 0.4));
}

.money-icon svg {
    width: 100%;
    height: 100%;
}

#money {
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(34, 197, 94, 0.5);
    color: #22c55e;
}

.shop-btn {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid #22c55e;
    border-radius: 12px;
    color: #22c55e;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s, transform 0.1s;
}

.shop-btn:hover {
    background: rgba(34, 197, 94, 0.35);
}

.shop-btn:active {
    transform: scale(0.97);
}

.shop-btn svg {
    width: 22px;
    height: 22px;
}

.shop-btn.hidden {
    display: none !important;
}

.shop-menu {
    position: absolute;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

.shop-menu.hidden {
    display: none !important;
}

.shop-menu-inner {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #22c55e;
    border-radius: 20px;
    padding: 24px;
    max-width: 360px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.shop-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.shop-menu-header h2 {
    margin: 0;
    color: #22c55e;
    font-size: 28px;
}

.shop-close {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 10px;
    padding: 0;
}

.shop-close:hover {
    background: rgba(255,255,255,0.2);
}

.shop-upgrades {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.upgrade-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    background: rgba(34, 197, 94, 0.15);
    border: 2px solid #22c55e;
    border-radius: 14px;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: background 0.2s, transform 0.1s;
}

.upgrade-btn:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.25);
}

.upgrade-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.upgrade-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.upgrade-title {
    font-weight: bold;
    font-size: 16px;
    color: #22c55e;
}

.upgrade-desc {
    opacity: 0.85;
}

.upgrade-level, .upgrade-cost {
    font-size: 13px;
    opacity: 0.9;
}

.shop-skins {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(34, 197, 94, 0.3);
}

.shop-skins h3 {
    color: #22c55e;
    font-size: 16px;
    margin-bottom: 10px;
}

.wheel-skin-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wheel-skin-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.12);
    border: 2px solid rgba(34, 197, 94, 0.5);
    border-radius: 10px;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, border-color 0.2s;
}

.wheel-skin-btn:hover:not(.locked) {
    background: rgba(34, 197, 94, 0.25);
}

.wheel-skin-btn.selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.3);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.wheel-skin-btn.locked {
    opacity: 0.6;
    cursor: default;
    border-color: rgba(255,255,255,0.2);
}

.wheel-skin-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
}

.lobby-case-result {
    font-size: 14px;
    color: #a5d6a7;
    margin: 8px 0;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 10px;
}

.world-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.btn-world {
    margin: 0;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.btn-world:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.btn-world.selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.25);
}

.btn-world:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lobby-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
}

.lobby-buttons .btn {
    margin: 0;
}

.btn-skins {
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid #22c55e;
}

.btn-skins:hover {
    background: rgba(34, 197, 94, 0.35);
}

.skin-picker-modal {
    position: absolute;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

.skin-picker-modal.hidden {
    display: none !important;
}

.skin-picker-inner {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #22c55e;
    border-radius: 16px;
    padding: 20px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.skin-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.skin-picker-header h2 {
    margin: 0;
    color: #22c55e;
    font-size: 22px;
}

.admin-trigger {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 25;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.5);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-trigger:hover {
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.7);
}

.admin-panel {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
}

.admin-panel.hidden {
    display: none !important;
}

.admin-panel-inner {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #64748b;
    border-radius: 14px;
    padding: 20px;
    min-width: 260px;
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.admin-panel-header h2 {
    margin: 0;
    color: #94a3b8;
    font-size: 18px;
}

.admin-panel-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-row label {
    min-width: 50px;
    color: #e2e8f0;
    font-size: 14px;
}

.admin-row input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #fff;
    font-size: 14px;
}

.admin-btn {
    padding: 8px 14px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: #334155;
    color: #e2e8f0;
    font-size: 13px;
    cursor: pointer;
}

.admin-btn:hover {
    background: #475569;
}

.admin-btn-block {
    width: 100%;
}

#controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    pointer-events: auto;
    z-index: 20;
}

.steer-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.1s;
    font-weight: bold;
}

.steer-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.screen.hidden {
    display: none;
}

#lobbyScreen {
    background: transparent;
    backdrop-filter: none;
    justify-content: flex-end;
    padding-bottom: 120px;
    pointer-events: none;
}

#lobbyScreen * {
    pointer-events: auto;
}

#lobbyScreen h2,
#lobbyScreen p {
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    color: #fff;
}

#lobbyScreen h2 {
    color: #64c8ff;
}

.screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(100, 200, 255, 0.5);
    color: #64c8ff;
}

.screen h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #ff6b6b;
}

.screen p {
    font-size: 18px;
    margin-bottom: 30px;
    opacity: 0.8;
    text-align: center;
    padding: 0 20px;
}

.btn {
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(135deg, #64c8ff, #4a90e2);
    border: none;
    border-radius: 30px;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(100, 200, 255, 0.4);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:active {
    transform: scale(0.95);
}

.instructions {
    margin-top: 40px;
    font-size: 16px;
    opacity: 0.7;
}

.instructions p {
    margin: 10px 0;
    font-size: 16px;
}

#finalScore {
    font-size: 28px;
    margin-bottom: 30px;
    color: #64c8ff;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .steer-btn {
        width: 70px;
        height: 70px;
        font-size: 30px;
    }
    
    .screen h1 {
        font-size: 36px;
    }
    
    .screen h2 {
        font-size: 28px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #scoreDisplay {
        top: 10px;
    }
    
    #score {
        font-size: 24px;
    }
    
    #controls {
        bottom: 15px;
    }
    
    .steer-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}
