/* PyQuest MP: HP (health), plain-English cards and arcade FX scenes. */

/* ── HP (health) ────────────────────────────────────────── */
.hp-stat { flex-direction: column; align-items: flex-start; gap: 2px; min-width: 150px; }
.hearts { display: flex; gap: 3px; font-size: 17px; line-height: 1; }
.heart { color: #ff4d6d; filter: drop-shadow(0 0 4px rgba(255, 77, 109, .55)); transition: transform .3s; }
.heart.lost { filter: grayscale(1) opacity(.45); }
.hp-sub { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hp-stat.danger { border-color: #8a2b2b; animation: danger-pulse 1.2s infinite; }
.hp-stat.danger .heart:not(.lost) { animation: heartbeat .8s infinite; }
@keyframes danger-pulse { 50% { box-shadow: 0 0 0 3px rgba(248, 81, 73, .25); } }
@keyframes heartbeat { 30% { transform: scale(1.25); } 60% { transform: scale(1); } }
.help-btn { font-weight: 700; font-size: 16px; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 50%; padding: 0; flex-shrink: 0; }

/* Long dialogs (like the rules) must scroll on short screens. */
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }

/* ── Lesson additions ───────────────────────────────────── */
.stakes {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5;
  background: #2a1218; border: 1px solid #5c2430; color: #ffc9d2; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}
.stakes.boss-stakes { background: #2a1a0c; border-color: #6b3d1a; color: #ffd8a8; }
.stakes strong { color: #fff; }
.card.plain-card { border-color: #3b4f2a; background: #141c12; }
.card.plain-card h3 { color: #a9e34b; }
.card.plain-card .md { font-size: 14.5px; line-height: 1.65; }
.rules { display: grid; gap: 12px; }
.rules ul { margin: 6px 0 0; padding-left: 20px; color: #c9d4df; }
.rules li { margin: 3px 0; }
.r-mp { color: var(--accent); }
.r-hp { color: #ff6b81; }

/* ── Parts, complexity and practice (DSA) ───────────────── */
.part-head {
  margin: 14px 8px 6px; padding: 6px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: rgba(255, 212, 59, .07); border: 1px solid rgba(255, 212, 59, .18);
}
.part-head:first-child { margin-top: 2px; }
.chip.complexity { color: #74c0fc; border-color: #1f4e79; font-family: var(--mono); font-weight: 600; }
.card.practice-card { border-color: #5c3d99; background: #17132a; }
.card.practice-card h3 { color: #b197fc; }
.practice-intro { margin: 0 0 8px; color: #c9d4df; font-size: 13px; }
.practice-list { margin: 0; padding-left: 18px; }
.practice-list li { margin: 4px 0; }
.practice-list a { color: #d0bfff; text-decoration: none; border-bottom: 1px dotted rgba(208, 191, 255, .5); }
.practice-list a:hover { color: #fff; border-bottom-style: solid; }

/* ── Screen shake ───────────────────────────────────────── */
.workspace.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-8px, 3px); }
  40%, 60% { transform: translate(8px, -3px); }
}

/* ── Arcade FX overlay ──────────────────────────────────── */
.fx { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; cursor: pointer; }
.fx::before { /* CRT scanlines + vignette */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, rgba(0, 0, 0, .25) 0%, rgba(0, 0, 0, .7) 100%);
  animation: fx-fade-in .2s ease;
}
.fx.blocking::before {
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, rgba(5, 5, 12, .88) 0%, rgba(0, 0, 0, .97) 100%);
}
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fx-stage {
  position: relative; text-align: center; padding: 24px; max-width: min(92vw, 900px);
  animation: fx-zoom-in .45s cubic-bezier(.17, .89, .32, 1.35);
}
.fx-stage.fx-out { animation: fx-zoom-out .22s ease-in forwards; }
@keyframes fx-fade-in { from { opacity: 0; } }
@keyframes fx-zoom-in { from { transform: scale(.3); opacity: 0; } }
@keyframes fx-zoom-out { to { transform: scale(1.4); opacity: 0; } }

.fx-title {
  font-family: "Press Start 2P", var(--mono); font-size: clamp(26px, 6vw, 64px); line-height: 1.25;
  color: var(--accent); letter-spacing: .02em;
  text-shadow: 0 4px 0 #b8860b, 0 8px 0 #7a5800, 0 0 30px rgba(255, 212, 59, .6);
}
.fx-title.fx-small { font-size: clamp(20px, 4.4vw, 44px); }
.fx-letter { display: inline-block; animation: fx-letter-pop .5s cubic-bezier(.17, .89, .32, 1.5) both; animation-delay: calc(var(--i) * 45ms); }
.fx-space { display: inline-block; width: .5em; }
.fx-word { display: inline-block; white-space: nowrap; }
@keyframes fx-letter-pop { from { transform: translateY(40px) scale(.2) rotate(-20deg); opacity: 0; } }
.fx-kicker { font-family: "Press Start 2P", var(--mono); font-size: clamp(10px, 1.6vw, 14px); color: #9fb3c8; margin-bottom: 14px; letter-spacing: .12em; line-height: 1.6; }
.fx-sub { font-size: clamp(14px, 2vw, 18px); color: #e6edf3; margin-top: 16px; font-weight: 600; }
.fx-dim { color: #8b98a9; font-weight: 500; font-size: clamp(12px, 1.6vw, 15px); margin-top: 8px; }
.fx-emoji { font-size: clamp(48px, 9vw, 92px); line-height: 1; margin-bottom: 10px; animation: fx-bounce 1s ease-in-out infinite; }
@keyframes fx-bounce { 50% { transform: translateY(-12px) scale(1.06); } }
.fx-coin {
  display: inline-block; margin-top: 22px; font-family: "Press Start 2P", var(--mono); font-size: clamp(16px, 3vw, 28px);
  color: #111; background: linear-gradient(180deg, #ffe066, #fab005); padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 6px 0 #b8860b, 0 0 30px rgba(250, 176, 5, .55);
  animation: fx-coin 1s ease-out both .25s;
}
@keyframes fx-coin {
  0% { transform: translateY(30px) scale(.4); opacity: 0; }
  60% { transform: translateY(-10px) scale(1.12); opacity: 1; }
  100% { transform: none; }
}

.fx-coin.fx-coin-none {
  color: #e6edf3; background: linear-gradient(180deg, #495057, #343a40);
  box-shadow: 0 6px 0 #212529; font-size: clamp(11px, 1.8vw, 16px);
}
.fx-quiz .fx-title { color: #8ce99a; text-shadow: 0 4px 0 #2b8a3e, 0 8px 0 #1b5e2a, 0 0 30px rgba(64, 192, 87, .55); }
.fx-boss .fx-title { color: #ffd43b; text-shadow: 0 4px 0 #c92a2a, 0 8px 0 #7a1616, 0 0 40px rgba(255, 146, 43, .8); }
.fx-streak .fx-title, .fx-levelup .fx-title { color: #d0bfff; text-shadow: 0 4px 0 #6741d9, 0 8px 0 #3b1f8f, 0 0 34px rgba(163, 113, 247, .7); }

/* MISS: red flash + glitch */
.fx-miss::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(248, 81, 73, .45) 100%);
  animation: fx-flash .6s ease-out forwards;
}
@keyframes fx-flash { from { opacity: 1; } to { opacity: 0; } }
.fx-glitch { position: relative; color: #ff6b6b; text-shadow: 0 4px 0 #8a1c1c, 0 0 30px rgba(248, 81, 73, .7); animation: fx-jitter .35s steps(2) 3; }
.fx-glitch::before, .fx-glitch::after { content: attr(data-text); position: absolute; inset: 0; padding: inherit; }
.fx-glitch::before { color: #4dabf7; transform: translate(-4px, 0); clip-path: inset(0 0 55% 0); opacity: .8; animation: fx-slice .3s steps(2) 4; }
.fx-glitch::after { color: #ffe066; transform: translate(4px, 0); clip-path: inset(55% 0 0 0); opacity: .8; animation: fx-slice .3s steps(2) 4 reverse; }
@keyframes fx-jitter { 50% { transform: translate(5px, -3px) skewX(-8deg); } }
@keyframes fx-slice { 50% { transform: translate(6px, 0); } }
.fx-heart { font-family: "Press Start 2P", var(--mono); font-size: clamp(16px, 2.6vw, 24px); color: #ff8787; margin-top: 18px; animation: fx-heart-break .7s ease-out both .1s; }
@keyframes fx-heart-break {
  0% { transform: scale(2); opacity: 0; }
  40% { transform: scale(.9) rotate(-8deg); opacity: 1; }
  70% { transform: rotate(6deg); }
  100% { transform: none; }
}

/* GAME OVER: letters drop in, blinking continue */
.fx-gameover .fx-title { color: #ff4d4d; text-shadow: 0 5px 0 #7a1010, 0 10px 0 #3d0808, 0 0 40px rgba(255, 0, 0, .55); font-size: clamp(32px, 8vw, 84px); }
.fx-drop .fx-letter { animation: fx-drop .7s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: calc(var(--i) * 110ms); }
@keyframes fx-drop { 0% { transform: translateY(-120vh) rotate(25deg); } 100% { transform: none; } }
.fx-loss { font-family: "Press Start 2P", var(--mono); color: #ffa8a8; font-size: clamp(12px, 2vw, 18px); margin-top: 18px; }
.fx-continue { font-family: "Press Start 2P", var(--mono); color: #fff; font-size: clamp(14px, 2.4vw, 22px); margin-top: 30px; animation: fx-blink 1s steps(2) infinite; }
.fx-count { color: var(--accent); }
@keyframes fx-blink { 50% { opacity: .2; } }

/* PHOENIX RESPAWN: fiery gradient title rising from below */
.fx-phoenix .fx-title {
  color: #ff922b; text-shadow: none;
  filter: drop-shadow(0 0 18px rgba(255, 120, 0, .85)) drop-shadow(0 4px 0 #7a2a00);
}
/* The gradient lives on each letter: background-clip:text on the parent doesn't paint through
   individually transformed inline-block children. */
.fx-phoenix .fx-letter {
  background: linear-gradient(0deg, #ff3d00 0%, #ff922b 45%, #ffe066 80%, #fff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: fx-rise-letter .8s ease-out both; animation-delay: calc(var(--i) * 60ms);
}
@keyframes fx-rise-letter { from { transform: translateY(80px) scaleY(1.6); opacity: 0; filter: blur(4px); } }
.fx-rise { animation: fx-rise 1.6s ease-out both, fx-bounce 1s ease-in-out infinite 1.6s; }
@keyframes fx-rise { from { transform: translateY(60vh) scale(.4); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .fx-stage, .fx-letter, .fx-coin, .fx-emoji, .fx-heart, .fx-glitch, .fx-glitch::before, .fx-glitch::after,
  .fx-continue, .workspace.shake, .hp-stat.danger, .heart, .fx-rise, .fx-drop .fx-letter, .fx-phoenix .fx-letter {
    animation: none !important;
  }
}
@media (max-width: 1180px) {
  .hp-stat { min-width: 0; }
}
