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

@font-face {
    font-family: 'PixelFont';
    src: local('Courier New');
}

body {
    background: #1a1a2e;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background: #1a1a2e;
}

#game-wrapper {
    position: relative;
    flex-shrink: 0;
}

#gameCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 10;
}

#stats-bar {
    position: relative;
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    pointer-events: auto;
    z-index: 200;
}

.stat {
    font-size: 18px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    padding: 5px 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 5px;
}

#money-stat { color: #ffd700; }
#lives-stat { color: #e74c3c; }
#gas-stat { color: #2ecc71; }
#sound-stat { padding: 0; background: none; pointer-events: auto; }
#game-sound-btn {
    background: rgba(0,0,0,0.5);
    border: none;
    pointer-events: auto;
    cursor: pointer;
    color: #fff;
    font-size: 16px;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
}

#mission-display {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    padding: 8px 16px;
    border-radius: 20px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#mission-display:not(.hidden) {
    opacity: 1;
}

#mission-text {
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
}

#mission-reward {
    display: none;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.95);
    z-index: 100;
    padding: 20px;
    text-align: center;
}

.screen.hidden {
    display: none;
}

#score-submitted.hidden,
#submit-score-section.hidden {
    display: none;
}

.screen h1 {
    font-size: 48px;
    color: #ff9f43;
    text-shadow: 4px 4px 0 #e55039;
    margin-bottom: 10px;
}

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

.screen p {
    color: #ccc;
    margin-bottom: 10px;
    font-size: 14px;
}

.tagline {
    font-style: italic;
    color: #ff9f43 !important;
    font-size: 18px !important;
    margin-bottom: 30px !important;
}

/* Buttons */
.pixel-btn {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    padding: 15px 40px;
    margin: 10px;
    background: #ff9f43;
    color: #1a1a2e;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    box-shadow: 0 4px 0 #e55039;
    transition: all 0.1s;
}

.pixel-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #e55039;
}

.pixel-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.pixel-btn.secondary {
    background: #576574;
    box-shadow: 0 4px 0 #2d3436;
}

.pixel-btn.secondary:hover {
    box-shadow: 0 2px 0 #2d3436;
}

/* Instructions */
.instructions {
    background: rgba(0,0,0,0.5);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    max-width: 400px;
}

.instructions p {
    margin: 10px 0;
    text-align: left;
}

/* Shop */
#shop-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    max-width: 600px;
    max-height: 50vh;
    overflow-y: auto;
}

.shop-item {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 8px;
    width: 150px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.shop-item:hover {
    border-color: #ff9f43;
    background: rgba(255,159,67,0.2);
}

.shop-item.owned {
    border-color: #2ed573;
    opacity: 0.7;
}

.shop-item.equipped {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255,215,0,0.5);
}

.shop-item h3 {
    color: #fff;
    font-size: 14px;
    margin-bottom: 5px;
}

.shop-item p {
    font-size: 11px;
    margin: 3px 0;
}

.shop-item .price {
    color: #ffd700;
    font-weight: bold;
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    height: calc(120px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    pointer-events: none;
    z-index: 50;
    background: linear-gradient(to top, rgba(26, 26, 46, 0.8) 0%, transparent 100%);
}

.control-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: rgba(255,255,255,0.2);
    pointer-events: auto;
    transition: background 0.1s;
}

.control-zone:active {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
}

#control-left {
    padding-left: 30px;
}

#control-right {
    padding-right: 30px;
}

/* Hide mobile controls on desktop */
@media (hover: hover) and (pointer: fine) {
    #mobile-controls {
        display: none;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .screen h1 {
        font-size: 36px;
    }
    
    .screen h2 {
        font-size: 20px;
    }
    
    .pixel-btn {
        padding: 12px 30px;
        font-size: 16px;
    }
    
    .stat {
        font-size: 14px;
    }
    
    #mission-text {
        font-size: 12px;
    }
    
    .shop-item {
        width: 120px;
        padding: 10px;
    }
}


/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mission list styling */
.mission-item {
    background: #333;
    padding: 8px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
}

.mission-item:hover {
    border-color: #ff9f43;
}

.mission-item.urgent {
    border-color: #e74c3c;
    animation: pulse 1s infinite;
}

/* Mission Modal */
.modal-box {
    background: linear-gradient(180deg, #2a2a4a 0%, #1a1a2e 100%);
    border: 3px solid #ff9f43;
    border-radius: 15px;
    padding: 25px;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 159, 67, 0.3);
}

#modal-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-icon canvas {
    image-rendering: pixelated;
}

.modal-client {
    color: #ff9f43;
    font-size: 14px;
    font-style: italic;
    margin-bottom: 15px;
}

.modal-desc {
    color: #ccc;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
    min-height: 60px;
}

.modal-details {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.modal-detail {
    display: flex;
    flex-direction: column;
}

.modal-detail .label {
    font-size: 10px;
    color: #888;
    margin-bottom: 5px;
}

.modal-detail .value {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

#decline-mission-btn {
    padding: 10px 25px;
    font-size: 14px;
}

#accept-mission-btn {
    padding: 12px 35px;
}

/* Crash modal styling */
.crash-box {
    background: linear-gradient(135deg, #ff4444, #cc0000) !important;
    animation: crashShake 0.5s ease-out;
}

@keyframes crashShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.crash-penalty {
    color: #ffcc00;
    font-weight: bold;
    margin-top: 10px;
}

.modal-title {
    color: #88ff88;
    font-size: 1.2em;
    margin-bottom: 5px;
}

/* Quiz modal styling */
.quiz-box {
    background: linear-gradient(135deg, #2c3e50, #1a252f) !important;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.quiz-answer-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid #3498db;
    color: #fff;
    padding: 12px 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    text-align: left;
}

.quiz-answer-btn:hover {
    background: rgba(52, 152, 219, 0.3);
    transform: translateX(5px);
}

.quiz-answer-btn:active {
    transform: scale(0.98);
}

#quiz-result-box.correct {
    background: linear-gradient(135deg, #27ae60, #1e8449) !important;
}

#quiz-result-box.wrong {
    background: linear-gradient(135deg, #c0392b, #922b21) !important;
}

/* Highscores */
#highscores-list {
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 20px;
    min-width: 300px;
    max-width: 400px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
}

.score-row:last-child {
    border-bottom: none;
}

.score-row.top-3 {
    background: rgba(255, 215, 0, 0.2);
}

.score-rank {
    width: 30px;
    color: #ffd700;
    font-weight: bold;
}

.score-name {
    flex: 1;
    color: #fff;
    text-align: left;
    margin-left: 10px;
}

.score-location {
    color: #888;
    font-size: 11px;
    margin-left: 5px;
}

.score-value {
    color: #2ecc71;
    font-weight: bold;
    min-width: 80px;
    text-align: right;
}

/* Submit score section */
#submit-score-section {
    margin: 15px 0;
}

#player-name {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 10px 15px;
    margin: 10px;
    background: rgba(255,255,255,0.1);
    border: 2px solid #ff9f43;
    border-radius: 5px;
    color: #fff;
    text-align: center;
    width: 200px;
}

#player-name::placeholder {
    color: #888;
}

#player-name:focus {
    outline: none;
    border-color: #ffd700;
    background: rgba(255,255,255,0.15);
}

#score-submitted {
    color: #2ecc71;
    font-weight: bold;
}

#your-rank {
    color: #ffd700;
    font-size: 1.2em;
}

/* Trivia Styles */
/* Trivia Modal - matches mission modal style */
.trivia-box {
    border-color: #9b59b6;
    box-shadow: 0 0 30px rgba(155, 89, 182, 0.3);
}

.trivia-box h2 {
    color: #9b59b6;
    margin-bottom: 5px;
}

#trivia-icon {
    font-size: 48px;
    margin-bottom: 10px;
    animation: triviaBounce 0.5s ease-in-out infinite alternate;
}

@keyframes triviaBounce {
    from { transform: scale(1) rotate(-5deg); }
    to { transform: scale(1.1) rotate(5deg); }
}

.trivia-question {
    font-size: 14px;
    color: #ccc;
    margin: 15px 0;
    line-height: 1.5;
    min-height: 40px;
}

.trivia-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.trivia-option {
    background: linear-gradient(180deg, #3d3d6b 0%, #2a2a4a 100%);
    border: 2px solid #9b59b6;
    border-radius: 8px;
    color: #ecf0f1;
    padding: 12px 15px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.trivia-option:hover {
    background: linear-gradient(180deg, #9b59b6 0%, #6b3fa0 100%);
    border-color: #bb79d6;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(155, 89, 182, 0.4);
}

.trivia-option:active {
    transform: translateY(0) scale(0.98);
}

.trivia-option.correct {
    background: linear-gradient(180deg, #27ae60 0%, #1e8449 100%);
    border-color: #2ecc71;
    animation: correctPulse 0.3s ease;
}

.trivia-option.wrong {
    background: linear-gradient(180deg, #c0392b 0%, #922b21 100%);
    border-color: #e74c3c;
    animation: wrongShake 0.3s ease;
}

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

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Trivia Result - matches mission complete style */
.trivia-result-box {
    text-align: center;
}

#trivia-result-icon {
    font-size: 64px;
    margin-bottom: 15px;
}

.trivia-result-box.correct {
    border-color: #27ae60;
    box-shadow: 0 0 30px rgba(39, 174, 96, 0.3);
}

.trivia-result-box.correct h2 {
    color: #2ecc71;
}

.trivia-result-box.wrong {
    border-color: #c0392b;
    box-shadow: 0 0 30px rgba(192, 57, 43, 0.3);
}

.trivia-result-box.wrong h2 {
    color: #e74c3c;
}

.trivia-tip {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.trivia-tip .label {
    font-size: 10px;
    color: #888;
    margin-right: 10px;
}

.trivia-tip .value {
    font-size: 18px;
    font-weight: bold;
    color: #2ecc71;
}

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