:root {
  color-scheme: light;
  --ink: #18332f;
  --ink-soft: #566763;
  --paper: #f4eedf;
  --paper-light: #fffdf6;
  --green: #2c6d5b;
  --green-dark: #19493e;
  --gold: #d9a84e;
  --line: rgba(24, 51, 47, 0.16);
  --shadow: 0 20px 60px rgba(31, 52, 46, 0.14);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(217, 168, 78, 0.2), transparent 30rem),
    radial-gradient(circle at 92% 16%, rgba(44, 109, 91, 0.18), transparent 32rem),
    var(--paper);
}

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

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(44, 109, 91, 0.4);
  outline-offset: 3px;
}

.site-header, footer {
  width: min(100% - 32px, 1040px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-header {
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.wordmark-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--paper-light);
  border-radius: 50% 46% 52% 44%;
  background: var(--green);
  transform: rotate(-8deg);
}

.service-status {
  padding: 7px 10px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 750;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 253, 246, 0.56);
}

.service-status.is-online::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #3b9b6d;
}

.page-shell {
  width: min(100% - 32px, 1040px);
  margin: 0 auto;
  padding: clamp(38px, 7vw, 80px) 0 80px;
}

.view {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(360px, 1.12fr);
  gap: clamp(32px, 7vw, 88px);
  align-items: center;
}

.view[hidden], [hidden] { display: none !important; }

.hero-copy h1, .error-card h1 {
  margin: 8px 0 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.65rem, 7vw, 5.25rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.hero-copy.compact h1, .error-card h1 { font-size: clamp(2.55rem, 6vw, 4.6rem); }

.eyebrow, .step-label {
  margin: 0;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lede {
  max-width: 36rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.play-card {
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(24, 51, 47, 0.12);
  border-radius: 28px;
  background: rgba(255, 253, 246, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card-heading, .game-status-row, .manage-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card-heading h2 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 4vw, 2rem);
  font-weight: 500;
}

.paint-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 24px 0;
  padding: 9px;
  border-radius: 19px;
  background: #d8d0be;
  box-shadow: inset 0 0 0 1px rgba(24, 51, 47, 0.13);
}

.paint-cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 0.86;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  background:
    linear-gradient(var(--stroke-angle), transparent 34%, var(--stroke) 36% 47%, transparent 49%),
    radial-gradient(circle at var(--spot-x) var(--spot-y), var(--spot) 0 14%, transparent 16%),
    var(--cell-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

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

.paint-cell.is-selected {
  box-shadow: inset 0 0 0 4px #fff9e9, 0 0 0 3px var(--green);
}

.paint-cell.is-wrong {
  animation: nudge 280ms ease;
  box-shadow: inset 0 0 0 3px rgba(126, 48, 44, 0.8);
}

.paint-cell.is-found {
  box-shadow: inset 0 0 0 4px #fff9e9, 0 0 0 4px var(--gold);
}

.creature {
  position: absolute;
  inset: 32% 18% 27% 23%;
  opacity: 0.78;
  border-radius: 55% 42% 50% 45%;
  background: var(--creature-color);
  transform: rotate(var(--creature-angle));
  box-shadow: inset -7px -5px 0 rgba(20, 43, 38, 0.08);
}

.creature::before {
  content: "";
  position: absolute;
  width: 48%;
  aspect-ratio: 1;
  top: -28%;
  right: -17%;
  border-radius: 50%;
  border: 6px solid var(--creature-color);
  border-left-color: transparent;
  transform: rotate(26deg);
}

.creature::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  top: 5%;
  left: 15%;
  border-radius: 50%;
  background: rgba(255, 250, 223, 0.9);
  box-shadow: 2px 1px 0 1px rgba(20, 43, 38, 0.62);
}

.is-seeker .creature { opacity: 0.46; filter: saturate(0.7); }

.palette-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.palette-button, .quiet-button, .danger-button {
  min-height: 42px;
  padding: 9px 12px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 760;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
  cursor: pointer;
}

.palette-button.is-selected {
  color: var(--paper-light);
  border-color: var(--green);
  background: var(--green);
}

.primary-button, .link-button {
  display: inline-grid;
  width: 100%;
  min-height: 54px;
  place-items: center;
  padding: 13px 20px;
  color: #fffdf6;
  font-weight: 830;
  text-decoration: none;
  border: 0;
  border-radius: 15px;
  background: var(--green);
  box-shadow: 0 10px 22px rgba(25, 73, 62, 0.18);
  cursor: pointer;
}

.primary-button:hover, .link-button:hover { background: var(--green-dark); }
button:disabled { opacity: 0.56; cursor: wait; }

.privacy-note {
  margin: 13px 0 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.5;
  text-align: center;
}

.ready-panel {
  display: grid;
  min-height: 280px;
  align-content: center;
  gap: 22px;
  text-align: center;
}

.ready-panel p { margin: 0; color: var(--ink-soft); }

.timer {
  min-width: 70px;
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 900;
}

.result-panel { padding: 32px 10px 10px; text-align: center; }

.result-panel h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  font-weight: 500;
}

.result-panel p { margin: 0 0 22px; color: var(--ink-soft); }
.share-label { display: block; margin-bottom: 8px; font-size: 0.78rem; font-weight: 800; }

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.share-row input {
  min-width: 0;
  padding: 11px 12px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(244, 238, 223, 0.6);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.stats-grid div {
  display: grid;
  gap: 4px;
  padding: 20px 8px;
  text-align: center;
  border-radius: 15px;
  background: rgba(44, 109, 91, 0.08);
}

.stats-grid strong {
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  font-variant-numeric: tabular-nums;
}

.stats-grid span { color: var(--ink-soft); font-size: 0.75rem; }
.manage-actions { align-items: stretch; }
.danger-button { color: #843d39; }

.text-link {
  display: block;
  margin-top: 18px;
  color: var(--green);
  font-weight: 750;
  text-align: center;
}

.error-card {
  grid-column: 1 / -1;
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
}

.error-card .link-button { width: auto; margin-top: 24px; }

footer {
  min-height: 76px;
  padding: 20px 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  border-top: 1px solid var(--line);
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

@media (max-width: 780px) {
  .site-header, footer, .page-shell { width: min(100% - 24px, 580px); }
  .view { grid-template-columns: 1fr; gap: 28px; }
  .hero-copy h1, .hero-copy.compact h1 { font-size: clamp(2.55rem, 12vw, 3.35rem); }
  .play-card { border-radius: 22px; }
  .paint-cell { min-height: 62px; }
}

@media (max-width: 480px) {
  .wordmark span:last-child { display: none; }
  .card-heading { align-items: flex-end; }
  .palette-picker { grid-template-columns: 1fr; }
  .share-row { grid-template-columns: 1fr 1fr; }
  .share-row input { grid-column: 1 / -1; }
  .manage-actions { flex-direction: column; }
  footer { align-items: flex-start; flex-direction: column; gap: 4px; }
}

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