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

body {
  background: #0a0a0f;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
}

#game {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
}

/* CRT scanlines */
#game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.16) 0px, rgba(0, 0, 0, 0.16) 1px,
    transparent 1px, transparent 3px
  );
  z-index: 50;
}

#screen {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1a4d24;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2.2%;
  color: #c8ffd0;
  text-shadow: 2px 2px 0 #000;
  font-weight: bold;
  font-size: clamp(12px, 2.4vmin, 22px);
  letter-spacing: 0.08em;
  z-index: 10;
}

#hud-speed {
  font-size: clamp(16px, 3.6vmin, 34px);
  color: #ffd84d;
}

#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.8vmin;
}

#hud-armor {
  width: clamp(70px, 14vmin, 130px);
  height: 1.2vmin;
  min-height: 7px;
  background: rgba(10, 20, 12, 0.7);
  border: 1px solid rgba(200, 255, 208, 0.5);
}

#hud-armor-fill {
  display: block;
  height: 100%;
  background: #5cc06c;
}

#hud-ammo {
  font-size: clamp(10px, 1.9vmin, 17px);
  color: #c8ffd0;
}

#standings {
  position: absolute;
  left: 2.2%;
  bottom: 3%;
  display: flex;
  flex-direction: column;
  gap: 0.5vmin;
  font-size: clamp(10px, 2vmin, 18px);
  background: rgba(5, 8, 6, 0.45);
  padding: 1vmin 1.2vmin;
  border-radius: 4px;
}

.st-row {
  display: flex;
  align-items: center;
  gap: 1ch;
  color: #c8ffd0;
}

.st-row.you { color: #ffd84d; }

.st-pos { width: 1ch; text-align: right; }

.st-swatch {
  display: inline-block;
  width: 1.1ch;
  height: 0.8em;
  border: 1px solid rgba(0, 0, 0, 0.6);
}

.st-name { width: 7ch; text-align: left; }
.st-gap { width: 6ch; text-align: right; }
.st-gap.wreck { color: #e04a3a; animation: blink 0.5s steps(2) infinite; }

.st-hp {
  width: 5ch;
  height: 0.55em;
  background: rgba(10, 20, 12, 0.8);
  border: 1px solid rgba(200, 255, 208, 0.35);
  display: inline-block;
}

.st-hp i {
  display: block;
  height: 100%;
}

#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: clamp(40px, 14vmin, 130px);
  font-weight: bold;
  color: #ffd84d;
  text-shadow: 4px 4px 0 #000;
  z-index: 20;
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.4vmin;
  background: rgba(5, 8, 6, 0.86);
  color: #8df0a0;
  text-align: center;
  letter-spacing: 0.1em;
  z-index: 30;
  padding: 3%;
}

.overlay h1 {
  font-size: clamp(26px, 7vmin, 64px);
  color: #ffd84d;
  text-shadow: 4px 4px 0 #a03030, 7px 7px 0 #000;
}

/* ArktIQ Turbo logo: faceted bear + arctic chrome title */
#logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5vmin;
}

#logo-bear {
  width: clamp(72px, 15vmin, 140px);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.55));
}

#logo h1 {
  color: #bce0f0;
  text-shadow: 4px 4px 0 #1b5e8a, 7px 7px 0 #000;
}

.overlay h2 {
  font-size: clamp(13px, 2.6vmin, 24px);
  color: #ffd84d;
}

.sub { color: #5cc06c; font-size: clamp(11px, 2vmin, 18px); }

.blink { animation: blink 1s steps(2) infinite; color: #ffffff; font-weight: bold;
  font-size: clamp(13px, 2.6vmin, 24px); }
@keyframes blink { 50% { opacity: 0; } }

#menu-items, #pause-items, #p2options {
  display: flex;
  flex-direction: column;
  gap: 1.2vmin;
  font-size: clamp(17px, 3.6vmin, 34px);
  font-weight: bold;
  white-space: pre;
}

.menu-item { color: #5cc06c; cursor: pointer; letter-spacing: 0.15em; }
.menu-item.sel { color: #ffffff; text-shadow: 2px 2px 0 #a03030; }

#laptimes .you { color: #ffd84d; font-weight: bold; }
#laptimes .you2 { color: #5cc9da; font-weight: bold; }

.p2hint {
  font-size: 0.6em;
  color: #5cc06c;
  letter-spacing: 0.05em;
  margin-top: 0.35em;
  font-weight: normal;
}

#ctrl-set {
  font-size: clamp(16px, 3.2vmin, 30px);
  color: #ffd84d;
  font-weight: bold;
}

#ctrl-list {
  display: flex;
  flex-direction: column;
  gap: 0.7vmin;
  width: min(84%, 640px);
  font-size: clamp(13px, 2.7vmin, 25px);
}

/* online */

#toast {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 8, 6, 0.9);
  border: 2px solid #ffd84d;
  color: #ffd84d;
  font-weight: bold;
  font-size: clamp(12px, 2.4vmin, 22px);
  letter-spacing: 0.1em;
  padding: 1vmin 2ch;
  z-index: 60;
}

#lobby-code {
  font-size: clamp(40px, 12vmin, 110px);
  letter-spacing: 0.25em;
  text-shadow: 4px 4px 0 #000;
}

#code-slots {
  font-size: clamp(28px, 8vmin, 72px);
  letter-spacing: 0.2em;
  min-height: 1.2em;
  text-shadow: 3px 3px 0 #000;
}

#icon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5vmin;
}

.icon-btn {
  font-size: clamp(26px, 7vmin, 60px);
  background: rgba(141, 240, 160, 0.08);
  border: 2px solid #2d6b3a;
  padding: 1vmin 2vmin;
  cursor: pointer;
  line-height: 1.2;
}

.icon-btn:hover { border-color: #8df0a0; background: rgba(141, 240, 160, 0.18); }

/* split-screen per-player HUD */
#hud .hud2 { display: none; }
#hud.duo #hud-left, #hud.duo #hud-right { display: none; }
#hud.duo .hud2 {
  display: flex;
  flex-direction: column;
  gap: 0.5vmin;
  position: absolute;
  top: 2.2%;
  font-size: clamp(10px, 2vmin, 18px);
  font-weight: bold;
  color: #c8ffd0;
  text-shadow: 2px 2px 0 #000;
}

.hud2-left { left: 1.5%; }
.hud2-right { left: 51.5%; }

.h2bar {
  width: clamp(60px, 12vmin, 110px);
  height: 1vmin;
  min-height: 6px;
  background: rgba(10, 20, 12, 0.7);
  border: 1px solid rgba(200, 255, 208, 0.5);
}

.h2bar i { display: block; height: 100%; }

.h2ammo {
  font-size: 0.85em;
  font-weight: normal;
}

.help { color: #4e9c5e; font-size: clamp(10px, 1.8vmin, 16px); }
.dim { color: #4e9c5e; }

#records ol {
  list-style: none;
  margin-top: 1vmin;
  font-size: clamp(12px, 2.4vmin, 22px);
  line-height: 1.6;
}

#records li { white-space: pre; }

/* ---------- Garage ---------- */

#cash {
  font-size: clamp(16px, 3.4vmin, 32px);
  color: #ffd84d;
  font-weight: bold;
}

#parts, #statbars {
  display: flex;
  flex-direction: column;
  gap: 1vmin;
  width: min(84%, 640px);
  font-size: clamp(13px, 2.7vmin, 25px);
}

.part-row {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  padding: 0.6vmin 1ch;
  cursor: pointer;
}

.part-row.sel { background: rgba(141, 240, 160, 0.14); color: #ffffff; }
.pips { letter-spacing: 0.3em; color: #ffd84d; }
.pcost { color: #4e9c5e; font-size: 0.8em; align-self: center; }

.stat-row {
  display: flex;
  align-items: center;
  gap: 1.5ch;
  font-size: clamp(10px, 1.9vmin, 17px);
  color: #5cc06c;
}

.sname { width: 14ch; text-align: left; }

.sbar {
  flex: 1;
  height: 1.2vmin;
  min-height: 6px;
  background: #143a1c;
  border: 1px solid #2d6b3a;
}

.sfill { display: block; height: 100%; background: #ffd84d; }
.sval { width: 9ch; text-align: right; }

/* ---------- Results ---------- */

#laptimes, #season-table {
  font-size: clamp(13px, 2.8vmin, 26px);
  line-height: 1.7;
  white-space: pre;
}

#laptimes .total, #season-table .total { color: #ffd84d; font-weight: bold; margin-top: 1vmin; }
#season-table .you { color: #ffd84d; font-weight: bold; }

#newrecord {
  font-size: clamp(13px, 2.6vmin, 24px);
  display: flex;
  align-items: center;
  gap: 1.5ch;
}

#initials {
  background: #0d1f12;
  border: 2px solid #8df0a0;
  color: #ffffff;
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
  width: 5ch;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  padding: 0.3vmin 0;
}
