* { box-sizing: border-box; }
:root {
  --bg: #0b1320;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-2: rgba(30, 41, 59, 0.9);
  --text: #ecf3ff;
  --muted: #9fb3cc;
  --accent: #8b5cf6;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --border: rgba(148, 163, 184, 0.18);
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(139, 92, 246, 0.22), transparent 35%),
    linear-gradient(180deg, #111827 0%, #0b1320 45%, #09111b 100%);
  color: var(--text);
}
.app-shell {
  width: min(980px, calc(100vw - 18px));
  margin: 0 auto;
  padding: 18px 0 28px;
  display: grid;
  gap: 16px;
}
.hero,
.panel,
.status-card {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.hero {
  border-radius: 24px;
  padding: 22px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}
.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #c4b5fd;
  font-size: 0.78rem;
}
h1 {
  margin: 0 0 6px;
  font-size: clamp(2rem, 4vw, 3.2rem);
}
.subtitle,
#puzzleBlurb,
.panel-title-row p,
.picker-label,
.group-card small,
.connection-feedback,
.message {
  color: var(--muted);
}
.hero-actions {
  min-width: 220px;
  display: grid;
  gap: 10px;
}
.status-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.status-card {
  border-radius: 18px;
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}
.status-card span { color: var(--muted); font-size: 0.92rem; }
.status-card strong { font-size: 1.45rem; }
.panel {
  border-radius: 22px;
  padding: 18px;
}
.board-header,
.panel-title-row,
.board-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.selection-summary {
  display: grid;
  gap: 8px;
  justify-items: end;
}
.wall-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.tile {
  appearance: none;
  border: 1px solid rgba(196, 181, 253, 0.16);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
  color: var(--text);
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 8px;
  font: inherit;
  font-size: clamp(0.74rem, 1.55vw, 1rem);
  font-weight: 700;
  line-height: 1.08;
  text-wrap: balance;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 140ms ease;
}
.tile:hover { transform: translateY(-2px); border-color: rgba(167, 139, 250, 0.35); }
.tile.selected { background: linear-gradient(180deg, rgba(91, 33, 182, 0.95), rgba(76, 29, 149, 0.94)); border-color: rgba(196, 181, 253, 0.7); }
.tile.locked { cursor: default; }
.tile.group-0 { background: linear-gradient(180deg, rgba(37, 99, 235, 0.95), rgba(29, 78, 216, 0.95)); }
.tile.group-1 { background: linear-gradient(180deg, rgba(217, 119, 6, 0.95), rgba(180, 83, 9, 0.95)); }
.tile.group-2 { background: linear-gradient(180deg, rgba(5, 150, 105, 0.95), rgba(4, 120, 87, 0.95)); }
.tile.group-3 { background: linear-gradient(180deg, rgba(190, 24, 93, 0.95), rgba(157, 23, 77, 0.95)); }
.tile.revealed { opacity: 0.74; }
.board-actions { margin-top: 14px; }
.connections-panel { display: none; }
.connections-panel.active { display: block; }
.connections-list {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}
.group-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-2);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.group-card h3 { margin: 0; }
.group-items { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 0.92rem;
}
.connection-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(15, 23, 42, 0.92);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}
button,
select {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
}
button {
  cursor: pointer;
  font-weight: 700;
  color: #0f172a;
  background: linear-gradient(180deg, #c4b5fd, #a78bfa);
}
button.secondary { background: linear-gradient(180deg, #cbd5e1, #94a3b8); }
button.ghost { background: linear-gradient(180deg, #fca5a5, #ef4444); color: white; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
select {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}
.message {
  margin: 14px 0 0;
  min-height: 1.4rem;
  font-size: 0.98rem;
}
.message.good { color: #86efac; }
.message.warn { color: #fde68a; }
.message.bad { color: #fca5a5; }
.connection-feedback.good { color: #86efac; }
.connection-feedback.bad { color: #fca5a5; }
@media (max-width: 760px) {
  .hero,
  .board-header,
  .panel-title-row,
  .board-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
  .status-bar { grid-template-columns: repeat(2, 1fr); }
  .wall-grid { gap: 6px; }
  .tile {
    border-radius: 12px;
    padding: 6px;
    font-size: clamp(0.62rem, 2.35vw, 0.84rem);
  }
  .selection-summary { justify-items: stretch; }
}
