/* ============ Rylee's Math Arena ============ */

@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/baloo2-800-latin.woff2') format('woff2');
}

:root {
  --blue: #1bc3e8;      /* Rylee — always the blue player (bottom) */
  --blue-deep: #0e9cbd;
  --red: #ef4653;       /* opponent (friend or bot) — red (top) */
  --red-deep: #c9303c;
  --ink: #2b3540;       /* dark slate */
  --paper: #eef4f8;     /* light card background */
  --card: #ffffff;
  --accent: #f6a21a;    /* orange */
  --accent-deep: #cc8205;
  --good: #6fce3f;      /* green flash */
  --blue-btn: #2f7fd1;
  --font: 'Baloo 2', ui-rounded, 'Arial Rounded MT Bold', 'Hiragino Maru Gothic ProN', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  font-weight: 800;
  background: var(--ink);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  position: fixed;
  inset: 0;
}

button {
  font-family: inherit;
  font-weight: inherit;
  border: none;
  cursor: pointer;
  color: inherit;
  background: none;
}

/* ---------- screens ---------- */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100%;
  flex-direction: column;
  overflow: hidden;
}
.screen--active { display: flex; animation: screenIn .22s ease; }
@keyframes screenIn { from { opacity: 0; transform: scale(.985); } }

/* ---------- HOME ---------- */
#screen-home {
  background: var(--paper);
}
.home-hero {
  position: relative;
  background: #6d4a5c;
  padding: calc(env(safe-area-inset-top, 0px) + 48px) 16px 44px;
  text-align: center;
  flex: 0 0 auto;
}
.home-title {
  position: relative;
  font-size: clamp(40px, 12.5vw, 62px);
  line-height: 1.02;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 4px 0 rgba(0,0,0,.28);
  animation: titleFloat 3.2s ease-in-out infinite;
}
@keyframes titleFloat { 50% { transform: translateY(-5px); } }
.home-deco {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 14px 6px;
  font-size: 30px;
  color: rgba(255,255,255,.14);
  pointer-events: none;
}
.deco-sym { display: inline-block; animation: decoDrift 4.5s ease-in-out infinite; }
.deco-sym:nth-child(2) { animation-delay: 1.1s; }
.deco-sym:nth-child(3) { animation-delay: 2.3s; }
.deco-sym:nth-child(4) { animation-delay: 3.2s; }
@keyframes decoDrift {
  50% { transform: translateY(-12px) rotate(-8deg); opacity: .55; }
}
.sound-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  font-size: 22px;
  line-height: 1;
}
.app-ver {
  text-align: center;
  font-size: 11px;
  color: #aab6c0;
  letter-spacing: 1px;
  margin-top: -6px;
}

.day-streak {
  align-self: center;
  background: #fdeedb;
  color: #b06a00;
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 18px;
  box-shadow: 0 2px 0 rgba(176,106,0,.18);
  animation: chipPop .35s cubic-bezier(.2,1.6,.4,1);
}
@keyframes chipPop { from { transform: scale(.5); opacity: 0; } }
#screen-home .card { flex: 1 1 auto; justify-content: center; gap: 18px; }

.card {
  background: var(--paper);
  border-radius: 26px 26px 0 0;
  margin-top: -16px;
  padding: 24px 22px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  overflow-y: auto;
}
.card-blurb {
  text-align: center;
  font-size: 19px;
  line-height: 1.45;
  color: var(--ink);
  padding: 0 6px 4px;
}

/* ---------- buttons ---------- */
.btn {
  border-radius: 18px;
  transition: transform .06s ease;
}
.btn:active { transform: translateY(3px); }

.btn--big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 17px 18px;
  font-size: 35px;
  color: #fff;
  letter-spacing: .5px;
}
.btn--blue   { background: var(--blue-btn);  box-shadow: 0 5px 0 #1d5a9b; }
.btn--green  { background: #3cab5c;          box-shadow: 0 5px 0 #288142; }
.btn--orange { background: var(--accent);    box-shadow: 0 5px 0 var(--accent-deep); }
.btn--big:active { box-shadow: 0 2px 0 rgba(0,0,0,.25); }

.btn-icon { font-size: 40px; line-height: 1; }
.btn-label { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.btn-label small { font-size: 15px; letter-spacing: 1.5px; opacity: .85; }

.btn--back {
  align-self: center;
  margin-top: 4px;
  padding: 11px 28px;
  font-size: 21px;
  color: #fff;
  background: #d98168;
  border-radius: 14px;
  box-shadow: 0 4px 0 #b35f47;
}

/* ---------- SETUP (dark, whimsical — matches the original's difficulty screen) */
.screen--setup {
  background: #31363e;
  --accent-now: #f6a21a;
  --face-c: #f6a21a;
}
.setup-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px calc(env(safe-area-inset-bottom, 0px) + 14px);
  overflow-y: auto;
}
.stats-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 22px calc(env(safe-area-inset-bottom, 0px) + 22px);
  overflow-y: auto;
}
.setup-title {
  text-align: center;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 1.5px;
}
.screen--setup .setup-title { color: rgba(255,255,255,.55); font-size: 17px; }

/* the bot face in a white ring, morphing with the speed slider */
.face-row {
  align-self: center;
  flex: 0 0 auto;   /* never squash in the scrolling column */
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: -56px;      /* overlaps the panel like the original */
  position: relative;
  z-index: 2;
}
.char-arrow {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  padding-bottom: 4px;
  transition: transform .1s ease;
}
.char-arrow:active { transform: scale(.88); }
.bot-face {
  width: 118px; height: 118px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  position: relative;
}
.face-head {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 50%;
  background: #17181b;
  display: grid;
  place-items: center;
  transition: transform .25s ease;
}
.face-inner {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--face-c);
  transition: background .25s ease;
}
.face-eye {
  position: absolute;
  top: 26px;
  width: 15px; height: 17px;
  border-radius: 50%;
  background: #fff;
  transition: all .25s ease;
}
.face-eye::after {
  content: '';
  position: absolute;
  left: 4px; top: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #17181b;
}
.face-eye--l { left: 12px; }
.face-eye--r { right: 12px; }
.face-brow {
  position: absolute;
  top: 18px;
  width: 20px; height: 7px;
  border-radius: 4px;
  background: #17181b;
  transition: all .25s ease;
}
.face-brow--l { left: 9px; transform: rotate(14deg); }
.face-brow--r { right: 9px; transform: rotate(-14deg); }
.face-mouth {
  position: absolute;
  left: 50%; bottom: 13px;
  width: 26px; height: 10px;
  transform: translateX(-50%);
  border-radius: 0 0 20px 20px;
  background: #17181b;
  transition: all .25s ease;
}
.face-horn {
  position: absolute;
  top: -7px;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: #17181b;
  opacity: 0;
  transition: all .25s ease;
}
.face-horn--l { left: -2px; transform: rotate(18deg); }
.face-horn--r { right: -2px; transform: rotate(-18deg); }

/* face moods per bot speed */
.bot-face[data-char="robo"][data-speed="fast"]    { --face-c: #f2821d; }
.bot-face[data-char="robo"][data-speed="faster"]  { --face-c: #ee5f24; }
.bot-face[data-char="robo"][data-speed="fastest"] { --face-c: #e8344a; }
.bot-face[data-speed="fast"] .face-brow--l   { transform: rotate(22deg) translateY(1px); }
.bot-face[data-speed="fast"] .face-brow--r   { transform: rotate(-22deg) translateY(1px); }
.bot-face[data-speed="faster"] .face-brow--l { transform: rotate(30deg) translateY(3px); }
.bot-face[data-speed="faster"] .face-brow--r { transform: rotate(-30deg) translateY(3px); }
.bot-face[data-speed="faster"] .face-mouth   { width: 20px; height: 7px; border-radius: 6px; }
.bot-face[data-speed="fastest"] .face-brow--l { transform: rotate(34deg) translateY(4px); }
.bot-face[data-speed="fastest"] .face-brow--r { transform: rotate(-34deg) translateY(4px); }
.bot-face[data-speed="fastest"] .face-mouth  { width: 30px; height: 12px; border-radius: 20px 20px 0 0; bottom: 11px; }
.bot-face[data-char="robo"][data-speed="fastest"] .face-horn { opacity: 1; }
.bot-face[data-speed="fastest"] .face-head   { transform: scale(1.06); }
/* friendly face for vs-Friend mode */
.bot-face[data-char="friend"]  { --face-c: #2f9df0; }
.bot-face[data-char="friend"] .face-brow { opacity: 0; }
.bot-face[data-char="friend"] .face-mouth { width: 32px; height: 14px; }

/* SVG character portraits (js/chars.js); robo/friend keep the CSS face */
.face-svg { display: none; width: 106px; height: 106px; }
.face-svg svg { display: block; width: 100%; height: 100%; }
.bot-face--svg .face-svg { display: block; }
.bot-face--svg .face-head { display: none; }

/* Every portrait reacts to the bot speed: game-face brows slide in, the
   smile swaps to an excited open grin, cheeks flush red, and at Fastest
   the whole face pumps. Smooth transitions keep the morph fluid. */
.face-svg .m-brow, .face-svg .m-grit, .face-svg .m-flush {
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  transform-box: fill-box;
  transform-origin: center;
}
.face-svg .m-smile { transition: opacity .3s ease; }
.bot-face[data-speed="fast"] .m-brow { opacity: .65; }
.bot-face[data-speed="faster"] .m-brow,
.bot-face[data-speed="fastest"] .m-brow { opacity: 1; }
.bot-face[data-speed="faster"] .m-brow--l { transform: rotate(6deg) translateY(1px); }
.bot-face[data-speed="faster"] .m-brow--r { transform: rotate(-6deg) translateY(1px); }
.bot-face[data-speed="fastest"] .m-brow--l { transform: rotate(11deg) translateY(2px); }
.bot-face[data-speed="fastest"] .m-brow--r { transform: rotate(-11deg) translateY(2px); }
.bot-face[data-speed="faster"] .m-flush { opacity: .3; }
.bot-face[data-speed="fastest"] .m-flush { opacity: .5; }
.bot-face[data-speed="faster"] .m-smile,
.bot-face[data-speed="fastest"] .m-smile { opacity: 0; }
.bot-face[data-speed="faster"] .m-grit,
.bot-face[data-speed="fastest"] .m-grit { opacity: 1; }
.bot-face[data-speed="fastest"] .face-svg svg { animation: facePump .85s ease-in-out infinite; }
@keyframes facePump { 50% { transform: scale(1.05); } }

.setup-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #3c424c;
  border-radius: 26px;
  padding: 66px 20px 22px;  /* room for the overlapping face */
  box-shadow: 0 6px 0 rgba(0,0,0,.2);
}

/* operation chips */
.op-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.op-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 2px 0 4px;
  color: rgba(255,255,255,.45);
  font-size: 12px;
  letter-spacing: .5px;
  border-radius: 14px;
  transition: transform .15s ease;
}
.op-btn .op-sym {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #4a515c;
  color: rgba(255,255,255,.6);
  font-size: 28px;
  border: 4px solid transparent;
  transition: all .18s ease;
}
.op-btn--selected { color: #fff; transform: scale(1.06); }
.op-btn--selected .op-sym {
  background: var(--accent-now);
  color: #fff;
  border-color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}

/* slider zones with giant colored names, like the original */
.zone { text-align: center; }
.zone-name {
  font-size: clamp(30px, 9vw, 40px);
  letter-spacing: 2px;
  line-height: 1.1;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.zone-name--accent { color: var(--accent-now); transition: color .25s ease; }
.zone-name--tier { color: #58c7e0; font-size: clamp(24px, 7vw, 32px); }
.zone-sub { margin-top: 6px; font-size: 14px; color: rgba(255,255,255,.35); }

/* chunky white-outline slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 82%;
  height: 30px;
  border-radius: 999px;
  background: #878d96;
  border: 6px solid #fff;
  outline: none;
}
.slider--accent { background: linear-gradient(to right, var(--accent-now) 0%, var(--accent-now) var(--fill, 5%), #878d96 var(--fill, 5%)); }
.slider--tier { background: linear-gradient(to right, #58c7e0 0%, #58c7e0 var(--fill, 5%), #878d96 var(--fill, 5%)); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 8px solid #fff;
  box-shadow: inset 0 0 0 20px rgba(0,0,0,.22);
}
.slider--accent::-webkit-slider-thumb { background: var(--accent-now); box-shadow: none; }
.slider--tier::-webkit-slider-thumb { background: #2ba7c4; box-shadow: none; }
.slider::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-now);
  border: 6px solid #fff;
}

/* race-to chips */
.target-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.target-label { font-size: 15px; color: rgba(255,255,255,.45); margin-right: 4px; }
.target-btn {
  width: 62px;
  padding: 8px 0;
  font-size: 24px;
  border-radius: 999px;
  background: #4a515c;
  color: rgba(255,255,255,.55);
  border: 4px solid transparent;
}
.target-btn--selected {
  background: var(--accent-now);
  border-color: #fff;
  color: #fff;
}

.btn--play {
  padding: 16px;
  font-size: 36px;
  letter-spacing: 3px;
  color: #fff;
  border-radius: 20px;
}
.btn--accent { background: var(--accent-now); box-shadow: 0 6px 0 rgba(0,0,0,.3); transition: background .25s ease; }
.btn--back-dark { margin-top: 16px; background: transparent; box-shadow: none; color: rgba(255,255,255,.7); }

/* ---------- DUEL ---------- */
.screen--duel {
  background: var(--duel-bg, #6d4a5c);
  touch-action: none;
}

/* the original's signature: giant circles expanding behind the problems */
.round-circle, .score-circle {
  position: absolute;
  left: 50%; top: 50%;
  width: 125vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}
.round-circle { background: rgba(38, 42, 54, .55); }
.round-circle--in {
  animation: circleIn .45s cubic-bezier(.2, 1.2, .4, 1) forwards;
}
@keyframes circleIn { to { transform: translate(-50%, -50%) scale(1); } }
.score-circle { background: var(--good); width: 160vmin; }
.score-circle--pop { animation: circlePop 1s ease forwards; }
@keyframes circlePop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: .95; }
  45% { transform: translate(-50%, -50%) scale(1); opacity: .95; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
.half {
  position: relative;
  height: 50%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.half--top { transform: rotate(180deg); }

.problem {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(46px, 16vw, 92px);
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 4px 0 rgba(0,0,0,.18);
  white-space: nowrap;
  position: relative;
  z-index: 1;
}
.problem--long { font-size: clamp(32px, 10.5vw, 62px); }

.bar {
  flex: 0 0 15px;
  margin: 0 16px;
  border-radius: 10px;
  position: relative;
  z-index: 1;
}
.half--top .bar { background: var(--red); }
.half--bottom .bar { background: var(--blue); }

.choices {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 18px 10px;
  position: relative;
  z-index: 1;
}
.half--bottom .choices { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5vh); }
.half--top .choices { padding-bottom: calc(env(safe-area-inset-top, 0px) + 5vh); }

.choice {
  flex: 1;
  max-width: 140px;
  min-height: 66px;
  padding: 8px 6px;
  font-size: clamp(26px, 8.5vw, 38px);
  border-radius: 999px;
  border: 5px solid;
  letter-spacing: 1px;
  transition: opacity .12s ease;
}
.half--top .choice {
  background: #f6abb0;
  border-color: #d8434e;
  color: #a82430;
}
.half--bottom .choice {
  background: #a9e4f1;
  border-color: #15aed0;
  color: #0b7f9c;
}
.choice--correct { background: var(--good) !important; border-color: #fff !important; color: #fff !important; }
.choice--wrong {
  background: #2e3238 !important;
  border-color: #17181b !important;
  color: #c9cdd3 !important;
  text-decoration: line-through;
  text-decoration-thickness: 4px;
}
.choices--dim .choice:not(.choice--correct):not(.choice--wrong) { opacity: .35; }

/* ---------- game juice ---------- */
.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9;
}

.problem--pop { animation: popIn .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } }

.choice--pop { animation: choicePop .38s cubic-bezier(.2, 1.8, .4, 1) backwards; }
.choices .choice--pop:nth-child(2) { animation-delay: .06s; }
.choices .choice--pop:nth-child(3) { animation-delay: .12s; }
@keyframes choicePop { from { transform: scale(.3); opacity: 0; } }

.choice--correct { animation: correctPulse .5s ease; }
@keyframes correctPulse { 30% { transform: scale(1.14); } }

/* wrong-tap shake (the top half must keep its 180-degree rotation) */
.half--shake { animation: shakeB .35s ease; }
.half--top.half--shake { animation: shakeT .35s ease; }
@keyframes shakeB {
  20%, 60% { transform: translateX(-9px); }
  40%, 80% { transform: translateX(9px); }
}
@keyframes shakeT {
  0%, 100% { transform: rotate(180deg); }
  20%, 60% { transform: rotate(180deg) translateX(-9px); }
  40%, 80% { transform: rotate(180deg) translateX(9px); }
}

/* score badge bounce (keyframes carry the badge's base translate) */
.edge-badge--score.edge-badge--bounce { animation: scoreBounce .45s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes scoreBounce {
  0%, 100% { transform: translate(-42%, -50%) scale(1); }
  40% { transform: translate(-42%, -50%) scale(1.22); }
}

/* combo banner ("3 IN A ROW!") */
.streak-note {
  position: absolute;
  left: 0; right: 0;
  top: 7%;
  text-align: center;
  font-size: clamp(22px, 7vw, 34px);
  letter-spacing: 1px;
  color: #ffe34d;
  text-shadow: 0 3px 0 rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.streak-note--show { animation: streakPop 1.2s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes streakPop {
  0% { opacity: 0; transform: scale(.3); }
  18% { opacity: 1; transform: scale(1.15); }
  30% { transform: scale(1); }
  75% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-26px); }
}

/* match point: the side bars pulse */
.duel--matchpoint .bar { animation: barPulse .85s ease-in-out infinite; }
@keyframes barPulse {
  50% { box-shadow: 0 0 20px 5px rgba(255,255,255,.5); filter: brightness(1.25); }
}

/* round-won arc flash */
.flash-arc {
  position: absolute;
  left: 50%;
  bottom: -90px;
  width: 150%;
  height: 170px;
  transform: translateX(-50%);
  border-radius: 50% 50% 0 0;
  background: var(--good);
  opacity: 0;
  pointer-events: none;
}
.flash-arc--show { animation: arcpop .7s ease-out; }
@keyframes arcpop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(40px); }
  25%  { opacity: .95; transform: translateX(-50%) translateY(0); }
  75%  { opacity: .95; }
  100% { opacity: 0; }
}

/* countdown / win notes rendered per-half so both players read them */
.big-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(50px, 18vw, 110px);
  color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,.25);
  pointer-events: none;
  opacity: 0;
}
.big-note--show { opacity: 1; }
.big-note--pop { animation: notepop .5s ease; }
@keyframes notepop {
  0% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* edge badges — circles half off-screen, text rotated to read vertically */
.edge-badge {
  position: absolute;
  top: 50%;
  width: 94px; height: 94px;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  z-index: 5;
}
.edge-badge--score {
  left: 0;
  transform: translate(-42%, -50%);
  font-size: 24px;
}
.edge-badge--score .edge-inner {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  display: flex;
  align-items: center;
  gap: 4px;
}
#score-top { color: var(--red-deep); }
#score-bottom { color: var(--blue-deep); }
.edge-badge--score i { font-style: normal; color: #9aa6b1; }

.edge-badge--exit {
  right: 0;
  transform: translate(42%, -50%);
  font-size: 16px;
  letter-spacing: 1px;
}
/* hold-to-quit: a pale pie wedge sweeps clockwise around the badge while
   held (the original's "loading up" exit). The wedge paints behind the
   white badge, so only the ring outside it shows. --sweep is driven
   frame-by-frame from JS: iOS Safari can't animate conic-gradient angles
   in CSS keyframes. */
.edge-badge--exit::before {
  content: '';
  position: absolute;
  inset: -26px;
  border-radius: 50%;
  z-index: -1;
  background: conic-gradient(rgba(255, 255, 255, .6) var(--sweep, 0deg), transparent 0deg);
}
.edge-badge--exit .edge-inner {
  position: absolute;
  z-index: 1;
  transition: color .15s ease;
  left: 2px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  display: block;
  width: 40px;
  text-align: center;
  margin-top: -9px;
}

/* ---------- MATCH OVER ---------- */
.screen--over { background: var(--paper); }
.over-half--top {
  height: 34%;
  display: grid;
  place-items: center;
  transform: rotate(180deg);
  font-size: clamp(30px, 9vw, 48px);
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.over-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 20px 26px calc(env(safe-area-inset-bottom, 0px) + 24px);
  text-align: center;
}
.over-trophy {
  font-size: 82px;
  line-height: 1;
  animation: trophyDrop .7s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes trophyDrop { from { transform: translateY(-60px) scale(.3); opacity: 0; } }
.over-title {
  font-size: clamp(34px, 11vw, 54px);
  color: var(--ink);
  animation: popIn .45s cubic-bezier(.2, 1.6, .4, 1) .1s backwards;
}
.over-score { font-size: 30px; color: #8a97a3; animation: popIn .4s ease .25s backwards; }

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

/* ---------- STATS ---------- */
#screen-stats { background: var(--paper); }
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-tile {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 3px 0 rgba(43,53,64,.12);
}
.stat-tile .num { font-size: 28px; color: var(--ink); line-height: 1.1; }
.stat-tile .lbl { font-size: 12px; color: #8a97a3; letter-spacing: .5px; }

.stats-section-title {
  font-size: 17px;
  color: var(--ink);
  margin: 10px 0 2px;
}
.stats-note { font-size: 13px; color: #8a97a3; margin-bottom: 6px; }

/* dual green/red accuracy bars */
.duo-list { display: flex; flex-direction: column; gap: 6px; }
.duo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
  text-align: left;
}
.acc-body .duo-row { background: var(--paper); }
.duo-label { flex: 0 0 auto; min-width: 42px; }
.duo-wl { font-size: 12px; color: #8a97a3; margin-left: 4px; }
.who-red { color: var(--red-deep); }
.duo-bar {
  flex: 1;
  height: 14px;
  border-radius: 8px;
  background: #e86a6a;   /* the "wrong" share shows through in red */
  overflow: hidden;
}
.duo-bar--empty { background: #e2e9ee; }
.duo-fill {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: 8px 0 0 8px;
}
.duo-pct { flex: 0 0 44px; text-align: right; font-size: 15px; }
.duo-pct--empty { color: #b3bec8; }
.duo-n { flex: 0 0 auto; font-size: 11px; color: #9aa6b1; min-width: 22px; text-align: right; }

/* expandable per-operation cards */
.acc-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 3px 0 rgba(43,53,64,.12);
  overflow: hidden;
  margin-bottom: 10px;
}
.acc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  font-size: 19px;
  color: var(--ink);
  text-align: left;
}
.acc-sym {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--blue);
  color: #fff;
  font-size: 24px;
}
.acc-chev { margin-left: auto; font-size: 24px; color: #9aa6b1; transition: transform .15s ease; }
.acc-card--open .acc-chev { transform: rotate(90deg); }
.acc-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px 10px 12px;
}
.acc-empty { text-align: center; color: #8a97a3; font-size: 14px; padding: 10px; }

/* per-fact mastery chips (xN drill-down) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 2px 4px 6px;
}
.chips-cap { font-size: 12px; color: #8a97a3; margin-right: 4px; }
.chip {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 7px;
  font-size: 11px;
  background: #e2e9ee;
  color: #8a97a3;
}
.chip--l0 { background: #e2534f; color: #fff; }
.chip--l1 { background: #f0924b; color: #fff; }
.chip--l2 { background: #f3c94e; color: #6b5300; }
.chip--l3 { background: #a5d653; color: #3c5c14; }
.chip--l4 { background: #5cbb4e; color: #fff; }

.games-list { display: flex; flex-direction: column; gap: 6px; }
.game-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  color: #5a6672;
}
.game-row .res { font-size: 16px; }
.game-row .res--win { color: #3cab5c; }
.game-row .res--loss { color: var(--red-deep); }

.btn--danger {
  align-self: center;
  padding: 8px 18px;
  font-size: 14px;
  color: #fff;
  background: #a05252;
  border-radius: 12px;
  margin-top: 8px;
}
.stats-empty {
  text-align: center;
  color: #8a97a3;
  font-size: 16px;
  padding: 30px 10px;
}
