/* ------------------------------------------------------------------ tokens */
:root {
  --menu-bg: #0a0d1a;
  --menu-panel: #121a2e;
  --menu-line: #24304d;
  --menu-text: #e9edf9;
  --menu-muted: #93a1c4;
  --coral: #e2603c;
  --gold: #d8a44c;

  --page: var(--menu-bg);
  --panel: var(--menu-panel);
  --ink: var(--menu-text);
  --muted: var(--menu-muted);
  --line: var(--menu-line);
  --accent: var(--coral);
  --accent-ink: #0b1020;
  --frame: #0b0f18;
  --radius: 14px;
}

/* the collector: warm paper, ink, coral accents */
body[data-game="zmniswinebi"] {
  --page: #efe4cd;
  --panel: #fbf6ea;
  --ink: #1d2933;
  --muted: #7a6a55;
  --line: #d9c9ad;
  --accent: #cf5630;
  --accent-ink: #fff8ec;
  --frame: #fffdf7;
}

/* abo: museum-dark, parchment, gold */
body[data-game="abo"] {
  --page: #170d10;
  --panel: #24141a;
  --ink: #f4e7cd;
  --muted: #b0937a;
  --line: #4a2c31;
  --accent: #d8a44c;
  --accent-ink: #1b1013;
  --frame: #24141a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background: var(--page);
  color: var(--ink);
  font-family: "Trebuchet MS", "Noto Sans Georgian", Verdana, sans-serif;
  line-height: 1.55;
  transition: background 0.35s ease, color 0.35s ease;
}

body[data-game="abo"] h1,
body[data-game="abo"] h2 {
  font-family: Georgia, "Noto Serif Georgian", serif;
  letter-spacing: 0.01em;
}

code {
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 0.9em;
  background: #ffffff10;
  padding: 1px 5px;
  border-radius: 4px;
}

button {
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.2s ease;
}

button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  padding: 8px 14px;
  font-weight: 500;
}

button.quiet:hover {
  color: var(--ink);
  border-color: var(--accent);
  filter: none;
}

/* ------------------------------------------------------------------- menu */
body:not([data-game]) {
  background: #f5f2e9;
  color: #182927;
}
.menu {
  width: min(1160px, 100%);
  margin: auto;
  padding: 0 clamp(18px, 4vw, 60px) 32px;
}
.mast, .mast strong { display: flex; align-items: center; }
.mast { justify-content: space-between; gap: 12px; border-bottom: 1px solid #babab0; padding: 20px 0; }
.mast strong { gap: 10px; font-size: 1.22rem; letter-spacing: -.03em; }
.mast strong span { display: grid; place-items: center; background: #224b40; color: #fff9dc; border-radius: 6px; width: 35px; height: 35px; font-size: 27px; line-height: 1; }
.mast a { color: #36554c; font-size: .86rem; text-underline-offset: 4px; }
.hero { padding: clamp(30px,5vw,65px) 0 32px; }
.hero h1 { margin: 0; font: 500 clamp(2.7rem,6.1vw,5.3rem)/1.02 Georgia,serif; letter-spacing: -.055em; }
.hero h1 span { color: #ac4729; }
.lede { color: #495b55; margin: 16px 0 0; max-width: 54ch; }
.cards { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: clamp(16px, 2vw, 28px); }
.card { display: flex; flex-direction: column; background: #fffdf5; border: 1px solid #c8c8bc; border-radius: 12px; overflow: hidden; }
.card-art { overflow: hidden; aspect-ratio: 52 / 23; border-bottom: 1px solid #c8c8bc; }
.card-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-body { flex: 1; display: flex; flex-direction: column; align-items: flex-start; padding: clamp(18px,2.5vw,32px); }
.card h2 { margin: 0; font: 700 clamp(1.55rem,3vw,2.15rem)/1.25 Georgia,serif; }
.tag { margin: 4px 0 12px; color: #526359; font-size: .92rem; }
.blurb { margin: 0 0 22px; max-width: 46ch; color: #35473f; }
.card :is(button, .play-link) { margin-top: auto; background: #254e40; color: #fffdf3; border-radius: 7px; padding: 9px 17px; }
.card :is(button, .play-link) span { margin-left: 12px; }
.card--gold :is(button, .play-link) { background: #513e48; }
.menu-foot { margin-top: 28px; border-top: 1px solid #babab0; color: #536059; font-size: .82rem; }
button:focus-visible, a:focus-visible { outline: 3px solid #3079c6; outline-offset: 3px; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }
/* ------------------------------------------------------------------- game */
.game {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px 20px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px max(0px, calc((100vw - 1180px) / 2 - 20px));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand h1 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}

#room-label {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 84px;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.stat .key {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.stat strong {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.hearts {
  color: var(--accent);
  letter-spacing: 0.08em;
}

.bar-actions {
  display: flex;
  gap: 8px;
}

.meter {
  width: min(100%, 1180px);
  margin: 12px auto 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#meter-label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.meter-track {
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  overflow: hidden;
}

#meter-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ffffff));
  transition: width 0.25s ease;
}

.stage {
  position: relative;
  margin: 16px auto 0;
  display: flex;
  justify-content: center;
  border-radius: 8px;
  background: var(--frame);
  box-shadow: 0 30px 70px #00000040, 0 0 0 1px var(--line);
  overflow: hidden;
  max-width: 100%;
}

body[data-game="zmniswinebi"] .stage {
  box-shadow: 0 24px 50px #6b563020, 0 0 0 1px var(--line), 0 0 0 8px #fffdf7;
}

body[data-game="abo"] .stage {
  box-shadow: 0 30px 80px #000000aa, 0 0 0 1px #6b4a2e;
}

.stage.fade {
  animation: room-fade 0.35s ease;
}

@keyframes room-fade {
  from {
    opacity: 0.35;
    transform: translateY(4px) scale(0.997);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

canvas {
  display: block;
  max-width: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}

/* the collector is keyboard-driven, the quiz is mouse-driven */
body[data-game="zmniswinebi"] canvas {
  cursor: default;
}

.hit-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, transparent 35%, #c9452ecc 100%);
}

.hit-flash.hit {
  animation: hit 0.4s ease-out;
}

@keyframes hit {
  0% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

body.shake .stage {
  animation: shake 0.32s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  45% {
    transform: translateX(4px);
  }
  70% {
    transform: translateX(-2px);
  }
}

.hint {
  margin: 14px auto 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* --------------------------------------------------------------- overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--page) 55%, #000000 55%);
  backdrop-filter: blur(5px);
  z-index: 20;
}

.overlay.active {
  display: grid;
}

.panel {
  width: min(92vw, 440px);
  padding: 28px 26px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px #00000066;
  text-align: center;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
}

.panel p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.dialog {
  position: relative;
  display: grid;
  place-items: center;
  gap: 14px;
  width: min(92vw, 420px);
  padding: 22px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px #00000077;
  overflow: hidden;
  text-align: center;
}

.dialog img#dialog-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: pixelated;
  z-index: 0;
}

.dialog p {
  position: relative;
  z-index: 1;
  margin: 0;
  white-space: pre-wrap;
  font-size: 1rem;
  text-shadow: 0 1px 3px #000000aa;
  line-height: 1.5;
}

.dialog p.on-background {
  padding: 6px 4px;
}

.dialog button {
  position: relative;
  z-index: 1;
}

.dialog button.image-button {
  background: transparent;
  padding: 0;
}

.dialog button.image-button img {
  display: block;
  image-rendering: pixelated;
  max-width: 220px;
}

@media (max-width: 720px) {
  .bar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .stats {
    order: 3;
    margin-left: 0;
    width: 100%;
  }

  .stat {
    flex: 1;
    align-items: flex-start;
  }

  .bar-actions {
    margin-left: auto;
  }
}

.dialog { max-width: 100%; max-height: calc(100dvh - 48px); overflow-y: auto; }
#pad { display: none; gap: 8px; justify-content: center; margin-top: 14px; }
#pad button { touch-action: none; user-select: none; min-width: 46px; padding: 8px; border-radius: 9px; }
@media (pointer: coarse), (max-width: 720px) { #pad {display: flex;} }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.play-link { display: inline-block; text-decoration: none; font-weight: 600; border: 1px solid transparent; }
.play-link:hover { filter: brightness(1.12); }
.flash-page { --page: #f5f2e9; --ink: #182927; --muted: #42574e; --line: #babab0; --accent: #254e40; }
.flash-page .bar { flex-wrap: wrap; }
.flash-page .bar-actions { margin-left: auto; }
.flash-page .brand p { margin: 4px 0 0; font-size: .82rem; color: var(--muted); }
.games-link { color: var(--ink); text-underline-offset: 4px; white-space: nowrap; }
#flash-stage {
  --movie-ratio: 1.375;
  width: min(100%, 1100px, calc(max(220px, 100dvh - 144px) * var(--movie-ratio)));
  aspect-ratio: var(--movie-ratio);
  margin: 18px auto;
}
#flash-stage ruffle-player { display: block; width: 100%; height: 100%; overflow: hidden; border-radius: 8px; }
