:root {
  color-scheme: light;
  --ink: #171a21;
  --muted: #5c6575;
  --paper: #f7f8fb;
  --panel: #ffffff;
  --line: #d9dee8;
  --accent: #f05f4b;
  --accent-2: #109a8f;
  --accent-3: #f1c84b;
  --shadow: 0 18px 42px rgba(30, 38, 55, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(240, 95, 75, 0.12), transparent 28%),
    linear-gradient(225deg, rgba(16, 154, 143, 0.14), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: #e8ebf1;
  color: var(--ink);
}

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

.shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1;
  letter-spacing: 0;
}

.lede {
  max-width: 620px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.scorebox {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.scorebox span,
.scorebox strong {
  display: block;
}

.scorebox span {
  color: var(--muted);
  font-size: 0.88rem;
}

.scorebox strong {
  margin-top: 4px;
  font-size: 1.7rem;
}

.best-score {
  margin-top: 6px;
  font-weight: 800;
}

.toolbar,
.target-strip,
.side-panel,
.board-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--muted);
  font-weight: 700;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

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

.swatch-block {
  display: grid;
  grid-template-columns: 74px 56px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 64px;
}

.swatch-label {
  color: var(--muted);
  font-weight: 800;
}

.swatch {
  width: 56px;
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  background: var(--swatch);
}

.hex {
  min-width: 0;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 14px;
}

.board-panel {
  padding: 14px;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 640px);
  margin: 0 auto;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 54px;
  padding: 0;
  border: 2px solid rgba(0, 0, 0, 0.12);
  background: var(--chip);
  color: var(--chip-text);
  box-shadow: inset 0 -16px 26px rgba(0, 0, 0, 0.12);
  font-size: 0.95rem;
  font-weight: 900;
  transition:
    transform 120ms ease,
    outline-color 120ms ease;
}

.tile:not(:disabled):hover,
.tile.next {
  transform: translateY(-2px);
}

.tile.selected {
  outline: 4px solid var(--accent-3);
  outline-offset: -6px;
}

.tile.next {
  outline: 3px solid rgba(16, 154, 143, 0.78);
  outline-offset: -5px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.prompt {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.chain-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
}

.mini-chip {
  display: grid;
  place-items: center;
  width: 40px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--chip);
  color: var(--chip-text);
  font-weight: 900;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.14);
}

.empty-chain {
  color: var(--muted);
  font-weight: 700;
}

.chain-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.feedback {
  min-height: 84px;
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #f1f4fa;
  padding: 12px 14px;
}

.feedback p {
  margin: 0 0 8px;
  color: var(--ink);
  line-height: 1.4;
}

.copy-fallback {
  margin: 0 0 8px;
  white-space: pre-wrap;
  color: var(--ink);
  font: 0.9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.answer-reveal {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.answer-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.answer-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.answer-chips {
  min-height: 40px;
}

.answer-code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.rules {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .hero {
    display: grid;
    gap: 14px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .scorebox {
    min-width: 0;
  }

  .target-strip,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .swatch-block {
    grid-template-columns: 70px 50px minmax(0, 1fr);
  }

  .swatch {
    width: 50px;
  }

  .board {
    gap: 6px;
  }

  .tile {
    min-height: 48px;
    font-size: 0.82rem;
  }
}
