:root {
  --lime: #adff00;
  --lime-dim: rgba(173, 255, 0, 0.16);
  --bg: #05070c;
  --surface: rgba(12, 16, 24, 0.82);
  --text: #f2f5f8;
  --muted: #8b93a7;
  --green: #60b900;
  --red: #ff4545;
  --border: rgba(255, 255, 255, 0.1);
  --font-d: "Montserrat", system-ui, sans-serif;
  --font-b: "Roboto", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ctl: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}

.app {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  left: 50%;
  transform: translateX(-50%);
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px 8px 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--lime);
  flex-shrink: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-title {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  min-width: 70px;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.pill .label {
  display: block;
  font-family: var(--font-d);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.pill .value {
  display: block;
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.pill.best .value {
  color: var(--lime);
}

.btn-mute {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-mute.is-muted {
  opacity: 0.65;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: radial-gradient(ellipse at 50% 20%, #10182a 0%, #05070c 70%);
  overflow: hidden;
}

#c3d {
  display: block;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  cursor: grab;
}

#error-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  background: rgba(255, 69, 69, 0.95);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  display: none;
}

#error-banner.is-on {
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(
    180deg,
    rgba(5, 7, 12, 0.55) 0%,
    rgba(5, 7, 12, 0.78) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: auto;
}

.overlay[hidden] {
  display: none !important;
}

.card {
  width: 100%;
  max-width: 360px;
  background: rgba(14, 18, 28, 0.94);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(173, 255, 0, 0.08);
}

.card-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  margin: 0 auto 14px;
  overflow: hidden;
  background: var(--lime);
  box-shadow: 0 0 32px rgba(173, 255, 0, 0.35);
}

.card-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.eyebrow {
  font-family: var(--font-d);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.card h1 {
  margin: 0 0 10px;
  font-family: var(--font-d);
  font-size: clamp(26px, 7vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 20%, var(--lime));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 18px;
}

.feat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.feat strong {
  display: block;
  color: var(--text);
  font-family: var(--font-d);
  font-size: 12px;
  margin-bottom: 2px;
}

.btn-primary {
  appearance: none;
  border: none;
  width: 100%;
  min-height: var(--ctl);
  border-radius: 999px;
  background: var(--lime);
  color: #000;
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(173, 255, 0, 0.35);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-primary:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
}

.final-label {
  font-family: var(--font-d);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.final-score {
  font-family: var(--font-d);
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 4px 0 8px;
  font-variant-numeric: tabular-nums;
  color: var(--lime);
}

.best-line {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.best-line strong {
  color: var(--text);
  font-family: var(--font-d);
}

.new-best {
  min-height: 1.2em;
  color: var(--green);
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 14px;
}

.speed-meter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  font-family: var(--font-d);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  white-space: nowrap;
}

.speed-meter span {
  color: var(--lime);
}

.coach {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  max-width: min(92vw, 420px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(8, 12, 20, 0.82);
  border: 1px solid rgba(173, 255, 0, 0.35);
  color: #e8f5c8;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.coach.is-on {
  opacity: 1;
}

.lane-hint {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  gap: 28px;
  pointer-events: none;
  font-family: var(--font-d);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.28);
}

.lane-hint .mid {
  color: rgba(173, 255, 0, 0.55);
}

.no-webgl {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--bg);
  color: var(--muted);
}

.no-webgl[hidden] {
  display: none !important;
}

@media (max-width: 380px) {
  .brand-sub {
    display: none;
  }

  .pill {
    min-width: 58px;
    padding: 6px 8px;
  }

  .features {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 900px) {
  .app {
    max-width: 720px;
    top: 12px;
    bottom: 12px;
    height: auto;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
  }
}
