:root {
  --bg: rgba(14, 18, 26, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f3f5f8;
  --muted: #aab3c0;
  --accent: #ffd54f;
  --green: #12a150;
  --ad: #3182f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9cc7ef; color: var(--text);
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', system-ui, sans-serif; }
#game canvas { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.tiny { color: var(--muted); font-size: 11px; margin: 10px 0 0; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20;
  background: rgba(8, 12, 20, 0.35); padding: 16px; }
.overlay.dim { background: rgba(5, 8, 14, 0.82); z-index: 30; }
.card { background: rgba(18, 22, 31, 0.92); border: 1px solid var(--line); border-radius: 18px; padding: 28px;
  width: min(440px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); backdrop-filter: blur(10px); }
.card h1 { margin: 6px 0 4px; font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.card h2 { margin: 0 0 12px; font-size: 22px; }
.card p { line-height: 1.55; margin: 6px 0; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 20px !important; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 1px; color: #111;
  background: var(--accent); padding: 3px 8px; border-radius: 6px; }

.field { display: block; font-size: 13px; color: var(--muted); margin: 14px 0; }
.field input { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font-size: 16px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text); font-family: inherit; }
#swatches { display: flex; gap: 8px; margin-top: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25); }
.swatch.on { border-color: #fff; transform: scale(1.12); }

.btn { display: block; width: 100%; margin-top: 10px; padding: 12px 14px; font-size: 15px; font-weight: 600;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); color: var(--text);
  cursor: pointer; font-family: inherit; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: transparent; }
.btn.ad { background: var(--ad); border-color: transparent; }
.btn.big { padding: 15px; font-size: 17px; margin-top: 18px; }

.keys { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 18px; font-size: 12px; color: var(--muted); }
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; margin-right: 2px; border-radius: 5px; font-size: 11px;
  text-align: center; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); color: var(--text); font-family: inherit; }

.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading .card { text-align: center; width: auto; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud .panel, #hud button, #hud input { pointer-events: auto; }
.panel { position: absolute; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  backdrop-filter: blur(8px); }
.tl { top: 14px; left: 14px; min-width: 250px; max-width: 340px; }
.objective { font-size: 13px; font-weight: 600; color: #b9f6ca; margin-bottom: 6px; line-height: 1.4; }
.tl .row { display: flex; gap: 10px; align-items: baseline; font-size: 14px; margin: 3px 0; }
.lbl { color: var(--muted); font-size: 12px; width: 70px; flex: none; }
.route { color: var(--accent); font-size: 12px; margin-left: auto; }
.tr { top: 14px; right: 14px; text-align: right; }
.money { font-size: 22px; font-weight: 800; color: var(--accent); }

.dash { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; align-items: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 10px 20px; backdrop-filter: blur(8px); }
.speed { font-size: 44px; font-weight: 800; line-height: 1; min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.speed small { font-size: 13px; color: var(--muted); margin-left: 4px; font-weight: 600; }
.fuel { width: 200px; }
.fuelHead { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.fuelTrack { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
#fuelBar { height: 100%; background: linear-gradient(90deg, #ffb300, #ffd54f); border-radius: 6px; transition: width 0.3s; }
#fuelBar.low { background: #ff5252; animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

#minimap { position: absolute; right: 14px; bottom: 18px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; }

#chat { position: absolute; left: 14px; bottom: 18px; width: 320px; }
#chatLog { font-size: 13px; margin-bottom: 6px; }
.chatLine { background: rgba(10, 14, 22, 0.6); padding: 4px 9px; border-radius: 8px; margin-top: 4px; width: fit-content;
  max-width: 100%; transition: opacity 1s; word-break: break-all; }
.chatLine.sys { color: var(--muted); font-style: italic; }
.chatLine.fade { opacity: 0; }
#chatInput { width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(10, 14, 22, 0.6);
  color: var(--text); font-size: 13px; font-family: inherit; }
#chatInput:focus { outline: 2px solid var(--accent); }

#toasts { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column;
  align-items: center; gap: 6px; }
.toast { background: rgba(10, 14, 22, 0.82); border: 1px solid var(--line); padding: 9px 16px; border-radius: 999px;
  font-size: 14px; animation: pop 0.25s ease-out; white-space: nowrap; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

.fuelPanel { right: 14px; top: 50%; transform: translateY(-60%); width: 330px; }
.fuelPanel h3 { margin: 0 0 4px; }
.fuelPanel p { margin: 0 0 4px; color: var(--muted); font-size: 13px; }

/* 광고 */
.adCard { text-align: center; }
.adTag { font-size: 11px; font-weight: 800; letter-spacing: 0.5px; color: #111; background: var(--accent);
  display: inline-block; padding: 3px 8px; border-radius: 6px; }
.adCreative { margin: 16px 0; padding: 30px 16px; border-radius: 14px; border: 2px dashed rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, rgba(49, 130, 246, 0.25), rgba(255, 213, 79, 0.15)); }
.adIcon { font-size: 52px; }
.adTitle { font-size: 22px; font-weight: 800; margin-top: 6px; }
.adCopy { color: var(--muted); margin-top: 4px; }
.adTrack { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-bottom: 10px; }
#adProgress { height: 100%; width: 0; background: var(--ad); }

#modalBody p { color: #d7dde6; }

@media (max-width: 720px) {
  .tl { min-width: 0; font-size: 12px; }
  #chat { width: 200px; bottom: 120px; }
  #minimap { width: 120px; height: 152px; }
  .dash { bottom: 10px; padding: 8px 14px; }
  .fuel { width: 120px; }
}

#damage.bad { color: #ff8a80; font-weight: 600; }
.viewBtn { position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer; }
.viewBtn:hover { background: rgba(30, 36, 48, 0.9); }
.prompt { position: absolute; bottom: 132px; left: 50%; transform: translateX(-50%); background: rgba(10, 14, 22, 0.82);
  border: 1px solid var(--accent); color: var(--accent); padding: 9px 18px; border-radius: 12px; font-weight: 600; font-size: 15px; white-space: nowrap; }

.driver { top: 130px; right: 14px; width: 230px; padding: 10px 12px; }
.dTitle { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.st { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 5px 0; }
.st span { width: 70px; flex: none; }
.st b { width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.sTrack { flex: 1; height: 8px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.sTrack div { height: 100%; width: 50%; background: #66bb6a; border-radius: 5px; transition: width 0.3s; }
.sTrack div.inv { background: #ffb74d; }
.sTrack div.bad { background: #ff5252; animation: blink 0.9s infinite; }
.mapBtn { position: absolute; right: 14px; bottom: 278px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 12px; cursor: pointer; }
.mapCard { width: auto; max-width: 96vw; text-align: center; padding: 18px; }
.mapCard h2 { font-size: 18px; margin-bottom: 8px; }
#bigMapCanvas { max-width: 100%; max-height: 78vh; border-radius: 10px; }
#blink { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 5; }
#fade { position: fixed; inset: 0; background: #05070b; opacity: 0; pointer-events: none; transition: opacity 0.5s; z-index: 40;
  display: flex; align-items: center; justify-content: center; }
#fade.on { opacity: 0.94; pointer-events: auto; }
#fade p { color: #fff; font-size: 22px; font-weight: 700; }
.tl { max-width: 380px; }

.vehicle { top: 252px; right: 14px; width: 230px; padding: 10px 12px; }
.sTrack div.eng { background: linear-gradient(90deg, #42a5f5, #ab47bc); }
.vInfo { font-size: 11px; color: var(--muted); margin-top: 4px; }
.btn.tune { background: linear-gradient(90deg, #6a1b9a, #c2185b); border-color: transparent; }
.mapBtn { bottom: 278px; }
.fuelPanel { left: 14px; right: auto; top: 200px; transform: none; }

#fade.sleep { opacity: 0.55; pointer-events: none; }

.card.start { position: relative; }
.card.start h1 { margin-top: 18px; }
.startTools { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; align-items: center; }
.startSound { width: 30px; height: 28px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 13px; cursor: pointer; }
.engineHint { position: absolute; bottom: 186px; left: 50%; transform: translateX(-50%); padding: 9px 16px; border-radius: 999px; white-space: nowrap;
  background: rgba(255, 179, 0, 0.92); color: #1a1a1a; font-weight: 800; font-size: 15px; animation: blink 1.4s infinite; pointer-events: none; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button { background: transparent; color: var(--muted); border: 0; padding: 5px 11px; font: 600 12px inherit; font-family: inherit; cursor: pointer; }
.lang button.on { background: rgba(255, 255, 255, 0.14); color: var(--text); }
.st span { width: 84px; white-space: nowrap; }

/* 내비게이션 */
.navDev { top: 200px; left: 14px; width: 324px; padding: 10px; }
.navTop { display: flex; gap: 10px; align-items: center; }
.navIcon { width: 54px; height: 54px; flex: none; border-radius: 12px; background: #18a058; color: #fff; font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; }
.navIcon.soon { background: #f57c00; animation: blink 0.9s infinite; }
.navDist { font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.navText { font-size: 13px; color: #d7dde6; line-height: 1.3; margin-top: 2px; }
.navLane { margin-top: 8px; padding: 5px 9px; border-radius: 8px; background: rgba(245, 124, 0, 0.18); color: #ffcc80; font-size: 12px; font-weight: 700; }
#navMap { display: block; width: 100%; height: auto; margin-top: 8px; border-radius: 10px; background: #1d2633; }
.navBottom { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.fuelPanel { top: 200px; z-index: 2; }
.card.start h1 { font-size: 26px; padding-right: 0; margin-top: 34px; line-height: 1.25; }

.soundBtn { position: absolute; right: 14px; bottom: 318px; width: 40px; height: 34px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 16px; cursor: pointer; }
.soundPanel { right: 64px; bottom: 278px; width: 280px; z-index: 3; }
.spHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.spClose { background: transparent; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; }
.vol { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 8px 0; }
.vol span { width: 92px; flex: none; color: #d7dde6; }
.vol input { flex: 1; accent-color: #18a058; }
.vol b { width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
