:root {
  color-scheme: dark;
  --bg-1: #180f27;
  --bg-2: #08111f;
  --panel: rgba(8, 14, 27, 0.86);
  --panel-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.12);
  --text: #fbf7ff;
  --muted: #d0cae1;
  --accent: #ff6f61;
  --accent-2: #ffd166;
  --good: #80f0bd;
  --danger: #ff5d8f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
  --red: #ff6f61;
  --blue: #54b7ff;
  --green: #62d48f;
  --yellow: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 111, 97, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(84, 183, 255, 0.16), transparent 30%),
    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,
.legend-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.3rem, 6vw, 4rem);
}

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

.hub-link,
.support-strip a,
.actions button,
.cell-btn,
.legend-chip {
  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), #ff8f45);
  color: #241112;
  text-decoration: none;
  text-align: center;
  font-weight: 800;
}

.hub-link:hover,
.support-strip a:hover,
.actions button:hover,
.cell-btn:hover:not(:disabled),
.legend-chip:hover {
  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,
.legend-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-wrap {
  overflow-x: auto;
}

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

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

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

.cell.blocker {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1) 6px, transparent 6px, transparent 12px);
}

.cell.gate-top { box-shadow: inset 0 6px 0 0 var(--gate-color); }
.cell.gate-right { box-shadow: inset -6px 0 0 0 var(--gate-color); }
.cell.gate-bottom { box-shadow: inset 0 -6px 0 0 var(--gate-color); }
.cell.gate-left { box-shadow: inset 6px 0 0 0 var(--gate-color); }

.cell.selected {
  outline: 2px solid rgba(128, 240, 189, 0.95);
  box-shadow: 0 0 0 4px rgba(128, 240, 189, 0.14);
}

.crate {
  width: calc(100% - 10px);
  height: calc(100% - 10px);
  margin: 5px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(1rem, 2vw, 1.35rem);
  color: #10121b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.crate-red { background: linear-gradient(145deg, var(--red), #ff9874); }
.crate-blue { background: linear-gradient(145deg, var(--blue), #7fd1ff); }
.crate-green { background: linear-gradient(145deg, var(--green), #8ff3b4); }
.crate-yellow { background: linear-gradient(145deg, var(--yellow), #ffe49b); }

.block-label,
.gate-label {
  position: absolute;
  inset: auto 8px 8px auto;
  font-size: 0.65rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.7);
}

.gate-label {
  inset: 6px 8px auto auto;
}

.legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.legend-chip {
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
}

.legend-chip strong {
  display: block;
  margin-bottom: 4px;
  color: #10121b;
}

.legend-red { background: linear-gradient(145deg, rgba(255,111,97,0.9), rgba(255,152,116,0.84)); }
.legend-blue { background: linear-gradient(145deg, rgba(84,183,255,0.9), rgba(127,209,255,0.84)); }
.legend-green { background: linear-gradient(145deg, rgba(98,212,143,0.9), rgba(143,243,180,0.84)); }
.legend-yellow { background: linear-gradient(145deg, rgba(255,209,102,0.94), rgba(255,228,155,0.88)); }

.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), #ff8f45);
  color: #251213;
}

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

.actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.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 {
    display: grid;
    grid-template-columns: 1fr;
  }

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

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

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

  .board {
    gap: 4px;
    min-width: 290px;
  }

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

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

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