:root {
  color-scheme: light dark;
  /* Gruvbox Light */
  --bg: #fbf1c7;
  --fg: #3c3836;
  --muted: #665c54;
  --accent: #d79921;
  --accent-ink: #8f3f0a;
  --border: #d5c4a1;
  --surface: #ebdbb2;
  --wrong: #9d0006;
  --same: #076678;
  --reflected: #79740e;
  --unrelated: #9d0006;
  --link-neutral: #a89984;
  --history-line: #282828;
  --history-complete: #a89984;
  --history-complete-ink: #282828;
  --history-optimal: var(--history-line);
  --history-optimal-text: var(--bg);
  --glow: radial-gradient(circle closest-side, #fbf1c7a6 12%, #fbf1c759 38%, #a899842e 60%, transparent 100%);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Gruvbox Dark */
    --bg: #282828;
    --fg: #ebdbb2;
    --muted: #bdae93;
    --accent: #fabd2f;
    --accent-ink: var(--accent);
    --border: #504945;
    --surface: #3c3836;
    --wrong: #fb4934;
    --same: #83a598;
    --reflected: #b8bb26;
    --unrelated: #fb4934;
    --link-neutral: #665c54;
    --history-line: #fbf1c7;
    --history-complete: #665c54;
    --history-complete-ink: #fbf1c7;
    --glow: radial-gradient(circle closest-side, #fbf1c766 12%, #fbf1c726 42%, transparent 100%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { max-width: 48rem; margin: 0 auto; padding: 2rem 1rem; }
::selection { background: var(--accent); color: #282828; }

header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; }
h1, h2 { font-weight: 600; line-height: 1.25; margin: 0 0 .6rem; }
h1 { display: flex; align-items: center; gap: .45rem; font-size: 2rem; }
h1 img { display: block; width: 2.625rem; height: 2.625rem; }
h2 { font-size: 1.5rem; }
p { margin: 0 0 1rem; }
#daily-label, #practice-label, .shelf, #feedback { color: var(--muted); font-size: .875rem; }

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.05;
  max-height: 42rem;
  margin: 0 auto 1rem;
  isolation: isolate;
}

.shelf {
  position: absolute;
  inset: 0 0 auto;
  height: 24%;
  padding: .2rem .55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .375rem;
  pointer-events: none;
}

#shelf-scroll {
  position: absolute;
  z-index: 2;
  inset: 1.35rem 0 76%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
#trophies {
  display: flex;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}
.trophy {
  position: relative;
  flex: 0 0 clamp(72px, 22%, 114px);
  text-align: center;
}
.trophy span {
  position: absolute;
  inset: auto 0 0;
  color: var(--muted);
  font-size: .75rem;
  pointer-events: none;
}

#board {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  cursor: default;
}

#board.over-shape { cursor: pointer; }
#glow, #links, #shapes { position: absolute; inset: 0; pointer-events: none; }
#glow { clip-path: inset(24% 0 0); }
#links { z-index: 0; }
#shapes, #load-status { z-index: 2; }
.shape-halo {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--glow);
}
.relation-line {
  position: absolute;
  height: 2px;
  border-radius: 2px;
  transform-origin: left center;
  background: var(--link-neutral);
}
.relation-line[data-relation="1"] { --relation-color: var(--same); }
.relation-line[data-relation="2"] { --relation-color: var(--reflected); }
.relation-line.revealed, .relation-line.glowing { background: var(--relation-color); }
.relation-line.glowing {
  z-index: 1;
  box-shadow: 0 0 8px color-mix(in srgb, var(--relation-color) 68%, transparent);
}

.shape {
  position: absolute;
  transform: translate(-50%, -50%);
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 50%;
  outline-offset: -2px;
}

.controls, #actions, .game-actions, .puzzle-modes { display: flex; flex-wrap: wrap; gap: .45rem; }
.controls { justify-content: space-between; align-items: center; }
.puzzle-modes { margin-bottom: .9rem; }
button, textarea { font: inherit; color: inherit; }
.controls button, .puzzle-modes button, #copy, #reattempt {
  min-height: 2.6rem;
  padding: .25rem .65rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
}
button:enabled { cursor: pointer; }
.controls button:enabled:hover, .puzzle-modes button:enabled:hover, #copy:hover, #reattempt:hover { border-color: var(--accent); color: var(--accent-ink); }
.controls button:disabled, .puzzle-modes button:disabled { color: var(--muted); opacity: .58; }
#actions [data-answer="1"] { --button-color: var(--same); }
#actions [data-answer="2"] { --button-color: var(--reflected); }
#actions [data-answer="3"] { --button-color: var(--unrelated); }
#actions button:enabled {
  border-color: var(--button-color);
  background: color-mix(in srgb, var(--button-color) 16%, var(--surface));
  color: color-mix(in srgb, var(--button-color) 20%, var(--fg));
}
#actions button:enabled:hover {
  background: color-mix(in srgb, var(--button-color) 26%, var(--surface));
}
#help-button[aria-expanded="true"] {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 24%, var(--surface));
}
button:focus-visible, textarea:focus-visible, #shelf-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#feedback { min-height: 1.4em; margin: .6rem 0; }
#feedback[data-tone="wrong"] { color: var(--wrong); }
#feedback[data-tone="correct"] { color: var(--accent-ink); }
#load-status { position: absolute; inset: 55% .5rem auto; text-align: center; }
#results { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
#help {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
}
#help p:last-child { margin-bottom: 0; }
#help .help-same { color: var(--same); }
#help .help-reflected { color: var(--reflected); }
#help .help-unrelated { color: var(--unrelated); }
#score {
  display: block;
  width: 100%;
  margin-bottom: .55rem;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
  font-family: ui-monospace, monospace;
  font-size: .875rem;
  resize: vertical;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 600px) {
  body { padding: 1rem; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.375rem; }
  .controls button { padding-inline: .48rem; }
}

.history-board { max-width: 28rem; margin-inline: auto; }
#history-grid {
  --history-radius: 6px;
  display: grid;
  grid-template-columns: repeat(var(--history-columns, 7), var(--history-cell-size, minmax(0, 1fr)));
  justify-content: center;
}
#history-grid button {
  position: relative;
  aspect-ratio: 1;
  border: solid var(--history-line);
  border-width: 1px 0 0 1px;
  padding: 0;
  background-color: var(--bg);
}
#history-grid button:not(.has-right-cell) { border-right-width: 1px; }
#history-grid button:not(.has-below-cell) { border-bottom-width: 1px; }
#history-grid button:not(.has-above-cell, .has-left-cell) { border-top-left-radius: var(--history-radius); }
#history-grid button:not(.has-above-cell, .has-right-cell) { border-top-right-radius: var(--history-radius); }
#history-grid button:not(.has-below-cell, .has-left-cell) { border-bottom-left-radius: var(--history-radius); }
#history-grid button:not(.has-below-cell, .has-right-cell) { border-bottom-right-radius: var(--history-radius); }
#history-grid button[data-status="complete"] { background-color: var(--history-complete); color: var(--history-complete-ink); }
#history-grid button[data-status="optimal"] { background-color: var(--history-optimal); color: var(--history-optimal-text); }

#history-grid button:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; z-index: 1; }

#practice-options {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .9rem;
}
#practice-options select {
  margin-inline-start: .25rem;
  padding: .2rem .35rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}
