:root {
  --bg-1: #f4f4f2;
  --bg-2: #f4f4f2;
  --bg-3: #fbfbf9;
  --ink: #1b1a16;
  --ink-soft: #5b574f;
  --accent: #e4572e;
  --accent-2: #2f6f8f;
  --accent-3: #f2a541;
  --card: rgba(255, 255, 255, 0.85);
  --ring: rgba(27, 26, 22, 0.12);
  --shadow: 0 30px 70px rgba(27, 26, 22, 0.18);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  color: var(--ink);
  background: var(--bg-1);
}

body[data-contrast="high"] {
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #ffffff;
  --ink: #000000;
  --ink-soft: #111111;
  --accent: #c61c1c;
  --accent-2: #0047ab;
  --accent-3: #1a7f2f;
  --card: #ffffff;
  --ring: #000000;
  --shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 18px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

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

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-mark {
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: 2px;
  font-weight: 700;
}

.brand-sub {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--ink-soft);
}

.shell {
  display: grid;
  gap: 22px;
  margin: 26px auto 0;
  width: min(720px, 100%);
}

.board,
.share,
.notes,
.found {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: rise 600ms ease both;
}

.board {
  display: grid;
  gap: 18px;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.label {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--ink-soft);
}

.value {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 600;
}

.round-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(47, 111, 143, 0.12);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 1px;
}

.progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.progress li {
  text-align: center;
  padding: 10px 0;
  border-radius: 14px;
  background: rgba(27, 26, 22, 0.06);
  font-weight: 600;
  color: var(--ink-soft);
  border: 1px solid transparent;
  padding: 0;
}

.progress-btn {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 0;
  display: grid;
  gap: 2px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.progress-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.round-len {
  font-size: 15px;
}

.round-count {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
}

.progress li[data-state="active"] {
  background: rgba(228, 87, 46, 0.2);
  color: var(--ink);
  border-color: rgba(228, 87, 46, 0.4);
}

.progress li[data-state="done"] {
  background: rgba(26, 127, 47, 0.18);
  color: var(--ink);
  border-color: rgba(26, 127, 47, 0.35);
}

.progress li[data-state="complete"] {
  background: rgba(47, 111, 143, 0.22);
  color: var(--ink);
  border-color: rgba(47, 111, 143, 0.4);
}

.wheel {
  padding: 8px;
  border-radius: 24px;
  border: 1px dashed rgba(27, 26, 22, 0.2);
  background: var(--bg-3);
}

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

.letter {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border: 2px solid rgba(27, 26, 22, 0.08);
  appearance: none;
  box-shadow: 0 10px 24px rgba(27, 26, 22, 0.12);
  animation: pop 500ms ease both;
  animation-delay: var(--delay, 0ms);
  cursor: pointer;
}

.letter.empty {
  background: transparent;
  border-style: dashed;
  color: transparent;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

.letter.used {
  background: rgba(27, 26, 22, 0.08);
  border-style: dashed;
  color: var(--ink-soft);
  box-shadow: none;
}

.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.entry-field {
  position: relative;
  display: flex;
  align-items: center;
}

.entry input {
  width: 100%;
  padding: 14px 16px;
  padding-right: 48px;
  border-radius: 16px;
  border: 1px solid rgba(27, 26, 22, 0.2);
  font-size: 18px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.entry-clear {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(27, 26, 22, 0.2);
  background: rgba(27, 26, 22, 0.04);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  appearance: none;
  cursor: pointer;
}

.entry-clear:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#submit-btn {
  padding: 14px 18px;
  border-radius: 16px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 1px;
}

.status {
  min-height: 24px;
  font-size: 14px;
  color: var(--ink-soft);
}

.status-actions {
  display: flex;
  justify-content: flex-end;
}

.status[data-tone="good"] {
  color: #1a7f2f;
  font-weight: 600;
}

.status[data-tone="bad"] {
  color: #c61c1c;
  font-weight: 600;
}

.share {
  display: grid;
  gap: 14px;
  animation-delay: 120ms;
}

.found {
  display: grid;
  gap: 14px;
  animation-delay: 80ms;
}

.found-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.found-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 1px;
}

.found-sub {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.found-grid {
  display: grid;
  gap: 12px;
}

.found-round {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(27, 26, 22, 0.12);
  background: rgba(27, 26, 22, 0.04);
}

.found-round.is-active {
  border-color: rgba(228, 87, 46, 0.45);
  background: rgba(228, 87, 46, 0.08);
}

.found-round-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.found-round-count {
  font-size: 12px;
  color: var(--ink-soft);
}

.found-list {
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.found-list li {
  margin: 0;
}

.found-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(27, 26, 22, 0.12);
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.found-empty {
  font-size: 12px;
  color: var(--ink-soft);
}

.share-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.share h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 1px;
}

.share-text {
  margin: 0;
  padding: 14px;
  border-radius: 18px;
  background: rgba(27, 26, 22, 0.05);
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  white-space: pre-wrap;
}

.notes {
  font-size: 13px;
  color: var(--ink-soft);
}

.footer {
  margin-top: auto;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  padding-top: 24px;
}

.ghost {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(27, 26, 22, 0.2);
  background: transparent;
  font-size: 13px;
}

.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

body.modal-open {
  overflow: hidden;
}

.help-modal {
  position: fixed;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(27, 26, 22, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 20;
}

.help-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.help-backdrop {
  position: absolute;
  inset: 0;
}

.help-dialog {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.help-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.help-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
}

.help-carousel {
  margin-top: 16px;
  display: grid;
  gap: 16px;
}

.help-slide {
  display: none;
  gap: 12px;
}

.help-slide.is-active {
  display: grid;
}

.help-slide h3 {
  margin: 0;
  font-size: 18px;
}

.help-slide p {
  margin: 0;
  color: var(--ink-soft);
}

.help-visual {
  margin-top: 8px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(27, 26, 22, 0.05);
  display: grid;
  gap: 12px;
}

.help-visual--split {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

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

.help-letter {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid rgba(27, 26, 22, 0.1);
}

.help-letter.empty {
  background: transparent;
  border-style: dashed;
  color: transparent;
}

.help-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.help-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid rgba(27, 26, 22, 0.12);
  font-weight: 600;
  font-size: 13px;
}

.help-pill--bad {
  border-color: rgba(198, 28, 28, 0.6);
  color: #c61c1c;
}

.help-tag {
  font-size: 12px;
  color: var(--ink-soft);
}

.help-tag--bad {
  color: #c61c1c;
}

.help-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.help-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.help-step {
  display: grid;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(27, 26, 22, 0.08);
  text-align: center;
  font-weight: 600;
}

.help-step span {
  font-size: 11px;
  color: var(--ink-soft);
}

.help-step.is-done {
  background: rgba(26, 127, 47, 0.18);
}

.help-step.is-active {
  background: rgba(228, 87, 46, 0.2);
}

.help-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(27, 26, 22, 0.1);
}

.help-card-title {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 14px;
}

.help-card-text {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.help-nav {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.help-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(27, 26, 22, 0.2);
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.help-dot[aria-current="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  background: #1b1a16;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
}

:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

@media (min-width: 720px) {
  .page {
    padding: 32px 40px 48px;
  }

  .shell {
    width: min(760px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

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

@keyframes pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
