* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #120a24;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  color: #fff;
  user-select: none;
}
#app,
#app canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hidden {
  display: none !important;
}
#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: #120a24;
  z-index: 50;
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(ellipse at center, rgba(40, 18, 80, 0.75), rgba(10, 4, 24, 0.92));
  z-index: 10;
  padding: 20px;
  text-align: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.screen > :first-child {
  margin-top: auto;
}
.screen > :last-child {
  margin-bottom: auto;
}
.screen h2 {
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #000;
}
button {
  font: inherit;
  font-weight: bold;
  font-size: 18px;
  padding: 10px 22px;
  border-radius: 12px;
  border: 3px solid #fff;
  background: #2a1a4f;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
}
button:hover,
button:focus-visible {
  background: #4b2d8f;
  outline: none;
}
button.big {
  font-size: 24px;
  padding: 12px 40px;
  background: linear-gradient(#ffb43a, #ff6a2a);
  border-color: #fff3c4;
  color: #2a0d00;
  box-shadow: 0 5px 0 #8a2c00;
}
button.big:hover {
  filter: brightness(1.1);
}
.logo {
  line-height: 0.9;
  font-weight: 900;
  font-style: italic;
  transform: skew(-8deg);
}
.logo-top {
  font-size: clamp(48px, 9vw, 110px);
  color: #ffd34d;
  text-shadow: 0 6px 0 #c4361d, 0 10px 18px rgba(0, 0, 0, 0.6);
  letter-spacing: 4px;
}
.logo-bottom {
  font-size: clamp(40px, 7vw, 86px);
  color: #5ee2ff;
  text-shadow: 0 6px 0 #2a3ba8, 0 10px 18px rgba(0, 0, 0, 0.6);
  letter-spacing: 18px;
}
.tag {
  font-size: 20px;
  margin: 4px 0 10px;
  opacity: 0.9;
}
.controls {
  margin-top: 10px;
  font-size: 15px;
  line-height: 2;
  opacity: 0.9;
}
.hint {
  max-width: 560px;
  opacity: 0.75;
  font-size: 14px;
}
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 6px;
  background: #fff;
  color: #1b1035;
  font-weight: bold;
  font-family: inherit;
  box-shadow: 0 2px 0 #9a8fbf;
  line-height: 1.5;
}

/* ---------- select ---------- */
#roster {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 1000px;
}
.fighter {
  width: 128px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  padding: 6px;
  cursor: pointer;
  transition: transform 0.1s;
}
.fighter img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
}
.fighter .fname {
  font-weight: bold;
  font-size: 14px;
}
.fighter.sel {
  border-color: #ffd34d;
  background: rgba(255, 211, 77, 0.18);
  transform: translateY(-4px) scale(1.05);
}
#fighter-info {
  min-height: 170px;
  max-width: 640px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 30px;
  text-align: left;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 14px;
  padding: 14px 20px;
}
#fighter-info .head {
  grid-column: 1 / 3;
}
#fighter-info .head b {
  font-size: 24px;
}
#fighter-info .head i {
  opacity: 0.75;
  margin-left: 8px;
}
#fighter-info .blurb {
  grid-column: 1 / 3;
  opacity: 0.85;
  margin-bottom: 6px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.stat span {
  width: 70px;
}
.pips {
  display: flex;
  gap: 3px;
}
.pips i {
  width: 18px;
  height: 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
}
.pips i.on {
  background: #ffd34d;
}
.special-line {
  grid-column: 1 / 3;
  margin-top: 4px;
  color: #ffb43a;
}
.special-line.ult-line {
  color: #ffe066;
}
/* kart picker: ◀ thumbnail + name ▶ */
.kart-pick {
  display: flex;
  align-items: center;
  gap: 10px;
}
.kart-pick > button {
  font-size: 20px;
  padding: 8px 14px;
}
.kart-pick {
  flex-wrap: wrap;
  justify-content: center;
}
.kart-pick .kart-match {
  flex-basis: 100%;
  justify-content: center;
  margin: 0;
  font-size: 14px;
}
.kart-pick.locked > button {
  opacity: 0.3;
  pointer-events: none;
}
.kart-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 4px 16px 4px 4px;
  text-align: left;
}
.kart-card img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
}
.kart-card small {
  display: block;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
}
.kart-card b {
  font-size: 18px;
}
.kart-card b i {
  display: block;
  font-weight: normal;
  font-size: 13px;
  opacity: 0.75;
}
.select-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

/* ---------- results ---------- */
#results-table {
  border-collapse: collapse;
  font-size: 18px;
  min-width: 420px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  overflow: hidden;
}
#results-table th,
#results-table td {
  padding: 8px 16px;
  text-align: left;
}
#results-table th {
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#results-table tr.me td {
  background: rgba(255, 211, 77, 0.2);
  font-weight: bold;
}
.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, 0.6);
}
#btn-ff {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  font-size: 16px;
  padding: 8px 18px;
  z-index: 6;
}
#btn-ff.on {
  background: #ffd34d;
  color: #1b1035;
}
#hud-tl {
  position: absolute;
  top: 14px;
  left: 18px;
  font-weight: 900;
  font-style: italic;
}
#hud-pos {
  font-size: 64px;
  line-height: 1;
  color: #ffd34d;
}
#hud-pos span {
  font-size: 26px;
}
#hud-lap {
  font-size: 26px;
}
#hud-time {
  font-size: 18px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
#hud-tr {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
#item-slot {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  border: 4px solid #fff;
  background: rgba(30, 14, 60, 0.75);
  display: grid;
  place-items: center;
  font-size: 48px;
}
#item-slot.rolling {
  border-color: #ffd34d;
}
#item-name {
  font-size: 14px;
  font-weight: bold;
}
.meter {
  position: relative;
  width: 180px;
  height: 22px;
  border-radius: 11px;
  border: 2px solid #fff;
  background: rgba(30, 14, 60, 0.75);
  overflow: hidden;
}
#basic-bar {
  height: 18px;
  width: 150px;
}
.meter .fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, #7a3cff, #ff4fd8);
}
#basic-bar .fill {
  background: linear-gradient(90deg, #2a8fbf, #5ee2ff);
}
.meter.ready .fill {
  background: linear-gradient(90deg, #ffb43a, #ffe066);
}
#special-bar.ult {
  width: 230px;
  height: 28px;
  border-color: #fff3c4;
  box-shadow: 0 0 14px #ffd34d;
}
#special-bar.ult .fill {
  width: 100% !important;
  background: linear-gradient(90deg, #ff4f4f, #ffb43a, #ffe066, #5eff8a, #5ee2ff, #b16cff, #ff4f4f);
  background-size: 200% 100%;
  animation: rainbow 1s linear infinite;
}
#special-bar.ult span {
  line-height: 24px;
  font-size: 13px;
  color: #1b1035;
  text-shadow: none;
}
@keyframes rainbow {
  to {
    background-position: 200% 0;
  }
}
.meter span {
  position: relative;
  font-size: 12px;
  font-weight: bold;
  line-height: 18px;
  display: block;
  text-align: center;
}
#minimap {
  width: 170px;
  height: 170px;
  margin-top: 6px;
  opacity: 0.9;
}
#hud-speed {
  position: absolute;
  right: 22px;
  bottom: 120px;
  font-weight: 900;
  font-style: italic;
  text-align: right;
}
#speed-num {
  font-size: 42px;
}
#hud-speed small {
  font-size: 14px;
  margin-left: 4px;
}
#drift-meter {
  height: 8px;
  width: 0;
  margin-left: auto;
  border-radius: 4px;
  transition: width 0.05s;
}
#center-msg {
  position: absolute;
  top: 32%;
  width: 100%;
  text-align: center;
  font-size: 96px;
  font-weight: 900;
  font-style: italic;
  color: #ffd34d;
  text-shadow: 0 6px 0 #c4361d, 0 10px 20px rgba(0, 0, 0, 0.6);
}
#center-msg.pop {
  animation: pop 0.35s ease-out;
}
@keyframes pop {
  from {
    transform: scale(1.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
#ult-banner {
  position: absolute;
  top: 18%;
  left: 0;
  right: 0;
  padding: 10px 0 14px;
  text-align: center;
  font-style: italic;
  font-weight: 900;
  opacity: 0;
  transform: skewY(-3deg);
}
#ult-banner.show {
  animation: ultin 1.8s ease-out forwards;
}
#ult-banner .ult-who {
  font-size: 22px;
  letter-spacing: 4px;
  text-transform: uppercase;
}
#ult-banner .ult-name {
  font-size: 60px;
  color: #ffe066;
  text-shadow: 0 5px 0 #000, 0 0 20px rgba(255, 220, 80, 0.8);
}
@keyframes ultin {
  0% {
    opacity: 0;
    transform: skewY(-3deg) translateX(-60%);
  }
  15% {
    opacity: 1;
    transform: skewY(-3deg) translateX(0);
  }
  80% {
    opacity: 1;
    transform: skewY(-3deg) translateX(0);
  }
  100% {
    opacity: 0;
    transform: skewY(-3deg) translateX(40%);
  }
}
#sub-msg {
  position: absolute;
  top: 50%;
  width: 100%;
  text-align: center;
  font-size: 28px;
  font-weight: bold;
}
#feed {
  position: absolute;
  left: 18px;
  top: 190px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 15px;
  font-weight: bold;
}
#feed div {
  background: rgba(20, 8, 40, 0.65);
  border-radius: 8px;
  padding: 3px 10px;
  animation: slidein 0.25s ease-out;
}
@keyframes slidein {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
}
#cards {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 200px 0 10px;
}
.card {
  width: 104px;
  border-radius: 10px;
  background: rgba(20, 8, 40, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 4px 6px 2px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.card.me {
  border-color: #ffd34d;
}
.card.out {
  opacity: 0.4;
}
.card .cname {
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .cdmg {
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
  line-height: 1.05;
}
.card .cdmg small {
  font-size: 16px;
}
.card .ckos {
  font-size: 10px;
  opacity: 0.8;
}
.card .stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
}
.card.shake {
  animation: shake 0.25s;
}
@keyframes shake {
  25% {
    transform: translate(-3px, 1px);
  }
  50% {
    transform: translate(3px, -1px);
  }
  75% {
    transform: translate(-2px, 0);
  }
}
@media (max-width: 800px) {
  #cards {
    padding: 0 10px;
  }
  .card {
    width: 84px;
  }
  #hud-speed {
    display: none;
  }
}

/* ---------- online lobby ---------- */
.title-buttons {
  display: flex;
  gap: 14px;
}
button.big.alt {
  background: linear-gradient(#5ee2ff, #2a7bd8);
  border-color: #d8f6ff;
  color: #071a33;
  box-shadow: 0 5px 0 #173c7a;
}
.online-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
#online input {
  font: inherit;
  font-size: 18px;
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 10px;
  border: 3px solid #fff;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  width: 180px;
  user-select: text;
}
#net-code {
  width: 120px !important;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
}
.or {
  opacity: 0.7;
}
.mini-roster {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.mini-roster .fighter {
  width: 84px;
  padding: 3px;
}
.mini-roster .fighter .fname {
  font-size: 11px;
}
#net-room {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 14px;
  padding: 12px 24px;
  min-width: 320px;
}
#net-code-show {
  font-size: 18px;
}
#net-code-show b {
  font-size: 40px;
  letter-spacing: 8px;
  color: #ffd34d;
  display: block;
}
#net-players {
  list-style: none;
  padding: 0;
  margin: 8px 0 12px;
  text-align: left;
  font-size: 17px;
  line-height: 1.7;
}
#net-status {
  min-height: 1.2em;
  color: #9fe8ff;
  margin: 0;
}
#results-wait {
  opacity: 0.85;
}

/* ---------- settings ---------- */
#btn-settings {
  margin-top: 4px;
}
#settings {
  justify-content: flex-start;
  padding: 28px 16px;
  overflow-y: auto;
}
.settings-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  width: min(980px, 96vw);
}
.settings-panel section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}
.settings-panel section.wide {
  grid-column: 1 / -1;
}
.settings-panel h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffd84a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.setting > label {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}
.setting label b {
  color: #ffd84a;
}
.setting input[type='range'] {
  width: 100%;
  accent-color: #ffd84a;
}
.settings-panel small,
.settings-panel .note {
  opacity: 0.7;
  line-height: 1.4;
  font-size: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: #ffd84a;
}
.seg {
  display: flex;
  gap: 6px;
}
.seg button {
  flex: 1;
  padding: 7px 0;
  font-size: 14px;
}
.seg button.on {
  background: #ffd84a;
  color: #2a1440;
}
button.small {
  padding: 4px 10px;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}
#key-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 6px 18px;
}
.key-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.key-row span {
  flex: 1;
  font-weight: 700;
}
.key-row button {
  min-width: 82px;
  padding: 5px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}
.key-row button.listening {
  background: #ffd84a;
  color: #2a1440;
}

/* ---------- results podium ---------- */
#results {
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: 24px;
}
#results-title {
  font-size: 46px;
  letter-spacing: 0.06em;
  margin: 4px 0 0;
}
#results-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
}
.podium {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 10px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, transparent), rgba(10, 4, 24, 0.85) 75%);
  border: 3px solid color-mix(in srgb, var(--c) 70%, white);
  box-shadow: 0 0 28px color-mix(in srgb, var(--c) 45%, transparent);
  animation: podium-in 0.5s ease-out both;
}
.podium img {
  width: 170px;
  height: 170px;
}
.podium.p1 img {
  width: 250px;
  height: 250px;
}
.podium.p1 {
  animation-delay: 0.25s;
}
.podium-place {
  position: absolute;
  top: 6px;
  left: 12px;
  font-size: 38px;
  font-weight: 900;
  font-style: italic;
  color: #ffd84a;
  text-shadow: 3px 3px 0 #2a1440;
}
.podium.p1 .podium-place {
  font-size: 56px;
}
.podium-place small {
  font-size: 0.45em;
}
.podium-name {
  font-weight: 900;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.podium.p1 .podium-name {
  font-size: 24px;
}
.podium-who {
  font-size: 13px;
  opacity: 0.75;
}
@keyframes podium-in {
  from {
    transform: translateY(40px) scale(0.9);
    opacity: 0;
  }
}

/* ---------- gamepad focus ---------- */
.pad-focus {
  outline: 4px solid #ffffff !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px rgba(255, 120, 40, 0.9), 0 0 22px rgba(255, 216, 74, 0.8);
}
.fighter.pad-focus {
  outline-offset: 1px;
}

/* ---------- race setup ---------- */
.setup-panel {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  width: min(1100px, 96vw);
  max-height: 70vh;
}
.setup-rules {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}
.transfer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}
.transfer-row input[type='text'] {
  flex: 1 1 220px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: 13px monospace;
}
.setup-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.setup-pair .seg button {
  padding-left: 6px;
  padding-right: 6px;
}
.setup-desc {
  margin: 4px 0 0;
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.4;
}
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 4px;
}
.map-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(20, 10, 40, 0.75);
}
.map-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  display: block;
}
.map-card .mname {
  font-size: 17px;
}
.map-card .mblurb {
  font-size: 12px;
  font-weight: normal;
  opacity: 0.8;
  line-height: 1.3;
}
.map-card.on {
  border-color: #ffd84a;
  box-shadow: 0 0 0 3px rgba(255, 216, 74, 0.5);
}
.cup-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.cup-thumbs img {
  aspect-ratio: 16 / 10;
}
#net-rules {
  font-size: 15px;
  opacity: 0.9;
  margin: 4px 0;
}

/* ---------- stocks + grand prix ---------- */
.card .cstock {
  font-size: 11px;
  letter-spacing: 1px;
  color: #ffd84a;
  min-height: 13px;
}
.card.elim {
  opacity: 0.35;
  filter: grayscale(1);
}
#results-sub {
  font-size: 18px;
  opacity: 0.9;
  margin-top: -8px;
}
.results-tables {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}
#results-gp {
  border-collapse: collapse;
  font-size: 17px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  overflow: hidden;
}
#results-gp th,
#results-gp td {
  padding: 7px 14px;
  text-align: left;
}
#results-gp th {
  background: rgba(255, 216, 74, 0.2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#results-gp tr.me td {
  background: rgba(255, 211, 77, 0.2);
  font-weight: bold;
}
#results-gp td.plus {
  color: #9dff8a;
  font-size: 14px;
}
@media (max-width: 760px) {
  .setup-panel {
    grid-template-columns: 1fr;
  }
}
/* Grand Prix results carry a second table, so shrink the podium to fit */
#results.compact {
  gap: 8px;
}
#results.compact .podium img {
  width: 110px;
  height: 110px;
}
#results.compact .podium.p1 img {
  width: 160px;
  height: 160px;
}
#results.compact .podium-place {
  font-size: 28px;
}
#results.compact .podium.p1 .podium-place {
  font-size: 40px;
}
#results.compact #results-table,
#results.compact #results-gp {
  font-size: 15px;
}
#results.compact #results-table td,
#results.compact #results-gp td {
  padding: 5px 12px;
}

/* ---------- touch controls ---------- */
#touch {
  display: none;
}
body.touch #touch {
  display: block;
}
body.touch .controls {
  display: none;
}
#touch .t-steer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 62%;
  pointer-events: auto;
  touch-action: none;
}
#touch .t-base {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 8, 40, 0.25);
  opacity: 0;
  transition: opacity 0.15s;
}
#touch .t-base.on {
  opacity: 1;
}
#touch .t-base::before,
#touch .t-base::after {
  content: '◀';
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  opacity: 0.6;
  font-size: 14px;
}
#touch .t-base::after {
  content: '▶';
  left: auto;
  right: 8px;
}
#touch .t-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
}
#touch .t-steer::after {
  content: 'slide to steer';
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 12px;
  opacity: 0.45;
  white-space: nowrap;
}
#touch .t-btn {
  pointer-events: auto;
  touch-action: none;
  position: absolute;
  border-radius: 50%;
  padding: 0;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.6);
  background: rgba(30, 14, 60, 0.55);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  -webkit-tap-highlight-color: transparent;
}
#touch .t-btn.down {
  transform: scale(0.92);
  background: rgba(255, 211, 77, 0.6);
}
#touch .t-pad {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 250px;
  height: 230px;
}
#touch .t-drift {
  right: 18px;
  bottom: 22px;
  width: 92px;
  height: 92px;
  font-size: 15px;
  background: rgba(94, 160, 255, 0.5);
}
#touch .t-brake {
  right: 124px;
  bottom: 14px;
  width: 66px;
  height: 66px;
}
#touch .t-basic {
  right: 118px;
  bottom: 92px;
  width: 70px;
  height: 70px;
  background: rgba(255, 122, 58, 0.5);
}
#touch .t-special {
  right: 40px;
  bottom: 126px;
  width: 70px;
  height: 70px;
  background: rgba(200, 80, 255, 0.5);
}
#touch .t-item {
  right: 190px;
  bottom: 150px;
  width: 58px;
  height: 58px;
  background: rgba(80, 200, 120, 0.5);
}
#touch .t-dodge {
  right: 194px;
  bottom: 84px;
  width: 54px;
  height: 54px;
  font-size: 11px;
  background: rgba(190, 232, 255, 0.35);
}
#touch .t-pause {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 14px;
}
#touch .t-pause.down {
  transform: translateX(-50%) scale(0.92);
}
/* make room for the buttons: speed and cards move out of their way */
body.touch #hud-speed {
  right: 50%;
  transform: translateX(50%);
  bottom: 8px;
  text-align: center;
}
body.touch #cards {
  bottom: auto;
  top: 60px;
  padding: 0 150px;
}
body.touch #feed {
  display: none;
}

/* ---------- small screens (phones) ---------- */
@media (max-height: 560px), (max-width: 760px) {
  .screen {
    padding: 10px 12px;
    gap: 8px;
  }
  .screen > * {
    flex-shrink: 0;
  }
  .screen h2 {
    font-size: 22px;
  }
  button {
    font-size: 15px;
    padding: 8px 16px;
  }
  button.big {
    font-size: 18px;
    padding: 10px 22px;
  }
  .logo-top {
    font-size: clamp(36px, 9vh, 70px);
  }
  .logo-bottom {
    font-size: clamp(30px, 7vh, 56px);
    letter-spacing: 10px;
  }
  .tag {
    font-size: 14px;
    margin: 0;
  }
  .hint,
  .controls {
    font-size: 12px;
  }
  /* fighter select: one scrolling row of fighters, compact info */
  #roster {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    max-width: 100%;
    gap: 8px;
    padding: 6px 4px;
    scrollbar-width: none;
  }
  .fighter {
    width: 72px;
    flex: none;
    padding: 3px;
    border-radius: 10px;
  }
  .fighter .fname {
    font-size: 11px;
  }
  .fighter.sel {
    transform: none;
  }
  #fighter-info {
    min-height: 0;
    padding: 8px 12px;
    gap: 2px 16px;
    font-size: 12px;
  }
  #fighter-info .head b {
    font-size: 17px;
  }
  #fighter-info .blurb {
    display: none;
  }
  .special-line {
    font-size: 12px;
  }
  .kart-card {
    min-width: 220px;
  }
  .kart-card img {
    width: 40px;
    height: 40px;
  }
  .kart-pick > button {
    padding: 4px 12px;
  }
  .stat {
    font-size: 12px;
  }
  .pips i {
    width: 14px;
    height: 8px;
  }
  .kart-card b {
    font-size: 14px;
  }
  .select-actions {
    position: sticky;
    bottom: -10px;
    padding: 6px 0 10px;
    width: 100%;
    justify-content: center;
    background: linear-gradient(transparent, rgba(20, 10, 45, 0.85) 40%);
  }
  /* race setup */
  .setup-panel {
    grid-template-columns: 210px 1fr;
    gap: 10px;
    max-height: none;
    height: calc(100vh - 110px);
  }
  .setup-rules {
    padding: 8px 10px;
    gap: 6px;
    overflow-y: auto;
  }
  .setup-desc {
    font-size: 11px;
  }
  .seg button {
    font-size: 12px;
    padding: 6px 8px;
  }
  .map-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
  }
  .map-card .mblurb {
    display: none;
  }
  /* HUD */
  #hud-tl {
    top: 8px;
    left: 10px;
  }
  #hud-pos {
    font-size: 40px;
  }
  #hud-pos span {
    font-size: 16px;
  }
  #hud-lap {
    font-size: 16px;
  }
  #hud-time {
    font-size: 12px;
  }
  #hud-tr {
    top: 8px;
    right: 10px;
  }
  #item-slot {
    width: 54px;
    height: 54px;
    border-width: 3px;
    border-radius: 12px;
    font-size: 30px;
  }
  .meter {
    transform: scale(0.8);
    transform-origin: right center;
  }
  #minimap {
    width: 104px;
    height: 104px;
  }
  #speed-num {
    font-size: 26px;
  }
  #center-msg {
    font-size: 48px !important;
  }
  #cards {
    gap: 4px;
    padding: 0 120px;
  }
  .card {
    width: 70px;
    padding: 2px 3px 1px;
    font-size: 10px;
  }
  .card .cdmg {
    font-size: 18px;
  }
  .card .cname {
    font-size: 9px;
  }
  .settings-panel {
    max-height: none;
  }
  #results-podium {
    transform: scale(0.7);
    margin: -30px 0;
  }
}
/* phones held upright: ask for landscape */
#rotate {
  display: none;
}
@media (orientation: portrait) and (max-width: 600px) {
  body.touch #rotate {
    display: grid;
    position: fixed;
    inset: 0;
    z-index: 60;
    place-items: center;
    background: #120a24;
    font-size: 20px;
    text-align: center;
    padding: 30px;
  }
}

/* mouse steering: where the wheel is */
#mouse-wheel {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 240px;
  height: 8px;
  margin-left: -120px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
#mouse-wheel::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -3px;
  width: 2px;
  height: 14px;
  background: rgba(255, 255, 255, 0.5);
}
#mouse-wheel i {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 14px;
  height: 16px;
  margin-left: -7px;
  border-radius: 4px;
  background: #ffd34d;
  box-shadow: 0 0 8px rgba(255, 211, 77, 0.8);
}
body.mouse-steer #mouse-wheel {
  display: block;
}
body.touch #mouse-wheel {
  display: none;
}
#keys-mode {
  font-size: 12px;
  opacity: 0.7;
  font-weight: normal;
}
