:root {
  color-scheme: dark;
  --ink: #f6f7fb;
  --muted: #aeb7c7;
  --panel: rgba(8, 10, 15, 0.72);
  --panel-strong: rgba(13, 15, 23, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --cyan: #5ae7ff;
  --amber: #ffd166;
  --rose: #ff6b6b;
  --green: #7fffb2;
  --violet: #b09cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #06070a;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 520px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(90, 231, 255, 0.16), transparent 31%),
    radial-gradient(circle at 84% 74%, rgba(255, 209, 102, 0.11), transparent 29%),
    linear-gradient(145deg, #05060a 0%, #111018 52%, #090b0d 100%);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(70px, 0.7fr) minmax(82px, 0.82fr) minmax(220px, 1.9fr) repeat(4, minmax(72px, 0.74fr)) auto auto auto;
  gap: 10px;
  align-items: stretch;
  pointer-events: none;
}

.hud-block,
.icon-button,
.dash-button {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.hud-block {
  min-width: 0;
  border-radius: 8px;
  padding: 10px 12px;
}

.hud-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1rem, 2.4vh, 1.55rem);
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 48px;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  pointer-events: auto;
  font-size: 0.72rem;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover,
.dash-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.icon-button:focus-visible,
.dash-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.mini-button:focus-visible,
.boss-choice:focus-visible,
.online-actions input:focus-visible,
.setup-grid input:focus-visible,
.menu-focused {
  outline: 3px solid rgba(90, 231, 255, 0.72);
  outline-offset: 3px;
}

.menu-focused {
  border-color: rgba(90, 231, 255, 0.9);
  filter: saturate(1.14) brightness(1.06);
}

.charge-wrap {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  height: 7px;
  z-index: 2;
}

.online-panel,
.setup-panel {
  position: absolute;
  top: max(84px, calc(env(safe-area-inset-top) + 84px));
  right: 18px;
  z-index: 4;
  width: min(330px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-strong);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.setup-panel {
  top: max(246px, calc(env(safe-area-inset-top) + 246px));
}

.run-panel {
  left: 18px;
  right: auto;
  top: max(84px, calc(env(safe-area-inset-top) + 84px));
}

.run-panel.is-below {
  top: max(246px, calc(env(safe-area-inset-top) + 246px));
}

.setup-panel.local-flow {
  inset: 0;
  top: 0;
  right: 0;
  left: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  width: auto;
  border: 0;
  border-radius: 0;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 48%, rgba(90, 231, 255, 0.12), transparent 25%),
    rgba(2, 3, 6, 0.58);
  box-shadow: none;
}

.setup-panel.local-flow > .online-topline,
.setup-panel.local-flow > .local-step {
  width: min(760px, calc(100vw - 48px));
}

.setup-panel.local-flow > .online-topline {
  margin-bottom: 16px;
}

.online-panel.is-collapsed,
.setup-panel.is-collapsed,
.boss-grid.is-collapsed {
  display: none;
}

.online-topline,
.online-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-topline {
  justify-content: space-between;
  margin-bottom: 10px;
}

.online-topline strong {
  font-size: 0.88rem;
}

.online-topline span,
.online-panel p,
.setup-panel p {
  color: var(--muted);
  font-size: 0.78rem;
}

.online-panel p,
.setup-panel p {
  margin: 10px 0 0;
  line-height: 1.35;
}

.online-actions input,
.setup-grid input {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

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

.run-mode-grid {
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setup-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.setup-grid input {
  width: 100%;
  font-weight: 900;
  text-align: center;
}

.setup-grid input:disabled {
  color: var(--ink);
  opacity: 1;
  cursor: default;
}

.local-step {
  display: grid;
  gap: 10px;
}

.local-step.is-collapsed {
  display: none;
}

.local-join-zone {
  display: grid;
  place-items: center;
  min-height: 128px;
  border: 1px dashed rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.035);
}

.local-join-zone strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.local-join-zone span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.42;
}

.local-players-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.42;
}

.local-player-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.local-player-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 0 16px currentColor;
}

.local-player-card strong,
.local-player-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-player-card strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.local-player-card span {
  color: var(--muted);
  font-size: 0.68rem;
}

.mini-button {
  min-width: 62px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  cursor: pointer;
  color: #071012;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-size: 0.78rem;
  font-weight: 900;
}

.mini-button.is-selected {
  background: linear-gradient(135deg, var(--rose), var(--amber));
}

.mini-button:disabled {
  cursor: default;
  filter: grayscale(0.65);
  opacity: 0.5;
}

.boss-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.boss-choice {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: left;
  padding: 0 10px;
}

.boss-choice.is-selected {
  color: #071012;
  background: linear-gradient(135deg, var(--rose), var(--amber));
}

.room-start {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, var(--amber), var(--green));
}

.objective-wrap {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: max(36px, calc(env(safe-area-inset-bottom) + 36px));
  width: min(520px, calc(100vw - 36px));
  z-index: 2;
}

.objective-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.objective-meta span,
.objective-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.objective-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  overflow: visible;
}

.objective-chip {
  display: inline-grid;
  grid-template-columns: 20px minmax(0, auto) auto;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  max-width: 100%;
  padding: 4px 8px 4px 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(9, 13, 19, 0.66);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.objective-chip.is-complete {
  border-color: rgba(127, 255, 178, 0.48);
  background: rgba(40, 92, 61, 0.52);
}

.objective-chip.is-rhythm {
  border-color: rgba(255, 209, 102, 0.42);
}

.objective-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.objective-orb {
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.96) 0 10%, transparent 11%),
    radial-gradient(circle at 50% 52%, var(--objective-color, var(--cyan)) 0 54%, rgba(255, 255, 255, 0.32) 55% 60%, transparent 61%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.42),
    0 0 15px var(--objective-color, var(--cyan));
}

.objective-orb.is-any {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.96) 0 10%, transparent 11%),
    conic-gradient(from 20deg, var(--cyan), var(--green), var(--amber), var(--rose), #b09cff, var(--cyan));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.42),
    0 0 16px rgba(90, 231, 255, 0.72);
}

.objective-orb.is-rhythm::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(255, 209, 102, 0.68);
  border-radius: inherit;
  animation: objectiveBeat 0.72s ease-in-out infinite;
}

.objective-symbol {
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--objective-color, var(--amber));
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.18);
  font-size: 0.68rem;
  overflow: hidden;
}

.objective-label,
.objective-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.objective-label {
  max-width: 150px;
  color: rgba(245, 247, 251, 0.9);
}

.objective-count {
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.objective-chip.is-complete .objective-count {
  color: var(--green);
}

@keyframes objectiveBeat {
  0%,
  100% {
    transform: scale(0.86);
    opacity: 0.45;
  }

  50% {
    transform: scale(1.16);
    opacity: 0.95;
  }
}

@media (max-width: 520px) {
  .objective-details {
    gap: 5px;
    margin-bottom: 7px;
  }

  .objective-chip {
    grid-template-columns: 18px minmax(0, auto) auto;
    min-height: 27px;
    gap: 5px;
    padding: 3px 7px 3px 4px;
    font-size: 0.62rem;
  }

  .objective-icon {
    width: 18px;
    height: 18px;
  }

  .objective-label {
    max-width: 118px;
  }
}

.objective-track {
  height: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.objective-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose), var(--amber), var(--green), var(--cyan));
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 160ms ease;
}

.charge-track {
  width: min(420px, calc(100vw - 36px));
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.charge-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--amber));
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 80ms linear;
}

.dash-button {
  position: absolute;
  right: 18px;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 3;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  color: #061014;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-weight: 900;
  box-shadow: 0 0 26px rgba(90, 231, 255, 0.28), 0 18px 44px rgba(0, 0, 0, 0.3);
}

.dash-button[disabled] {
  cursor: default;
  filter: grayscale(0.55);
  opacity: 0.52;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 28px;
  text-align: center;
  pointer-events: auto;
  background:
    radial-gradient(circle at 50% 48%, rgba(90, 231, 255, 0.14), transparent 24%),
    rgba(2, 3, 6, 0.46);
  backdrop-filter: blur(8px);
}

.screen.is-hidden {
  display: none;
}

.kicker {
  margin: 0;
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  max-width: 900px;
  margin: 0;
  line-height: 0.92;
}

h1 {
  font-size: clamp(4rem, 15vh, 9.5rem);
}

h2 {
  font-size: clamp(3rem, 9vh, 6.8rem);
}

.tagline {
  max-width: min(560px, calc(100vw - 48px));
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vh, 1.2rem);
  line-height: 1.5;
}

.primary-button,
.secondary-button {
  min-width: 164px;
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0 22px;
  cursor: pointer;
  color: #071012;
  background: linear-gradient(135deg, var(--amber), var(--green));
  font-weight: 900;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
  transition: transform 160ms ease, filter 160ms ease;
}

.secondary-button {
  color: var(--ink);
  background: var(--panel-strong);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(142px, 1fr));
  gap: 12px;
  width: min(560px, calc(100vw - 48px));
}

.mode-grid .primary-button {
  min-width: 0;
  width: 100%;
}

.mode-hint {
  font-size: 0.94rem;
}

.primary-button:active,
.secondary-button:active,
.dash-button:active,
.icon-button:active {
  transform: translateY(1px) scale(0.98);
}

@media (max-width: 720px) {
  .game-shell {
    min-height: 100svh;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr)) repeat(3, 48px);
  }

  .hud-best {
    display: none;
  }

  .hud-rhythm {
    display: none;
  }

  .online-panel,
  .setup-panel,
  .run-panel {
    top: max(144px, calc(env(safe-area-inset-top) + 144px));
    left: 18px;
    right: 18px;
    width: auto;
  }

  .setup-panel.local-flow {
    inset: 0;
    top: 0;
  }

  .local-players-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-panel {
    top: max(296px, calc(env(safe-area-inset-top) + 296px));
  }

  .run-panel {
    top: max(144px, calc(env(safe-area-inset-top) + 144px));
  }

  .run-panel.is-below {
    top: max(296px, calc(env(safe-area-inset-top) + 296px));
  }

  .hud-objective {
    grid-column: 1 / span 2;
  }

  .hud-block {
    padding: 9px 10px;
  }

  .hud strong {
    font-size: 1rem;
  }

  .icon-button {
    min-height: 48px;
  }

  h1 {
    font-size: clamp(3.3rem, 20vw, 5.7rem);
  }

  h2 {
    font-size: clamp(2.5rem, 15vw, 4.3rem);
  }

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

@media (hover: hover) and (pointer: fine) {
  .dash-button {
    display: none;
  }
}
