:root {
  color-scheme: light;
  --paper: #faf7ef;
  --tile: #fffdf8;
  --ink: #1d1a15;
  --ink-soft: #55503f;
  --ink-faint: #8a8375;
  --line: #d8d2c2;
  --line-soft: #e0dac9;
  --red: #b3352c;
  --red-tint: #fdf6f0;
  --red-band: #f6ddd4;
  --red-band-text: #4a231c;
  --green: #2e5d43;
  --green-shadow: #1e4230;
  --green-band: #e2ebe2;
  --green-band-text: #22331f;
  --panel: #f3efe4;
  --serif: "Libre Caslon Text", Georgia, serif;
  --sans: "Space Grotesk", system-ui, sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--red);
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 446px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
}

.broadsheet-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  padding: 0;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.25;
  text-align: left;
}

.brand svg {
  flex: 0 0 auto;
}

.header-status {
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.solved-panel:not([hidden]) ~ * .header-status,
.header-status.is-solved {
  color: var(--green);
  font-weight: 700;
}

.daily-switch {
  min-height: 54px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.slot-button {
  position: relative;
  min-width: 0;
  padding: 11px 4px 10px;
  border: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
}

.slot-button + .slot-button {
  border-left: 1px solid var(--line-soft);
}

.slot-button::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -1px;
  left: 22px;
  height: 2px;
  background: transparent;
}

.slot-button.active {
  color: var(--ink);
}

.slot-button.active::after {
  background: var(--red);
}

.slot-button.complete::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

.slot-button span {
  font-size: 9px;
  letter-spacing: 0.08em;
}

.slot-button strong {
  overflow: hidden;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.playing-panel,
.solved-panel,
.empty-panel {
  min-height: calc(100dvh - 164px);
  display: flex;
  flex-direction: column;
}

.puzzle-meta {
  min-height: 24px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--green);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.difficulty-chip {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.2;
}

.quiet-instruction {
  margin: 16px 0 26px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  min-width: 0;
  min-height: 56px;
  padding: 20px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--tile);
  box-shadow: 0 1px 2px rgba(29, 26, 21, 0.05);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  transition: transform 80ms ease-out, border-color 100ms ease, color 100ms ease, background 100ms ease;
}

.tile:active:not(:disabled) {
  transform: scale(0.97);
}

.tile.selected {
  padding: 19.5px 6.5px;
  border: 1.5px solid var(--red);
  color: var(--red);
  background: var(--red-tint);
}

.tile.wrong {
  animation: wrong-shake 300ms ease;
}

.tile:disabled {
  cursor: default;
}

.swap-divider {
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.24em;
}

.swap-divider i {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.play-footer {
  margin-top: auto;
  padding-top: 28px;
}

.game-status {
  min-height: 19px;
  margin: 0 0 7px;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  line-height: 1.4;
  text-align: center;
}

.attempts-row {
  min-height: 24px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.attempt-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attempt-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  transition: opacity 180ms ease, background 180ms ease;
}

.attempt-dots i.spent {
  background: var(--line-soft);
}

.primary-button,
.primary-link {
  width: 100%;
  min-height: 52px;
  padding: 17px 18px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--green);
  box-shadow: 0 2px 0 var(--green-shadow);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.primary-button:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: default;
}

.primary-button:active:not(:disabled),
.primary-link:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--green-shadow);
}

.solved-panel h1,
.empty-panel h1 {
  margin: 22px 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.25;
}

.category-bands {
  display: grid;
  gap: 10px;
}

.category-band {
  padding: 14px 16px;
  border-radius: 8px;
  animation: build-in 320ms ease both;
}

.category-band-1 {
  color: var(--green-band-text);
  background: var(--green-band);
}

.category-band-2 {
  color: var(--red-band-text);
  background: var(--red-band);
  animation-delay: 80ms;
}

.category-band h2 {
  margin: 0 0 7px;
  color: inherit;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.2;
}

.category-band p {
  margin: 0;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.45;
}

.category-band strong {
  font-weight: 700;
}

.wires-panel {
  margin-top: 22px;
  padding: 18px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel);
}

.wires-panel > h2 {
  margin: 0 0 16px;
  color: var(--green);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.definition-list {
  display: grid;
  gap: 14px;
}

.definition-entry {
  padding-left: 12px;
  border-left: 3px solid var(--red);
  animation: build-in 320ms ease both;
  animation-delay: var(--entry-delay);
}

.definition-entry h3 {
  margin: 0 0 4px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.definition-entry p {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.5;
}

.solved-spacer {
  min-height: 28px;
  flex: 1;
}

.solved-summary {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.empty-panel {
  justify-content: center;
}

.empty-panel .puzzle-kicker {
  margin: 0;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.empty-panel p:not(.puzzle-kicker) {
  margin: -8px 0 28px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.55;
}

.utility-footer {
  min-height: 38px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-size: 11px;
  font-style: italic;
  line-height: 1.4;
}

.utility-footer span {
  max-width: 235px;
}

.utility-footer a {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

@keyframes build-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 28px;
    padding-bottom: 24px;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 16px;
  }

  .tile {
    font-size: 12.5px;
  }

  .slot-button strong {
    font-size: 9.5px;
  }
}

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