:root {
  --paper: #f6efdf;
  --paper-dark: #eadfc7;
  --ink: #1d1812;
  --muted: #6b5b4d;
  --accent: #af3c27;
  --accent-soft: rgba(175, 60, 39, 0.14);
  --gold: #b78b38;
  --grid-fill: #fffaf0;
  --grid-line: #2b241c;
  --grid-block: #221c15;
  --grid-active: #f9d772;
  --grid-highlight: #f6ebc9;
  --grid-solved: #d7e8c7;
  --surface: rgba(255, 250, 240, 0.76);
  --shadow: 0 18px 40px rgba(43, 36, 28, 0.15);
  --headline-font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua",
    "URW Palladio L", serif;
  --ui-font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(183, 139, 56, 0.24), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(175, 60, 39, 0.12), transparent 22rem),
    linear-gradient(180deg, #fbf5e6 0%, var(--paper) 45%, #efe1c1 100%);
  color: var(--ink);
  font-family: var(--ui-font);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(29, 24, 18, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 24, 18, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

.page-shell {
  width: min(1220px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero {
  padding: 1.5rem 0 2rem;
}

.studio-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
  padding: 0.38rem 0.7rem;
  border: 1px solid rgba(43, 36, 28, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.studio-mark a {
  color: var(--ink);
  text-decoration: none;
}

.studio-mark a:hover,
.studio-mark a:focus-visible {
  text-decoration: underline;
}

.kicker,
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--headline-font);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.8rem, 6vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.45rem, 2vw, 1.9rem);
}

.deck {
  max-width: 42rem;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: end;
  margin-top: 1.3rem;
}

.puzzle-picker {
  min-width: min(16rem, 100%);
}

.select-label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.select-field {
  width: min(18rem, 100%);
  padding: 0.95rem 1rem;
  border: 1px solid rgba(43, 36, 28, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.hero-note {
  max-width: 32rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 0.95fr) minmax(320px, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.page-footer {
  margin-top: 1.4rem;
  padding: 1rem 1.1rem;
  border-radius: 24px;
  background: rgba(255, 250, 240, 0.48);
  border: 1px solid rgba(43, 36, 28, 0.1);
}

.storage-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  margin-top: 0.85rem;
}

.footer-feedback {
  min-height: 1.3rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.modal-brand {
  margin: 0.95rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal-brand a {
  color: inherit;
  text-decoration: none;
}

.modal-brand a:hover,
.modal-brand a:focus-visible {
  text-decoration: underline;
}

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(43, 36, 28, 0.12);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 1.25rem;
  overflow: hidden;
}

.panel-grid {
  scroll-margin-top: 1rem;
}

.panel::after {
  content: "";
  position: absolute;
  inset: auto -3rem -3rem auto;
  width: 10rem;
  height: 10rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(183, 139, 56, 0.2), transparent 70%);
  pointer-events: none;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.status-pill {
  min-width: 7rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(43, 36, 28, 0.1);
  border-radius: 18px;
}

.status-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.grid-card {
  padding: 1rem;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.36)),
    var(--paper-dark);
  border: 1px solid rgba(43, 36, 28, 0.12);
}

.crossword-grid {
  display: grid;
  gap: 2px;
  width: min(100%, 30rem);
  margin: 0 auto;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: var(--grid-fill);
  border-radius: 9px;
  font: inherit;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 120ms ease, background-color 120ms ease;
}

.cell:hover {
  transform: translateY(-1px);
}

.cell.active {
  background: var(--grid-active);
}

.cell.highlight {
  background: var(--grid-highlight);
}

.cell.solved {
  background: var(--grid-solved);
}

.cell input {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: center;
  font-size: max(16px, clamp(1rem, 2vw, 1.5rem));
  font-weight: 700;
  text-transform: uppercase;
  outline: none;
  border-radius: inherit;
  -webkit-appearance: none;
}

.cell-number {
  position: absolute;
  top: 0.18rem;
  left: 0.22rem;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}

.grid-actions,
.connection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.grid-actions {
  margin-top: 1rem;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  background: var(--accent);
  color: #fffaf2;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background-color 120ms ease;
}

.button:hover:enabled {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-secondary {
  background: #3f4d3b;
}

.button-support {
  background: #467ceb;
}

.button-ghost {
  background: rgba(43, 36, 28, 0.12);
  color: var(--ink);
}

.feedback {
  min-height: 1.5rem;
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.feedback.success {
  color: #36502a;
}

.feedback.warning {
  color: #855f15;
}

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

.clue-list {
  display: grid;
  gap: 0.8rem;
}

.clue-card {
  padding: 0.95rem 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(43, 36, 28, 0.1);
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
  cursor: pointer;
}

.clue-card:hover {
  transform: translateY(-1px);
}

.clue-card.active {
  border-color: rgba(175, 60, 39, 0.4);
  background: rgba(175, 60, 39, 0.08);
}

.clue-card.solved {
  border-color: rgba(63, 77, 59, 0.25);
  background: rgba(215, 232, 199, 0.5);
}

.clue-label {
  display: inline-flex;
  margin-bottom: 0.4rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: rgba(43, 36, 28, 0.08);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.clue-text {
  margin: 0;
  line-height: 1.45;
}

.answer-meta {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.note-card,
.reveal-panel {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(43, 36, 28, 0.1);
}

.note-card p,
.reveal-panel p {
  margin: 0;
  line-height: 1.55;
}

.note-title {
  margin-bottom: 0.35rem;
  font-family: var(--headline-font);
  font-size: 1.15rem;
}

.connection-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 9rem;
  padding: 1rem;
  border: 1px solid rgba(43, 36, 28, 0.15);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  outline: none;
}

.connection-form textarea:focus {
  border-color: rgba(175, 60, 39, 0.5);
  box-shadow: 0 0 0 4px rgba(175, 60, 39, 0.09);
}

.connection-actions {
  margin-top: 0.85rem;
}

.attempt-count {
  color: var(--muted);
  font-size: 0.92rem;
}

.reveal-list {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
}

.reveal-list li + li {
  margin-top: 0.5rem;
}

.reveal-actions {
  margin-top: 1rem;
}

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

.share-preview {
  margin: 0.9rem 0 0;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(43, 36, 28, 0.06);
  color: var(--ink);
  font: 0.95rem/1.55 "SFMono-Regular", "Menlo", "Monaco", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.share-feedback {
  min-height: 1.2rem;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.share-modal[hidden] {
  display: none;
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 24, 18, 0.55);
  backdrop-filter: blur(6px);
}

.share-dialog {
  position: relative;
  width: min(100%, 32rem);
  padding: 1.4rem 1.2rem 1.2rem;
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(249, 215, 114, 0.45), transparent 14rem),
    linear-gradient(180deg, #fff8eb 0%, #f2e4c7 100%);
  border: 1px solid rgba(43, 36, 28, 0.12);
  box-shadow: 0 28px 60px rgba(29, 24, 18, 0.28);
  overflow: hidden;
  animation: modal-pop 220ms ease-out;
}

.support-dialog {
  width: min(100%, 42rem);
}

.support-iframe {
  width: 100%;
  height: 712px;
  margin-top: 1rem;
  padding: 4px;
  border: none;
  border-radius: 18px;
  background: #f9f9f9;
}

.share-subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.share-streak {
  margin: 0.75rem 0 0;
  color: #3f4d3b;
  font-weight: 700;
  line-height: 1.4;
}

.share-canonical-answer {
  margin: 0.75rem 0 0;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.45;
}

.share-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(43, 36, 28, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 1.35rem;
  cursor: pointer;
}

.splash-dialog {
  width: min(100%, 36rem);
}

.splash-steps {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.splash-steps p {
  margin: 0;
  line-height: 1.5;
}

.splash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.share-celebration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.share-celebration span {
  position: absolute;
  top: -1rem;
  width: 0.65rem;
  height: 1rem;
  border-radius: 0.2rem;
  opacity: 0.8;
  animation: confetti-fall 2.8s linear infinite;
}

.share-celebration span:nth-child(1) {
  left: 10%;
  background: #f39a3a;
  animation-delay: 0s;
}

.share-celebration span:nth-child(2) {
  left: 24%;
  background: #3f4d3b;
  animation-delay: 0.35s;
}

.share-celebration span:nth-child(3) {
  left: 39%;
  background: #f9d772;
  animation-delay: 0.7s;
}

.share-celebration span:nth-child(4) {
  left: 58%;
  background: #af3c27;
  animation-delay: 1.1s;
}

.share-celebration span:nth-child(5) {
  left: 76%;
  background: #d87b26;
  animation-delay: 0.5s;
}

.share-celebration span:nth-child(6) {
  left: 88%;
  background: #36502a;
  animation-delay: 1.4s;
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-1rem) rotate(0deg);
  }

  100% {
    transform: translateY(24rem) rotate(220deg);
  }
}

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

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

  .panel-connection {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 42rem);
    padding-top: 1rem;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 1rem;
    border-radius: 24px;
  }

  .grid-card {
    padding: 0.75rem;
  }

  .panel-head {
    flex-direction: column;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .hero-tools,
  .hero-note {
    width: 100%;
  }

  .puzzle-picker,
  .select-field {
    width: 100%;
  }

  .share-head {
    align-items: stretch;
  }

  .share-dialog {
    padding: 1.2rem 1rem 1rem;
  }

  .support-iframe {
    height: min(70vh, 712px);
  }

  .crossword-grid {
    width: 100%;
  }
}
