:root {
  --ink: #071323;
  --paper: #fffaf0;
  --global: #28527a;
  --gold: #f8c35a;
  --coral: #ed694f;
  --cyan: #65c7cf;
  --shadow: 5px 5px 0 var(--ink);
}

* { box-sizing: border-box; }

html { background: #e9e4da; }

body.hg-game-page {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, #fffaf0 0 11rem, transparent 11.1rem),
    #e9e4da;
  font-family: "Arial Rounded MT Bold", "Hiragino Sans", system-ui, sans-serif;
}

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

.game-wrap {
  width: min(800px, 100%);
  margin: 0 auto;
  padding: 8px 14px 48px;
}

.game-mast {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .78rem;
  letter-spacing: .08em;
}

.game-mast a { color: inherit; font-weight: 900; }
.game-mast .locale-link { white-space: nowrap; }

.game-card {
  border: 4px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.intro-copy { padding: 18px 20px 20px; }
.eyebrow { margin: 0 0 4px; color: var(--global); font-size: .72rem; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  max-width: 16ch;
  font-size: clamp(2rem, 8vw, 4.5rem);
  line-height: .86;
  letter-spacing: -.055em;
}
.deck { max-width: 58ch; font-size: 1rem; line-height: 1.42; }
.bridge { font-size: .82rem; color: #3d4b5d; }

.hero {
  position: relative;
  aspect-ratio: 1200 / 630;
  overflow: hidden;
  border-top: 4px solid var(--ink);
  background: var(--global);
}
.hero img { width: 100%; height: 100%; display: block; object-fit: cover; }
.hero-rule {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(490px, calc(100% - 28px));
  margin: 0;
  padding: 8px 11px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: clamp(.75rem, 2vw, .95rem);
}

.primary,
.mode-button,
.shutter,
.action {
  min-height: 48px;
  border: 3px solid var(--ink);
  border-radius: 0;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.primary { width: 100%; margin-top: 10px; background: var(--gold); }
button:disabled { opacity: .55; cursor: wait; }
button:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:focus-visible, a:focus-visible { outline: 4px solid var(--coral); outline-offset: 3px; }

.play-shell { scroll-margin-top: 4px; }
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 7px 10px;
  border: 4px solid var(--ink);
  border-bottom: 0;
  background: var(--paper);
  font-size: .78rem;
}
.hud span:nth-child(2) { text-align: center; }
.hud span:last-child { text-align: right; }
.hud b { font-size: 1.1rem; }

.world {
  --frame-w: 56%;
  --frame-h: 61%;
  position: relative;
  width: 100%;
  height: clamp(310px, 53vw, 390px);
  overflow: hidden;
  border: 4px solid var(--ink);
  background: var(--global) url("./art/hero.webp?v=1") center / cover no-repeat;
  touch-action: none;
  isolation: isolate;
}
.world::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, rgba(7, 19, 35, .08), transparent 30% 70%, rgba(7, 19, 35, .08));
  pointer-events: none;
}
.world[data-family="archive"] { filter: saturate(.82); }

.target {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  width: var(--w);
  height: var(--h);
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 250, 240, .85);
  border-radius: 50%;
  pointer-events: none;
}
.target span {
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translate(-50%, 50%);
  padding: 2px 5px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-size: clamp(.52rem, 1.6vw, .7rem);
  white-space: nowrap;
}
.subject-target { border-style: solid; border-color: rgba(248, 195, 90, .95); }

.viewfinder {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: var(--frame-w);
  height: var(--frame-h);
  transform: translate(-50%, -50%);
  border: 7px solid white;
  outline: 3px solid var(--ink);
  box-shadow: 0 0 0 999px rgba(7, 19, 35, .46);
  pointer-events: none;
  transition: width 130ms ease, height 130ms ease;
}
.viewfinder::before,
.viewfinder::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.viewfinder::before { inset: 18%; border: 2px dashed rgba(7, 19, 35, .85); }
.viewfinder::after {
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(7, 19, 35, .55);
}

.flash-distinct { animation: flashGood 260ms both; }
.flash-clipped, .flash-missing-context, .flash-crowded, .flash-repeated, .flash-missed {
  animation: flashBad 260ms both;
}
@keyframes flashGood { 50% { box-shadow: inset 0 0 0 12px var(--gold); } }
@keyframes flashBad { 50% { box-shadow: inset 0 0 0 12px var(--coral); } }

.feedback {
  min-height: 46px;
  margin: 7px 0;
  padding: 10px 12px;
  border-left: 8px solid var(--cyan);
  background: var(--paper);
  font-size: .82rem;
  pointer-events: none;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.mode-button { min-width: 0; padding-inline: 5px; font-size: .72rem; }
.mode-button[aria-pressed="true"] { background: var(--gold); }
.shutter { grid-column: 1 / -1; background: var(--coral); color: white; }

.contact-sheet {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  min-height: 70px;
  padding: 7px 0 0;
  margin: 0;
  list-style: none;
}
.contact-print {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: white;
  box-shadow: 2px 2px 0 var(--ink);
}
.print-crop {
  position: absolute;
  inset: 0;
  background: url("./art/hero.webp?v=1") var(--crop-x) var(--crop-y) / 300% auto no-repeat;
  opacity: .72;
}
.print-number {
  position: absolute;
  z-index: 2;
  top: 2px;
  left: 3px;
  min-width: 16px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--ink);
  font-size: .61rem;
}
.print-state {
  position: absolute;
  z-index: 2;
  inset: 16% 21% 28%;
}
.print-state svg { width: 100%; height: 100%; }
.print-label {
  position: absolute;
  z-index: 3;
  inset: auto 0 0;
  padding: 2px;
  background: rgba(255, 250, 240, .92);
  border-top: 2px solid var(--ink);
  font-size: clamp(.42rem, 1.2vw, .62rem);
  text-align: center;
  white-space: nowrap;
}
.state-distinct { border-color: var(--global); }
.state-clipped, .state-missed { border-style: dashed; border-color: var(--coral); }
.state-missing-context .print-crop { filter: saturate(0); opacity: .32; }
.state-crowded .print-crop { background-size: 180% auto; }
.state-repeated { transform: rotate(-1deg); box-shadow: 5px 3px 0 rgba(40, 82, 122, .65); }

.result-card { scroll-margin-top: 4px; overflow: hidden; }
.result-hero {
  min-height: 210px;
  padding: 18px;
  color: white;
  background:
    linear-gradient(rgba(7, 19, 35, .54), rgba(7, 19, 35, .72)),
    url("./art/hero.webp?v=1") center / cover;
}
.result-hero h2 { margin-bottom: 4px; font-size: clamp(2rem, 7vw, 4rem); line-height: .95; }
.score-line { margin: 0; font-size: 1.05rem; }
.score-line strong { font-size: 2.8rem; }
.result-body { padding: 16px; }
.result-sheet { margin-bottom: 16px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action { display: grid; place-items: center; color: inherit; text-decoration: none; text-align: center; }
.action.share { background: var(--ink); color: white; }
.action.reply { grid-column: 1 / -1; }

.story {
  margin-top: 28px;
  padding: 20px;
  border: 3px solid var(--ink);
  background: rgba(255, 250, 240, .85);
}
.story h2 { margin-bottom: 8px; }
.story li { margin-bottom: 5px; }
.story a { color: var(--global); font-weight: 900; }
.source-note { font-size: .78rem; }

[hidden] { display: none !important; }

@media (max-width: 520px) {
  .game-wrap { padding: 4px 5px 36px; }
  .game-mast { min-height: 38px; padding-inline: 3px; }
  .intro-copy { padding: 13px 14px 15px; }
  h1 { font-size: clamp(2.2rem, 14vw, 3.6rem); }
  .hero-rule { left: 8px; bottom: 8px; }
  .world { height: min(330px, 55vh); min-height: 280px; }
  .target span { font-size: .5rem; }
  .contact-sheet { grid-template-columns: repeat(3, 1fr); min-height: 0; }
  .contact-print { aspect-ratio: 1.22; }
  .result-actions { grid-template-columns: 1fr; }
  .action.reply { grid-column: auto; }
  .story { padding: 15px; }
}

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

