:root {
  color-scheme: dark;
  font-family: Inter, "SF Pro Display", system-ui, sans-serif;
  --panel-bg: rgba(15, 23, 42, 0.42);
  --panel-border: rgba(255, 255, 255, 0.14);
  --accent: #7bd1ff;
  --accent-strong: #8df3d0;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 248, 235, 0.84), transparent 32%),
    linear-gradient(180deg, #a7d0ff 0%, #7ba4df 34%, #55678b 62%, #222b3c 100%);
  color: #fff;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
}

.screen.is-active {
  display: block;
}

.landing-screen,
.controller-screen {
  overflow-y: auto;
  padding: 24px;
  box-sizing: border-box;
}

.landing-screen {
  display: none;
  align-items: center;
  justify-content: center;
}

.landing-screen.is-active {
  display: flex;
}

.controller-screen.is-active {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.landing-card,
.controller-card {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 28px;
  border-radius: 28px;
  backdrop-filter: blur(20px);
  background: rgba(15, 23, 42, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.landing-card h1,
.controller-card h2 {
  margin: 0 0 12px;
  line-height: 0.95;
}

.landing-card h1 {
  font-size: clamp(40px, 6vw, 72px);
}

.controller-card h2 {
  font-size: clamp(28px, 5vw, 42px);
}

.lead,
.status-copy,
.tips-card p,
.info-card p,
.title-panel p,
.help-panel p {
  margin: 0;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.84);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.74);
}

.role-actions,
.controller-actions,
.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.role-actions {
  margin-top: 22px;
}

.primary-action,
.secondary-action,
.ghost-action,
.audio-toggle {
  pointer-events: auto;
  border-radius: 999px;
  padding: 12px 18px;
  border: 1px solid transparent;
  color: #fff;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-action:hover,
.secondary-action:hover,
.ghost-action:hover,
.audio-toggle:hover {
  transform: translateY(-1px);
}

.primary-action {
  background: linear-gradient(135deg, rgba(118, 214, 255, 0.94), rgba(87, 165, 255, 0.92));
  color: #08111f;
  font-weight: 800;
}

.secondary-action,
.audio-toggle {
  background: rgba(113, 212, 255, 0.14);
  border-color: rgba(113, 212, 255, 0.35);
}

.ghost-action {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}

.audio-toggle.is-on {
  background: rgba(99, 236, 180, 0.18);
  border-color: rgba(99, 236, 180, 0.42);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.info-card,
.tips-card {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-card strong {
  display: block;
  margin-bottom: 8px;
}

.game-screen {
  background: #101722;
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
}

.target-indicators {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.target-indicator {
  --offset-x: 0px;
  --angle: 0deg;
  position: absolute;
  top: 18px;
  left: 25vw;
  transform: translateX(calc(-50% + var(--offset-x)));
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
}

.target-indicator.is-visible {
  display: inline-flex;
}

.target-indicator.right {
  left: 75vw;
}

.target-arrow {
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 18px solid rgba(140, 226, 255, 0.94);
  transform: rotate(var(--angle));
  transform-origin: center;
}

.target-label,
.target-distance {
  font-size: 13px;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  box-sizing: border-box;
}

.panel {
  backdrop-filter: blur(18px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.title-panel {
  max-width: 460px;
  padding: 18px 20px;
}

.title-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 0.92;
}

.session-code-box {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(8, 17, 31, 0.42);
  border: 1px solid rgba(123, 209, 255, 0.28);
}

.session-code-box span {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
}

.session-code-box strong {
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: 0.22em;
}

.stats-panel {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(6, minmax(96px, auto));
  gap: 1px;
  overflow: hidden;
  align-self: center;
  border-radius: 16px;
}

.stat {
  min-width: 96px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.62);
}

.stat strong {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.help-panel {
  align-self: flex-start;
  max-width: 420px;
  padding: 14px 18px;
  display: grid;
  gap: 6px;
}

.controller-stage {
  width: min(100%, 1380px);
  min-height: calc(100vh - 48px);
  display: grid;
  gap: 14px;
}

.controller-header-card,
.controller-panel {
  backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
}

.controller-header-card {
  padding: 16px 18px;
  display: grid;
  gap: 14px;
}

.controller-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.controller-connect-row,
.controller-status-row {
  display: grid;
  gap: 14px;
}

.controller-connect-row {
  grid-template-columns: minmax(210px, 320px) 1fr;
  align-items: end;
}

.controller-top-actions {
  justify-content: flex-start;
}

.controller-code-field input[type="text"] {
  font-size: clamp(24px, 3vw, 34px);
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-pill.is-connected {
  background: rgba(99, 236, 180, 0.18);
  border-color: rgba(99, 236, 180, 0.34);
}

.status-pill.is-landscape {
  background: rgba(113, 212, 255, 0.16);
  border-color: rgba(113, 212, 255, 0.34);
}

.controller-layout {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) minmax(190px, 240px);
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.controller-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.panel-title {
  display: block;
  margin-top: 6px;
  font-size: clamp(24px, 3vw, 30px);
}

.panel-copy,
.panel-note {
  margin: 0;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.8);
}

.panel-note {
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.speed-value {
  font-size: clamp(28px, 4vw, 34px);
  font-weight: 800;
}

.vertical-throttle-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0;
}

.vertical-throttle-wrap::before {
  content: "";
  position: absolute;
  width: 18px;
  top: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.vertical-throttle {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  width: 56px;
  height: 100%;
  min-height: 240px;
  background: transparent;
}

.center-panel {
  gap: 16px;
}

.axis-readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.axis-readout {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.axis-readout span {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.68);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.axis-readout strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 32px;
  letter-spacing: 0.24em;
  text-align: center;
}

.field input[type="range"] {
  width: 100%;
}

.controller-live-grid {
  display: grid;
  gap: 18px;
}

.sensor-bars {
  display: grid;
  gap: 12px;
}

.sensor-bar {
  display: grid;
  gap: 6px;
}

.bar-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.16);
}

.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transform-origin: left center;
}

.bar-fill.is-negative {
  left: auto;
  right: 50%;
  transform-origin: right center;
}

.controller-tips {
  margin-top: auto;
}

.fire-panel {
  padding: 0;
  overflow: hidden;
  background: rgba(166, 18, 28, 0.32);
  border-color: rgba(255, 110, 124, 0.3);
}

.fire-button {
  flex: 1;
  width: 100%;
  min-height: 100%;
  border: 0;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 112, 112, 0.18), rgba(125, 0, 18, 0.34)),
    rgba(176, 28, 38, 0.28);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
  padding: 22px 20px;
  text-align: left;
  transition: transform 120ms ease, background 120ms ease;
}

.fire-button:active {
  transform: scale(0.985);
  background:
    linear-gradient(180deg, rgba(255, 128, 128, 0.26), rgba(145, 0, 22, 0.42)),
    rgba(176, 28, 38, 0.4);
}

.fire-button.is-firing {
  transform: scale(0.985);
  background:
    linear-gradient(180deg, rgba(255, 128, 128, 0.26), rgba(145, 0, 22, 0.42)),
    rgba(176, 28, 38, 0.4);
}

.fire-button strong {
  font-size: clamp(28px, 4vw, 38px);
  line-height: 0.95;
}

.fire-button span {
  color: rgba(255, 255, 255, 0.8);
}

.fire-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .landing-screen,
  .controller-screen {
    padding: 16px;
  }

  .landing-card,
  .controller-card {
    padding: 20px;
    border-radius: 24px;
  }

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

  .hud {
    padding: 16px;
    gap: 14px;
  }

  .stats-panel {
    left: 16px;
    right: 16px;
    bottom: 14px;
    width: auto;
    transform: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .target-indicator {
    top: 12px;
    padding: 8px 10px;
    gap: 8px;
  }

  .controller-stage {
    min-height: auto;
  }

  .controller-header {
    flex-direction: column;
  }

  .controller-connect-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .controller-layout {
    grid-template-columns: 1fr;
  }

  .throttle-panel {
    min-height: 280px;
  }
}

@media (orientation: landscape) and (max-width: 950px) {
  .controller-screen {
    padding: 12px;
  }

  .controller-stage {
    min-height: calc(100vh - 24px);
    gap: 12px;
  }

  .controller-header-card {
    padding: 14px 16px;
  }

  .controller-layout {
    grid-template-columns: 110px minmax(0, 1fr) 180px;
    gap: 12px;
  }

  .controller-panel {
    padding: 14px;
  }

  .axis-readouts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
