:root {
  color-scheme: dark;
  --charcoal: #1c1c1b;
  --charcoal-soft: #2a2928;
  --forest: #1e3d2f;
  --forest-deep: #142a21;
  --forest-muted: #2d4f3e;
  --forest-glow: #3a6b52;
  --cream: #e8e4dc;
  --cream-dim: #c9c3b6;
  --gold-line: rgba(200, 184, 148, 0.35);
  --gold-strong: rgba(212, 196, 160, 0.65);
  --page-bg-1: #2a2928;
  --page-bg-2: #1c1c1b;
  --text-on-forest: #e8e4dc;
  --streak-bar-bg: rgba(28, 28, 27, 0.45);
  --streak-pill-bg: rgba(42, 41, 40, 0.6);
  --streak-pill-border: rgba(200, 184, 148, 0.25);
  --nav-rest-border: rgba(200, 184, 148, 0.2);
  --tab-hover-border: rgba(200, 184, 148, 0.25);
  --tab-selected-bg: rgba(30, 61, 47, 0.25);
  --cell-hover-border: rgba(200, 184, 148, 0.55);
  --cell-hover-inset: rgba(30, 61, 47, 0.25);
  --board-status-bingo: #c4d4c8;
  --board-status-full: #d8ccb8;
  --cell-line-ring: rgba(212, 196, 160, 0.45);
  --modal-backdrop: rgba(12, 12, 11, 0.72);
  --modal-shadow: rgba(0, 0, 0, 0.45);
  --error-text: #c9a9a9;
  --input-bg: var(--charcoal);
}

html[data-theme="light"] {
  color-scheme: light;
  --charcoal: #f7f5f0;
  --charcoal-soft: #ebe7de;
  --forest: #1e3d2f;
  --forest-deep: #142a21;
  --forest-muted: #2d4f3e;
  --forest-glow: #2f5c45;
  --cream: #1c1c1b;
  --cream-dim: #5c574e;
  --gold-line: rgba(55, 48, 38, 0.22);
  --gold-strong: rgba(55, 48, 38, 0.42);
  --page-bg-1: #e5e1d8;
  --page-bg-2: #f3efe8;
  --text-on-forest: #f9f7f3;
  --streak-bar-bg: rgba(255, 255, 255, 0.72);
  --streak-pill-bg: rgba(235, 231, 222, 0.95);
  --streak-pill-border: rgba(55, 48, 38, 0.12);
  --nav-rest-border: rgba(55, 48, 38, 0.12);
  --tab-hover-border: rgba(55, 48, 38, 0.18);
  --tab-selected-bg: rgba(30, 61, 47, 0.12);
  --cell-hover-border: rgba(55, 48, 38, 0.35);
  --cell-hover-inset: rgba(30, 61, 47, 0.12);
  --board-status-bingo: #2d4f3e;
  --board-status-full: #5c4f3a;
  --cell-line-ring: rgba(188, 158, 108, 0.58);
  --modal-backdrop: rgba(28, 26, 22, 0.4);
  --modal-shadow: rgba(28, 26, 22, 0.18);
  --error-text: #8b4a4a;
  --input-bg: #ffffff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 112.5%;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, var(--page-bg-1) 0%, var(--page-bg-2) 55%);
  color: var(--cream);
  font-family: "Cormorant Garamond", "Libre Baskerville", Georgia, "Times New Roman", serif;
  line-height: 1.45;
  overflow-x: clip;
}

.site-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 0.35rem;
}

.theme-toggle {
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
}

.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.25rem max(1.15rem, env(safe-area-inset-right)) max(3rem, env(safe-area-inset-bottom))
    max(1.15rem, env(safe-area-inset-left));
}

.masthead {
  border-bottom: 1px solid var(--gold-line);
  padding-bottom: 1.35rem;
  margin-bottom: 1.25rem;
}

.masthead__row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.masthead__brand {
  min-width: 0;
  max-width: 100%;
}

.masthead__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--cream-dim);
  font-family: "Libre Baskerville", Georgia, serif;
  text-align: center;
}

.masthead__title {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.9rem, 5.5vw, 2.65rem);
  letter-spacing: 0.02em;
  color: var(--cream);
  text-align: center;
}

.masthead__tagline {
  margin: 0.65rem 0 0;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(0.95rem, 2.4vw, 1.05rem);
  line-height: 1.45;
  color: var(--cream-dim);
  text-align: center;
  font-style: italic;
}

.masthead__date {
  margin: 1rem 0 0;
  font-size: 1.12rem;
  font-style: italic;
  color: var(--cream-dim);
  text-align: center;
}

.btn {
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 0.85rem;
  min-height: 2.5rem;
  border-radius: 2px;
  border: 1px solid var(--gold-line);
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
}

.btn:hover {
  border-color: var(--gold-strong);
}

.btn:focus {
  outline: 2px solid var(--forest-muted);
  outline-offset: 2px;
}

.btn:focus:not(:focus-visible) {
  outline: none;
}

.btn--primary {
  background: linear-gradient(145deg, var(--forest) 0%, var(--forest-deep) 100%);
  border-color: var(--forest-muted);
}

.btn--primary:hover {
  border-color: var(--forest-glow);
}

.streak-bar {
  width: min(100%, min(56rem, calc(100vw - 2rem)));
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.35rem;
  padding: 1.05rem 1.15rem 1.2rem;
  border: 1px solid var(--gold-line);
  background: var(--streak-bar-bg);
  border-radius: 2px;
}

.streak-bar__label {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  color: var(--cream-dim);
  font-family: "Libre Baskerville", Georgia, serif;
}

.streak-bar__sub {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: center;
  color: var(--cream-dim);
  font-style: italic;
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
}

.streak-bar__body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.streak-bar__row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.55rem 0.75rem;
}

.streak-bar__row--main {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--nav-rest-border);
}

.streak-bar__row--rest {
  padding-top: 0.05rem;
}

.streak-pill-wrap {
  display: flex;
  justify-content: center;
  max-width: 100%;
}

.streak-pill-wrap--main {
  flex: 0 1 auto;
  width: 100%;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.streak-pill {
  font-family: "Cormorant Garamond", "Libre Baskerville", Georgia, serif;
  font-size: clamp(0.98rem, 2.5vw, 1.14rem);
  color: var(--cream);
  padding: 0.48rem 0.9rem;
  border: 1px solid var(--streak-pill-border);
  border-radius: 2px;
  background: var(--streak-pill-bg);
  max-width: 100%;
  width: auto;
  line-height: 1.35;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.streak-pill:hover {
  border-color: var(--tab-hover-border);
}

.streak-pill--main {
  padding: 0.58rem 1.1rem;
  font-size: clamp(1.05rem, 2.85vw, 1.22rem);
  flex-wrap: wrap;
  text-align: center;
  width: 100%;
}

.streak-pill--selected {
  border-color: var(--gold-line);
  background: var(--tab-selected-bg);
}

.streak-pill:focus {
  outline: 2px solid var(--forest-muted);
  outline-offset: 2px;
}

.streak-pill:focus:not(:focus-visible) {
  outline: none;
}

.streak-pill__cat {
  color: var(--cream-dim);
}

.streak-pill__n {
  font-family: "Libre Baskerville", Georgia, serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--cream);
  min-width: 1.25em;
  text-align: center;
}

.board-wrap {
  margin-bottom: 2.25rem;
}

.stats-panel {
  margin-top: 1.75rem;
  padding: 1.1rem 1.15rem 1.2rem;
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  background: var(--streak-bar-bg);
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.stats-panel__title {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--cream-dim);
  font-family: "Libre Baskerville", Georgia, serif;
}

.stats-panel__grid {
  margin: 0;
  display: grid;
  gap: 0.55rem 1rem;
}

.stats-panel__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--nav-rest-border);
}

.stats-panel__row:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.stats-panel__dt {
  margin: 0;
  font-size: 1.02rem;
  color: var(--cream-dim);
}

.stats-panel__dd {
  margin: 0;
  font-family: "Libre Baskerville", Georgia, serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  color: var(--cream);
}

.stats-panel__note {
  margin: 0.85rem 0 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--cream-dim);
  font-style: italic;
  text-align: center;
}

.board-hint {
  text-align: center;
  margin: 0 0 0.85rem;
  font-size: 1.02rem;
  color: var(--cream-dim);
  font-style: italic;
}

.board-status {
  text-align: center;
  min-height: 1.65rem;
  margin-bottom: 0.65rem;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--cream);
}

.board-status--bingo {
  color: var(--board-status-bingo);
}

.board-status--full {
  color: var(--board-status-full);
}

.grid {
  --tile-font: 1rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  aspect-ratio: 1 / 1;
  width: min(100%, min(56rem, calc(100vw - 2rem)));
  max-width: 100%;
  margin: 0 auto;
  min-height: 0;
}

.cell {
  touch-action: manipulation;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.4rem 0.35rem;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  align-self: stretch;
  justify-self: stretch;
  overflow: hidden;
  font-size: var(--tile-font);
  line-height: 1.28;
  letter-spacing: 0.01em;
  color: var(--cream);
  background: var(--charcoal-soft);
  border: 1px solid var(--gold-line);
  cursor: pointer;
  user-select: none;
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  font-family: inherit;
  border-radius: 2px;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  -webkit-hyphens: none;
}

.cell:hover {
  border-color: var(--cell-hover-border);
  box-shadow: inset 0 0 0 1px var(--cell-hover-inset);
}

.cell:focus {
  outline: 2px solid var(--forest-muted);
  outline-offset: 2px;
}

.cell:focus:not(:focus-visible) {
  outline: none;
}

.cell--done {
  background: linear-gradient(145deg, var(--forest) 0%, var(--forest-deep) 100%);
  color: var(--text-on-forest);
  border-color: var(--forest-muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cell--line {
  box-shadow: inset 0 0 0 2px var(--cell-line-ring);
}

.foot {
  text-align: center;
  border-top: 1px solid var(--gold-line);
  padding-top: 1.25rem;
}

.foot__note {
  margin: 0;
  font-size: 0.92rem;
  color: var(--cream-dim);
  font-style: italic;
}

.foot__share {
  margin-top: 1.15rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem 0.65rem;
}

.foot__share-btn {
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 0.88rem;
  padding: 0.5rem 1.15rem;
  min-height: 2.6rem;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}

@keyframes celebration-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--rot0));
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--tx), 120vh, 0) rotate(var(--rot1));
    opacity: 0.92;
  }
}

.celebration__piece {
  position: absolute;
  animation-name: celebration-fall;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
  animation-fill-mode: forwards;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.celebration-toast {
  position: fixed;
  left: 50%;
  top: max(12%, 4.5rem);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.75rem 1.35rem 0.85rem;
  min-width: 11rem;
  max-width: calc(100vw - 2rem);
  text-align: center;
  background: var(--charcoal-soft);
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  box-shadow: 0 14px 48px var(--modal-shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) scale(0.82);
  animation: celebration-toast-in 0.58s cubic-bezier(0.34, 1.45, 0.64, 1) forwards;
  font-family: "Libre Baskerville", Georgia, serif;
}

.celebration-toast--out {
  animation: celebration-toast-out 0.45s ease forwards;
}

.celebration-toast__emoji {
  font-size: 2.1rem;
  line-height: 1;
  display: block;
  margin-bottom: 0.15rem;
}

.celebration-toast__title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream);
}

.celebration-toast__sub {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--cream-dim);
  line-height: 1.3;
}

@keyframes celebration-toast-in {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.75);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@keyframes celebration-toast-out {
  0% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(0.96) translateY(-8px);
  }
}

@keyframes celebration-cell-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

.grid--celebrate .cell--line {
  animation: celebration-cell-pop 0.62s cubic-bezier(0.34, 1.35, 0.64, 1);
}

@media (prefers-reduced-motion: reduce) {
  .celebration__piece {
    display: none;
  }

  .celebration-toast {
    animation: none;
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }

  .celebration-toast--out {
    animation: none;
    opacity: 0;
  }

  .grid--celebrate .cell--line {
    animation: none;
  }
}

@media (max-width: 479px) {
  .modal__actions {
    flex-direction: column-reverse;
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
  }

  .modal__actions .btn {
    width: 100%;
    justify-content: center;
  }

  .site-toolbar .btn {
    min-height: 2.75rem;
  }

  .celebration-toast {
    top: max(8%, env(safe-area-inset-top));
    max-width: calc(100vw - 1.5rem);
  }
}

@media (min-width: 480px) {
  .masthead__row {
    align-items: center;
  }

  .grid {
    gap: 0.65rem;
  }

  .cell {
    padding: 0.48rem 0.42rem;
  }
}

