:root {
  color-scheme: dark;
  --bg: #101116;
  --panel: #191b23;
  --panel-2: #20232d;
  --line: #343846;
  --text: #f6f7fb;
  --muted: #a8adbd;
  --accent: #26d07c;
  --warn: #f6c453;
  --danger: #ff5d5d;
  --blue: #51a7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -10%, #26313a 0, #101116 44rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.mode-strip,
.garage,
.telemetry,
.stage {
  border: 1px solid var(--line);
  background: rgba(25, 27, 35, 0.94);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 92px;
  padding: 18px;
  border-radius: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.topbar p,
.hint,
.keys,
small {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 8px;
  min-width: min(430px, 100%);
}

.stats span,
.mode,
.ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.stats span {
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: right;
}

.stats strong {
  font-size: 1.1rem;
}

.stats small {
  text-transform: uppercase;
  font-size: 0.7rem;
}

.mode-strip {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin: 12px 0;
  padding: 10px;
  border-radius: 8px;
}

.mode,
.ghost,
.part,
.slot,
.touch-controls button {
  min-height: 44px;
  color: var(--text);
  cursor: pointer;
}

.mode {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
}

.mode.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mode span {
  font-weight: 800;
}

.ghost {
  padding: 0 16px;
}

.game-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  gap: 12px;
  align-items: stretch;
}

.garage,
.telemetry,
.stage {
  border-radius: 8px;
}

.garage,
.telemetry {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  font-size: 1.05rem;
}

.panel-head span {
  color: var(--accent);
  font-weight: 800;
  white-space: nowrap;
}

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

.part {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #232734;
  padding: 10px 12px;
  text-align: left;
}

.part.selected {
  border-color: var(--warn);
  box-shadow: inset 0 0 0 1px var(--warn);
}

.part.done {
  opacity: 0.42;
  cursor: default;
}

.part.decoy {
  border-style: dashed;
}

.hint {
  margin-top: 14px;
  font-size: 0.93rem;
  line-height: 1.45;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 620px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  background: #15181d;
}

.message {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 2;
  display: grid;
  gap: 3px;
  max-width: min(430px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.72);
  backdrop-filter: blur(8px);
}

.message span {
  color: var(--muted);
  font-size: 0.9rem;
}

.telemetry dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.telemetry dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
}

.keys {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.touch-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  display: none;
  grid-template-columns: repeat(4, 52px);
  gap: 8px;
}

.touch-controls button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(32, 35, 45, 0.82);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
}

@media (max-width: 1080px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

  .garage,
  .telemetry {
    min-height: 0;
  }

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

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats,
  .mode-strip,
  .parts {
    grid-template-columns: 1fr;
  }

  .stage,
  canvas {
    min-height: 520px;
  }

  .message {
    font-size: 0.9rem;
  }
}
