:root {
  color-scheme: dark;
  --bg-1: #1b1331;
  --bg-2: #0e1525;
  --panel: rgba(11, 18, 31, 0.86);
  --panel-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f7f3ff;
  --muted: #c8bfdc;
  --accent: #ff8552;
  --accent-2: #ffd166;
  --good: #74f0b3;
  --danger: #ff6677;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 133, 82, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(116, 240, 179, 0.16), transparent 28%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: "Trebuchet MS", "Arial Black", system-ui, sans-serif;
}

button,
a {
  touch-action: manipulation;
}

.shell {
  width: min(1040px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

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

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

.eyebrow,
.label,
.result-label,
.stats span {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent-2);
}

.hero h1,
.section-head h2 {
  margin: 8px 0 6px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  letter-spacing: 0.04em;
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.8rem);
}

.subtitle,
.goal-card p,
.section-head p,
.message {
  color: var(--muted);
  line-height: 1.55;
}

.hub-link,
.support-strip a,
.actions button,
.rack-piece,
.cell-btn {
  transition: transform 0.15s ease, opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.hub-link {
  min-width: 88px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #ff5d8f);
  color: #1d0f19;
  text-decoration: none;
  text-align: center;
  font-weight: 800;
}

.hub-link:hover,
.support-strip a:hover,
.actions button:hover,
.rack-piece:hover:not(:disabled),
.cell-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

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

.stats div {
  padding: 14px 10px;
  border-radius: 18px;
  background: var(--panel-2);
  text-align: center;
}

.stats strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.panel,
.board-section,
.rack-section,
.result {
  margin-top: 14px;
  padding: 18px;
}

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

.goal-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.goal-card strong {
  display: block;
  margin: 8px 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.section-head h2,
.section-head p {
  margin: 0;
}

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

.cell {
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.cell-btn {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  position: relative;
  cursor: pointer;
}

.cell.filled {
  background:
    linear-gradient(145deg, rgba(255, 133, 82, 0.96), rgba(255, 93, 143, 0.9));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.cell.filled::after {
  content: "";
  position: absolute;
  inset: 20%;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
}

.cell.anchor {
  outline: 2px solid rgba(116, 240, 179, 0.95);
  box-shadow: 0 0 0 4px rgba(116, 240, 179, 0.15);
}

.cell.ghost {
  background: rgba(116, 240, 179, 0.12);
}

.rack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.rack-piece {
  min-height: 132px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  color: var(--text);
  padding: 14px;
  cursor: pointer;
}

.rack-piece.selected {
  border-color: var(--good);
  box-shadow: 0 0 0 3px rgba(116, 240, 179, 0.18);
}

.rack-piece:disabled {
  opacity: 0.35;
  cursor: default;
}

.rack-piece-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.82rem;
}

.rack-piece-title {
  font-weight: 800;
}

.mini-grid {
  --size: 4;
  display: grid;
  grid-template-columns: repeat(var(--size), 20px);
  gap: 4px;
  justify-content: center;
}

.mini-cell {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.mini-cell.on {
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
}

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

.actions button,
.support-strip a,
.result button {
  border: 0;
  border-radius: 999px;
  padding: 14px 16px;
  font-weight: 800;
  cursor: pointer;
}

.actions .primary,
.result .primary {
  background: linear-gradient(135deg, var(--accent), #ff5d8f);
  color: #1a0d18;
}

.actions .ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.support-strip {
  margin-top: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.support-strip a {
  text-decoration: none;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.result {
  text-align: center;
}

.result strong {
  display: block;
  margin: 8px 0 10px;
  font-size: clamp(2.1rem, 8vw, 3.6rem);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 14px, 720px);
    padding-top: 10px;
  }

  .hero,
  .section-head,
  .support-strip {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .goal-grid,
  .rack,
  .actions,
  .support-strip {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    grid-template-columns: repeat(var(--size), 18px);
  }
}

@media (max-width: 480px) {
  .hero,
  .panel,
  .board-section,
  .rack-section,
  .result {
    padding: 14px;
    border-radius: 20px;
  }

  .board {
    gap: 4px;
  }

  .cell,
  .cell-btn {
    border-radius: 10px;
  }

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

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