:root {
  --paper: #f3ecdc;
  --ink: #1d1a16;
  --red: #d7263d;
  --line: rgba(60, 110, 170, .18);
}
* { -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; color: var(--ink);
  font-family: 'Courier Prime', monospace;
  background:
    radial-gradient(circle at 15% 10%, rgba(215,38,61,.08), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(42,157,143,.10), transparent 45%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.015) 0 2px, transparent 2px 8px),
    #e8e1d0;
}
.title { font-family: 'Fraunces', serif; font-weight: 900; font-size: clamp(2.6rem, 9vw, 4rem); letter-spacing: -.04em; line-height: 1; }
.supword { font-weight: 300; font-style: italic; font-size: .5em; vertical-align: super; color: var(--red); margin-left: 2px; }
.tag { font-size: .85rem; opacity: .7; margin-top: 4px; }
.stats { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.hot { color: var(--red); font-weight: 700; }
.review-badge { background: var(--ink); color: var(--paper); padding: 0 6px; }
.progress { width: min(340px, 86vw); height: 4px; background: rgba(0,0,0,.08); }
.progress div { height: 100%; background: var(--ink); transition: width .3s; }

.card-wrap { width: min(340px, 86vw); height: 420px; perspective: 1400px; cursor: pointer; user-select: none; transition: transform .2s; }
.card-wrap:hover { transform: translateY(-4px); }
.card-wrap:active { transform: scale(.98); }
.card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .65s cubic-bezier(.34,1.45,.5,1); }
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px;
  box-shadow: 0 2px 0 rgba(0,0,0,.08), 0 20px 40px -12px rgba(40,30,10,.35);
}
.front {
  background:
    linear-gradient(90deg, transparent 38px, rgba(215,38,61,.45) 38px, rgba(215,38,61,.45) 40px, transparent 40px),
    repeating-linear-gradient(transparent 0 31px, var(--line) 31px 32px),
    var(--paper);
}
.corner { position: absolute; top: 16px; right: 20px; font-size: .75rem; opacity: .5; letter-spacing: .1em; }
.problem { font-family: 'Fraunces', serif; font-weight: 900; font-size: 7rem; line-height: 1; letter-spacing: -.05em; }
.problem sup { font-size: .45em; color: var(--red); font-weight: 300; font-style: italic; top: -1.1em; margin-left: 4px; }
.eq { font-size: 2.2rem; margin-top: 4px; opacity: .8; }
.hint { position: absolute; bottom: 22px; font-size: .75rem; letter-spacing: .25em; text-transform: uppercase; opacity: .45; animation: bob 2s ease-in-out infinite; }
.back { transform: rotateY(180deg); color: #10100f; }
.back.mint { background: linear-gradient(160deg, #c9f2df, #8fd9bd); }
.back.sky { background: linear-gradient(160deg, #cfe6ff, #8ebcf0); }
.back.plum { background: linear-gradient(160deg, #e7d4f7, #b893dd); }
.back.sunset { background: linear-gradient(160deg, #ffd27a, #f4845f 55%, #d7263d); color: #1a0606; }
.answer { font-family: 'Fraunces', serif; font-weight: 900; letter-spacing: -.03em; text-align: center; word-break: break-all; line-height: 1; }
.expanded { margin-top: 14px; font-size: .85rem; text-align: center; opacity: .75; }
.quip { position: absolute; bottom: 22px; left: 22px; right: 22px; font-size: .8rem; text-align: center; border-top: 1px dashed rgba(0,0,0,.3); padding-top: 10px; }
.summary .big { font-family: 'Fraunces', serif; font-weight: 900; font-size: 6rem; line-height: 1; margin-top: 8px; }

.judge { display: flex; gap: 10px; height: 0; opacity: 0; overflow: hidden; transition: all .3s; margin-top: 14px; }
.judge.show { height: 48px; opacity: 1; }
.btn { font-family: inherit; font-weight: 700; padding: 10px 18px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.btn.got { background: #2a9d8f; color: #fff; }
.btn.miss { background: #f4a261; }
.btn.alt { background: var(--ink); color: var(--paper); }
.pill { font-family: 'Fraunces', serif; font-weight: 900; font-size: 1.1rem; padding: 12px 22px; border-radius: 999px; background: var(--ink); color: var(--paper); box-shadow: 0 6px 14px -6px rgba(0,0,0,.5); transition: transform .15s; }
.pill:hover { transform: translateY(-2px); }
.pill:active { transform: scale(.95); }
.mini { font-family: inherit; font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; padding: 8px 10px; border: 1.5px solid var(--ink); border-radius: 999px; background: transparent; }
.mini:hover { background: var(--ink); color: var(--paper); }
.mini:disabled { opacity: .3; pointer-events: none; }
.settings { margin-top: 12px; padding: 16px; background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink); width: min(340px, 86vw); }
.num { width: 56px; font-family: inherit; padding: 4px 6px; border: 1.5px solid var(--ink); border-radius: 8px; background: #fff; }

.hero { position: fixed; right: 14px; bottom: 14px; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 6px 10px; text-align: center; box-shadow: 3px 3px 0 var(--ink); transition: transform .3s; }
.hero-face { font-weight: 700; font-size: .95rem; white-space: nowrap; }
.hero-name { font-size: .55rem; letter-spacing: .2em; text-transform: uppercase; opacity: .55; }
.hero.cheer { transform: translateY(-10px) rotate(-4deg); background: #c9f2df; }
.hero.shrug { transform: rotate(3deg); background: #ffe0c7; }
@media (max-width: 500px) { .hero { bottom: auto; top: 10px; right: 10px; transform: scale(.85); } }

.slide-r { animation: inR .35s ease-out; }
.slide-l { animation: inL .35s ease-out; }
@keyframes inR { from { opacity: 0; transform: translateX(60px) rotate(3deg); } }
@keyframes inL { from { opacity: 0; transform: translateX(-60px) rotate(-3deg); } }
@keyframes bob { 50% { transform: translateY(-4px); } }
.rise { animation: rise .5s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.confetti span { position: absolute; top: -20px; width: 9px; height: 14px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }