/* ==========================================================================
   Gumshoe — mobile-first styles
   Phone-shaped by default; the layout just centres itself on larger screens.
   ========================================================================== */

:root {
  --ink: #241a12;
  --ink-soft: #4b3a2a;
  --paper: #f6e8cd;
  --paper-2: #eddcbb;
  --night: #1d1611;
  --night-2: #2c2118;
  --amber: #e8a33d;
  --amber-deep: #c97f22;
  --brick: #c2543d;
  --teal: #3f7d6e;
  --mint: #8fc9b4;

  --radius: 16px;
  --radius-lg: 24px;
  --shadow-hard: 0 4px 0 rgba(36, 26, 18, 0.45);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-body: ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background: var(--night);
  color: var(--paper);
  font-family: var(--font-body);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: relative;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--night);
}

/* --------------------------------------------------------------- views --- */

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
}

.view.is-active {
  display: flex;
  opacity: 1;
  animation: fade-in 260ms ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

.btn {
  appearance: none;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 16px 28px;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  width: 100%;
  transition: transform 90ms ease, box-shadow 90ms ease, filter 120ms ease;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(36, 26, 18, 0.45);
}

.btn--primary {
  background: var(--amber);
  color: var(--ink);
  box-shadow: var(--shadow-hard);
}

.btn--primary:disabled {
  filter: grayscale(0.6) brightness(0.85);
  cursor: default;
}

.btn--ghost {
  background: transparent;
  border-color: rgba(246, 232, 205, 0.45);
  color: var(--paper);
  box-shadow: none;
}

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

.view--landing {
  justify-content: flex-end;
}

.landing__bg {
  position: absolute;
  inset: 0;
  background-color: var(--night-2);
  background-size: cover;
  background-position: center;
  filter: saturate(0.9);
}

.landing__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(29, 22, 17, 0.55) 0%,
    rgba(29, 22, 17, 0.35) 35%,
    rgba(29, 22, 17, 0.94) 82%,
    var(--night) 100%
  );
}

.landing__inner {
  position: relative;
  padding: 0 24px calc(40px + var(--safe-bottom));
  text-align: center;
}

.landing__kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
}

.logo {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 17vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--paper);
  text-shadow: 4px 4px 0 var(--brick), 8px 8px 0 rgba(0, 0, 0, 0.35);
}

.logo__glass {
  display: inline-block;
  font-size: 0.45em;
  transform: translateY(-0.35em) rotate(-12deg);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.3));
}

.landing__tag {
  margin: 18px auto 28px;
  max-width: 22ch;
  font-size: 1.02rem;
  line-height: 1.5;
  color: rgba(246, 232, 205, 0.86);
}

.landing__foot {
  margin: 16px 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(246, 232, 205, 0.45);
}

/* --------------------------------------------------------------- topbar --- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 20px 12px;
  background: var(--night);
  border-bottom: 2px solid rgba(246, 232, 205, 0.1);
}

.topbar__brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--amber);
}

.topbar__date {
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(246, 232, 205, 0.5);
}

/* ---------------------------------------------------------------- clues --- */

.clues__scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 20px 8px;
}

.casefile {
  margin-bottom: 20px;
}

.casefile__stamp {
  display: inline-block;
  margin: 0 0 10px;
  padding: 5px 12px;
  border: 2px dashed var(--brick);
  border-radius: 6px;
  color: var(--brick);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform: rotate(-2.5deg);
}

.casefile__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.1rem;
  line-height: 1.1;
  color: var(--paper);
}

.casefile__sub {
  margin: 8px 0 0;
  font-size: 0.94rem;
  line-height: 1.45;
  color: rgba(246, 232, 205, 0.65);
}

.clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Cards size to their content — clue text length changes every day. */
.clue-card {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  animation: card-in 340ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.clue-card:nth-child(1) {
  transform: rotate(-0.7deg);
  animation-delay: 40ms;
}
.clue-card:nth-child(2) {
  transform: rotate(0.6deg);
  animation-delay: 120ms;
  background: var(--paper-2);
}
.clue-card:nth-child(3) {
  transform: rotate(-0.4deg);
  animation-delay: 200ms;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) rotate(0deg);
  }
}

.clue-card__num {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--amber);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.clue-card__body {
  min-width: 0;
}

.clue-card__text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.clue-card__label {
  margin: 6px 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.75;
}

.clue-card--skeleton {
  min-height: 74px;
  background: rgba(246, 232, 205, 0.08);
  border-color: rgba(246, 232, 205, 0.15);
  box-shadow: none;
}

.clue-card--skeleton span {
  display: block;
  width: 70%;
  height: 14px;
  border-radius: 7px;
  background: rgba(246, 232, 205, 0.18);
  animation: pulse 1.2s ease-in-out infinite;
}

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

/* Result variant on the End screen. */
.clue-card--found .clue-card__num {
  background: var(--teal);
  color: var(--paper);
}

.clue-card--found .clue-card__text {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: 0.62;
}

.clue-card--missed {
  background: rgba(246, 232, 205, 0.9);
}

.clue-card__mark {
  flex: none;
  margin-left: auto;
  align-self: center;
  font-size: 1.3rem;
  line-height: 1;
}

.dock {
  flex: none;
  padding: 14px 20px calc(18px + var(--safe-bottom));
  background: linear-gradient(to top, var(--night) 70%, rgba(29, 22, 17, 0));
}

/* --------------------------------------------------------------- detect --- */

.view--detect {
  justify-content: flex-start;
  background: var(--night);
}

.hud {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
}

.timer {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
}

.timer__ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.timer__track {
  fill: none;
  stroke: rgba(246, 232, 205, 0.15);
  stroke-width: 5;
}

.timer__fill {
  fill: none;
  stroke: var(--amber);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.98s linear, stroke 300ms ease;
}

.timer.is-urgent .timer__fill {
  stroke: var(--brick);
}

.timer.is-urgent .timer__num {
  color: var(--brick);
  animation: tick 1s steps(2) infinite;
}

@keyframes tick {
  50% {
    transform: scale(1.14);
  }
}

.timer__num {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--paper);
}

.hud__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 6px 11px;
  border-radius: 999px;
  border: 2px solid rgba(246, 232, 205, 0.25);
  background: rgba(246, 232, 205, 0.06);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
  color: rgba(246, 232, 205, 0.8);
  transition: all 200ms ease;
}

.chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 12ch;
}

.chip.is-found {
  background: var(--teal);
  border-color: var(--mint);
  color: #fff;
  animation: pop 380ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.chip.is-found .chip__name {
  max-width: none;
  text-decoration: line-through;
}

@keyframes pop {
  40% {
    transform: scale(1.16);
  }
}

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 4px 10px;
  min-height: 0;
}

/* Square frame keeps tap→image coordinate mapping trivial. */
.stage__frame {
  position: relative;
  width: min(100%, calc(100dvh - 210px));
  aspect-ratio: 1 / 1;
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--night-2);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(246, 232, 205, 0.12);
  touch-action: manipulation;
}

.stage__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

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

.mark {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(246, 232, 205, 0.9);
  animation: mark-in 320ms cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.mark--miss {
  border-color: rgba(246, 232, 205, 0.75);
  animation: mark-in 260ms ease both, mark-out 500ms 500ms ease forwards;
}

.mark--hit {
  border-color: var(--mint);
  border-width: 4px;
  background: rgba(143, 201, 180, 0.22);
  box-shadow: 0 0 0 3px rgba(63, 125, 110, 0.5);
}

@keyframes mark-in {
  from {
    transform: translate(-50%, -50%) scale(0.35);
    opacity: 0;
  }
}

@keyframes mark-out {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5);
  }
}

.stage__hint {
  flex: none;
  margin: 0;
  padding: 10px 20px calc(14px + var(--safe-bottom));
  text-align: center;
  font-size: 0.84rem;
  letter-spacing: 0.06em;
  color: rgba(246, 232, 205, 0.5);
}

.flash {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(29, 22, 17, 0.82);
  z-index: 5;
}

.flash.is-on {
  display: grid;
}

.flash__text {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 15vw, 4rem);
  color: var(--paper);
  text-shadow: 4px 4px 0 var(--brick);
  animation: flash-beat 620ms ease-in-out 2;
}

@keyframes flash-beat {
  0%,
  100% {
    transform: scale(1) rotate(-2deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.1) rotate(2deg);
    opacity: 0.55;
  }
}

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

.end__scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(34px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
}

.verdict {
  text-align: center;
  margin-bottom: 26px;
}

.verdict__score {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
}

.verdict__line {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 8vw, 2.3rem);
  line-height: 1.18;
  color: var(--paper);
  text-wrap: balance;
}

.clue-list--result {
  margin-bottom: 26px;
}

.end__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.end__foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(246, 232, 205, 0.4);
}

/* ------------------------------------------------------------ a11y prefs -- */

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