* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000;
  font-family: 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  color: #f2f4f8; user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.mono { font-family: 'Consolas', 'SF Mono', 'Menlo', monospace; font-variant-numeric: tabular-nums; }

.panel {
  background: rgba(10, 14, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* ── HUD ───────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; }

#timerPanel {
  position: absolute; top: 16px; right: 16px; width: 250px; padding: 14px 16px 16px;
}
.panel-title { font-size: 13px; letter-spacing: .08em; color: #9fb0c8; text-transform: uppercase; }
#stopwatch { display: block; width: 150px; height: 150px; margin: 8px auto 4px; }
#timeNow { font-size: 38px; font-weight: 700; text-align: center; letter-spacing: .02em; }
.row { display: flex; justify-content: space-between; font-size: 14px; color: #c7d2e2; margin-top: 4px; }
.row b { color: #fff; font-weight: 600; }
#sectors { margin-top: 10px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; }
.sector { display: grid; grid-template-columns: 28px 1fr 70px; font-size: 13px; padding: 2px 0; color: #9fb0c8; }
.sector .t { color: #e6ecf5; text-align: right; }
.sector .d { text-align: right; }
.faster { color: #3ddc84 !important; }
.slower { color: #ff5c5c !important; }
#minimap { display: block; margin: 12px auto 0; width: 110px; height: 110px; }

#speedPanel {
  position: absolute; left: 16px; bottom: 16px; width: 210px; padding: 12px 16px 14px;
  display: grid; grid-template-columns: 52px 1fr; align-items: end; gap: 4px 10px;
}
#gear {
  grid-row: span 2; font-size: 44px; font-weight: 800; text-align: center;
  border: 2px solid rgba(255,255,255,.25); border-radius: 10px; line-height: 58px;
}
#speed { font-size: 44px; font-weight: 700; line-height: 1; }
.unit { font-size: 14px; color: #9fb0c8; margin-left: 4px; }
#rpmBar { height: 8px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; }
#rpmFill { height: 100%; width: 0; background: linear-gradient(90deg, #3ddc84, #ffd23d 70%, #ff4b4b 92%); }

/* 부스터: 속도계 위, 남은 횟수 점 + 가동 중 남은 시간 막대 */
#boostPanel { position: absolute; left: 16px; bottom: 116px; width: 210px; padding: 8px 14px 10px; transition: border-color .2s, box-shadow .2s, opacity .2s; }
.boost-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #c7d2e2; font-weight: 700; }
.boost-top kbd {
  display: inline-block; padding: 0 5px; margin-left: 4px; border-radius: 4px; font: 600 10px 'Segoe UI', sans-serif;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #fff;
}
#boostDots i { display: inline-block; width: 13px; height: 13px; margin-left: 5px; border-radius: 50%; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); }
#boostDots i.on { background: #4aa3ff; border-color: #9fd0ff; box-shadow: 0 0 8px rgba(74,163,255,.9); }
#boostBar { height: 5px; margin-top: 7px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; }
#boostFill { height: 100%; width: 0; background: linear-gradient(90deg, #66ccff, #ffffff); }
#boostPanel.active { border-color: #66ccff; box-shadow: 0 0 18px rgba(102,204,255,.5); }
#boostPanel.empty { opacity: .45; }

#progress {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  width: min(460px, 40vw); height: 10px; background: rgba(0,0,0,.45); border-radius: 5px;
  border: 1px solid rgba(255,255,255,.15);
}
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, #4aa3ff, #7cf); border-radius: 5px; }
#progressText { position: absolute; top: 14px; width: 100%; text-align: center; font-size: 12px; color: #dfe7f2; text-shadow: 0 1px 3px #000; }
.tick { position: absolute; top: -3px; width: 2px; height: 16px; background: rgba(255,255,255,.6); }

#message {
  position: absolute; top: 32%; left: 50%; transform: translate(-50%, -50%);
  font-size: 34px; font-weight: 800; text-align: center; text-shadow: 0 3px 12px rgba(0,0,0,.7);
  white-space: pre-line; opacity: 0; transition: opacity .2s;
}
#message.show { opacity: 1; }
#message.big { font-size: 110px; }
#message small { display: block; font-size: 20px; font-weight: 600; margin-top: 6px; }

#hint { position: absolute; left: 16px; top: 16px; font-size: 12px; color: rgba(255,255,255,.55); text-shadow: 0 1px 2px #000; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .25s; }
#fade.on { opacity: 1; }

/* ── 메뉴 / 오버레이 ──────────────────────────────── */
.overlay { position: fixed; inset: 0; }
#menu { display: flex; justify-content: space-between; padding: 28px; gap: 24px; pointer-events: none; }
#menu > * { pointer-events: auto; }
#menuLeft { width: 400px; max-width: 45vw; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
#menuRight { width: 360px; max-width: 42vw; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; overflow-y: auto; }

.title { padding: 18px 20px; }
.title h1 { margin: 0; font-size: 30px; letter-spacing: .03em; }
.title h1 span { color: #4aa3ff; }
.title p { margin: 6px 0 0; color: #9fb0c8; font-size: 13px; line-height: 1.5; }

.section-label { font-size: 12px; letter-spacing: .1em; color: #9fb0c8; margin: 4px 4px -6px; }
.course {
  padding: 12px 16px; cursor: pointer; transition: border-color .15s, background .15s;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
}
.course:hover { border-color: rgba(74,163,255,.6); }
.course.sel { border-color: #4aa3ff; background: rgba(20, 50, 90, .75); }
.course .name { font-size: 18px; font-weight: 700; }
.course .sub { font-size: 12px; color: #9fb0c8; }
.course .best { grid-row: span 2; text-align: right; align-self: center; }
.course .best .t { font-size: 18px; font-weight: 700; }
.course .best .c { font-size: 11px; color: #9fb0c8; }
.course .meta { grid-column: span 2; font-size: 12px; color: #b9c6d8; margin-top: 4px; }

.garage { padding: 16px 18px; }
.garage-head { display: flex; align-items: center; justify-content: space-between; }
.garage-head button { width: 38px; height: 38px; font-size: 18px; }
.car-name { text-align: center; }
.car-name .n { font-size: 22px; font-weight: 800; }
.car-name .c { font-size: 12px; color: #9fb0c8; }
.car-desc { font-size: 13px; color: #c7d2e2; margin: 10px 0 8px; min-height: 36px; line-height: 1.4; }
.stat { display: grid; grid-template-columns: 70px 1fr 88px; align-items: center; gap: 8px; font-size: 12px; color: #9fb0c8; margin: 5px 0; }
.stat .bar { height: 6px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: #4aa3ff; }
.stat .v { text-align: right; color: #e6ecf5; }
/* 구동방식 카드 (위에서 본 차: 구동 바퀴 강조) */
.drive-row { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; padding: 8px 10px; background: rgba(255,255,255,.05); border-radius: 10px; }
#driveSvg { flex: none; }
#driveSvg .body { fill: rgba(255,255,255,.08); stroke: rgba(255,255,255,.35); stroke-width: 1.5; }
#driveSvg .w { fill: #3a4250; }
#driveSvg .w.on { fill: #4aa3ff; }
#driveSvg .axle { stroke: rgba(255,255,255,.15); stroke-width: 2; }
#driveSvg .axle.on { stroke: #4aa3ff; stroke-width: 3; }
#driveSvg .lbl { fill: #9fb0c8; font-size: 9px; text-anchor: middle; }
.drive-name { font-size: 15px; font-weight: 800; }
.drive-note { font-size: 12px; color: #b9c6d8; line-height: 1.45; margin-top: 2px; }
/* 성능 / 상세 스펙 탭 */
.tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.tab { flex: 1; padding: 6px 0; font-size: 12px; border-radius: 8px; color: #9fb0c8; }
.tab.on { background: rgba(74,163,255,.22); border-color: #4aa3ff; color: #fff; font-weight: 700; }
#carSpecs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.spec { display: flex; flex-direction: column; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.spec span { font-size: 11px; color: #8fa0b8; }
.spec b { font-size: 13px; color: #eef3fa; font-weight: 600; }
.locked-note { text-align: center; color: #ffd23d; font-size: 13px; margin-top: 8px; }
.car-dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.car-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.2); }
.car-dots i.on { background: #4aa3ff; }
.car-dots i.cur { outline: 2px solid #fff; outline-offset: 1px; }

button {
  font: inherit; color: #fff; cursor: pointer; border-radius: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2);
  transition: background .15s, transform .05s;
}
button:hover { background: rgba(255,255,255,.16); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
.primary { background: #2f7fe0; border-color: #4aa3ff; font-size: 20px; font-weight: 800; padding: 16px; letter-spacing: .05em; }
.primary:hover { background: #3b8ff5; }
.controls { padding: 12px 16px; font-size: 12px; color: #b9c6d8; line-height: 1.7; }
.controls kbd {
  display: inline-block; min-width: 22px; padding: 0 5px; text-align: center; border-radius: 4px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); font-family: inherit; font-size: 11px; color: #fff;
}
.small-btn { font-size: 12px; padding: 6px 10px; color: #9fb0c8; align-self: flex-start; }

.center-card {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(460px, 92vw); padding: 26px 28px; text-align: center;
}
.center-card h2 { margin: 0 0 6px; font-size: 26px; }
.center-card .btns { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.center-card .btns button { padding: 12px; font-size: 16px; }
#resTime { font-size: 54px; font-weight: 800; margin: 6px 0; }
#resBadge { display: inline-block; padding: 4px 14px; border-radius: 20px; font-weight: 800; font-size: 14px; letter-spacing: .08em; }
#resBadge.rec { background: #ffd23d; color: #222; }
#resBadge.first { background: #4aa3ff; color: #fff; }
#resBadge.none { background: rgba(255,255,255,.12); color: #c7d2e2; }
#resInfo { font-size: 14px; color: #c7d2e2; margin-top: 10px; line-height: 1.7; }
#resSectors { margin: 12px auto 0; width: 260px; }
#newCar {
  margin-top: 16px; padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,210,61,.22), rgba(255,140,40,.15));
  border: 1px solid rgba(255,210,61,.6);
}
#newCar .lbl { font-size: 12px; letter-spacing: .12em; color: #ffd23d; font-weight: 700; }
#newCar .n { font-size: 22px; font-weight: 800; margin-top: 4px; }
#newCar .c { font-size: 13px; color: #e6ecf5; }
