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

body {
    background: #848485;
    font-family: Roboto, "Open Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    color: #111827;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    position: relative;
}


 .game-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    padding: 16px 16px 24px;
}

h1 {
    margin-bottom: 12px;
    font-size: 24px;
    font-weight: 600;
}

p {
    margin-bottom: 24px;
    color: #4b5563;
}

.intersection-container {
    position: relative;
    width: 600px;
    height: 600px;
    background: #6b7280;
    margin: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    overflow: hidden;
}

@media (max-width: 1200px) {
    .intersection-container { transform: scale(0.95); transform-origin: top left; }
}
@media (max-width: 1080px) {
    .intersection-container { transform: scale(0.9); transform-origin: top left; }
}
@media (max-width: 980px) {
    .game-layout { flex-direction: column; align-items: center; gap: 16px; }
    .control-panel { width: 100%; max-width: 600px; }
    .intersection-container { transform: scale(1); transform-origin: top center; }
}


#pauseBtn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 50;
    padding: 8px 12px;
    font-size: 14px;
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

#pauseBtn[aria-pressed="true"] {
    background: #fecaca;
}

.score-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 50;
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
    min-width: 120px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    backdrop-filter: blur(4px) saturate(120%);
}

.score-label {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
    text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.score-value {
    font-size: 28px;
    font-weight: 800;
    color: #f8fafc; 
    text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.score-change {
    animation: scoreChange 0.3s ease-out;
}

@keyframes scoreChange {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.streak-indicator {
    font-size: 11px;
    color: #92400e;
    margin-top: 4px;
    font-weight: 600;
}

.bonus-indicator {
    position: fixed;
    top: 100px;
    right: 16px;
    z-index: 51;
    background: #fef9c3;
    color: #92400e;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    border: 1px solid #f4ab2c;
}

.bonus-appear {
    animation: bonusAppear 1.5s ease-out;
}

@keyframes bonusAppear {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translateY(0) scale(1.1);
    }
    80% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
}

.game-over-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.game-over-content {
    background: #4b5563;
    color: #f8fafc;
    width: 420px;
    height: 420px;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
    border-radius: 6px;
    padding: 28px;
    text-align: center;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    border: 6px solid transparent;
    background-clip: padding-box;
}

.game-over-content::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 10px;
    background: repeating-linear-gradient(45deg, #111827 0 8px, rgba(255,255,255,0) 8px 16px);
    z-index: -1;
}

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

.game-over-content h2 {
    font-size: 22px;
    color: #991b1b;
    margin: 0 0 8px 0;
    letter-spacing: 0.3px;
}

.game-over-message {
    font-size: 14px;
    color: #e0e2e6;
    margin-bottom: 10px;
}

.game-over-response {
    font-size: 17px;
    color: #bdc0c7;
    font-style: oblique;
    margin: 10px 0 16px 0;
    padding: 0;
    background: transparent;
    border-left: none;
    border-radius: 0;
}

.final-score-container {
    background: #4b5563;
    color: #f8fafc;
    width: 160px;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    position: relative;
    border: 4px solid transparent;
    background-clip: padding-box;
}

.final-score-container::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 10px;
    background: repeating-linear-gradient(45deg, #111827 0 6px, rgba(255,255,255,0) 6px 12px);
    z-index: -1;
}

.final-score-label {
    display: block;
    font-size: 12px;
    color: #9bb9fd;
    text-decoration: dotted;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.final-score-value {
    font-size: 32px;
    font-weight: 700;
    color: #dddddd;
}

.restart-btn {
    background: #111827;
    color: #fff;
    border: 1px solid #111827;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}

.crash-alert {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: opacity 0.2s ease-in-out;
}

.road {
    position: absolute;
    background: #4b5563;
}

.road.horizontal {
    width: 600px;
    height: 120px;
    top: 240px;
    left: 0;
    border-top: 2px dashed #e5e7eb;
    border-bottom: 2px dashed #e5e7eb;
}

.road.vertical {
    width: 120px;
    height: 600px;
    left: 240px;
    top: 0;
    border-left: 2px dashed #e5e7eb;
    border-right: 2px dashed #e5e7eb;
}

.road.horizontal::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    background-image: repeating-linear-gradient(90deg, rgba(229,231,235,0.5) 0 8px, transparent 8px 16px);
}

.road.vertical::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    background-image: repeating-linear-gradient(0deg, rgba(229,231,235,0.5) 0 8px, transparent 8px 16px);
}

.intersection {
    position: absolute;
    width: 120px;
    height: 120px;
    top: 240px;
    left: 240px;
    background: #6b7280;
    border: 1px solid #d1d5db;
}

.traffic-light {
    position: absolute;
    width: 30px;
    height: 50px;
    background: #111827;
    border: 1px solid #111827;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.traffic-light .light {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #16a34a;
}

.traffic-light.red .light {
    background: #dc2626;
}

.traffic-light.north {
    top: 210px;
    left: 285px;
}

.traffic-light.south {
    top: 340px;
    left: 285px;
}

.traffic-light.east {
    top: 275px;
    left: 370px;
}

.traffic-light.west {
    top: 275px;
    left: 200px;
}

.car {
    position: absolute;
    width: 40px;
    height: 25px;
    border-radius: 3px;
    transition: opacity 0.2s linear;
    z-index: 5;
    pointer-events: none;
}

.car::before { display: none; }

.dialogue-box {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.dialogue-content {
    background: #f3f4f6;
    color: #111827;
    padding: 24px;
    border-radius: 8px;
    text-align: left;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
    max-width: 540px;
    border: 1px solid #d1d5db;
}

.dialogue-content h2 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #111827;
}

.dialogue-content p {
    font-size: 14px;
    margin-bottom: 12px;
}

.dialogue-content ol {
    text-align: left;
    margin-bottom: 16px;
    padding-left: 18px;
}

.dialogue-content li {
    margin-bottom: 8px;
}

.start-game-btn {
    background: #111827;
    color: white;
    border: 1px solid #111827;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.dialogue-box.fade-out {
    animation: fadeOut 0.5s ease forwards;
}


.game-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 980px) {
    .game-layout { flex-direction: column; align-items: center; }
}