:root {
  color-scheme: dark;
  --bg-top: #2f3237;
  --bg-bottom: #181a1d;
  --panel: rgba(22, 24, 28, 0.92);
  --panel-strong: rgba(18, 20, 24, 0.97);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8e3d4;
  --muted: #ada48e;
  --accent: #7fa650;
  --accent-soft: rgba(127, 166, 80, 0.18);
  --accent-strong: #a9d06d;
  --warn: #c4704a;
  --grid-light: #f0eadc;
  --grid-dark: #e6dfd0;
  --grid-line: #beb39b;
  --grid-fill: #20242a;
  --grid-text: #171717;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.38);
  --radius: 18px;
  --cell-size: min(4.1vw, 44px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(127, 166, 80, 0.08), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", "Segoe UI",
    sans-serif;
}

body {
  min-height: 100vh;
}

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

.topbar {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.brand-kicker,
.panel-label,
.clue-heading,
.board-meta,
.board-help,
.select-wrap span,
.stat-label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.brand-kicker,
.panel-label,
.board-meta,
.muted-copy,
.board-help,
.select-wrap span,
.stat-label {
  color: var(--muted);
}

.brand-block h1,
.board-title,
.hero-label,
.stat-value {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
    serif;
}

.brand-block h1 {
  margin: 2px 0 0;
  font-size: clamp(2.2rem, 4.6vw, 3.4rem);
  line-height: 0.95;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.select-wrap {
  display: grid;
  gap: 6px;
}

.select-wrap select,
.action-button {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 11px 14px;
  font: inherit;
  box-shadow: var(--shadow);
}

.action-button {
  cursor: pointer;
  min-width: 116px;
}

.action-button:hover,
.select-wrap select:hover {
  border-color: rgba(169, 208, 109, 0.44);
}

.action-button.subtle {
  background: rgba(31, 35, 40, 0.88);
}

.layout {
  display: grid;
  grid-template-columns: minmax(230px, 290px) minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.panel,
.board-frame,
.board-header {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-section + .panel-section,
.clue-section + .clue-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hero-label {
  margin-top: 8px;
  font-size: 1.8rem;
}

.muted-copy {
  margin: 6px 0 0;
  line-height: 1.5;
}

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

.stat-card {
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px;
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 1.7rem;
}

.board-column {
  display: grid;
  gap: 16px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
}

.board-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.status-pill {
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(169, 208, 109, 0.25);
  white-space: nowrap;
}

.board-frame {
  padding: 18px;
  overflow: auto;
}

.crossword-grid {
  display: grid;
  gap: 0;
  width: fit-content;
  margin: 0 auto;
  border: 2px solid rgba(190, 179, 155, 0.45);
  background: rgba(0, 0, 0, 0.22);
}

.cell {
  position: relative;
  width: var(--cell-size-inline, var(--cell-size));
  height: var(--cell-size-inline, var(--cell-size));
  border: 1px solid var(--grid-line);
  background: var(--grid-light);
  color: var(--grid-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", sans-serif;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 700;
  text-transform: uppercase;
  cursor: text;
  user-select: none;
}

.cell:nth-child(odd) {
  background: var(--grid-light);
}

.cell.block {
  background: var(--grid-fill);
  border-color: rgba(255, 255, 255, 0.02);
  cursor: default;
}

.cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.56rem;
  line-height: 1;
  color: rgba(23, 23, 23, 0.78);
  font-weight: 700;
}

.cell.block .cell-number {
  display: none;
}

.cell.is-active {
  background: #cddf9d;
}

.cell.in-entry {
  background: #dde9b8;
}

.cell.is-error {
  color: var(--warn);
}

.cell.is-correct {
  color: #44671f;
}

.board-help {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding-bottom: 4px;
}

.clue-heading {
  margin-bottom: 10px;
}

.clue-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
}

.clue-item {
  padding: 8px 10px;
  margin-left: -10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.clue-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.clue-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.clue-item.solved {
  color: #cfc7b2;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel,
  .clue-panel {
    order: 2;
  }

  .board-column {
    order: 1;
  }

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

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .select-wrap,
  .select-wrap select,
  .action-button {
    width: 100%;
  }

  :root {
    --cell-size: min(5.8vw, 38px);
  }
}
