:root {
  --bg: #0e0b14;
  --bg2: #161022;
  --card: #1c1528;
  --ink: #f4f0ff;
  --muted: #a89bc4;
  --line: rgba(255, 255, 255, 0.1);
  --a: #ff6bcb;
  --a2: #ff8e53;
  --b: #5b8cff;
  --b2: #7cf5ff;
  --good: #3dff9a;
  --bad: #ff4d6d;
  --warn: #ffd166;
  --comic: 3px solid #0a0612;
  --radius: 18px;
  --font-display: "Nunito", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #2a1848 0%, transparent 55%),
    var(--bg);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding:
    calc(16px + var(--safe-t))
    calc(18px + var(--safe-r))
    calc(18px + var(--safe-b))
    calc(18px + var(--safe-l));
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}

.screen[hidden] {
  display: none !important;
}

.screen.active:not([hidden]) {
  display: flex;
}

/* blobs */
.bg-blobs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.45;
  animation: floaty 12s ease-in-out infinite;
}
.b1 { width: 220px; height: 220px; background: #ff6bcb; top: -40px; left: -50px; }
.b2 { width: 260px; height: 260px; background: #5b8cff; bottom: 10%; right: -80px; animation-delay: -4s; }
.b3 { width: 160px; height: 160px; background: #7cf5ff; bottom: -30px; left: 30%; animation-delay: -7s; opacity: 0.3; }

@keyframes floaty {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12px, -18px) scale(1.06); }
}

/* START */
.start-inner {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  animation: enter 0.7s var(--ease-out) both;
}

/* Soft radial neon burst behind icon + title */
.start-inner::before {
  content: "";
  position: absolute;
  top: 6%;
  left: 50%;
  width: min(340px, 92vw);
  height: 280px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 55% 50% at 50% 42%, rgba(255, 107, 203, 0.38) 0%, transparent 70%),
    radial-gradient(ellipse 48% 42% at 42% 48%, rgba(124, 245, 255, 0.22) 0%, transparent 68%),
    radial-gradient(ellipse 40% 36% at 60% 36%, rgba(255, 209, 102, 0.18) 0%, transparent 65%);
  filter: blur(4px);
}

.logo-badge {
  width: 92px;
  height: 92px;
  border-radius: 28px;
  background: linear-gradient(145deg, #2f1d48, #1a1228);
  border: 4px solid #0a0612;
  box-shadow:
    0 8px 0 #0a0612,
    0 14px 36px rgba(255, 107, 203, 0.35),
    0 0 0 2px rgba(255, 107, 203, 0.25);
  display: grid;
  place-items: center;
  font-size: 46px;
  margin-bottom: 2px;
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

.title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(36px, 10vw, 48px);
  letter-spacing: 0.02em;
  line-height: 1.05;
  background: linear-gradient(120deg, #ff8e53 0%, #ff6bcb 45%, #7cf5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter:
    drop-shadow(4px 4px 0 #0a0612)
    drop-shadow(0 0 18px rgba(255, 107, 203, 0.35));
}

.tagline {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 300px;
  margin-top: 2px;
}

/* Expressive comic BEST STREAK badge */
.score-pill {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 30px 10px;
  margin: 6px 0 2px;
  border-radius: 18px;
  background: linear-gradient(165deg, #2a1f3d 0%, #1a1228 100%);
  border: 4px solid #0a0612;
  box-shadow:
    0 6px 0 #0a0612,
    0 0 0 2px rgba(255, 209, 102, 0.45),
    0 10px 28px rgba(255, 209, 102, 0.18);
  transform: rotate(-2.5deg);
}

.score-pill::before,
.score-pill::after {
  content: "✦";
  position: absolute;
  top: 50%;
  font-size: 14px;
  color: var(--warn);
  text-shadow: 0 0 8px rgba(255, 209, 102, 0.7);
  pointer-events: none;
}

.score-pill::before {
  left: 10px;
  transform: translateY(-50%) rotate(-12deg);
}

.score-pill::after {
  right: 10px;
  transform: translateY(-50%) rotate(12deg);
}

.pill-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--warn);
  text-transform: uppercase;
}

.pill-value {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 34px;
  color: #ffe08a;
  line-height: 1.05;
  text-shadow: 2px 2px 0 #0a0612;
}

.btn-primary {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 300px;
  min-height: 64px;
  padding: 18px 28px 20px;
  margin-top: 6px;
  border-radius: 18px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.08em;
  color: #120816;
  background: linear-gradient(135deg, #ffd166 0%, #ff8e53 50%, #ff6bcb 100%);
  border: 4px solid #0a0612;
  box-shadow:
    0 8px 0 #0a0612,
    0 14px 32px rgba(255, 107, 203, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out, filter 0.1s ease-out;
}

.btn-primary:active {
  transform: translateY(6px) scale(0.985);
  box-shadow:
    0 2px 0 #0a0612,
    0 4px 12px rgba(255, 107, 203, 0.22),
    inset 0 3px 8px rgba(0, 0, 0, 0.22);
  filter: brightness(0.96);
}

.btn-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.35) 50%, transparent 60%);
  transform: translateX(-120%);
  animation: shine 3.2s ease-in-out infinite;
}

@keyframes shine {
  0%, 60% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

.mode-selector {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin: 6px 0 2px;
}

.mode-btn {
  flex: 1;
  padding: 10px 8px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  border-radius: 12px;
  background: #1a1228;
  border: 2px solid #0a0612;
  color: var(--muted);
  box-shadow: 0 3px 0 #0a0612;
  transition: all 0.15s ease;
  cursor: pointer;
}

.mode-btn.active {
  background: linear-gradient(135deg, #2f1f48, #1c1528);
  color: var(--warn);
  border-color: var(--warn);
  box-shadow: 0 3px 0 #0a0612, 0 0 12px rgba(255, 209, 102, 0.25);
}

.how-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  text-align: left;
}

.how-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: #1a1228;
  border: 2px solid #0a0612;
  border-radius: 14px;
  padding: 11px 14px;
  box-shadow:
    0 3px 0 #0a0612,
    0 0 0 1.5px rgba(124, 245, 255, 0.55);
}

.how-list li:nth-child(1) {
  box-shadow:
    0 3px 0 #0a0612,
    0 0 0 1.5px rgba(255, 209, 102, 0.65);
}

.how-list li:nth-child(2) {
  box-shadow:
    0 3px 0 #0a0612,
    0 0 0 1.5px rgba(255, 107, 203, 0.6);
}

.how-list li:nth-child(3) {
  box-shadow:
    0 3px 0 #0a0612,
    0 0 0 1.5px rgba(61, 255, 154, 0.55);
}

.how-ico {
  font-size: 20px;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.45));
}

/* GAME HUD */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.hud-lives {
  display: flex;
  gap: 2px;
  font-size: clamp(16px, 4.5vw, 20px);
  line-height: 1;
  flex-shrink: 0;
}

.heart {
  transition: transform 0.25s var(--ease-pop), opacity 0.25s, filter 0.25s;
  filter: drop-shadow(0 2px 0 #0a0612);
}

.heart.lost {
  opacity: 0.25;
  filter: grayscale(1);
  transform: scale(0.85);
}

.heart.pop {
  animation: heart-pop 0.45s var(--ease-pop);
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35) rotate(-8deg); }
  100% { transform: scale(0.85); }
}

.hud-shields {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--b2);
  background: #1a1228;
  padding: 5px 10px;
  border-radius: 999px;
  border: 2px solid #0a0612;
  box-shadow: 0 3px 0 #0a0612;
  white-space: nowrap;
}

.hud-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: var(--comic);
  box-shadow: 0 3px 0 #0a0612;
  min-width: 58px;
  justify-content: center;
}

.btn-hint {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: #120816;
  background: var(--warn);
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid #0a0612;
  box-shadow: 0 3px 0 #0a0612;
  transition: transform 0.1s ease, filter 0.1s ease;
  white-space: nowrap;
}

.btn-hint:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0a0612;
}

.btn-hint:disabled {
  opacity: 0.5;
  filter: grayscale(0.8);
  cursor: default;
}

.scenario-hint {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 209, 102, 0.12);
  border: 1.5px dashed var(--warn);
  color: #ffe89e;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  animation: card-in 0.3s ease-out;
}

.fb-badge.shield-used {
  background: var(--b2);
  color: #0a1220;
}

.streak-fire { font-size: 18px; }

.hud-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  min-width: 40px;
  text-align: right;
}

.timer-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 2px solid #0a0612;
  overflow: hidden;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3dff9a, #ffd166 60%, #ff4d6d);
  transform-origin: left center;
  transform: scaleX(1);
  will-change: transform;
}

.scenario-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin-bottom: 14px;
}

.scenario-card {
  width: 100%;
  padding: 28px 22px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #241832 0%, #1a1228 100%);
  border: var(--comic);
  box-shadow:
    0 8px 0 #0a0612,
    0 16px 40px rgba(0,0,0,0.35);
  text-align: center;
  animation: card-in 0.45s var(--ease-out) both;
}

.scenario-card.swap {
  animation: card-swap 0.4s var(--ease-out) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes card-swap {
  0% { opacity: 0; transform: translateX(24px) rotate(1deg); }
  100% { opacity: 1; transform: translateX(0) rotate(0); }
}

.scenario-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #120816;
  background: linear-gradient(90deg, var(--b2), var(--b));
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid #0a0612;
  margin-bottom: 14px;
}

.scenario-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 5.6vw, 26px);
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
  padding-bottom: 4px;
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 14px 16px;
  border-radius: 16px;
  border: var(--comic);
  text-align: left;
  box-shadow: 0 6px 0 #0a0612;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, filter 0.2s;
  animation: choice-in 0.5s var(--ease-out) both;
}

.choice-btn:nth-child(2) { animation-delay: 0.07s; }

@keyframes choice-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.choice-btn:active:not(:disabled) {
  transform: translateY(4px) scale(0.985);
  box-shadow: 0 2px 0 #0a0612;
}

.choice-btn:disabled {
  cursor: default;
}

.choice-a {
  background: linear-gradient(135deg, #ff6bcb 0%, #ff8e53 100%);
  color: #1a0a12;
}

.choice-b {
  background: linear-gradient(135deg, #5b8cff 0%, #7cf5ff 100%);
  color: #0a1220;
}

.choice-letter {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  background: rgba(0,0,0,0.18);
  border: 2px solid rgba(0,0,0,0.35);
}

.choice-label {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  line-height: 1.3;
  flex: 1;
}

.choice-btn.correct-flash {
  filter: brightness(1.15);
  box-shadow: 0 6px 0 #0a0612, 0 0 0 3px var(--good);
}

.choice-btn.wrong-flash {
  filter: saturate(0.6) brightness(0.85);
  box-shadow: 0 6px 0 #0a0612, 0 0 0 3px var(--bad);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* FEEDBACK OVERLAY */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding:
    calc(12px + var(--safe-t))
    calc(14px + var(--safe-r))
    calc(14px + var(--safe-b))
    calc(14px + var(--safe-l));
  background: rgba(8, 4, 16, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in 0.25s var(--ease-out) both;
}

.overlay[hidden] {
  display: none !important;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.feedback-sheet {
  width: 100%;
  max-width: 420px;
  padding: 28px 22px 22px;
  border-radius: 24px 24px 20px 20px;
  background: linear-gradient(180deg, #241832, #161022);
  border: var(--comic);
  box-shadow: 0 -4px 0 #0a0612, 0 20px 50px rgba(0,0,0,0.45);
  text-align: center;
  animation: sheet-up 0.4s var(--ease-pop) both;
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.fb-badge {
  width: 72px;
  height: 72px;
  margin: -52px auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 900;
  border: var(--comic);
  box-shadow: 0 6px 0 #0a0612;
  background: var(--good);
  color: #0a1a12;
}

.fb-badge.bad {
  background: var(--bad);
  color: #1a0610;
}

.fb-badge.timeout {
  background: var(--warn);
  color: #1a1408;
}

.fb-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.fb-pick {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

.fb-why {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  text-align: left;
}

.btn-next {
  max-width: none;
  width: 100%;
}

/* GAME OVER */
.over-inner {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: enter 0.6s var(--ease-out) both;
  padding-bottom: 8px;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.over-emoji {
  font-size: 56px;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,0.35));
  animation: bob 2s ease-in-out infinite;
}

.over-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 36px;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, #ff4d6d, #ff8e53);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.over-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin: 8px 0 4px;
}

.stat-box {
  padding: 14px 8px;
  border-radius: 14px;
  background: var(--card);
  border: var(--comic);
  box-shadow: 0 4px 0 #0a0612;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-box.best {
  background: linear-gradient(160deg, #3a2a18, #241832);
  box-shadow: 0 4px 0 #0a0612, 0 0 20px rgba(255, 209, 102, 0.15);
}

.stat-num {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  line-height: 1.1;
  color: var(--ink);
}

.stat-box.best .stat-num { color: var(--warn); }

.stat-lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.traps-block {
  width: 100%;
  text-align: left;
  margin: 4px 0 8px;
}

.traps-heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
  text-align: center;
}

.traps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.traps-list li {
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 77, 109, 0.1);
  border: 1px solid rgba(255, 77, 109, 0.28);
  color: var(--ink);
}

.traps-list li strong {
  color: var(--bad);
  font-weight: 700;
}

.traps-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
}

.btn-ghost {
  min-height: 48px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  border-radius: 12px;
  transition: color 0.15s, background 0.15s;
}

.btn-ghost:active {
  color: var(--ink);
  background: rgba(255,255,255,0.06);
}

@media (min-height: 740px) {
  .scenario-card { padding: 36px 26px; }
  .choice-btn { min-height: 80px; }
}

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