/* ==========================================================================
   Landscape-first. The game is designed for a tablet held sideways: two tall
   panels side by side with a slim strip of chrome above them. Every other shape
   is handled, none is optimised for.
   ========================================================================== */

:root {
  --ink: #171310;
  --ink-2: #221c16;
  --ink-3: #2f2720;
  --paper: #f4e9d6;
  --paper-dim: #c9bda8;
  --brass: #d9a441;
  --brass-dim: #8a6a2c;
  --found: #6fbf73;
  --miss: #d4614e;
  --hud-height: 56px;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", Segoe UI, system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  /* The play surface is a comparison instrument, not a document. Nothing here
     should scroll, select, callout or zoom under a finger. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.view.is-active {
  display: flex;
}

/* ------------------------------------------------------------- buttons --- */

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 2rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn--primary {
  background: var(--brass);
  color: #24190a;
  box-shadow: 0 8px 22px rgba(217, 164, 65, 0.28);
}

.btn--ghost {
  background: transparent;
  color: var(--paper-dim);
  border: 1.5px solid rgba(244, 233, 214, 0.28);
}

/* ------------------------------------------------------------- landing --- */

.view--landing {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.landing__bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 15%, #3a2c1e 0%, #171310 70%);
  background-size: cover;
  background-position: center;
  opacity: 0.9;
}

.landing__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(23, 19, 16, 0.15) 0%, rgba(23, 19, 16, 0.9) 78%);
}

.landing__inner {
  position: relative;
  padding: 2rem;
  max-width: 40rem;
}

.landing__kicker {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
}

.logo {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo__glass {
  display: inline-block;
  margin-left: 0.2em;
  transform: rotate(-12deg);
}

.landing__tag {
  margin: 1rem 0 2rem;
  font-size: 1.15rem;
  color: var(--paper-dim);
}

.landing__foot {
  margin: 1.4rem 0 0;
  font-size: 0.9rem;
  color: rgba(244, 233, 214, 0.45);
}

.landing__rotate {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--brass-dim);
}

/* Only worth saying when they are actually holding it the wrong way. */
@media (min-aspect-ratio: 1/1) {
  .landing__rotate {
    display: none;
  }
}

/* --------------------------------------------------------------- brief --- */

.view--brief {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.casefile {
  max-width: 34rem;
  background: var(--ink-2);
  border: 1px solid rgba(217, 164, 65, 0.22);
  border-radius: var(--radius);
  padding: 2rem 2.2rem 2.2rem;
  box-shadow: var(--shadow);
  text-align: left;
}

.casefile__stamp {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
}

.casefile__title {
  margin: 0.3rem 0 0.6rem;
  font-size: 1.9rem;
}

.casefile__sub {
  margin: 0 0 1.2rem;
  color: var(--paper-dim);
  line-height: 1.55;
}

.brief__rules {
  margin: 0 0 1.8rem;
  padding-left: 1.1rem;
  line-height: 1.9;
  color: var(--paper-dim);
}

.brief__rules b {
  color: var(--paper);
}

/* ---------------------------------------------------------------- play --- */

.view--play {
  flex-direction: column;
}

.hud {
  height: var(--hud-height);
  flex: 0 0 var(--hud-height);
  display: flex;
  align-items: center;
  gap: 1.6rem;
  padding: 0 1.2rem;
  background: var(--ink-2);
  border-bottom: 1px solid rgba(244, 233, 214, 0.07);
}

.hud__group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.hud__group--clock {
  margin-left: auto;
}

.hud__label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 233, 214, 0.4);
}

.pips {
  display: flex;
  gap: 0.4rem;
}

.pip {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(244, 233, 214, 0.28);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.pip.is-on {
  background: var(--found);
  border-color: var(--found);
  transform: scale(1.12);
}

.pips--miss .pip.is-on {
  background: var(--miss);
  border-color: var(--miss);
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.clock.is-urgent {
  color: var(--miss);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* --------------------------------------------------------------- stage --- */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  /* The stage owns all pointer handling: no panning, no pinch, no double-tap
     zoom. Without this the browser eats the press-and-hold before we see it. */
  touch-action: none;
}

.panel {
  position: absolute;
  overflow: hidden;
  border-radius: 6px;
  background: var(--ink-3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.panel__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
}

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

.mark {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--paper-dim);
  opacity: 0.9;
}

.mark--hit {
  border-color: var(--found);
  box-shadow: 0 0 0 3px rgba(111, 191, 115, 0.22);
  animation: pop 0.28s ease-out;
}

.mark--miss {
  border-color: var(--miss);
  animation: shake 0.36s ease-out;
}

.mark--reveal {
  border-color: var(--brass);
  border-width: 3px;
  box-shadow: 0 0 0 4px rgba(217, 164, 65, 0.18);
}

.mark--missed {
  border-color: var(--miss);
  border-style: dashed;
}

@keyframes pop {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.12);
  }
}

@keyframes shake {
  25% {
    transform: translate(-50%, -50%) rotate(-7deg);
  }
  75% {
    transform: translate(-50%, -50%) rotate(7deg);
  }
}

/* --------------------------------------------------------------- loupe --- */

/*
  Two of these, one over each panel, always showing the same region of the
  scene. The sameness is the feature — see loupeView() in layout.js.
*/
.loupe {
  position: absolute;
  border-radius: 50%;
  border: 3px solid var(--brass);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), inset 0 0 24px rgba(0, 0, 0, 0.28);
  background-repeat: no-repeat;
  /* Keep the magnified pixels crisp: this is flat cartoon art, and smoothing it
     hides exactly the fine detail the loupe was brought out to resolve. */
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 3;
}

/* --------------------------------------------------------- toast, flash --- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  background: rgba(23, 19, 16, 0.88);
  border: 1px solid rgba(244, 233, 214, 0.14);
  font-size: 0.95rem;
  color: var(--paper);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 4;
}

.toast.is-on {
  opacity: 1;
}

.flash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 19, 16, 0.82);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 5;
}

.flash.is-on {
  opacity: 1;
}

.flash__text {
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800;
  color: var(--brass);
}

/* ----------------------------------------------------------------- end --- */

.view--end {
  overflow-y: auto;
  justify-content: center;
}

.end__inner {
  width: 100%;
  max-width: 60rem;
  padding: 2rem 1.5rem 3rem;
  text-align: center;
}

.verdict__score {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
}

.verdict__line {
  margin: 0.35rem 0 1.4rem;
  font-size: clamp(1.4rem, 3.4vw, 2rem);
}

.stage--reveal {
  position: relative;
  height: 44vh;
  min-height: 260px;
  flex: none;
  margin-bottom: 1.5rem;
}

.answers {
  margin: 0 0 1.8rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
  text-align: left;
}

.answer {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.8rem 1.1rem;
  border-radius: 10px;
  background: var(--ink-2);
  border-left: 3px solid var(--miss);
}

.answer.is-found {
  border-left-color: var(--found);
}

.answer__num {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244, 233, 214, 0.4);
  flex: 0 0 auto;
}

.answer__text {
  margin: 0;
}

.end__actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}

.end__foot {
  margin: 1.4rem 0 0;
  font-size: 0.9rem;
  color: rgba(244, 233, 214, 0.4);
}

/* ------------------------------------------------------------ portrait --- */

/*
  Portrait is not the intended shape, and stacking the panels would be a worse
  game — the eye has to travel much further between two points that ought to be
  compared. It stays side by side and simply gets smaller.
*/
@media (max-aspect-ratio: 3/4) {
  .hud {
    gap: 1rem;
    padding: 0 0.8rem;
  }

  .hud__label {
    display: none;
  }
}
