:root {
  color-scheme: light;
  --page: #f7f6f1;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #666660;
  --line: #d8d8d2;
  --tile: #e7e7e2;
  --tile-hover: #dcdcd6;
  --selected: #242424;
  --selected-ink: #ffffff;
  --yellow: #f9df6d;
  --yellow-ink: #211f14;
  --green: #a0c35a;
  --green-ink: #17200a;
  --blue: #79a5c7;
  --blue-ink: #0b1b27;
  --purple: #b78cc8;
  --purple-ink: #211026;
  --danger: #b32929;
  --shadow: 0 18px 55px rgb(0 0 0 / 0.16);
  --focus: #1f6feb;
  --max-width: 650px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #121212;
  --surface: #1d1d1d;
  --ink: #f4f3ee;
  --muted: #b6b5af;
  --line: #44443f;
  --tile: #333331;
  --tile-hover: #41413e;
  --selected: #f1f0e9;
  --selected-ink: #151515;
  --yellow: #b89d2d;
  --yellow-ink: #111108;
  --green: #739438;
  --green-ink: #0d1305;
  --blue: #4e7fa4;
  --blue-ink: #07131c;
  --purple: #8e5fa2;
  --purple-ink: #130819;
  --danger: #ff8585;
  --shadow: 0 22px 65px rgb(0 0 0 / 0.48);
  --focus: #87b7ff;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  transition: background-color 180ms ease, color 180ms ease;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.masthead__inner {
  width: min(100%, 1080px);
  min-height: 64px;
  margin: 0 auto;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

.brand__flag {
  width: 30px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 3px;
  transform: rotate(-3deg);
}

.brand__flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

.masthead__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 3px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 9px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--tile);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.account-button {
  position: relative;
}

.account-button.is-authenticated::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--green);
}

.theme-icon--moon,
[data-theme="dark"] .theme-icon--sun {
  display: none;
}

[data-theme="dark"] .theme-icon--moon {
  display: block;
}

.game-shell {
  width: min(calc(100% - 28px), var(--max-width));
  margin: 0 auto;
  padding: 38px 0 44px;
  text-align: center;
}

.game-heading {
  margin-bottom: 22px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(1.35rem, 5.2vw, 1.8rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.puzzle-date {
  margin-bottom: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.game-board {
  display: grid;
  gap: 8px;
}

.solved-groups {
  display: grid;
  gap: 8px;
}

.solved-group {
  min-height: 86px;
  padding: 14px 12px;
  display: grid;
  align-content: center;
  gap: 5px;
  border-radius: 7px;
  animation: settle 260ms ease both;
}

.solved-group--yellow { background: var(--yellow); color: var(--yellow-ink); }
.solved-group--green { background: var(--green); color: var(--green-ink); }
.solved-group--blue { background: var(--blue); color: var(--blue-ink); }
.solved-group--purple { background: var(--purple); color: var(--purple-ink); }

.solved-group__title {
  font-size: clamp(0.84rem, 3.1vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.solved-group__words {
  font-size: clamp(0.78rem, 2.9vw, 0.94rem);
  line-height: 1.3;
  text-transform: uppercase;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.word-grid--unavailable {
  display: block;
}

.unavailable-message {
  margin: 36px auto;
  color: var(--muted);
  line-height: 1.5;
}

.word-tile {
  position: relative;
  min-width: 0;
  min-height: 86px;
  padding: 7px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: var(--tile);
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(0.67rem, 2.35vw, 0.91rem);
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.word-tile:hover:not(:disabled) {
  background: var(--tile-hover);
}

.word-tile[aria-pressed="true"] {
  background: var(--selected);
  color: var(--selected-ink);
  transform: translateY(-1px);
}

.word-tile:disabled {
  cursor: default;
}

.word-tile.is-wrong {
  animation: shake 360ms ease;
}

.word-tile.is-correct {
  animation: pop 420ms ease;
}

.feedback {
  min-height: 34px;
  padding: 10px 4px 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.feedback.is-error {
  color: var(--danger);
}

.mistakes {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.mistake-dots {
  display: inline-flex;
  gap: 6px;
}

.mistake-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
}

.mistake-dot.is-used {
  background: var(--line);
}

.game-actions {
  margin-top: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}

.pill-button {
  min-height: 48px;
  padding: 0 22px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.pill-button:hover:not(:disabled) {
  background: var(--tile);
}

.pill-button--primary {
  background: var(--ink);
  color: var(--page);
}

.pill-button--primary:hover:not(:disabled) {
  background: var(--selected);
  color: var(--selected-ink);
}

.pill-button:disabled {
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
  opacity: 0.6;
}

.results-actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.results-actions .pill-button {
  width: 100%;
}

.keyboard-hint {
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.modal {
  width: min(calc(100% - 28px), 520px);
  max-height: calc(100vh - 42px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(2px);
}

.modal__header {
  min-height: 65px;
  padding: 0 14px 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.modal__header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.modal__body {
  padding: 24px;
}

.prose {
  text-align: left;
  line-height: 1.55;
}

.prose ul {
  padding-left: 22px;
}

.prose li + li {
  margin-top: 7px;
}

.difficulty-key {
  margin: 22px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.key-swatch {
  min-height: 46px;
  padding: 8px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #141414;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.key-swatch--yellow { background: var(--yellow); color: var(--yellow-ink); }
.key-swatch--green { background: var(--green); color: var(--green-ink); }
.key-swatch--blue { background: var(--blue); color: var(--blue-ink); }
.key-swatch--purple { background: var(--purple); color: var(--purple-ink); }

.small-print,
.copy-status {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.account-heading {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  line-height: 1.25;
}

.account-intro {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.account-import-notice {
  margin: -7px 0 12px;
  padding: 11px 12px;
  border-left: 3px solid var(--blue);
  background: var(--tile);
  font-size: 0.84rem;
  line-height: 1.45;
}

.account-form {
  display: grid;
  gap: 8px;
}

.account-form label {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.account-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
}

.account-form input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.field-hint {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.account-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.account-actions .pill-button {
  width: 100%;
  padding-inline: 12px;
}

.account-security {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

#account-signed-in {
  text-align: center;
}

.account-status {
  min-height: 20px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  text-align: center;
}

.account-status.is-error {
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.stats-grid div {
  display: grid;
  gap: 3px;
  text-align: center;
}

.stats-grid strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 8vw, 2.6rem);
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.72rem;
}

.next-puzzle {
  margin-top: 25px;
  padding-top: 21px;
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.next-puzzle span {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.next-puzzle strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.65rem;
  letter-spacing: 0.04em;
}

.results-copy {
  margin-bottom: 18px;
  text-align: center;
}

.share-grid {
  width: min(100%, 225px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.share-cell {
  aspect-ratio: 1;
  border-radius: 3px;
}

.share-cell--yellow { background: var(--yellow); }
.share-cell--green { background: var(--green); }
.share-cell--blue { background: var(--blue); }
.share-cell--purple { background: var(--purple); }
.share-cell--mistake { background: var(--tile); }

.copy-status {
  min-height: 20px;
  margin-top: 9px;
  text-align: center;
}

noscript {
  display: block;
  padding: 24px;
  color: var(--danger);
  text-align: center;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@keyframes pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes settle {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 520px) {
  .masthead__inner {
    min-height: 58px;
    padding: 0 10px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    padding: 8px;
  }

  .game-shell {
    width: min(calc(100% - 20px), var(--max-width));
    padding-top: 28px;
  }

  .word-grid,
  .solved-groups,
  .game-board {
    gap: 6px;
  }

  .word-tile,
  .solved-group {
    min-height: 76px;
    border-radius: 6px;
  }

  .pill-button {
    min-height: 44px;
    padding: 0 16px;
    font-size: 0.88rem;
  }
}

@media (max-width: 370px) {
  .brand {
    font-size: 1.28rem;
  }

  .masthead__inner {
    grid-template-columns: 38px auto 117px;
    gap: 4px;
  }

  .masthead__actions {
    gap: 0;
  }

  .word-tile {
    min-height: 69px;
    padding: 4px;
    font-size: 0.61rem;
  }

  .solved-group {
    min-height: 76px;
  }

  .difficulty-key {
    grid-template-columns: 1fr;
  }

  .results-actions {
    grid-template-columns: 1fr;
  }

  .account-actions {
    grid-template-columns: 1fr;
  }
}
