:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: rgba(247, 251, 255, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(8, 12, 18, 0.66);
  --track: #222b30;
  --accent: #ffcc4d;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0b1015;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 204, 77, 0.12), transparent 28%),
    linear-gradient(180deg, #192734, #101820 45%, #0b1015);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.brand,
.room-stats,
.sound-button,
.rider-panel,
.join-panel,
.controller {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(380px, 48vw);
  padding: 12px 14px;
}

.mark-swatch {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    inset -8px -10px 16px rgba(0, 0, 0, 0.22),
    0 0 0 3px rgba(255, 255, 255, 0.16);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
  line-height: 1;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.room-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 1px;
  min-width: min(430px, 48vw);
  overflow: hidden;
}

.room-stats div {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.045);
}

.room-stats span,
.rider-panel > span,
.event-log > span,
label span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.room-stats div:nth-child(3) {
  display: none;
}

.room-stats div:first-child span {
  color: transparent;
  font-size: 0;
}

.room-stats div:first-child span::after {
  content: "Track";
  color: var(--muted);
  font-size: 11px;
}

.room-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
  line-height: 1;
}

.sound-button {
  min-width: 78px;
  min-height: 58px;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 900;
  pointer-events: auto;
}

.sound-button.is-muted {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.44);
}

.sound-button.is-active {
  color: #111820;
  background: linear-gradient(135deg, #42d7f5, #ffd166);
}

.rider-panel {
  position: absolute;
  top: 100px;
  right: 16px;
  z-index: 5;
  width: min(260px, calc(100vw - 32px));
  padding: 13px;
  pointer-events: none;
}

.rider-panel ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.rider-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
}

.rider-panel strong {
  margin-left: auto;
  font-size: 12px;
}

.rider-panel i {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.event-log {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.event-log ul {
  margin-top: 8px;
}

.event-log li {
  justify-content: flex-start;
  color: var(--muted);
}

.join-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 8;
  width: min(430px, calc(100vw - 28px));
  transform: translate(-50%, -50%);
  padding: 22px;
}

.join-panel.is-hidden {
  display: none;
}

.join-panel h2 {
  font-size: clamp(30px, 5vw, 44px);
  line-height: 0.98;
}

.join-panel p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.mobile-note {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

input,
select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 18px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) calc(100% - 13px) 50% / 7px 7px no-repeat,
    rgba(0, 0, 0, 0.28);
  padding-right: 36px;
  font-weight: 800;
}

select option {
  color: #111820;
  background: #f7fbff;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  outline: 0;
  background: rgba(0, 0, 0, 0.28);
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
}

label strong {
  color: var(--ink);
  font-size: 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.join-panel button {
  min-height: 52px;
  border-radius: 8px;
  font-weight: 900;
  background: linear-gradient(135deg, #3d8bff, #ffcc4d);
}

.join-panel button {
  width: 100%;
  margin-top: 14px;
}

.join-options {
  margin-top: 12px;
}

.join-options summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.controller {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 6;
  display: none;
  grid-template-columns: 118px 64px;
  gap: 10px;
  align-items: center;
  width: auto;
  padding: 10px;
  pointer-events: auto;
}

.controller.is-visible {
  display: grid;
}

.steer-pad {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0 3px, transparent 4px),
    radial-gradient(circle at center, transparent 0 35%, rgba(255, 255, 255, 0.08) 36%, transparent 38%),
    rgba(0, 0, 0, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  touch-action: none;
}

.pad-label {
  position: absolute;
  top: 10px;
  left: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.steer-pad i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #f7fbff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
}

.pulse-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: #111820;
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(135deg, #ffd166, #ff5a6f);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.pulse-button:disabled {
  color: rgba(247, 251, 255, 0.5);
  background: rgba(0, 0, 0, 0.34);
}

.energy-meter {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 8px;
}

.energy-meter span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.energy-meter i {
  display: block;
  height: 7px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #42d7f5, #ffd166);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.35);
  transform-origin: left center;
}

.toast {
  position: absolute;
  left: 50%;
  top: 104px;
  z-index: 9;
  max-width: min(440px, calc(100vw - 40px));
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 760px) {
  .app-shell {
    min-height: 100dvh;
  }

  .topbar {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .brand {
    min-width: 0;
    max-width: calc(100vw - 184px);
    padding: 8px 9px;
    gap: 8px;
  }

  .mark-swatch {
    width: 30px;
    height: 30px;
  }

  h1 {
    font-size: 15px;
  }

  .brand p {
    display: none;
  }

  .room-stats {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
    width: 100%;
  }

  .topbar-actions {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, 52px);
    gap: 6px;
  }

  .sound-button {
    min-width: 52px;
    min-height: 46px;
    padding: 0 6px;
    font-size: 11px;
  }

  .room-stats div {
    padding: 7px 8px;
  }

  .room-stats strong {
    font-size: 16px;
  }

  .rider-panel {
    top: 126px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 86px;
    padding: 8px 9px;
    overflow: hidden;
  }

  .rider-panel ul {
    display: flex;
    overflow: hidden;
    gap: 7px;
    margin-top: 7px;
  }

  .rider-panel li {
    min-width: 112px;
    font-size: 12px;
  }

  .event-log {
    display: none;
  }

  .join-panel {
    width: min(380px, calc(100vw - 20px));
    padding: 18px;
  }

  .join-panel h2 {
    font-size: 30px;
  }

  .join-panel p {
    font-size: 14px;
  }

  .mobile-note {
    display: block;
  }

  .controller {
    left: max(8px, env(safe-area-inset-left));
    bottom: max(8px, env(safe-area-inset-bottom));
    grid-template-columns: 108px 58px;
    gap: 8px;
    padding: 8px;
  }

  .steer-pad {
    width: 108px;
    height: 108px;
  }

  .pulse-button {
    width: 58px;
    height: 58px;
    font-size: 12px;
  }

  .toast {
    top: 212px;
  }
}

@media (max-width: 390px) {
  .brand {
    max-width: calc(100vw - 168px);
  }

  h1 {
    font-size: 13px;
  }

  .topbar-actions {
    grid-template-columns: repeat(3, 48px);
  }

  .sound-button {
    min-width: 48px;
    font-size: 10px;
  }

  .room-stats span,
  .rider-panel > span,
  .event-log > span,
  label span {
    font-size: 10px;
  }

  .room-stats strong {
    font-size: 15px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .topbar {
    grid-template-columns: minmax(160px, 1fr) minmax(230px, 1.2fr) auto;
    align-items: start;
  }

  .brand {
    max-width: none;
  }

  .room-stats {
    grid-column: auto;
  }

  .rider-panel {
    display: none;
  }

  .toast {
    top: 78px;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  .join-panel {
    top: calc(50% + 12px);
    padding: 14px;
  }

  .join-panel h2 {
    font-size: 24px;
  }

  .join-panel p {
    margin-top: 7px;
    font-size: 12px;
  }

  .join-panel button {
    min-height: 46px;
  }

  .join-options {
    display: none;
  }
}
