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

html, body {
  height: 100vh;
  height: 100dvh; /* dynamic viewport: tracks the mobile URL bar so nothing shifts/clips */
  background: #0a0f1c;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#game, #hud { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#hud { pointer-events: none; }
.hidden { display: none !important; }

/* ---------- start menu / lobby ---------- */
#menu {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px;
  background: rgba(5, 9, 20, 0.55);
  overflow-y: auto;
}
#menu h1 {
  font-size: clamp(34px, 8vw, 72px); color: #ffd54d; letter-spacing: 2px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}
#menu .names { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
#menu label { display: flex; flex-direction: column; align-items: center; gap: 6px; font: bold 14px "Trebuchet MS"; letter-spacing: 0.04em; }
#menu .p1 { color: #ff5a4d; } #menu .p2 { color: #37d0ff; }
#menu input {
  width: 160px; padding: 10px; text-align: center; font: bold 18px "Trebuchet MS";
  color: #fff; background: rgba(8, 12, 24, 0.9); border: 2px solid currentColor; border-radius: 10px; outline: none;
}
#modeButtons, #onlinePanel, #lobby { display: flex; flex-direction: column; gap: 10px; align-items: center; width: min(420px, 92vw); }
.start:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.5); }
button { cursor: pointer; font-family: inherit; }
.big {
  width: 100%; padding: 16px 18px; font: bold 19px "Trebuchet MS"; color: #fff;
  background: linear-gradient(180deg, #2a3a66, #1a2742); border: 2px solid #4a6bb0; border-radius: 14px;
}
.big:hover, .big:active { border-color: #7dffb0; }
#settingsRow { display: flex; justify-content: center; margin-top: 4px; }
.toggle {
  padding: 8px 14px; font: bold 13px "Trebuchet MS"; letter-spacing: 0.02em; color: #9fb4d6;
  background: rgba(16,22,40,0.6); border: 1.5px solid #34507e; border-radius: 10px;
}
.toggle:hover { border-color: #7dffb0; color: #fff; }
.toggle[aria-pressed="true"] { color: #7dffb0; border-color: #7dffb0; background: rgba(20,46,30,0.55); }
.newsList { list-style: none; padding: 0; margin: 10px 0 16px; max-width: 440px; text-align: left; }
.newsList li { font: 15px/1.5 "Trebuchet MS"; color: #cfe0f5; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
#arenaPick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 460px; margin: 0 auto; }
#arenaPick .arena { padding: 8px 12px; font: bold 14px "Trebuchet MS"; color: #cfe0f5; background: rgba(16,22,40,0.7); border: 1.5px solid #34507e; border-radius: 10px; cursor: pointer; }
#arenaPick .arena:hover { border-color: #7dffb0; }
#arenaPick .arena.sel { color: #0b1020; background: #ffd54d; border-color: #ffd54d; }
.overlay .sub { color: #9fb4d6; font: 14px "Trebuchet MS"; margin: -4px 0 10px; }
#lbBody { max-width: 460px; margin: 6px auto 14px; text-align: left; max-height: 52vh; overflow-y: auto; width: min(460px, 88vw); }
#lbBody .row { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.08); font: 15px "Trebuchet MS"; color: #cfe0f5; }
#lbBody .row .rk { color: #ffd54d; font-weight: bold; width: 30px; }
#lbBody .row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbBody .row .tm { font-variant-numeric: tabular-nums; color: #fff; }
#lbBody .row.me { background: rgba(255,213,77,0.14); border-radius: 8px; }
#optBody { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#statsBox { color: #cfe0f5; font: 15px/1.8 "Trebuchet MS"; text-align: center; }
#statsBox b { color: #ffd54d; }
.start {
  width: min(420px, 92vw); padding: 18px; margin-top: 4px; font: bold 24px "Trebuchet MS"; color: #08210f;
  background: linear-gradient(180deg, #9dffb0, #4fd07a); border: none; border-radius: 16px;
}
.small { padding: 8px 14px; font: bold 13px "Trebuchet MS"; color: #dfe6f5; background: rgba(8, 12, 24, 0.85); border: 2px solid #5a6b85; border-radius: 10px; }
#joinBox { display: flex; gap: 8px; }
#joinBox input { width: 120px; text-transform: uppercase; letter-spacing: 4px; }
#joinBox button { padding: 0 18px; background: #37d0ff; border: none; border-radius: 10px; font: bold 16px "Trebuchet MS"; }
#codeBox { text-align: center; font: 16px "Trebuchet MS"; color: #dfe6f5; }
#codeBox b { font-size: 40px; letter-spacing: 8px; color: #ffd54d; display: block; margin: 6px 0; }
.hint, .foot { font-size: 12px; color: #9fb0d0; text-align: center; }
#netStatus { font: bold 14px "Trebuchet MS"; color: #7dffb0; text-align: center; min-height: 18px; }

#dailyNote { font: bold 14px "Trebuchet MS"; color: #ffd54d; text-align: center; max-width: 360px; line-height: 1.4; }

/* ---------- vs-CPU rival picker ---------- */
#cpuPanel { display: flex; flex-direction: column; gap: 10px; align-items: center; }
#cpuPanel .cpuLabel { font: bold 14px "Trebuchet MS"; color: #9fb0d0; letter-spacing: 0.05em; }
#cpuCount { display: flex; gap: 10px; }
#cpuCount .cpu {
  width: 50px; height: 50px; font: bold 22px "Trebuchet MS"; color: #dfe6f5;
  background: rgba(8, 12, 24, 0.85); border: 2px solid #5a6b85; border-radius: 12px;
}
#cpuCount .cpu.sel { color: #08210f; background: linear-gradient(180deg, #9dffb0, #4fd07a); border-color: #9dffb0; }

/* ---------- results / pause overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 25;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; background: rgba(5, 9, 20, 0.8);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); overflow-y: auto;
}
.overlay h2 { font: 800 clamp(28px, 6.5vw, 56px) "Trebuchet MS"; color: #ffd54d; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5); text-align: center; }
.overlayBtns { display: flex; flex-direction: column; gap: 10px; width: min(360px, 90vw); }
#finishBody { width: min(440px, 92vw); display: flex; flex-direction: column; gap: 5px; }
#finishBody .sub { text-align: center; font: bold 15px "Trebuchet MS"; color: #7dffb0; }
#finishBody .lbhead { text-align: center; font: bold 12px "Trebuchet MS"; color: #9fb0d0; letter-spacing: 0.1em; margin-top: 8px; }
#finishBody .row { display: flex; align-items: center; gap: 10px; font: bold 15px "Trebuchet MS"; color: #dfe6f5; padding: 5px 12px; border-radius: 9px; background: rgba(255, 255, 255, 0.05); }
#finishBody .row .pos { color: #9fb0d0; min-width: 30px; }
#finishBody .row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#finishBody .row .tm { color: #b9c4dc; font-variant-numeric: tabular-nums; }
#finishBody .row.me { background: rgba(255, 210, 80, 0.18); color: #ffe27a; }
#finishBody .row.me .pos, #finishBody .row.me .tm { color: #ffe27a; }

/* ---------- touch controls ---------- */
/* left thumb = steer (two big arrows) + FIRE just above · right thumb = BRAKE / BOOST
   (BOOST biggest, at the bottom where the thumb rests). The kart auto-accelerates, so
   there is no gas pedal. */
#touch { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#touch .pad { position: fixed; bottom: max(22px, env(safe-area-inset-bottom)); display: flex; }
#touch .left { left: 16px; flex-direction: column; align-items: flex-start; gap: 14px; }
#touch .left .steerrow { display: flex; gap: 14px; align-items: flex-end; }
#touch .left .fire { margin-left: 8px; } /* sit the fire button over the steering arrows */
#touch .right { right: 16px; flex-direction: column; align-items: center; gap: 14px; }

.tbtn {
  pointer-events: auto; border-radius: 50%; display: grid; place-items: center;
  color: #fff; background: rgba(18, 26, 48, 0.5);
  border: 3px solid rgba(255, 255, 255, 0.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  touch-action: none; -webkit-user-select: none; user-select: none;
  transition: transform 0.05s, filter 0.05s;
}
.tbtn span { font-size: 30px; line-height: 1; }
.tbtn i { margin-top: 2px; font: 800 10px/1 "Trebuchet MS"; font-style: normal; letter-spacing: 0.06em; opacity: 0.9; }
.tbtn.active { filter: brightness(1.5); transform: scale(0.92); }

/* steering */
.tbtn.steer { width: 92px; height: 92px; font-size: 42px; }
/* actions, smallest (top) → biggest (bottom, under the thumb) */
.tbtn.brake { width: 70px; height: 70px; background: rgba(40, 60, 92, 0.5); border-color: #9fc0ff; }
.tbtn.fire  { width: 80px; height: 80px; background: rgba(180, 55, 45, 0.5); border-color: #ff8a7a; }
.tbtn.boost { width: 98px; height: 98px; background: rgba(200, 130, 24, 0.52); border-color: #ffd54d; }
.tbtn.boost span { font-size: 36px; }
