:root {
  --bg: #fff8fd;
  --surface: #ffffff;
  --surface-strong: #fffdf7;
  --surface-soft: #eef9ff;
  --ink: #20202a;
  --muted: #66707d;
  --line: #ded9ef;
  --accent: #ffd84d;
  --accent-dark: #f5b83e;
  --accent-soft: #fff0a8;
  --teal: #22b8b0;
  --blue: #72b7ff;
  --coral: #ff7f8f;
  --mint: #9be7c9;
  --warn: #ff6b6b;
  --pass: #39bf76;
  --shadow: 0 22px 60px rgba(70, 60, 120, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(255, 216, 77, 0.18) 0 10px, transparent 10px 34px),
    linear-gradient(135deg, rgba(255, 127, 143, 0.22), transparent 32%),
    linear-gradient(315deg, rgba(114, 183, 255, 0.22), transparent 36%),
    linear-gradient(180deg, #fff8fd, #f5fbff 54%, #fffdf2),
    var(--bg);
  background-attachment: fixed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

img,
video {
  max-width: 100%;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 14px;
}

.reset-button,
.secondary,
.primary {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.reset-button,
.secondary {
  border-color: rgba(102, 112, 125, 0.18);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
}

.reset-button:hover,
.secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(32, 28, 22, 0.08);
}

.primary {
  color: #23202b;
  background: linear-gradient(135deg, var(--accent), #ffb7c2);
  font-weight: 820;
  box-shadow: 0 14px 30px rgba(255, 127, 143, 0.22);
}

.primary:hover {
  background: linear-gradient(135deg, var(--accent-dark), #ff9dad);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(255, 127, 143, 0.28);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.stage-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stage-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(102, 112, 125, 0.14);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(70, 60, 120, 0.08);
}

.stage-pill span {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #23202b;
  background: var(--accent);
  font-size: 0.9rem;
  font-weight: 760;
}

.stage-pill strong {
  overflow: hidden;
  font-size: 0.94rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-pill.is-active {
  border-color: rgba(34, 184, 176, 0.38);
  color: var(--ink);
  background: rgba(238, 249, 255, 0.92);
}

.stage-pill.is-done span {
  color: #fff;
  background: var(--pass);
}

.screen {
  min-height: calc(100vh - 150px);
  display: grid;
  align-items: center;
}

.intro-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(420px, 1.22fr);
  gap: clamp(28px, 5vw, 58px);
  align-items: center;
}

.intro-copy {
  padding: 24px 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: #0d9488;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.02;
}

h1 {
  max-width: 720px;
  color: #23202b;
  font-size: clamp(3rem, 7.4vw, 6.2rem);
}

h2 {
  color: #252433;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.lead,
.panel p,
.problem-text {
  color: var(--muted);
  line-height: 1.65;
}

.lead {
  max-width: 560px;
  margin: 24px 0 30px;
  font-size: 1.1rem;
}

.photo-collage {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: 70px;
  gap: clamp(10px, 1.4vw, 16px);
  align-items: stretch;
  min-height: 560px;
}

.photo-frame {
  position: relative;
  overflow: hidden;
  border: 8px solid #fff;
  border-radius: 8px;
  margin: 0;
  background: #fff;
  box-shadow: 0 18px 44px rgba(52, 53, 90, 0.18);
}

.photo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-orientation: from-image;
}

.frame-1 {
  grid-column: 1 / span 7;
  grid-row: 1 / span 4;
  transform: rotate(-2deg);
}

.frame-2 {
  grid-column: 7 / span 6;
  grid-row: 1 / span 3;
  transform: rotate(2deg);
}

.frame-3 {
  grid-column: 2 / span 5;
  grid-row: 5 / span 3;
  transform: rotate(1.5deg);
}

.frame-4 {
  grid-column: 7 / span 5;
  grid-row: 4 / span 4;
  transform: rotate(-1.2deg);
}

.frame-5 {
  grid-column: 4 / span 6;
  grid-row: 8 / span 2;
  transform: rotate(1deg);
}

.panel {
  width: 100%;
  border: 1px solid rgba(222, 217, 239, 0.88);
  border-radius: 8px;
  padding: clamp(24px, 4vw, 44px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 253, 247, 0.94)),
    var(--surface);
  box-shadow: var(--shadow);
}

.panel.narrow {
  max-width: 720px;
  margin: 0 auto;
}

.challenge-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.timer,
.level-badge {
  flex: 0 0 auto;
  min-width: 82px;
  border: 1px solid rgba(34, 184, 176, 0.24);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
  color: #245257;
  background: linear-gradient(135deg, #eef9ff, #fff8d9);
  font-weight: 820;
}

.math-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.math-focus {
  max-width: 820px;
  margin: 0 auto;
}

.single-math {
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
}

.question-progress {
  border: 1px solid rgba(45, 212, 191, 0.34);
  border-radius: 999px;
  padding: 8px 14px;
  color: #16645f;
  background: rgba(155, 231, 201, 0.34);
  font-weight: 820;
}

.big-question {
  width: 100%;
  border: 1px solid rgba(245, 184, 62, 0.46);
  border-radius: 8px;
  padding: clamp(30px, 6vw, 58px) 18px;
  color: #23202b;
  background:
    linear-gradient(135deg, rgba(255, 216, 77, 0.46), rgba(255, 183, 194, 0.38)),
    #fffdf7;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.74);
  font-size: clamp(3.4rem, 10vw, 7rem);
  font-weight: 900;
  line-height: 1;
}

.big-answer {
  width: min(360px, 100%);
  border: 2px solid rgba(243, 191, 60, 0.42);
  border-radius: 8px;
  padding: 16px 18px;
  color: var(--ink);
  background: #fff;
  font-size: 2rem;
  font-weight: 820;
  text-align: center;
}

.big-answer:focus {
  border-color: var(--accent);
  outline: 4px solid rgba(243, 191, 60, 0.14);
}

.big-timer {
  min-width: 108px;
  color: #245257;
  font-size: 2rem;
}

.answer-card {
  display: grid;
  gap: 10px;
  min-height: 118px;
  border: 1px solid rgba(222, 217, 239, 0.82);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.answer-card span {
  font-weight: 780;
}

.answer-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fffdf7;
}

.answer-card input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(47, 111, 102, 0.16);
}

.span-full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result.is-pass {
  border-color: rgba(44, 111, 69, 0.28);
  background: linear-gradient(180deg, #f7fff9, #ffffff);
}

.result.is-fail {
  border-color: rgba(159, 75, 61, 0.28);
  background: linear-gradient(180deg, #fff7f6, #ffffff);
}

.hint-box {
  border: 1px dashed var(--accent-dark);
  border-radius: 8px;
  margin-top: 22px;
  padding: 22px;
  color: #4a4020;
  background: rgba(255, 216, 77, 0.24);
  font-weight: 760;
}

.reward-screen {
  display: grid;
  gap: 24px;
  width: min(960px, 100%);
  margin: 0 auto;
  text-align: center;
}

.reward-copy {
  border: 1px solid rgba(222, 217, 239, 0.88);
  border-radius: 8px;
  padding: clamp(24px, 4vw, 42px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 253, 247, 0.94)),
    var(--surface);
  box-shadow: var(--shadow);
}

.reward-title {
  color: #23202b;
  font-size: clamp(3.4rem, 9vw, 7.4rem);
  line-height: 0.94;
}

.reward-videos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(18px, 3vw, 30px);
  overflow: visible;
}

.reward-video {
  position: relative;
  overflow: visible;
  border: 8px solid #fff;
  border-radius: 8px;
  margin: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255, 216, 77, 0.2) 0 12px, rgba(255, 127, 143, 0.18) 12px 24px),
    #fff;
  box-shadow:
    0 16px 0 rgba(255, 216, 77, 0.68),
    0 24px 42px rgba(70, 60, 120, 0.22);
  transform: rotate(-1.6deg);
}

.reward-video:nth-child(2) {
  transform: rotate(1.4deg);
  box-shadow:
    0 16px 0 rgba(34, 184, 176, 0.48),
    0 24px 42px rgba(70, 60, 120, 0.22);
}

.reward-video video {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 2px;
  background: #111;
  object-fit: cover;
  pointer-events: none;
}

.confetti-layer,
.confetti-layer span {
  position: absolute;
  pointer-events: none;
}

.confetti-layer {
  inset: -38% -12% -18%;
  z-index: 2;
  overflow: visible;
}

.confetti-layer span {
  left: var(--x);
  top: -18px;
  width: calc(var(--w) * 1.25);
  height: calc(var(--h) * 1.25);
  border-radius: 2px;
  background: hsl(var(--hue), 88%, 58%);
  opacity: 0.92;
  transform: rotate(var(--turn));
  animation: confettiFall var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.confetti-layer span:nth-child(3n) {
  border-radius: 999px;
}

.confetti-layer span:nth-child(4n) {
  width: 14px;
  height: 6px;
}

.final-hint {
  justify-self: center;
  border: 4px solid #23202b;
  border-radius: 8px;
  padding: clamp(16px, 3vw, 24px) clamp(28px, 6vw, 70px);
  color: #23202b;
  background:
    repeating-linear-gradient(-8deg, rgba(255, 216, 77, 0.75) 0 16px, rgba(255, 127, 143, 0.45) 16px 30px),
    #fff8d9;
  box-shadow: 8px 8px 0 #22b8b0;
  font-size: clamp(2.4rem, 8vw, 6rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -18px, 0) rotate(0deg);
  }

  50% {
    transform: translate3d(var(--drift-mid), 260px, 0) rotate(190deg);
  }

  100% {
    transform: translate3d(var(--drift-end), 560px, 0) rotate(380deg);
  }
}

.memory-grid {
  display: grid;
  width: min(560px, 100%);
  aspect-ratio: 1;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 auto;
}

.memory-cell {
  border: 1px solid rgba(114, 183, 255, 0.34);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #eef9ff);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.memory-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(70, 60, 120, 0.12);
}

.memory-cell.is-lit {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(243, 191, 60, 0.18);
}

.memory-cell.is-hit {
  background: var(--mint);
}

.status-line {
  margin: 18px 0 0;
  color: var(--muted);
  text-align: center;
}

.maze-stage {
  width: min(1040px, 100%);
  border: 1px solid rgba(222, 217, 239, 0.88);
  border-radius: 8px;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 22px);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.maze-stage .challenge-head {
  margin-bottom: 10px;
}

.mini-reset {
  min-width: 112px;
}

.prank-maze {
  position: relative;
  width: min(920px, calc(100vw - 40px), calc(100vh - 260px));
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 3px solid #00f4f7;
  border-radius: 8px;
  background: #00f4f7;
  box-shadow: 0 18px 48px rgba(10, 34, 44, 0.18);
  cursor: crosshair;
  touch-action: none;
}

.prank-maze.normalcursor {
  cursor: auto;
}

.wall,
.scare-zone {
  position: absolute;
  display: none;
}

.wall {
  z-index: 5;
  background: #000;
}

.dead .wall {
  background: #bf0000;
}

.level1 .lev1,
.level2 .lev2,
.level3 .lev3,
.level3 .scare-zone {
  display: block;
}

.level3.has-survived-scare .scare-zone {
  display: none;
}

.maze-start-prank,
.maze-finish,
.maze-level-label {
  position: absolute;
}

.maze-start-prank {
  top: 70%;
  left: 26%;
  right: 51%;
  bottom: 20%;
  z-index: 8;
  border: 0;
  border-radius: 20px;
  color: #fff;
  background: #137913;
  font-size: clamp(1rem, 4vw, 2.3rem);
  font-weight: 900;
  text-align: center;
}

.maze-start-prank:hover {
  background: #096309;
}

.maze-finish {
  z-index: 6;
  overflow: hidden;
  background:
    conic-gradient(#111 25%, #fff 0 50%, #111 0 75%, #fff 0) 0 0 / 18px 18px;
}

.level1 .maze-finish {
  top: 15%;
  left: 75%;
  right: 9%;
  bottom: 77%;
}

.level2 .maze-finish {
  top: 86%;
  left: 78%;
  right: 4%;
  bottom: 8%;
}

.level3 .maze-finish {
  top: 12%;
  left: 62%;
  right: 28%;
  bottom: 78%;
}

.maze-level-label {
  z-index: 7;
  color: #fff;
  font-size: clamp(1.3rem, 3.4vw, 2.4rem);
  font-weight: 900;
}

.level1 .maze-level-label {
  top: 25%;
  right: 10%;
}

.level2 .maze-level-label {
  right: 7%;
  bottom: 16%;
}

.level3 .maze-level-label {
  top: 15%;
  right: 42%;
}

.scare-zone {
  z-index: 9;
  top: 21%;
  left: 61%;
  right: 27%;
  bottom: 73%;
}

.scare-two {
  top: 21%;
  left: 56%;
  right: 40%;
  bottom: 66%;
}

.scare-three {
  top: 27%;
  left: 62%;
  right: 27%;
  bottom: 68%;
}

.trail-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: visible;
  pointer-events: none;
}

.trail-dot {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #000;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.trail-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}

.touch-note {
  display: none;
}

.jumpscare {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: #000;
  color: #fff;
  cursor: none;
  animation: scareShake 3000ms steps(14, end);
}

.jumpscare img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
}

@keyframes scareShake {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    filter: contrast(1);
  }

  20% {
    transform: translate(-12px, 8px) scale(1.03);
    filter: contrast(1.8);
  }

  40% {
    transform: translate(10px, -10px) scale(1.01);
    filter: contrast(1.2);
  }

  60% {
    transform: translate(-8px, -6px) scale(1.04);
    filter: contrast(2);
  }

  80% {
    transform: translate(8px, 12px) scale(1.02);
    filter: contrast(1.4);
  }
}

@media (max-width: 820px) {
  .intro-layout {
    grid-template-columns: 1fr;
  }

  .photo-collage {
    grid-auto-rows: 58px;
    min-height: 470px;
  }

  .math-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .reward-videos {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .reset-button {
    width: 100%;
  }

  .app-shell {
    width: min(100% - 20px, 1120px);
  }

  .screen {
    min-height: auto;
  }

  h1 {
    font-size: 3rem;
  }

  .photo-collage {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    min-height: 0;
  }

  .photo-frame,
  .frame-1,
  .frame-2,
  .frame-3,
  .frame-4,
  .frame-5 {
    grid-column: auto;
    grid-row: auto;
    transform: none;
  }

  .photo-frame {
    aspect-ratio: 4 / 3;
    border-width: 6px;
  }

  .frame-1 {
    aspect-ratio: 16 / 10;
  }

  .challenge-head {
    align-items: stretch;
    flex-direction: column;
  }

  .timer,
  .level-badge {
    width: 100%;
  }

  .math-grid {
    grid-template-columns: 1fr;
  }

  .big-question {
    font-size: clamp(2.8rem, 18vw, 4.5rem);
  }

  .reward-copy {
    padding: 22px;
  }

  .maze-stage {
    padding: 10px;
  }

  .prank-maze {
    width: min(calc(100vw - 20px), calc(100vh - 260px));
  }
}

@media (pointer: coarse) {
  .touch-note {
    display: block;
  }
}
