*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --ink: #241c14;
  --muted: #5e554b;
  --paper: #fffaf3;
  --line: #eadfce;
  --navy: #243044;
  --gold: #c98512;
  --red: #e10600;
  --bg: #e9e0d1;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at top left, #f7f1e6 0%, transparent 52%),
    radial-gradient(ellipse at bottom right, #ddd2c0 0%, transparent 46%);
}

button,
.card {
  font: inherit;
}

.wrap {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero h1 {
  margin: 0;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede {
  max-width: 68ch;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 22px;
  align-items: start;
  margin-top: 22px;
  overflow: visible;
}

.board {
  position: relative;
  margin: 8px 0 12px;
  overflow: visible;
}

@media (min-width: 981px) {
  .board {
    margin: 18px 156px 8px 172px;
  }
}

.photo-frame {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border-radius: 18px;
  line-height: 0;
  box-shadow: 0 22px 50px rgba(48, 32, 12, 0.18);
}

.board img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.caption {
  margin: 10px 4px 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.leaders,
.zones,
.clouds {
  position: absolute;
  inset: 0;
}

.leaders {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
}

.leaders path {
  fill: none;
  stroke-linecap: round;
}

.leaders .shadow {
  stroke: rgba(20, 14, 8, 0.55);
  stroke-width: 5;
}

.leaders .line {
  stroke: #fffef8;
  stroke-width: 2.4;
}

.zones {
  z-index: 3;
  pointer-events: none;
}

.clouds {
  z-index: 4;
  pointer-events: none;
}

.zone {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.zone:disabled {
  cursor: default;
}

.pin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border: 3px solid #1a140e;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 0 7px rgba(240, 180, 41, 0.45);
  transform: translate(-50%, -50%);
  animation: pulse 1.8s ease-out infinite;
}

.zone.is-hot .pin {
  transform: translate(-50%, -50%) scale(1.4);
  background: #ffe08a;
  box-shadow:
    0 0 0 4px #fff,
    0 0 0 11px rgba(240, 180, 41, 0.7);
}

.zone.is-miss .pin {
  background: var(--red);
  animation: none;
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 9px rgba(225, 6, 0, 0.45);
}

.zone.is-solved .pin {
  width: 11px;
  height: 11px;
  border-color: #fff;
  background: #f0b429;
  animation: none;
  box-shadow: 0 0 0 3px rgba(20, 14, 8, 0.55);
}

.cloud {
  position: absolute;
  z-index: 5;
  width: max-content;
  max-width: 158px;
  margin: 0;
  padding: 8px 2px 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
}

.cloud-body {
  position: relative;
  padding: 6px 11px 7px;
  border-radius: 999px;
  background: #fffefb;
  animation: float 3.6s ease-in-out infinite, enchant 2.8s ease-in-out infinite;
}

.cloud-body::before,
.cloud-body::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: #fffefb;
  z-index: 0;
}

.cloud-body::before {
  width: 16px;
  height: 16px;
  left: 12px;
  top: -7px;
}

.cloud-body::after {
  width: 12px;
  height: 12px;
  left: 26px;
  top: -5px;
}

.cloud-name {
  position: relative;
  z-index: 1;
  display: block;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.15;
}

.spark {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  background: #f2c14e;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 1.5s ease-in-out infinite;
}

.spark.s1 { top: 2px; right: 8px; }
.spark.s2 { left: 0; bottom: 8px; animation-delay: 0.4s; }
.spark.s3 { right: 18px; bottom: -2px; width: 6px; height: 6px; animation-delay: 0.8s; }

.cloud-desc {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  width: 230px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--ink);
  color: #fffaf3;
  font-size: 0.8rem;
  font-weight: 450;
  line-height: 1.35;
  text-align: left;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 6;
}

.cloud.flip .cloud-desc {
  bottom: auto;
  top: calc(100% + 4px);
}

.cloud:hover .cloud-desc,
.cloud:focus-visible .cloud-desc,
.cloud.is-open .cloud-desc {
  opacity: 1;
}

.panel {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 22px;
  background: rgba(255, 250, 243, 0.82);
  box-shadow: 0 16px 40px rgba(60, 40, 10, 0.06);
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.stat {
  margin: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.92rem;
}

.stat strong {
  font-variant-numeric: tabular-nums;
}

.stat strong.bad {
  color: var(--red);
}

.bar {
  height: 7px;
  margin: 12px 0 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6dccb;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #c98512, #f0c14b);
  transition: width 0.35s ease;
}

.tray {
  max-height: calc(100vh - 168px);
  overflow: auto;
  padding-right: 4px;
}

.kicker {
  margin: 14px 4px 8px;
  color: #8a7d6c;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  width: 100%;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  color: inherit;
  text-align: left;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.card:hover {
  border-color: #d8c7ad;
}

.card.is-selected {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(36, 48, 68, 0.16);
}

.card.is-dragging {
  z-index: 60;
  margin: 0;
  cursor: grabbing;
  pointer-events: none;
  box-shadow: 0 18px 40px rgba(30, 20, 8, 0.22);
  transform: rotate(-1.5deg);
  transition: none;
}

.card.is-returning {
  z-index: 60;
  margin: 0;
  pointer-events: none;
  transition: left 0.34s cubic-bezier(0.2, 0.7, 0.2, 1), top 0.34s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card.is-wrong {
  border-color: var(--red);
  background: #fff1f0;
  animation: shake 0.42s ease;
}

.card.is-wrong .name,
.card.is-wrong .miss {
  color: var(--red);
}

.card.is-done {
  cursor: default;
  touch-action: auto;
  background: #fbf6ee;
}

.grip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  align-content: center;
  width: 12px;
  padding-top: 4px;
}

.grip i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #c8bba8;
}

.name {
  display: block;
  margin: 0 0 4px;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.15;
}

.desc {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.miss {
  display: none;
  margin: 6px 0 0;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.card.is-wrong .miss {
  display: block;
}

.mini-cloud {
  width: 28px;
  height: 20px;
  margin-top: 4px;
  fill: #fff;
  stroke: var(--gold);
  stroke-width: 1.4;
}

.placeholder {
  margin: 0 0 10px;
  border: 2px dashed rgba(36, 28, 20, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.28);
}

.empty {
  margin: 0 4px 8px;
  color: #8a7d6c;
  font-size: 0.9rem;
  line-height: 1.35;
}

.btn {
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fffaf3;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid #cfc3b2;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.08);
}

.success {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 18px;
  background: var(--navy);
  color: #fffaf3;
}

.success h2 {
  margin: 0 0 6px;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.success p:last-of-type {
  margin: 0 0 12px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 80;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-weight: 700;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(120, 10, 10, 0.25);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

:focus-visible {
  outline: 3px solid #e6a317;
  outline-offset: 2px;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.92), 0 0 0 6px rgba(240, 180, 41, 0.55); }
  100% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.92), 0 0 0 14px rgba(240, 180, 41, 0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes enchant {
  0%, 100% { filter: drop-shadow(0 8px 8px rgba(30, 20, 8, 0.18)) drop-shadow(0 0 0 rgba(242, 193, 78, 0)); }
  50% { filter: drop-shadow(0 10px 10px rgba(30, 20, 8, 0.2)) drop-shadow(0 0 8px rgba(242, 193, 78, 0.95)); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.7) rotate(0deg); }
  50% { opacity: 1; transform: scale(1) rotate(20deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

.only-narrow {
  display: none;
}

@media (max-width: 980px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-scroll {
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .board {
    width: 440px;
    margin: 16px 150px 8px 176px;
  }

  .tray {
    max-height: none;
  }

  .only-narrow {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
