:root {
  color-scheme: dark;
  --bg: #081018;
  --ink: #f7f1df;
  --muted: #b8b3a4;
  --line: rgba(247, 241, 223, 0.16);
  --panel: rgba(18, 23, 35, 0.9);
  --cyan: #55e6ff;
  --gold: #f9c846;
  --green: #78e08f;
  --pink: #ff6f91;
  --red: #ff5a67;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(8, 16, 24, 0.34), rgba(8, 16, 24, 0.92)),
    url("https://images.unsplash.com/photo-1518005020951-eccb494ad742?auto=format&fit=crop&w=1800&q=80") center / cover fixed;
}

button,
input {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

button {
  min-height: 46px;
  padding: 0.72rem 0.9rem;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    #232a37;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

button:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.primary {
  color: #101319;
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.signalApp {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 14px;
}

.stageWrap {
  position: relative;
  min-width: 0;
  min-height: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10131b;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
  touch-action: none;
}

.signalControls {
  display: grid;
  align-content: start;
  gap: 12px;
  height: 100%;
  overflow: auto;
  padding-right: 2px;
}

.sideHeader,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.sideHeader {
  padding: 14px;
}

.panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.panel.compact {
  gap: 8px;
}

.shopPanel {
  gap: 12px;
}

.panel button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.panel span {
  color: var(--gold);
}

.kicker {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 1000;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
}

p {
  color: var(--muted);
  line-height: 1.42;
}

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

.scoreStrip span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.58rem 0.64rem;
  color: var(--muted);
  background: rgba(9, 13, 23, 0.72);
}

.scoreStrip strong {
  display: block;
  color: var(--ink);
  font-size: 1.25rem;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 850;
}

label span {
  justify-self: end;
  margin-top: -1.45rem;
}

.shopStatus {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.62rem 0.7rem;
  background: rgba(9, 13, 23, 0.58);
  font-weight: 850;
}

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

.shopGroup h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

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

.skinBuy {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 68px;
  padding: 0.54rem;
  text-align: left;
}

.skinBuy[aria-pressed="true"] {
  color: #101319;
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.skinSample {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--sample-a), var(--sample-b));
  box-shadow: 0 0 16px color-mix(in srgb, var(--sample-a), transparent 48%);
}

.skinBuy span,
.skinBuy small {
  display: block;
  min-width: 0;
}

.skinBuy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skinBuy small {
  color: inherit;
  opacity: 0.78;
  font-size: 0.72rem;
}

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

.levelPanel.collapsed .levelGrid {
  display: none;
}

.levelGrid button {
  min-width: 0;
  min-height: 64px;
  justify-content: center;
  text-align: center;
  line-height: 1.18;
  white-space: pre-line;
}

.levelGrid button[aria-pressed="true"] {
  color: #101319;
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.levelGrid button.locked {
  opacity: 0.45;
}

.touchPad {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  pointer-events: none;
}

.touchPad button {
  min-height: 48px;
  padding: 0.4rem;
  background: rgba(18, 23, 35, 0.78);
  pointer-events: auto;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .signalApp {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .stageWrap {
    height: min(68vh, 560px);
    min-height: 390px;
  }

  .signalControls {
    height: auto;
    overflow: visible;
  }

  .touchPad {
    display: grid;
  }
}
