@font-face { font-family: system-fallback; src: local('Arial'); }
:root { color-scheme: dark; --ink: #eef5f1; --muted: #9bb7b6; --panel: #122830; --accent: #e96c55; --teal: #87d0c2; }
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #183b31; }
body { font-family: Inter, 'Segoe UI', Arial, sans-serif; overscroll-behavior: none; color: var(--ink); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #a6e5da; outline-offset: 3px; }
#app, #game-container { position: relative; width: 100%; height: 100%; height: 100dvh; }
canvas { display: block; touch-action: none; }
.game-overlay { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.game-overlay button { pointer-events: auto; }
.menu-screen, .ranking-screen, .result-screen { display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(90deg, #071c26d9, #071c2694); }
.menu-panel, .ranking-panel, .result-panel { pointer-events: auto; background: linear-gradient(145deg, #17333bee, #0c212af5); border: 1px solid #badbd52e; border-radius: 24px; box-shadow: 0 25px 80px #07161b80; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px 32px; scrollbar-width: thin; }
.menu-panel { width: min(730px, 100%); }
.eyebrow { display: block; color: var(--teal); font-weight: 700; font-size: 11px; letter-spacing: 3px; }
h1 { font-size: clamp(25px, 3vw, 36px); font-weight: 900; line-height: 1.03; letter-spacing: -.9px; margin: 9px 0; }
h1 span { color: #abdcd1; }
p { color: var(--muted); font-size: 13px; line-height: 1.4; }
header { position: relative; min-height: 116px; padding-right: 84px; }
header p { margin: 10px 0 15px; }
.menu-ambulance { position: absolute; right: 0; top: -8px; width: 70px; height: 132px; object-fit: contain; filter: drop-shadow(4px 8px 5px #06131c80); }
.selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 15px 0 12px; }
h2 { font-size: 14px; margin: 0; }
.record-pill { font-size: 10px; border: 1px solid #c6ded52b; color: #c4dcd6; padding: 6px 10px; border-radius: 20px; white-space: nowrap; }
.record-owner { display: block; color: #c5ded4; font-size: 11px; font-weight: 600; letter-spacing: 0; line-height: 1.2; overflow-wrap: anywhere; }
.record-pill .record-owner { margin-top: 3px; font-size: 10px; text-align: right; }
.result-stats .record-owner { max-width: 115px; margin: 3px auto 0; font-size: 10px; }
.hud-record .record-owner { font-size: 11px; }
.driver-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.master-heading { display: flex; align-items: center; gap: 12px; margin: 15px 0 10px; color: #e6c98f; }
.master-heading span { font-size: 11px; color: var(--muted); }
.master-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.master-grid .driver-card { border-color: #cead6a55; }
.driver-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px; color: var(--ink); background: #ffffff05; border: 1px solid #c7ddd225; border-radius: 14px; transition: border-color .15s, background .15s, transform .15s; }
.driver-card:hover { background: #ffffff0b; transform: translateY(-2px); }
.portrait { width: 56px; height: 56px; flex-shrink: 0; }
.driver-card strong { font-size: 13px; }
.driver-card small { font-size: 9px; color: #8fb1af; letter-spacing: 1px; }
.driver-card.selected { border-color: var(--teal); background: #75c9b91a; box-shadow: inset 0 0 0 1px #75c9b970; }
.check { display: none; position: absolute; top: 7px; right: 8px; font-style: normal; color: #a6e5da; }
.selected .check { display: block; }
.driver-description { min-height: 19px; font-size: 11px; margin: 12px 0; }
.menu-actions { display: flex; gap: 10px; }
.primary, .secondary { min-height: 46px; border-radius: 10px; border: 1px solid transparent; font-weight: 800; font-size: 12px; letter-spacing: 1px; padding: 12px 18px; }
.primary { color: #fff; background: linear-gradient(120deg, #df6452, #ed8763); flex: 1; box-shadow: 0 5px 18px #d7634823; }
.primary span { float: right; }
.primary:disabled { opacity: .35; cursor: default; box-shadow: none; }
.secondary { color: #d5e9e1; border-color: #c1dcd133; background: #ffffff06; }
.primary:not(:disabled):hover, .secondary:hover { filter: brightness(1.12); }
footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 15px; }
footer p { font-size: 10px; text-align: right; margin: 0; }
.sound-controls { display: flex; gap: 6px; }
.mini-button { color: #a9c9c2; border: 1px solid #d0e7df2c; background: #132b33da; border-radius: 8px; padding: 8px 9px; font-size: 9px; font-weight: 700; letter-spacing: .5px; min-height: 32px; }
.mini-button[aria-pressed=true] { color: #b4eade; border-color: #82c6b765; }
.ranking-panel { width: min(530px, 100%); }
.ranking-list { margin: 20px 0; display: flex; flex-direction: column; gap: 6px; max-height: 53dvh; overflow-y: auto; }
.ranking-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; background: #ffffff05; }
.ranking-row .portrait { width: 36px; height: 36px; }
.rank-position { font-size: 13px; color: #91b2b1; }
.ranking-row strong { font-size: 13px; flex: 1; }
.ranking-row small { font-size: 9px; color: var(--muted); }
.ranking-row b { text-align: right; font-size: 18px; min-width: 45px; }
.ranking-row b span { display: block; font-size: 8px; color: var(--muted); }
.ranking-row.leader { background: #e4bc6615; border: 1px solid #dfc48045; }
.ranking-panel > .primary { width: 100%; }
.result-panel { width: min(470px, 100%); text-align: center; }
.result-driver { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.result-driver .portrait { width: 48px; height: 48px; }
.final-score { font-size: 70px; font-weight: 900; letter-spacing: -3px; line-height: 1.1; margin: 18px 0; }
.final-score span { display: block; font-size: 11px; letter-spacing: 4px; color: var(--muted); }
.new-record { color: #f0cf8d; margin-top: 20px; font-size: 12px; letter-spacing: 2px; }
.result-stats { display: flex; justify-content: space-around; padding: 15px 0; border-top: 1px solid #a1c6be22; border-bottom: 1px solid #a1c6be22; margin-bottom: 20px; }
.result-stats span { display: block; font-size: 9px; letter-spacing: 1px; color: var(--muted); }
.result-stats b { font-size: 23px; }
.result-panel > .primary { width: 100%; margin-bottom: 9px; }
.result-panel .menu-actions { justify-content: center; }
.result-panel .secondary { font-size: 9px; flex: 1; }
.result-panel .sound-controls { justify-content: center; margin-top: 20px; }
.hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: minmax(130px, 1fr) 72px 110px 94px 90px; gap: 12px; align-items: center; width: min(780px, calc(100% - 24px)); padding: 10px 16px; border-radius: 13px; background: #102630ec; border: 1px solid #b1d9cd28; box-shadow: 0 6px 25px #10252e33; }
.hud small { display: block; font-size: 9px; letter-spacing: 1px; color: #99bcb7; }
.hud b { font-size: 24px; }
.hud-driver { display: flex; align-items: center; gap: 10px; }
.hud-driver .portrait { width: 38px; height: 38px; }
.hud-driver b { font-size: 15px; white-space: nowrap; }
.speedometer { border-left: 1px solid #b1d9cd33; padding-left: 18px; }
.speedometer b { color: #e0c7a3; font-variant-numeric: tabular-nums; }
.speedometer small { font-size: 8px; letter-spacing: 0; }
.speedometer span { margin-left: 5px; }
.play-screen > .sound-controls { position: absolute; top: 88px; right: 12px; }
.touch-controls { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 22px; }
.touch-controls button { width: 104px; height: 82px; border-radius: 20px; border: 1px solid #d8ece370; background: #132b3480; color: #eefaf4; touch-action: none; user-select: none; box-shadow: inset 0 1px 0 #ffffff20; }
.touch-controls span { font-size: 53px; line-height: 1; }
.touch-controls .held { background: #7cbdad80; transform: scale(.96); }
.phase-notice { position: absolute; top: 100px; left: 20px; padding: 12px 18px; border-left: 3px solid #deba7b; border-radius: 8px; background: #18323aeb; opacity: 0; }
.phase-notice strong { display: block; font-size: 18px; letter-spacing: 2px; }
.phase-notice span { font-size: 11px; color: #c9d9cc; }
.phase-notice.show { animation: phase-feedback 2.2s ease both; }
.point-notice { position: absolute; bottom: 18%; left: 50%; color: #b2f0cd; font-size: 24px; font-weight: 800; opacity: 0; }
.point-notice.show { animation: point-feedback .7s ease-out; }
.crashed { animation: collision .35s ease-out; }
@keyframes phase-feedback { 0% { opacity: 0; transform: translateX(-12px); } 15%, 75% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; } }
@keyframes point-feedback { 0% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -35px); } }
@keyframes collision { 0% { background: #e4825930; } 100% { background: transparent; } }
@media (max-width: 600px) and (orientation: portrait) {
 .menu-screen, .ranking-screen, .result-screen { padding: 12px; }
 .menu-panel, .ranking-panel, .result-panel { padding: 20px; max-height: calc(100dvh - 24px); border-radius: 18px; }
 .driver-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
 .driver-card { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 10px 5px; column-gap: 8px; }
 .driver-card .portrait { width: 39px; height: 39px; }
 .driver-card strong { font-size: 12px; }
 .driver-card small { width: 100%; font-size: 8px; }
 .selection-heading h2 { font-size: 12px; }
 .record-pill { font-size: 8px; padding: 5px 7px; }
 footer { flex-direction: column; } footer p { text-align: center; }
 .hud { grid-template-columns: 1fr 1fr 1fr; gap: 5px 8px; padding: 7px 9px; width: calc(100% - 16px); }
 .hud-driver { grid-column: span 2; } .hud-score { grid-column: 3; grid-row: 1; text-align: right; }
 .hud-record { grid-column: 1; grid-row: 2; } .hud-personal { grid-column: 2; grid-row: 2; } .speedometer { grid-column: 3; grid-row: 2; text-align: right; }
 .hud-driver { gap: 6px; } .hud-driver .portrait { width: 30px; height: 30px; }
 .hud-driver b { font-size: 11px; } .hud small { font-size: 7px; letter-spacing: .2px; } .hud b { font-size: 21px; } .hud-driver b { font-size: 11px; }
 .speedometer { padding-left: 6px; } .speedometer small { font-size: 7px; } .speedometer span { margin: 0; display: block; }
 .play-screen > .sound-controls { top: 128px; }
 .phase-notice { top: auto; bottom: 108px; left: 12px; right: auto; padding: 5px 9px; display: flex; justify-content: center; gap: 5px; align-items: center; }
 .phase-notice strong { font-size: 13px; } .phase-notice span { font-size: 9px; }
 .touch-controls { padding: 0 16px; } .touch-controls button { width: 94px; height: 76px; }
 .ranking-row { gap: 8px; padding: 7px; } .ranking-row strong { font-size: 12px; }
}
@media (max-height: 360px) {
 .hud { padding: 5px 10px; top: 5px; } .hud b { font-size: 18px; } .hud-driver b { font-size: 12px; } .hud-driver .portrait { width: 28px; height: 28px; }
 .play-screen > .sound-controls { top: 58px; }
}
@media (max-height: 560px) and (orientation: landscape) {
 .menu-panel { padding: 15px 24px; } .menu-panel header { min-height: 80px; } .menu-ambulance { height: 86px; width: 48px; top: 0; } .menu-panel header h1 { font-size: 25px; } .menu-panel header h1 br { display: none; }
 .menu-panel header p { margin: 6px 0; } .selection-heading { margin: 10px 0; }
 .driver-card { padding: 7px 4px; gap: 4px; } .driver-card .portrait { width: 38px; height: 38px; }
 .driver-description { margin: 8px 0; } footer { margin-top: 10px; }
 .ranking-list { max-height: 48dvh; } .result-panel { padding: 18px 25px; }
 .result-driver { margin-top: 10px; } .final-score { font-size: 48px; margin: 10px 0; }
 .touch-controls button { width: 90px; height: 65px; } .touch-controls { bottom: 12px; }
 .hud { padding: 7px 12px; top: 8px; } .play-screen > .sound-controls { top: 76px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .1s !important; transition: none !important; } }
