@font-face {
  font-family: "Syne";
  src: url("fonts/syne-4.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("fonts/dm-sans-1.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("fonts/dm-sans-3.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1A1D1F;
  color: #FCFDFD;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.speed-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 54%, rgba(244, 88, 140, 0.30) 100%);
  z-index: 5;
}

/* TOUCH SWIPE & DOUBLE-TAP FEEDBACK */
.touch-swipe-indicator {
  position: fixed;
  z-index: 28;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.swipe-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 144px;
  height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(24, 26, 30, 0.52);
  border: 2px solid rgba(255, 230, 138, 0.65);
  backdrop-filter: blur(6px);
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.swipe-arrow {
  font-size: 11px;
  color: rgba(252, 253, 253, 0.65);
}
.swipe-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #FFF4B8, #F4588C 72%);
  border: 2px solid #FCFDFD;
  box-shadow: 0 0 16px rgba(244, 88, 140, 0.85);
}

.touch-tap-ripple {
  position: fixed;
  z-index: 29;
  pointer-events: none;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 3px solid #FFE68A;
  background: radial-gradient(circle, rgba(244, 88, 140, 0.42), transparent 68%);
  transform: translate(-50%, -50%) scale(0.35);
  animation: tapRipplePop 0.38s ease-out forwards;
}
@keyframes tapRipplePop {
  0% { transform: translate(-50%, -50%) scale(0.35); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.65); opacity: 0; }
}

.back-games-pill {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 40;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-color: rgba(255, 255, 255, 0.30);
}
.back-games-pill:hover {
  border-color: #FFE68A;
  color: #FFE68A;
}

.quick-bar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 40;
  display: flex;
  gap: 7px;
}

.pill-btn {
  background: rgba(20, 22, 26, 0.88);
  color: #FCFDFD;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.pill-btn:hover {
  transform: translateY(-1px);
  background: rgba(37, 40, 43, 0.92);
}
.pill-btn.is-muted {
  opacity: 0.72;
  border-color: rgba(244, 88, 140, 0.55);
}
.howto-pill {
  min-width: 30px;
  padding: 6px 10px;
  border-color: rgba(255, 230, 138, 0.65);
  color: #FFE68A;
}

/* HOW-TO-PLAY QUICK GUIDE CARD */
.howto-card {
  max-width: 410px;
  text-align: left;
  gap: 14px;
}
.howto-card h2 {
  text-align: center;
}
.howto-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.howto-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F6F3F5;
  border-radius: 16px;
  padding: 10px 12px;
}
.howto-ico {
  width: 56px;
  height: 44px;
  border-radius: 14px;
  background: #1A1D1F;
  color: #FFE68A;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid #E8C266;
}
.howto-ico.gold-ico {
  background: linear-gradient(135deg, #F4588C, #FFE68A, #16C689);
  color: #1A1D1F;
  font-family: "Syne", sans-serif;
  font-size: 24px;
}
.howto-ico.pink-ico {
  background: linear-gradient(135deg, #F4588C, #D63D70);
  color: #FFF;
  font-size: 22px;
}
.howto-list li div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.howto-list li strong {
  font-size: 14px;
  color: #1A1D1F;
}
.howto-list li span {
  font-size: 12px;
  color: #4D555B;
  line-height: 1.32;
}

/* TITLE OVERLAY */
.title-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 42px 36px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(16, 18, 22, 0.72) 0%, rgba(16, 18, 22, 0.28) 38%, rgba(16, 18, 22, 0.08) 56%, rgba(16, 18, 22, 0.30) 100%);
}

.title-left, .title-right {
  pointer-events: auto;
}

.title-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
}

/* COHESIVE ARCADE BRAND + SALON KART HERO LOCKUP (ZERO GLUED-ON PILL!) */
.hero-lockup {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: rotate(-2.5deg);
  transform-origin: left center;
  margin: 0 0 10px 4px;
}

.brand-lockup-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-crest {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #32373C, #171A1D 85%);
  border: 2.5px solid #FFE68A;
  box-shadow: 0 4px 0 #D63D70, 0 10px 22px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 6px;
}
.brand-crest img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.brand-arcade-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-main {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: clamp(14px, 1.62vw, 21px);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: #FCFDFD;
  -webkit-text-stroke: 1.5px #1A1D1F;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #16C689, 0 8px 18px rgba(0, 0, 0, 0.48);
  white-space: nowrap;
}
.brand-dot {
  color: #5FE3B4;
  text-shadow: 0 4px 0 #0B7A54, 0 8px 18px rgba(0, 0, 0, 0.48);
}

.brand-presents {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: clamp(9.5px, 0.92vw, 12px);
  letter-spacing: 0.11em;
  color: #FFE68A;
  text-shadow: 0 2px 0 #1A1D1F, 0 4px 10px rgba(0, 0, 0, 0.65);
  margin-top: 2px;
  white-space: nowrap;
}

.hero-logo {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  line-height: 0.90;
  letter-spacing: -0.02em;
  margin: 4px 0 0 0;
  display: flex;
  flex-direction: column;
}
.logo-top {
  font-size: clamp(44px, 6.0vw, 76px);
  color: #FFF4B8;
  -webkit-text-stroke: 3px #1A1D1F;
  paint-order: stroke fill;
  text-shadow: 0 7px 0 #D63D70, 0 12px 24px rgba(0, 0, 0, 0.48);
}
.logo-bottom {
  font-size: clamp(50px, 6.8vw, 86px);
  color: #F4588C;
  -webkit-text-stroke: 3px #1A1D1F;
  paint-order: stroke fill;
  text-shadow: 0 7px 0 #16C689, 0 14px 26px rgba(0, 0, 0, 0.48);
  margin-left: 14px;
}

.track-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.track-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #FFE4EE;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  margin-right: 4px;
}
.track-btn {
  background: rgba(26, 29, 31, 0.74);
  color: #FCFDFD;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s;
}
.track-btn.active {
  background: #16C689;
  color: #1A1D1F;
  border-color: #FCFDFD;
  box-shadow: 0 4px 14px rgba(22, 198, 137, 0.45);
}
.difficulty-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.difficulty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(20, 22, 26, 0.90);
  border: 1.5px solid rgba(255, 230, 138, 0.78);
  border-radius: 999px;
  padding: 4px 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}
.diff-step-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 230, 138, 0.65);
  background: rgba(244, 88, 140, 0.92);
  color: #FCFDFD;
  font-family: "DM Sans", sans-serif;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.14s, background 0.14s;
}
.diff-step-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: #F4588C;
}
.diff-step-btn:active:not(:disabled) {
  transform: scale(0.94);
}
.diff-step-btn:disabled {
  opacity: 0.62;
  cursor: default;
  background: rgba(255, 255, 255, 0.20);
  border-color: rgba(255, 255, 255, 0.36);
  color: #E8ECEF;
}
.level-pill-btn {
  background: transparent;
  color: #FFE68A;
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s;
}
.level-pill-btn strong {
  color: #FFE68A;
}
.level-pill-btn em {
  font-style: normal;
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #1A1D1F;
  background: #5FE3B4;
  border-radius: 999px;
  padding: 2px 8px;
}
.level-pill-btn:hover strong {
  color: #FCFDFD;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}
.cta-row.center {
  justify-content: center;
}

.cta-gold, .cta-pink {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.03em;
  padding: 14px 24px;
  border-radius: 999px;
  border: 2.5px solid #FCFDFD;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
}
.cta-gold {
  background: linear-gradient(180deg, #FFE68A 0%, #E8C266 100%);
  color: #1A1D1F;
  box-shadow: 0 6px 0 #B38A26, 0 12px 24px rgba(0, 0, 0, 0.3);
}
.cta-pink {
  background: linear-gradient(180deg, #FB8FB3 0%, #F4588C 100%);
  color: #FCFDFD;
  box-shadow: 0 6px 0 #B0315B, 0 12px 24px rgba(0, 0, 0, 0.3);
}
.cta-gold:hover, .cta-pink:hover {
  transform: translateY(-2px);
}
.cta-gold:active, .cta-pink:active {
  transform: translateY(2px);
}
.full {
  width: 100%;
}

.key-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(252, 253, 253, 0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.key-hints kbd {
  background: rgba(26, 29, 31, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 11px;
  margin-right: 4px;
}
.key-hints em {
  font-style: normal;
  opacity: 0.88;
}

/* RACER CAROUSEL */
.title-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.racer-spotlight {
  background: rgba(24, 26, 30, 0.84);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(232, 194, 102, 0.38);
  border-radius: 18px;
  padding: 13px 17px;
  min-width: 262px;
  text-align: right;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34);
}
.racer-name {
  font-family: "Syne", sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: #FFE68A;
  line-height: 1.05;
}
.racer-role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #8ADCB4;
  margin-bottom: 8px;
}
.racer-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}
.racer-bars div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.racer-bars i {
  display: inline-block;
  width: 96px;
  height: 7px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 99px;
  position: relative;
  overflow: hidden;
}
.racer-bars i::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--val, 85%);
  background: linear-gradient(90deg, #16C689, #F4588C);
  border-radius: 99px;
  transition: width 0.2s ease-out;
}

.carousel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #FCFDFD;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

.racer-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(24, 26, 30, 0.82);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(232, 194, 102, 0.38);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
}

.car-arrow {
  background: transparent;
  border: none;
  color: #FCFDFD;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
}
.racer-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}
.racer-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  background: radial-gradient(circle, #FDF0F3 0%, #E8F6F0 100%);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.14s, border-color 0.14s;
}
.racer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.racer-avatar.active {
  transform: scale(1.16);
  border-color: #FFE68A;
  box-shadow: 0 0 0 3px rgba(244, 88, 140, 0.65);
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 22, 26, 0.68);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  background: #FCFDFD;
  color: #1A1D1F;
  border-radius: 26px;
  padding: 26px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.modal-card h2 {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: #1A1D1F;
}
.modal-desc {
  font-size: 14px;
  color: #555D63;
}
.lobby-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.or-sep {
  font-size: 12px;
  color: #7D858C;
}
.join-row {
  display: flex;
  gap: 8px;
}
.join-row input {
  flex: 1;
  border: 2px solid #DDD4D8;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  outline: none;
}
.join-row input:focus {
  border-color: #F4588C;
}
.room-code-box {
  background: #FDF0F3;
  border: 1.5px solid #F7C7D8;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.room-code-box span {
  font-size: 11px;
  font-weight: 700;
  color: #B05B79;
}
.room-code-box strong {
  font-family: "Syne", sans-serif;
  font-size: 36px;
  letter-spacing: 0.14em;
  color: #1A1D1F;
}
.mini-pill {
  background: #1A1D1F;
  color: #FCFDFD;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.room-settings-box {
  background: #F6F8F9;
  border: 1.5px solid #E1E7EA;
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.room-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.room-setting-lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #5E676E;
}
.lobby-track-pills {
  display: flex;
  gap: 6px;
}
.lobby-track-pill {
  border: 1.5px solid #D3DCE0;
  background: #FCFDFD;
  color: #25282B;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}
.lobby-track-pill.active {
  background: #16C689;
  border-color: #16C689;
  color: #1A1D1F;
}
.lobby-track-pill:disabled {
  cursor: default;
  opacity: 0.72;
}
.lobby-track-pill.active:disabled {
  opacity: 1;
}
.lobby-diff-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lobby-diff-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: #F4588C;
  color: #FCFDFD;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lobby-diff-btn:disabled {
  background: #D6DDE1;
  color: #7D858C;
  cursor: default;
}
.lobby-level-tag {
  font-size: 12px;
  font-weight: 800;
  color: #1A1D1F;
  background: #FFF4B8;
  border: 1px solid #E8C266;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.room-settings-note {
  font-size: 11px;
  color: #6B747B;
  text-align: center;
}
.room-players {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.room-players li {
  background: #E8F6F0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}
.ghost-btn {
  background: transparent;
  border: 1.5px solid #D5DCE0;
  color: #4B5258;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.error-msg {
  color: #D93025;
  font-size: 13px;
  font-weight: 700;
}
.waiting-msg {
  font-size: 13px;
  color: #0D9C69;
  font-weight: 700;
}

/* RACE HUD */
.race-hud {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

.hud-top-left {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  transform: translateZ(0);
  contain: layout style;
}
.hud-chip {
  background: rgba(20, 22, 26, 0.88);
  border: 1.5px solid rgba(232, 194, 102, 0.40);
  border-radius: 14px;
  padding: 7px 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}
.hud-chip.place-chip {
  background: linear-gradient(135deg, rgba(244, 88, 140, 0.94), rgba(214, 61, 112, 0.92));
  border-color: rgba(255, 244, 184, 0.75);
  min-width: 112px;
  justify-content: center;
}
.hud-chip.place-chip strong {
  font-family: "Syne", sans-serif;
  font-size: 21px;
  line-height: 1;
  color: #FFF4B8;
  font-variant-numeric: tabular-nums;
}
.hud-chip.place-chip em {
  font-style: normal;
  color: #FCFDFD;
}
.hud-chip.big {
  min-width: 112px;
  justify-content: center;
}
.hud-chip.big strong {
  font-family: "Syne", sans-serif;
  font-size: 21px;
  line-height: 1;
  color: #FFE68A;
  font-variant-numeric: tabular-nums;
}
.hud-chip.big em {
  font-style: normal;
  color: #FCFDFD;
}
.hud-chip.mono {
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 800;
  min-width: 92px;
  justify-content: center;
}
.hud-chip.gold {
  min-width: 66px;
  justify-content: center;
}
.hud-chip.gold strong {
  color: #FFE68A;
  font-size: 18px;
  display: inline-block;
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hud-chip.level-chip {
  background: linear-gradient(135deg, rgba(26, 29, 31, 0.90), rgba(56, 34, 48, 0.88));
  border-color: rgba(255, 230, 138, 0.74);
  color: #FFE68A;
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  align-items: center;
}
.coin-dot {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFF6B8, #E8C266 70%, #B38A26 100%);
  border: 1.5px solid #FFF4B8;
  align-self: center;
}

.hud-top-right {
  position: absolute;
  top: 54px;
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  transform: translateZ(0);
  contain: layout style;
}
.minimap-box {
  background: rgba(20, 22, 26, 0.86);
  border: 1.5px solid rgba(232, 194, 102, 0.42);
  border-radius: 16px;
  padding: 4px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}
.rank-list {
  list-style: none;
  background: rgba(20, 22, 26, 0.86);
  border: 1.5px solid rgba(232, 194, 102, 0.32);
  border-radius: 14px;
  padding: 7px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 146px;
  font-size: 12px;
  font-weight: 700;
}
.rank-list li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rank-list li.is-me {
  color: #FFE68A;
}
.rank-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.center-banner {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Syne", sans-serif;
  font-size: clamp(54px, 9vw, 108px);
  font-weight: 800;
  color: #FFE68A;
  -webkit-text-stroke: 3px #1A1D1F;
  paint-order: stroke fill;
  text-shadow: 0 8px 0 #F4588C, 0 16px 32px rgba(0,0,0,0.45);
  white-space: nowrap;
}

.action-toast {
  position: absolute;
  top: 19%;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(244, 88, 140, 0.94), rgba(22, 198, 137, 0.92));
  color: #FCFDFD;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: clamp(14px, 2.2vw, 22px);
  letter-spacing: 0.05em;
  padding: 8px 20px;
  border-radius: 999px;
  border: 2px solid #FFE68A;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36);
  white-space: nowrap;
}

.wrong-way-banner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: #E53935;
  color: #FFF;
  font-family: "Syne", sans-serif;
  font-size: 20px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid #FFF;
}

.mobile-gesture-hint {
  display: none;
  position: absolute;
  bottom: 136px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 22, 26, 0.88);
  color: #FFE68A;
  border: 1.5px solid rgba(255, 230, 138, 0.45);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.hud-bottom-left {
  position: absolute;
  bottom: 18px;
  left: 16px;
  background: rgba(20, 22, 26, 0.88);
  border: 1.5px solid rgba(232, 194, 102, 0.38);
  border-radius: 16px;
  padding: 9px 12px;
  max-width: calc(100vw - 320px);
  pointer-events: auto;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  transform: translateZ(0);
  contain: layout style;
}
.tips-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #E8C266;
  margin-bottom: 6px;
}
.desktop-keys-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}
.dkey-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 5px 9px;
  color: #FCFDFD;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
@media (max-width: 1080px) and (min-width: 861px) {
  .hud-bottom-left {
    padding: 7px 9px;
  }
  .desktop-keys-grid {
    gap: 4px;
  }
  .dkey-row {
    padding: 4px 7px;
    font-size: 10px;
    gap: 4px;
  }
}
.dkey-btn {
  cursor: pointer;
}
.dkey-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}
.dkey-row kbd {
  background: rgba(20, 22, 26, 0.92);
  border: 1px solid rgba(232, 194, 102, 0.55);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
  color: #FFE68A;
}
.dkey-row em {
  font-style: normal;
  opacity: 0.92;
}
.dkey-row.key-active {
  background: rgba(22, 198, 137, 0.28);
  border-color: #5FE3B4;
  box-shadow: 0 0 12px rgba(22, 198, 137, 0.45);
}
.dkey-row.ready-glow {
  border-color: #FFE68A;
  background: rgba(244, 88, 140, 0.30);
  box-shadow: 0 0 14px rgba(244, 88, 140, 0.55);
}

.hud-bottom-right {
  position: absolute;
  bottom: 18px;
  right: 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
  transform: translateZ(0);
  contain: layout style;
}
.item-slot {
  background: rgba(20, 22, 26, 0.90);
  border: 2px solid #F4588C;
  border-radius: 16px;
  min-width: 96px;
  height: 84px;
  padding: 6px 10px;
  color: #FCFDFD;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, border-color 0.18s;
}
.item-slot:hover, .speedo-card:hover {
  transform: translateY(-2px);
}
.item-slot.roulette-spin {
  border-color: #5FE3B4;
  background: linear-gradient(180deg, rgba(22, 198, 137, 0.38), rgba(244, 88, 140, 0.36));
  box-shadow: 0 0 24px rgba(22, 198, 137, 0.72);
  animation: roulettePulse 0.18s infinite alternate;
}
@keyframes roulettePulse {
  from { transform: scale(0.98); }
  to { transform: scale(1.06); }
}
.item-slot.ready-glow {
  border-color: #FFE68A;
  background: linear-gradient(180deg, rgba(244, 88, 140, 0.44), rgba(24, 26, 30, 0.90));
  box-shadow: 0 0 22px rgba(244, 88, 140, 0.76);
}
.item-icon {
  font-size: 30px;
  line-height: 1;
}
.item-key {
  font-size: 10px;
  font-weight: 700;
  color: #FFE68A;
  white-space: nowrap;
}
.speedo-card {
  background: rgba(20, 22, 26, 0.90);
  border: 1.5px solid rgba(232, 194, 102, 0.42);
  border-radius: 16px;
  padding: 10px 14px;
  min-width: 170px;
  color: #FCFDFD;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s, box-shadow 0.18s, border-color 0.18s;
}
.speedo-card.ready-glow {
  border-color: #FFE68A;
  box-shadow: 0 0 22px rgba(232, 194, 102, 0.68);
}
.speed-num {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.speed-num strong {
  font-family: "Syne", sans-serif;
  font-size: 28px;
  line-height: 1;
  display: inline-block;
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}
.speed-num span {
  font-size: 11px;
  opacity: 0.78;
}
.turbo-bars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 7px 0 4px;
}
.turbo-bars .bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
  overflow: hidden;
}
.turbo-bars .bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #16C689, #FFE68A);
  transition: width 0.06s linear;
}
.turbo-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #FFE68A;
}

/* TOUCH CONTROLS (hidden on desktop mouse, visible on touch / narrow) */
.touch-controls {
  display: none;
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.touch-left, .touch-right {
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: auto;
}
.steer-pad {
  position: relative;
  width: 156px;
  height: 54px;
  border-radius: 999px;
  background: rgba(20, 22, 26, 0.84);
  border: 2px solid rgba(255, 230, 138, 0.65);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  touch-action: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.34);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.steer-pad.is-active {
  border-color: #5FE3B4;
  box-shadow: 0 0 18px rgba(22, 198, 137, 0.58);
}
.sp-arrow {
  font-size: 14px;
  font-weight: 800;
  color: rgba(255, 230, 138, 0.88);
  pointer-events: none;
}
.sp-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(252, 253, 253, 0.55);
  pointer-events: none;
}
.sp-puck {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #FFF4B8, #F4588C 72%);
  border: 2px solid #FCFDFD;
  box-shadow: 0 0 14px rgba(244, 88, 140, 0.8);
  pointer-events: none;
  transition: transform 0.05s linear;
}
.t-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.48);
  background: rgba(20, 22, 26, 0.84);
  color: #FCFDFD;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.1s, box-shadow 0.15s;
}
.t-btn:active {
  transform: scale(0.92);
}
.t-btn.accent {
  background: rgba(22, 198, 137, 0.90);
  color: #1A1D1F;
  width: 58px;
  border-radius: 25px;
  font-size: 11px;
}
.t-btn.gold {
  background: linear-gradient(180deg, #FFE68A, #E8C266);
  color: #1A1D1F;
  width: 60px;
  border-radius: 25px;
  font-size: 11px;
}
.t-btn.pink {
  background: rgba(244, 88, 140, 0.88);
  color: #FFF;
  font-size: 20px;
}
.t-btn.ready-glow {
  border-color: #FFE68A;
  box-shadow: 0 0 18px rgba(255, 230, 138, 0.9);
  transform: scale(1.06);
}

/* FINISH MODAL */
.finish-place {
  font-family: "Syne", sans-serif;
  font-size: 40px;
  font-weight: 800;
  color: #F4588C;
}
.finish-time {
  font-size: 20px;
  font-weight: 700;
  color: #0FA874;
}
.finish-level-banner {
  background: linear-gradient(135deg, #F4588C, #E8C266);
  color: #1A1D1F;
  font-family: "Syne", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(244, 88, 140, 0.28);
}
.finish-standings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}
.finish-standings li {
  background: #F4F1F3;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}
.finish-standings li.is-me {
  background: #FDF0F3;
  border: 1.5px solid #F4588C;
}
.finish-standings li.is-dnf,
.rank-list li.is-dnf {
  opacity: 0.5;
  text-decoration: line-through;
}
.finish-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.copied-toast {
  font-size: 12px;
  font-weight: 700;
  color: #0FA874;
}

@media (max-width: 860px), (pointer: coarse) {
  .back-games-pill {
    left: max(10px, env(safe-area-inset-left));
  }
  .quick-bar {
    gap: 5px;
  }
  .pill-btn {
    padding: 5px 9px;
    font-size: 11px;
  }
  .title-overlay {
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    padding: max(54px, calc(env(safe-area-inset-top) + 46px)) 16px max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(14,16,20,0.84) 0%, rgba(14,16,20,0.58) 26%, rgba(14,16,20,0.06) 46%, rgba(14,16,20,0.06) 66%, rgba(14,16,20,0.72) 100%);
  }
  .title-left {
    gap: 8px;
    max-width: 100%;
  }
  .hero-lockup {
    gap: 3px;
    margin: 0 0 2px 2px;
    transform: rotate(-1.2deg);
  }
  .brand-lockup-row {
    gap: 8px;
  }
  .brand-crest {
    width: 32px;
    height: 32px;
    border-width: 2px;
    padding: 4px;
    box-shadow: 0 3px 0 #D63D70, 0 6px 14px rgba(0, 0, 0, 0.42);
  }
  .brand-main {
    font-size: clamp(11px, 3.15vw, 15px);
    -webkit-text-stroke: 2px #1A1D1F;
    text-shadow: 0 2.5px 0 #16C689, 0 5px 12px rgba(0, 0, 0, 0.72);
  }
  .brand-presents {
    font-size: 8px;
    letter-spacing: 0.05em;
    white-space: nowrap;
    -webkit-text-stroke: 1px #1A1D1F;
    paint-order: stroke fill;
    text-shadow: 0 2px 0 #1A1D1F, 0 4px 10px rgba(0, 0, 0, 0.85);
  }
  .hero-logo {
    margin: 2px 0 0 0;
  }
  .logo-top {
    font-size: clamp(32px, 8.6vw, 44px);
    -webkit-text-stroke: 2px #1A1D1F;
    text-shadow: 0 4px 0 #D63D70, 0 8px 16px rgba(0,0,0,0.4);
  }
  .logo-bottom {
    font-size: clamp(36px, 9.5vw, 50px);
    -webkit-text-stroke: 2px #1A1D1F;
    text-shadow: 0 4px 0 #16C689, 0 8px 16px rgba(0,0,0,0.4);
    margin-left: 10px;
  }
  .track-selector,
  .difficulty-selector {
    gap: 6px;
  }
  .track-btn {
    padding: 5px 11px;
    font-size: 11px;
  }
  .diff-step-btn {
    width: 28px;
    height: 28px;
    font-size: 17px;
  }
  .level-pill-btn {
    padding: 2px 8px;
    font-size: 12px;
    gap: 6px;
  }
  .level-pill-btn em {
    font-size: 10px;
    padding: 2px 7px;
  }
  .cta-row {
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 2px;
  }
  .cta-gold, .cta-pink {
    flex: 1;
    font-size: 11px;
    padding: 10px 10px;
    white-space: nowrap;
  }
  .title-right {
    align-items: center;
    gap: 6px;
  }
  .racer-spotlight {
    display: none;
  }
  .racer-carousel {
    padding: 6px 10px;
    gap: 5px;
  }
  .racer-dots {
    gap: 6px;
  }
  .racer-avatar {
    width: 40px;
    height: 40px;
  }
  .key-hints, .hud-bottom-left {
    display: none;
  }
  .hud-top-left {
    top: max(44px, calc(env(safe-area-inset-top) + 34px));
    left: 10px;
    display: grid;
    grid-template-columns: auto auto;
    gap: 4px;
    align-items: stretch;
  }
  .hud-chip {
    padding: 4px 8px;
    font-size: 10px;
    gap: 4px;
    border-radius: 11px;
    justify-content: center;
    min-width: 0;
  }
  .hud-chip.place-chip,
  .hud-chip.big {
    min-width: 88px;
  }
  .hud-chip.mono {
    min-width: 78px;
    font-size: 13px;
  }
  .hud-chip.gold {
    min-width: 56px;
  }
  .hud-chip.big strong,
  .hud-chip.place-chip strong,
  .hud-chip.gold strong {
    font-size: 14px;
  }
  .speed-num strong {
    font-size: 21px;
    min-width: 50px;
  }
  .hud-chip.level-chip {
    grid-column: 1 / -1;
    justify-self: start;
    padding: 3px 8px;
    font-size: 10px;
  }
  .hud-top-right {
    top: max(48px, calc(env(safe-area-inset-top) + 38px));
    right: 10px;
  }
  .hud-top-right .rank-list {
    display: none;
  }
  .minimap-box {
    border-radius: 12px;
    padding: 3px;
  }
  .minimap-box canvas {
    width: 84px;
    height: 84px;
  }
  .hud-bottom-right {
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 70px));
    right: 10px;
    gap: 6px;
  }
  .item-slot {
    min-width: 66px;
    height: 56px;
    padding: 3px 6px;
    border-radius: 13px;
  }
  .item-icon {
    font-size: 22px;
  }
  .item-key {
    font-size: 8.5px;
  }
  .speedo-card {
    min-width: 112px;
    padding: 5px 9px;
    border-radius: 13px;
  }
  .speed-num strong {
    font-size: 19px;
    min-width: 44px;
  }
  .turbo-lbl {
    font-size: 8.5px;
  }
  .mobile-gesture-hint {
    display: block;
    top: max(158px, calc(env(safe-area-inset-top) + 148px));
    bottom: auto;
    font-size: 10px;
    padding: 4px 11px;
  }
  .action-toast,
  .wrong-way-banner {
    top: 23%;
  }
  .touch-controls {
    display: flex;
  }
  .steer-pad {
    width: min(148px, 40vw);
    height: 52px;
  }
}

/* LANDSCAPE SMARTPHONE LAYOUT (e.g. 844x390 / 667x375) */
@media (max-height: 500px) and (pointer: coarse), (max-height: 500px) and (max-width: 960px) {
  .back-games-pill {
    top: max(8px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
  }
  .quick-bar {
    top: max(8px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    gap: 5px;
  }
  .pill-btn {
    padding: 4px 8px;
    font-size: 10px;
  }
  .title-overlay {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    padding: max(42px, calc(env(safe-area-inset-top) + 34px)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: linear-gradient(90deg, rgba(14,16,20,0.78) 0%, rgba(14,16,20,0.30) 40%, rgba(14,16,20,0.06) 58%, rgba(14,16,20,0.34) 100%);
  }
  .title-left {
    gap: 6px;
    max-width: 370px;
  }
  .hero-lockup {
    gap: 2px;
    margin: 0 0 2px 0;
    transform: rotate(-1.5deg);
  }
  .brand-crest {
    width: 28px;
    height: 28px;
    padding: 3px;
  }
  .brand-main {
    font-size: 13px;
  }
  .brand-presents {
    font-size: 8px;
  }
  .logo-top {
    font-size: 30px;
  }
  .logo-bottom {
    font-size: 35px;
    margin-left: 8px;
  }
  .track-btn {
    padding: 4px 10px;
    font-size: 11px;
  }
  .difficulty-selector {
    gap: 5px;
  }
  .diff-step-btn {
    width: 24px;
    height: 24px;
    font-size: 15px;
  }
  .level-pill-btn {
    padding: 1px 6px;
    font-size: 11px;
    gap: 5px;
  }
  .level-pill-btn em {
    font-size: 9.5px;
    padding: 1px 6px;
  }
  .cta-gold, .cta-pink {
    font-size: 11px;
    padding: 8px 13px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 8px 16px rgba(0, 0, 0, 0.3);
  }
  .title-right {
    align-items: flex-end;
    gap: 5px;
  }
  .racer-carousel {
    padding: 5px 8px;
    gap: 4px;
  }
  .racer-avatar {
    width: 36px;
    height: 36px;
  }
  .hud-top-left {
    top: max(8px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
  }
  .hud-chip {
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 10px;
  }
  .hud-chip.level-chip {
    grid-column: auto;
    padding: 4px 8px;
    font-size: 10px;
  }
  .hud-top-right {
    top: max(40px, calc(env(safe-area-inset-top) + 34px));
    right: max(12px, env(safe-area-inset-right));
  }
  .minimap-box canvas {
    width: 68px;
    height: 68px;
  }
  .hud-bottom-right {
    bottom: max(64px, calc(env(safe-area-inset-bottom) + 58px));
    right: max(12px, env(safe-area-inset-right));
    gap: 6px;
  }
  .item-slot {
    min-width: 62px;
    height: 54px;
    padding: 3px 6px;
  }
  .item-icon {
    font-size: 20px;
  }
  .speedo-card {
    min-width: 108px;
    padding: 5px 8px;
  }
  .speed-num strong {
    font-size: 18px;
  }
  .touch-controls {
    display: flex;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
  }
  .steer-pad {
    width: 156px;
    height: 46px;
  }
  .t-btn {
    width: 44px;
    height: 44px;
    font-size: 14px;
  }
  .t-btn.accent, .t-btn.gold {
    width: 56px;
    font-size: 10px;
  }
  .mobile-gesture-hint {
    top: max(48px, calc(env(safe-area-inset-top) + 42px));
    bottom: auto;
    font-size: 10px;
    padding: 4px 11px;
  }
  .center-banner {
    top: 34%;
    font-size: clamp(38px, 7vw, 68px);
  }
  .modal-card {
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    padding: 14px 18px;
    gap: 8px;
  }
  .modal-card h2 {
    font-size: 20px;
  }
  .howto-list li {
    padding: 7px 10px;
  }
}
