﻿:root {
  --paper: #f8f0e2;
  --sand: #eddcc6;
  --ink: #1f2c2a;
  --muted: #5d6f6c;
  --teal: #2e7d74;
  --coral: #d66d3e;
  --mist: #d0e6e1;
  --line: rgba(31, 44, 42, 0.18);
  --card: rgba(255, 255, 255, 0.72);
  --shadow: 0 16px 40px rgba(31, 44, 42, 0.14);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Bricolage Grotesque", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(214, 109, 62, 0.25), transparent 28%),
    radial-gradient(circle at 84% 16%, rgba(46, 125, 116, 0.2), transparent 34%),
    linear-gradient(160deg, #f5e9d4 0%, #f8f0e2 44%, #e6f0ea 100%);
}

body.modal-open {
  overflow: hidden;
}

.backdrop-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
  background-image: radial-gradient(rgba(31, 44, 42, 0.2) 0.6px, transparent 0.6px);
  background-size: 3px 3px;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1160px, 94vw);
  margin: 0 auto;
  padding: 1.2rem 0 3.2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: #fef9ef;
  background: linear-gradient(135deg, var(--coral), #b14f27);
  font-size: 0.76rem;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.topnav a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.45);
}

.hero {
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.88), rgba(238, 248, 244, 0.9));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 2.8vw, 2.5rem);
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.76rem;
  font-weight: 800;
}

.hero h1 {
  margin: 0.55rem 0 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.65rem, 4vw, 3.15rem);
  line-height: 1.08;
}

.hero-copy {
  max-width: 68ch;
  margin-top: 0.95rem;
  margin-bottom: 0;
  color: #2f3f3c;
}

.hero-actions {
  margin-top: 1.3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.64rem;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.62rem 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  color: #fdf7eb;
  border-color: transparent;
  background: linear-gradient(135deg, var(--teal), #245f58);
}

.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
}

.status-bar {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.status-bar article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 1rem;
}

.status-bar h2 {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-bar p {
  margin: 0.42rem 0 0;
  font-family: "Space Mono", monospace;
  font-size: 1.1rem;
  font-weight: 700;
}

.scene-section {
  margin-top: 1.5rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.7rem);
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.scene-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.scene-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.scene-head {
  padding: 0.85rem 0.95rem 0.35rem;
}

.scene-head h3 {
  margin: 0;
  font-size: 1.07rem;
}

.scene-head p {
  margin: 0.35rem 0 0;
  color: #32433f;
  font-size: 0.9rem;
}

.scene-canvas {
  position: relative;
  height: 230px;
  margin: 0.4rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  overflow: hidden;
  cursor: crosshair;
  --mx: 50%;
  --my: 50%;
  --scene-bg: linear-gradient(145deg, var(--scene-a), var(--scene-b));
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.26), transparent 30%),
    radial-gradient(circle at 80% 25%, rgba(255, 255, 255, 0.14), transparent 26%),
    var(--scene-bg);
  background-size: auto, auto, cover;
  background-position: center, center, center;
}

.scene-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(125deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 12px);
  mix-blend-mode: overlay;
  opacity: 0.34;
  pointer-events: none;
}

.scene-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle 98px at var(--mx) var(--my), rgba(255, 255, 248, 0.44), rgba(255, 255, 255, 0));
  pointer-events: none;
  transition: background-position 80ms linear;
}

.hidden-token {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot));
}

.hidden-token.decoy {
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: rgba(255, 252, 243, 0.22);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.hidden-token.trigger {
  width: 48px;
  height: 56px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 251, 235, 0.24);
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0 2px, rgba(245, 236, 215, 0.12) 2px 7px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(239, 225, 198, 0.08));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.14);
  opacity: 0.15;
  cursor: pointer;
}

.hidden-token.trigger::before {
  content: "#";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Space Mono", monospace;
  font-size: 0.9rem;
  color: rgba(255, 248, 233, 0.46);
}

.scene-canvas:hover .hidden-token.trigger,
.scene-canvas.scene-pulsing .hidden-token.trigger {
  opacity: 0.36;
}

.scene-canvas.scene-pulsing .hidden-token.trigger {
  animation: pulse 1.1s ease-in-out 3;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) rotate(var(--rot)) scale(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.35);
  }
  70% {
    transform: translate(-50%, -50%) rotate(var(--rot)) scale(1.06);
    box-shadow: 0 0 0 14px rgba(255, 255, 255, 0);
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--rot)) scale(1);
  }
}

.scene-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.95rem 0.9rem;
}

.scene-status {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.scene-card.is-found .scene-status,
.scene-card.is-solved .scene-status {
  color: #285f56;
  font-weight: 700;
}

.scene-open {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.63);
  padding: 0.38rem 0.74rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.how {
  margin-top: 1.6rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem;
}

.how h2 {
  margin-top: 0;
}

.how ol {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.34rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 20;
  background: rgba(12, 21, 19, 0.68);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

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

.modal-card {
  width: min(1160px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(145deg, #fff9ef, #f2f6f4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.modal-close {
  margin-left: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.4rem 0.72rem;
  cursor: pointer;
}

.modal-head {
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
}

.modal-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.75rem;
  color: var(--teal);
  font-weight: 800;
}

.modal-head h2 {
  margin: 0.2rem 0 0;
  font-family: "Fraunces", serif;
}

.modal-hint {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  text-align: right;
}

.modal-body {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr 1.65fr 1.2fr;
  gap: 0.85rem;
}

.dog-panel,
.puzzle-panel,
.clue-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  padding: 0.72rem;
}

.dog-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(31, 44, 42, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 12px 22px rgba(31, 44, 42, 0.2);
  background: linear-gradient(135deg, #dcece7, #f3e8d6);
}

#dogImage {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  transform: scale(1.02);
  filter: contrast(1.06) saturate(1.1) brightness(1.02);
}

.dog-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dog-overlay-grain {
  mix-blend-mode: soft-light;
  opacity: 0.26;
  background-image: radial-gradient(rgba(255, 255, 255, 0.35) 0.7px, rgba(0, 0, 0, 0.14) 0.7px);
  background-size: 3px 3px;
}

.dog-overlay-vignette {
  background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.35));
}

.dog-badge {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  font-size: 0.68rem;
  padding: 0.25rem 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  color: #f8f4eb;
  background: rgba(25, 40, 37, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dog-panel p {
  margin: 0.52rem 0 0;
  font-size: 0.87rem;
  color: var(--muted);
}

.dog-note {
  font-size: 0.76rem;
  line-height: 1.38;
}

.crossword-grid {
  display: grid;
  gap: 4px;
  justify-content: start;
  --cell-size: 40px;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 1px solid rgba(31, 44, 42, 0.28);
  overflow: hidden;
  width: var(--cell-size);
  min-width: 0;
}

.cell.block {
  background: #243530;
  border-color: #243530;
}

.cell input {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fffdf7;
  text-transform: uppercase;
  text-align: center;
  font-family: "Space Mono", monospace;
  font-size: 1rem;
  color: var(--ink);
}

.cell input:focus {
  outline: 2px solid rgba(46, 125, 116, 0.48);
}

.cell-num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.56rem;
  color: #37524c;
  font-family: "Space Mono", monospace;
  pointer-events: none;
}

.cell input.correct {
  background: #dbf1e8;
}

.cell input.wrong {
  background: #ffe5dc;
}

.puzzle-actions {
  margin-top: 0.72rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.puzzle-message {
  margin: 0.62rem 0 0;
  font-size: 0.9rem;
  min-height: 1.2em;
  color: #314744;
}

.clue-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.clue-panel h3 + ol {
  margin-top: 0;
}

.clue-panel ol {
  margin: 0.1rem 0 0.8rem;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
}

.clue-panel li {
  font-size: 0.84rem;
  line-height: 1.3;
}

.clue-empty {
  color: #5d6f6c;
  font-style: italic;
}

@media (max-width: 1060px) {
  .scene-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .modal-hint {
    text-align: left;
  }
}

@media (max-width: 720px) {
  .status-bar {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    justify-content: flex-start;
  }

  .scene-canvas {
    height: 220px;
  }

  .cell {
    min-width: 30px;
  }
}
