:root {
    /* Brand theme colors - dynamically updated by JavaScript */
    --brand-primary: #B22234;
    --brand-bg: linear-gradient(135deg, #3C3B6E 0%, #B22234 100%);
    --truck-doors: #B22234;
    --truck-accent: #F5F5F5;
    --truck-wheels: #3C3B6E;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--brand-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 900px;
    width: 100%;
    touch-action: manipulation;
}

.header {
    text-align: center;
    margin-bottom: 25px;
}

.header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* Customer company name (shown when a branded theme is active) */
.company-name {
    color: var(--brand-primary);
    font-size: 1.05em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.brand-selector {
    margin-top: 15px;
    font-size: 0.9em;
}

.brand-selector label {
    color: #666;
    margin-right: 8px;
}

.brand-selector select {
    padding: 5px 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    font-size: 0.95em;
}

.brand-selector select:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
}

.info-item {
    text-align: center;
}

.info-item .label {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.info-item .value {
    display: block;
    color: #333;
    font-size: 1.8em;
    font-weight: bold;
}

.game-area {
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: flex-start;
}

.truck-container {
    position: relative;
}

#gameCanvas {
    border: 4px solid #333;
    border-radius: 8px;
    background: #f0f0f0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    touch-action: none;
}

.next-piece-container {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #ddd;
    text-align: center;
    min-width: 150px;
}

.next-piece-container h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

#nextPieceCanvas {
    background: white;
    border: 2px solid #ddd;
    border-radius: 5px;
}

.controls {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #ddd;
    min-width: 150px;
}

.controls h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.controls ul {
    list-style: none;
}

.controls li {
    color: #666;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.controls strong {
    color: #333;
}

.message {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    text-align: center;
    border-radius: 10px;
    font-size: 1.2em;
    font-weight: bold;
    display: none;
    animation: slideIn 0.5s ease;
}

.message strong {
    display: block;
    font-size: 1.4em;
    margin-bottom: 10px;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Touch Controls */
.mobile-controls {
    display: none;
    margin-top: 20px;
    text-align: center;
}

.control-btn {
    background: var(--brand-bg);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 25px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.direction-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

/* Responsive design */
@media (max-width: 768px) {
    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .header h1 {
        font-size: 2em;
    }

    #gameCanvas {
        width: 100%;
        max-width: 400px;
        height: auto;
    }

    .controls {
        display: none;
    }

    .mobile-controls {
        display: block;
    }

    .next-piece-container {
        width: 100%;
        max-width: 400px;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}

/* Truck cab decoration (visual enhancement) */
.truck-container::before {
    content: '';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 20px;
    background: #333;
    border-radius: 5px 5px 0 0;
    border: 3px solid #333;
}

.truck-container::after {
    content: '🚚';
    position: absolute;
    top: -55px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2em;
}


/* Game Over Overlay Styles */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-over-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.game-over-box h2 {
    font-size: 32px;
    margin-bottom: 20px;
    color: #2c5f7c;
}

.game-over-box .stats {
    font-size: 18px;
    margin: 20px 0;
    color: #333;
}

.game-over-box .cta-message {
    font-size: 16px;
    margin: 20px 0;
    color: #555;
    line-height: 1.6;
}

.replay-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s;
}

.replay-btn:hover {
    transform: scale(1.05);
}

/* Countdown Overlay */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.countdown-number {
    font-size: 120px;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    animation: countdown-pulse 1s ease-in-out;
}

.countdown-overlay.banner-mode {
    background: transparent;
    pointer-events: none;
}

.countdown-overlay.banner-mode .countdown-number {
    font-size: 56px;
    text-shadow: 0 0 24px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 255, 255, 0.6);
}

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


/* Pack mode toggle (DIY vs Movers) */
.mode-selector {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.mode-label {
    color: #666;
    font-size: 0.9em;
}
.mode-btn {
    border: 2px solid #ddd;
    background: white;
    color: #333;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
}
.mode-btn.is-active {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: white;
}
body.pack-movers .mode-btn[data-mode="movers"] {
    border-color: #2e7d32;
    background: #2e7d32;
}

.damage-bill {
    text-align: left;
    margin: 16px 0;
    padding: 14px 16px;
    background: #fff6f2;
    border: 2px solid #e87722;
    border-radius: 10px;
}
.damage-bill h3 {
    font-size: 1em;
    color: #9a3412;
    margin-bottom: 8px;
}
.damage-bill.pros {
    background: #f1f8f2;
    border-color: #2e7d32;
}
.damage-bill.pros h3 {
    color: #1b5e20;
}
.damage-bill ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.damage-bill li {
    display: flex;
    justify-content: space-between;
    font-size: 0.95em;
    color: #333;
    padding: 3px 0;
}
.damage-total {
    margin-top: 8px;
    font-weight: 800;
    font-size: 1.15em;
    color: #9a3412;
}
.damage-bill.pros .damage-total {
    color: #1b5e20;
}
#damageMeterWrap .value {
    color: #c2410c;
}
body.pack-movers #damageMeterWrap .value {
    color: #2e7d32;
}
