/* Cosmic shell shared with the rest of anul.space. Every token below is copied
   verbatim from mathconnect/styles.css so the two games cannot drift apart;
   --slop and --not-slop reuse Math Connect's subtract/add hues. */
:root {
  --field: #050810;
  --panel: rgba(12, 20, 36, 0.94);
  --panel-solid: #0c1424;
  --panel-line: #2d405d;
  --text: #e2e8f0;
  --text-bright: #eef3ff;
  --muted: #9eabc0;
  --cyan: #67e8f9;
  --cyan-hot: #22d3ee;
  --slop: #fb7185;
  --not-slop: #4ade80;
  --gold: #facc15;
  --ink: #050810;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--field);
  color: var(--text);
  font-family: "Baloo 2", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button { color: inherit; font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--cyan-hot); outline-offset: 3px; }

/* Announced by screen readers, never painted. `display:none` would hide it
   from assistive tech too, which defeats the point of a live region. */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Shared topbar — mirrors the Math Connect/Twistris/DMC hub-back pill */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: 1100px; margin: 0 auto;
}
.hub-back {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px; border: 1px solid var(--panel-line);
  border-radius: 999px; color: #dfe7f5; background: #111c2d;
  font-size: 13px; font-weight: 800; text-decoration: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.hub-back:hover { border-color: var(--cyan-hot); background: #16243a; transform: translateY(-1px); }
.wordmark {
  margin: 0; font-weight: 400;
  font-family: "Press Start 2P", monospace; font-size: 12px;
  color: var(--cyan); letter-spacing: 1px;
}

#app { max-width: 1100px; margin: 0 auto; padding: 0 16px 28px; }

/* ---- Buttons ---- */
.btn {
  display: block; width: 100%; min-height: 52px; margin: 10px 0;
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  background: var(--panel-solid); color: var(--text-bright);
  font-size: 20px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.55);
  transition: transform .12s ease, border-color .12s ease, background .12s ease, color .12s ease;
}
.btn:hover { transform: translateY(-2px); border-color: var(--cyan-hot); }
.btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.55); }
.btn-primary { border-color: var(--cyan); color: var(--ink); background: var(--cyan); }
.btn-primary:hover { border-color: var(--cyan-hot); background: var(--cyan-hot); }
.icon-btn {
  min-width: 44px; min-height: 44px; border: 1px solid var(--panel-line);
  border-radius: 12px; background: var(--panel-solid); cursor: pointer;
  font-size: 18px; line-height: 1;
}
.icon-btn:hover { border-color: var(--cyan-hot); }

/* ---- Menu ---- */
.menu { max-width: 420px; margin: 6vh auto 0; text-align: center; }
.menu-title {
  font-family: "Press Start 2P", monospace; font-size: clamp(20px, 5vw, 34px);
  color: var(--text-bright); line-height: 1.5; margin: 0 0 8px;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.35);
}
.menu-title .or { color: var(--cyan); }
.menu-sub { color: var(--muted); margin: 0 0 22px; }
.menu-progress { color: var(--muted); font-weight: 700; margin: 14px 0 4px; }
.menu-best { color: var(--gold); font-weight: 800; }
.option-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; font-weight: 700; }

/* ---- Game screen ---- */
.game { max-width: 560px; margin: 0 auto; }
.game-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 4px 0 12px; min-height: 44px;
}
.lives { font-size: 24px; letter-spacing: 5px; line-height: 1; color: var(--slop); }
.lives .spent { color: var(--panel-line); }
.streak-box { display: flex; align-items: baseline; gap: 9px; }
.streak-label { font-family: "Press Start 2P", monospace; font-size: 10px; color: var(--muted); }
.streak-value {
  font-size: 28px; font-weight: 800; color: var(--text-bright); line-height: 1;
  font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.4);
}

/* Sticker-style frame. The area is fixed so swapping images never nudges the
   page: aspect-ratio holds the box, object-fit letterboxes whatever lands in it. */
.frame {
  position: relative; margin: 0; width: 100%;
  aspect-ratio: 4 / 3; max-height: 56vh;
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  background: var(--panel-solid); overflow: hidden;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.55);
  transition: border-color .15s ease;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  cursor: grab; will-change: transform;
}
.frame.dragging { cursor: grabbing; transition: border-color .15s ease; }
.frame.spring { transition: transform 0.24s ease, border-color .15s ease; }

/* Tinder-style corner stamps, revealed by drag distance (opacity set inline). */
.stamp {
  position: absolute; top: 12px; z-index: 3; padding: 8px 12px;
  font-family: "Press Start 2P", monospace; font-size: 11px; letter-spacing: 1px;
  border: 3px solid; border-radius: 10px; background: rgba(5, 8, 16, 0.6);
  opacity: 0; pointer-events: none;
}
.stamp-not-slop { left: 12px; transform: rotate(-12deg); color: var(--not-slop); border-color: var(--not-slop); }
.stamp-slop { right: 12px; transform: rotate(12deg); color: var(--slop); border-color: var(--slop); }
.frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.frame.correct { border-color: var(--not-slop); }
.frame.wrong { border-color: var(--slop); }
.frame-count {
  position: absolute; right: 8px; bottom: 8px;
  padding: 4px 8px; border-radius: 999px; background: rgba(5, 8, 16, 0.74);
  font-family: "Press Start 2P", monospace; font-size: 9px; color: var(--muted);
}
.frame-missing {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; padding: 20px;
  text-align: center; color: var(--muted);
}
.frame.broken .frame-missing { display: flex; }

/* The image sits above this row, so the reveal card replacing the buttons can
   never move it — the fixed aspect frame is what keeps the picture still. No
   min-height here: reserving reveal-sized space would leave a dead gap under
   the buttons for the whole game just to hold the hint line steady. */
.decision { margin-top: 14px; }
.verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  margin: 0; min-height: 68px; padding: 6px;
  font-family: "Press Start 2P", monospace; font-size: 13px; line-height: 1.5;
}
.choice .key {
  display: block; margin-top: 7px; font-size: 8px; color: var(--muted); letter-spacing: 1px;
}
.choice.slop { border-color: var(--slop); color: var(--slop); }
.choice.slop:hover { border-color: var(--slop); background: var(--slop); color: var(--ink); }
.choice.slop:hover .key { color: var(--ink); }
.choice.not-slop { border-color: var(--not-slop); color: var(--not-slop); }
.choice.not-slop:hover { border-color: var(--not-slop); background: var(--not-slop); color: var(--ink); }
.choice.not-slop:hover .key { color: var(--ink); }

.hint { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.hint kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px;
  border: 1px solid var(--panel-line); border-radius: 5px;
  background: var(--panel-solid); color: var(--text); font-family: inherit; font-weight: 800;
}
@media (hover: none) { .hint { display: none; } }

/* ---- Reveal card ---- */
.reveal {
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  background: var(--panel); padding: 16px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.55);
  animation: reveal-in .18s ease;
}
.reveal.correct { border-color: var(--not-slop); }
.reveal.wrong { border-color: var(--slop); }
.reveal-verdict { font-family: "Press Start 2P", monospace; font-size: 14px; margin: 0 0 10px; }
.reveal.correct .reveal-verdict { color: var(--not-slop); }
.reveal.wrong .reveal-verdict { color: var(--slop); }
.reveal-truth { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--text-bright); }
.reveal-truth .label-ai { color: var(--slop); }
.reveal-truth .label-real { color: var(--not-slop); }
.reveal-tell { margin: 0 0 10px; color: var(--text); line-height: 1.55; }
.reveal-source { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.reveal .btn { margin: 0; }

/* ---- End screen ---- */
.endcard { max-width: 420px; margin: 4vh auto 0; text-align: center; }
.end-title {
  font-family: "Press Start 2P", monospace; font-size: clamp(15px, 4.4vw, 22px);
  color: var(--text-bright); line-height: 1.5; margin: 0 0 6px;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.35);
}
.end-sub { color: var(--muted); margin: 0 0 16px; }
.end-score {
  font-size: clamp(52px, 14vw, 80px); font-weight: 800; color: var(--cyan);
  line-height: 1; margin: 0; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 26px rgba(34, 211, 238, 0.4);
}
.end-score-label {
  display: block; margin-top: 10px;
  font-family: "Press Start 2P", monospace; font-size: 10px; color: var(--muted);
}
.end-best { color: var(--muted); font-weight: 700; margin: 16px 0 4px; }
.end-best .new-best { color: var(--gold); font-weight: 800; }
.share-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 18px; }
.share-line {
  flex: 1; min-width: 0; padding: 11px 12px; text-align: left;
  border: 1px solid var(--panel-line); border-radius: 10px;
  background: var(--panel-solid); color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Loading / failure ---- */
.notice {
  max-width: 420px; margin: 8vh auto 0; padding: 22px; text-align: center;
  border: 2px solid var(--panel-line); border-radius: 18px; background: var(--panel);
  color: var(--muted);
}
.notice h2 { font-family: "Press Start 2P", monospace; font-size: 14px; color: var(--text-bright); margin: 0 0 12px; }

/* ---- Overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center;
  justify-content: center; background: rgba(5, 8, 16, 0.74);
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.modal {
  width: min(420px, 100%); border: 2px solid var(--panel-line);
  border-radius: 18px; background: var(--panel); padding: 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  max-height: calc(100dvh - 40px); overflow-y: auto;
}
.modal h2 { font-family: "Press Start 2P", monospace; font-size: 15px; color: var(--text-bright); margin: 0 0 14px; text-align: center; }
.modal .rules { color: var(--muted); line-height: 1.55; font-size: 15px; }
.modal .rules strong { color: var(--text-bright); }
.modal .rules .slop-word { color: var(--slop); font-weight: 800; }
.modal .rules .not-slop-word { color: var(--not-slop); font-weight: 800; }
.modal .rules kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px;
  border: 1px solid var(--panel-line); border-radius: 5px;
  background: var(--panel-solid); color: var(--text); font-family: inherit; font-weight: 800;
}

.toast {
  position: fixed; left: 50%; bottom: 9%; transform: translateX(-50%);
  z-index: 40; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--cyan); background: var(--panel);
  color: var(--cyan); font-weight: 800; pointer-events: none;
  animation: toast-in 0.2s ease;
}

/* ---- FX ---- */
.pop { animation: target-pop 0.35s ease; }
.shake { animation: shake 0.3s ease; }
.particle {
  position: fixed; z-index: 50; width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none;
}
@keyframes target-pop { 40% { transform: scale(1.03); } }
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes reveal-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes particle-fly { to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }

@media (max-width: 380px) {
  .choice { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .pop, .shake, .toast, .reveal { animation: none; }
  .particle { display: none; }
  .btn, .hub-back, .frame, .frame.spring { transition: none; }
}
