:root {
  color-scheme: dark;
  --bg: #101523;
  --bg-soft: #182036;
  --panel: rgba(12, 17, 31, 0.86);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3ff;
  --muted: #95a2c8;
  --accent: #ff8f5a;
  --accent-2: #5ae0ff;
  --good: #7af7b1;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at top, rgba(90, 224, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 143, 90, 0.2), transparent 30%),
    linear-gradient(180deg, #12192d 0%, #0a0f1b 100%);
  color: var(--text);
}

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

.hero,
.stats,
.panel,
.board-shell,
.actions,
.support-strip,
.result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 22px;
}

.eyebrow,
.stats span,
.result-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 0.95;
}

.subtitle,
.message,
#resultText {
  margin: 10px 0 0;
  color: #d7def6;
  line-height: 1.6;
}

.hub-link,
.support-strip a {
  color: var(--text);
  text-decoration: none;
}

.hub-link {
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 143, 90, 0.24), rgba(90, 224, 255, 0.18));
  white-space: nowrap;
}

.stats {
  margin-top: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stats div,
.panel {
  padding: 14px;
}

.stats strong {
  display: block;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}

.panel {
  margin-top: 16px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.board-shell {
  margin-top: 16px;
  padding: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 14px;
}

.rack {
  position: relative;
  min-height: 314px;
  padding: 16px 10px 12px;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    linear-gradient(180deg, rgba(90, 224, 255, 0.05), rgba(255, 143, 90, 0.04));
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  justify-content: flex-start;
  touch-action: manipulation;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.rack:hover,
.rack.selected {
  transform: translateY(-3px);
  border-color: rgba(90, 224, 255, 0.48);
  box-shadow: 0 0 0 3px rgba(90, 224, 255, 0.12);
}

.rack.done {
  border-color: rgba(122, 247, 177, 0.56);
  box-shadow: 0 0 0 3px rgba(122, 247, 177, 0.12);
}

.rack-label {
  position: absolute;
  top: 12px;
  left: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.slot {
  height: 54px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.plate {
  height: 54px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #0c1220;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.actions {
  margin-top: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

button {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 14px 10px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), #ffb15c);
  color: #1a1320;
}

button.ghost {
  background: rgba(255, 255, 255, 0.06);
}

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

.support-strip {
  margin-top: 16px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.result {
  margin-top: 16px;
  padding: 18px;
}

.result strong {
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  line-height: 1;
}

[hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  .hero {
    flex-direction: column;
  }

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

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

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

  .rack {
    min-height: 286px;
  }
}
