:root {
  color-scheme: dark;
  --bg: #04060f;
  --panel: #10162b;
  --edge: #41558f;
  --text: #edf2ff;
  --muted: #acb8de;
  --cyan: #79eeff;
  --pink: #ff83d0;
  --gold: #ffd680;
  --ok: #95ffb7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(121, 238, 255, 0.2), transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(255, 131, 208, 0.2), transparent 35%),
    linear-gradient(180deg, #080c17 0%, #03050a 100%);
}

.deck {
  width: min(1120px, 94vw);
  margin: 1.5rem auto;
  display: grid;
  gap: 1rem;
}

.topbar,
.panel {
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(16, 22, 43, 0.97), rgba(9, 12, 24, 0.97));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
}

.topbar {
  padding: 1rem 1.15rem;
}

.kicker {
  margin: 0;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

h1 {
  margin: 0.4rem 0;
  font-size: clamp(1.65rem, 3.1vw, 2.25rem);
  line-height: 1.1;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(290px, 0.88fr) minmax(370px, 1.12fr);
}

.panel {
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1.03rem;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.48rem;
  margin-bottom: 0.86rem;
}

button {
  border: 1px solid #5b6ca8;
  border-radius: 8px;
  padding: 0.55rem 0.78rem;
  background: #12193a;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
}

button.primary {
  border-color: #cfa54a;
  background: linear-gradient(180deg, #604917, #422f0d);
  color: #fff0c6;
}

button.ghost {
  border-color: #5272a6;
  background: #101a32;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.8rem;
}

.stats p {
  margin: 0;
  border: 1px solid #465586;
  border-radius: 9px;
  background: #0f1428;
  padding: 0.48rem 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.stats span {
  font-size: 0.84rem;
  color: var(--muted);
}

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

.target,
.wiring-panel,
.status {
  border: 1px solid #435181;
  border-radius: 10px;
  background: #0d1223;
  padding: 0.65rem;
}

.target {
  margin-bottom: 0.74rem;
}

.target h3,
.wiring-panel h3 {
  margin: 0;
  font-size: 0.92rem;
  color: #dce5ff;
}

.target p,
.hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.34;
}

.target-pins {
  margin-top: 0.58rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.target-chip {
  border: 1px solid #506399;
  border-radius: 7px;
  background: #141d3a;
  padding: 0.3rem;
  text-align: center;
  font-size: 0.75rem;
}

.target-chip strong {
  display: block;
  color: #cfe0ff;
  font-size: 0.65rem;
  margin-bottom: 0.1rem;
}

.pin-buttons {
  margin-top: 0.58rem;
  display: grid;
  gap: 0.35rem;
}

.pin-btn {
  width: 100%;
  border: 1px solid #51639c;
  border-radius: 8px;
  background: #121936;
  color: var(--text);
  padding: 0.4rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.83rem;
}

.pin-btn .left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pin-btn .pin-no {
  color: var(--muted);
  min-width: 2.2rem;
  text-align: left;
}

.swatch {
  width: 22px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.pin-btn.selected {
  border-color: #ff91d8;
  box-shadow: 0 0 0 2px rgba(255, 131, 208, 0.22);
}

.pin-btn.good {
  border-color: #7ef6aa;
}

.status {
  margin: 0.8rem 0 0;
  min-height: 3.2rem;
  font-size: 0.9rem;
  line-height: 1.35;
  color: #dce5ff;
}

.frame {
  border: 1px solid #435381;
  border-radius: 12px;
  background: #050913;
  padding: 0.65rem;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  image-rendering: crisp-edges;
}

.legend {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.legend-item {
  border: 1px solid #415385;
  border-radius: 8px;
  background: #0f1730;
  padding: 0.32rem 0.38rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.73rem;
  color: #d4deff;
}

.legend-item .swatch {
  width: 18px;
  height: 10px;
}

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

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