/* Prime Arcade design system. Every game page loads this first.
   Games theme themselves by overriding --accent / --accent-2 / --bg on <body>. */
@import url('./vendor/fonts/fonts.css');
@import url('./vendor/katex/katex.min.css');

:root {
  --bg: #0a0d1f;
  --bg-2: #141a3a;
  --panel: rgba(18, 24, 56, 0.82);
  --panel-2: rgba(30, 38, 84, 0.9);
  --panel-solid: #161c44;
  --line: rgba(255, 255, 255, 0.12);
  --line-2: rgba(255, 255, 255, 0.22);
  --text: #f5f7ff;
  --muted: #a3acd6;
  --dim: #6b75a6;
  --accent: #ffb020;
  --accent-2: #ff6a3d;
  --accent-ink: #1c1206;
  --good: #2ee59d;
  --bad: #ff4d6d;
  --warn: #ffc233;
  --c0: #ff5d73; --c0d: #c7314a;
  --c1: #3fa9ff; --c1d: #1d6fc4;
  --c2: #ffc233; --c2d: #c98d00;
  --c3: #33d69f; --c3d: #149e70;
  --arith: #3ee089; --alg: #4aa8ff; --calc: #c36bff;
  --r-sm: 10px; --r: 16px; --r-lg: 24px;
  --font-display: 'Fredoka', 'Rubik', system-ui, sans-serif;
  --font-ui: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-pixel: 'Press Start 2P', monospace;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(255, 255, 255, 0.06) inset;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --topbar-h: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  position: fixed; inset: 0;
}
button { font: inherit; color: inherit; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
.pa-hidden { display: none !important; }
.pa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------- stage */
.pa-stage { position: fixed; inset: 0; overflow: hidden; }
.pa-canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.pa-layer { position: absolute; inset: 0; pointer-events: none; }
.pa-layer > * { pointer-events: auto; }
.pa-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pa-label {
  position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform;
  font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .55), 0 0 12px rgba(0, 0, 0, .5);
}
.pa-label .katex { font-size: 1em; }

/* ---------------------------------------------------------- buttons */
.pa-btn {
  --b: var(--panel-2); --b-d: #0d1230; --ink: var(--text);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px;
  border: 0; border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--b) 88%, #fff) 0%, var(--b) 55%);
  color: var(--ink);
  font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: .02em;
  box-shadow: 0 5px 0 var(--b-d), 0 10px 22px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .35);
  cursor: pointer; transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
  touch-action: manipulation;
}
.pa-btn svg { width: 1em; height: 1em; flex: none; }
.pa-btn:hover { filter: brightness(1.08); }
.pa-btn:active, .pa-btn.is-pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--b-d), 0 4px 10px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .3); }
.pa-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.pa-btn:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; transform: none; }
.pa-btn--primary { --b: var(--accent); --b-d: color-mix(in srgb, var(--accent) 55%, #000); --ink: var(--accent-ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .35); }
.pa-btn--good { --b: #22c985; --b-d: #0f7a50; --ink: #042416; text-shadow: none; }
.pa-btn--danger { --b: #ff4d6d; --b-d: #a3203a; --ink: #fff; }
.pa-btn--ghost { background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.pa-btn--ghost:active { transform: translateY(1px); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.pa-btn--big { min-height: 62px; padding: 14px 34px; font-size: 24px; border-radius: 18px; }
.pa-btn--sm { min-height: 38px; padding: 6px 14px; font-size: 15px; border-radius: 11px; box-shadow: 0 3px 0 var(--b-d), 0 6px 14px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .3); }
.pa-btn--icon { width: 44px; min-height: 44px; padding: 0; border-radius: 12px; font-size: 20px; }
.pa-btn--block { width: 100%; }

.pa-iconbtn {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 0; cursor: pointer;
  background: rgba(10, 14, 34, .55); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--text);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .1s, background .15s;
}
.pa-iconbtn:hover { background: rgba(30, 38, 84, .8); }
.pa-iconbtn:active { transform: scale(.92); }
.pa-iconbtn svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------- panels & overlays */
.pa-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.pa-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: radial-gradient(ellipse at center, rgba(6, 8, 22, .55), rgba(4, 5, 14, .86));
  animation: pa-fade .25s ease both;
  overflow-y: auto;
}
.pa-overlay > * { margin-top: auto; margin-bottom: auto; flex-shrink: 0; max-width: 100%; }
.pa-overlay.is-leaving { animation: pa-fade-out .2s ease both; }
.pa-overlay--clear { background: transparent; pointer-events: none; }
.pa-overlay--clear > * { pointer-events: auto; }
.pa-dialog { width: min(560px, 100%); padding: 26px; animation: pa-pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.pa-dialog h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 30px; }
.pa-dialog p { margin: 0 0 14px; color: var(--muted); }

@keyframes pa-fade { from { opacity: 0; } }
@keyframes pa-fade-out { to { opacity: 0; } }
@keyframes pa-pop { from { opacity: 0; transform: scale(.86) translateY(14px); } }
@keyframes pa-rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes pa-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
@keyframes pa-pulse { 50% { transform: scale(1.06); } }
@keyframes pa-glow { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent), 0 0 40px color-mix(in srgb, var(--accent) 60%, transparent); } }
@keyframes pa-spin { to { transform: rotate(360deg); } }
@keyframes pa-float { 50% { transform: translateY(-8px); } }
@keyframes pa-shine { from { transform: translateX(-120%) skewX(-20deg); } to { transform: translateX(220%) skewX(-20deg); } }

/* ---------------------------------------------------------- top bar */
.pa-topbar {
  position: fixed; z-index: 80; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--sat)) calc(10px + var(--sar)) 8px calc(10px + var(--sal));
  pointer-events: none;
}
.pa-topbar > * { pointer-events: auto; }
.pa-topbar__title {
  font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .03em;
  padding: 7px 14px; border-radius: 12px; background: rgba(10, 14, 34, .5); box-shadow: inset 0 0 0 1.5px var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw;
}
.pa-topbar__spacer { flex: 1; pointer-events: none; }
.pa-topbar.is-min .pa-topbar__title { display: none; }

/* ---------------------------------------------------------- title screen */
.pa-title {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(70px + var(--sat)) 18px calc(24px + var(--sab));
  animation: pa-fade .4s ease both;
}
.pa-title__art { position: absolute; inset: 0; z-index: -1; }
.pa-title__inner { width: min(760px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; margin: auto 0; }
.pa-logo {
  margin: 0; text-align: center; line-height: .92;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(48px, 11vw, 104px); letter-spacing: .01em;
  color: #fff;
  background: linear-gradient(180deg, #fff 10%, color-mix(in srgb, var(--accent) 60%, #fff) 55%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 color-mix(in srgb, var(--accent) 45%, #000)) drop-shadow(0 8px 0 rgba(0, 0, 0, .35)) drop-shadow(0 0 30px color-mix(in srgb, var(--accent) 55%, transparent));
  animation: pa-pop .6s cubic-bezier(.2, 1.4, .4, 1) both;
}
.pa-tagline { margin: -4px 0 0; text-align: center; color: var(--muted); font-size: clamp(15px, 3.6vw, 19px); max-width: 560px; animation: pa-rise .5s .1s ease both; }
.pa-kicker { font-family: var(--font-display); font-weight: 600; letter-spacing: .22em; text-transform: uppercase; font-size: 13px; color: var(--accent); animation: pa-rise .5s ease both; }

.pa-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; animation: pa-rise .5s .18s ease both; }
.pa-tier {
  --tc: var(--arith);
  position: relative; cursor: pointer; border: 0; text-align: left;
  display: flex; flex-direction: column; gap: 4px; padding: 14px 14px 13px;
  border-radius: 18px; background: rgba(14, 19, 46, .72);
  box-shadow: inset 0 0 0 2px var(--line), 0 10px 26px rgba(0, 0, 0, .3);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .15s ease, box-shadow .2s ease, background .2s;
}
.pa-tier:hover { transform: translateY(-3px); }
.pa-tier.is-on { background: color-mix(in srgb, var(--tc) 18%, rgba(14, 19, 46, .85)); box-shadow: inset 0 0 0 2.5px var(--tc), 0 0 0 4px color-mix(in srgb, var(--tc) 22%, transparent), 0 14px 34px color-mix(in srgb, var(--tc) 30%, transparent); }
.pa-tier__icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 24px; color: #0a0d1f;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tc) 70%, #fff), var(--tc));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--tc) 50%, #000);
}
.pa-tier__name { font-family: var(--font-display); font-weight: 700; font-size: 19px; margin-top: 4px; }
.pa-tier__blurb { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.pa-tier__check svg { width: 14px; height: 14px; }
.pa-tier__check { position: absolute; right: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--tc); color: #0a0d1f; display: none; place-items: center; font-weight: 900; font-size: 13px; }
.pa-tier.is-on .pa-tier__check { display: grid; }
.pa-tier[data-tier="algebra"] { --tc: var(--alg); }
.pa-tier[data-tier="calculus"] { --tc: var(--calc); }

.pa-title__actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; animation: pa-rise .5s .26s ease both; }
.pa-title__actions .pa-btn--big { min-width: 220px; }
.pa-title__foot { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; color: var(--dim); font-size: 13px; animation: pa-rise .5s .34s ease both; }
.pa-title__foot b { color: var(--muted); font-weight: 600; }

.pa-howto { display: grid; gap: 10px; margin: 6px 0 18px; }
.pa-howto__row { display: flex; gap: 12px; align-items: flex-start; }
.pa-howto__icon { flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.pa-howto__text { padding-top: 7px; color: var(--text); }
.pa-keys { display: inline-flex; gap: 4px; }
.pa-kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, .12); box-shadow: 0 2px 0 rgba(0, 0, 0, .4); font-size: 12px; font-weight: 600; text-align: center; }

/* ---------------------------------------------------------- question card */
.pa-q {
  --qpad: 16px;
  position: relative; width: min(720px, 100%);
  padding: var(--qpad);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(24, 31, 72, .92), rgba(14, 19, 48, .94));
  border: 1px solid var(--line-2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .12);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: pa-q-in .38s cubic-bezier(.2, 1.3, .4, 1) both;
}
.pa-q.is-out { animation: pa-q-out .22s ease both; }
@keyframes pa-q-in { from { opacity: 0; transform: translateY(26px) scale(.96); } }
@keyframes pa-q-out { to { opacity: 0; transform: translateY(18px) scale(.97); } }
.pa-q__head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; min-height: 22px; }
.pa-q__topic { font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pa-q__lvl { display: inline-flex; gap: 3px; }
.pa-q__lvl i { width: 7px; height: 7px; border-radius: 2px; background: rgba(255, 255, 255, .18); transform: rotate(45deg); }
.pa-q__lvl i.on { background: var(--accent); }
.pa-q__ask { font-family: var(--font-display); font-weight: 500; font-size: clamp(16px, 3.8vw, 20px); color: #dfe4ff; text-align: center; margin: 2px 0; }
.pa-q__expr { text-align: center; font-size: clamp(26px, 6.6vw, 40px); line-height: 1.25; padding: 4px 0 10px; overflow: hidden; white-space: nowrap; color: #fff; }
.pa-q__expr .katex { font-size: 1em; }
.pa-q__expr .katex-display { margin: 0; }
.pa-q__expr:empty { display: none; }
.pa-q__timer { position: absolute; left: 18px; right: 18px; top: 0; height: 5px; border-radius: 0 0 6px 6px; overflow: hidden; background: rgba(255, 255, 255, .08); }
.pa-q__timer i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, var(--good), #ffd23f 70%, var(--bad)); background-size: 300% 100%; }
.pa-q__choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pa-choice {
  --cc: var(--c0); --ccd: var(--c0d);
  position: relative; min-height: 64px; padding: 10px 12px 10px 48px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 16px; cursor: pointer; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cc) 85%, #fff) 0%, var(--cc) 60%);
  box-shadow: 0 5px 0 var(--ccd), 0 10px 20px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .45);
  color: #fff; font-size: clamp(19px, 4.6vw, 25px); font-weight: 600;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  transition: transform .08s, box-shadow .08s, filter .2s, opacity .25s;
  touch-action: manipulation;
}
.pa-choice .katex { font-size: 1em; }
.pa-choice:nth-child(2) { --cc: var(--c1); --ccd: var(--c1d); }
.pa-choice:nth-child(3) { --cc: var(--c2); --ccd: var(--c2d); color: #2a1d00; text-shadow: 0 1px 0 rgba(255, 255, 255, .35); }
.pa-choice:nth-child(4) { --cc: var(--c3); --ccd: var(--c3d); color: #03261a; text-shadow: 0 1px 0 rgba(255, 255, 255, .3); }
.pa-choice:hover { filter: brightness(1.07); }
.pa-choice:active, .pa-choice.is-pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--ccd), 0 4px 10px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .4); }
.pa-choice__key {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(0, 0, 0, .2); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .3);
  font-family: var(--font-display); font-size: 14px; font-weight: 700; color: inherit; text-shadow: none;
}
.pa-choice__key svg { width: 14px; height: 14px; fill: currentColor; }
.pa-choice__body { max-width: 100%; overflow: hidden; white-space: nowrap; }
.pa-choice.is-correct { filter: none; background: linear-gradient(180deg, #5bffc0, #19d488); --ccd: #0a8a56; color: #002a17; text-shadow: none; animation: pa-pulse .45s ease; box-shadow: 0 5px 0 #0a8a56, 0 0 0 4px rgba(46, 229, 157, .45), 0 0 36px rgba(46, 229, 157, .6); z-index: 1; }
.pa-choice.is-wrong { background: linear-gradient(180deg, #ff7a8e, #e5334f); --ccd: #8e1830; color: #fff; animation: pa-shake .45s ease; }
.pa-choice.is-dim { opacity: .35; filter: grayscale(.6); }
.pa-q.is-locked .pa-choice { cursor: default; }
.pa-q__explain { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); color: #dbe1ff; font-size: 15px; text-align: center; animation: pa-rise .3s ease both; }
.pa-q__explain b { color: var(--good); }
.pa-q__explain .katex { font-size: 1.05em; }

/* docked question card: bottom of the screen, slimmer */
.pa-qdock {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; pointer-events: none;
  padding: 0 calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal));
}
.pa-qdock > .pa-q { pointer-events: auto; }
.pa-qdock .pa-choice { min-height: 56px; }
@media (max-width: 520px) {
  .pa-q { --qpad: 12px; border-radius: 18px; }
  .pa-q__choices { gap: 8px; }
  .pa-choice { min-height: 54px; padding-left: 42px; border-radius: 14px; }
  .pa-choice__key { left: 8px; width: 24px; height: 24px; border-radius: 8px; font-size: 12px; }
  .pa-q__expr { padding-bottom: 6px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .pa-q__choices { grid-template-columns: repeat(4, 1fr); }
  .pa-choice { min-height: 48px; padding: 6px 8px 6px 36px; font-size: 18px; }
  .pa-choice__key { width: 22px; height: 22px; left: 7px; }
  .pa-q__expr { font-size: 26px; padding: 0 0 6px; }
  .pa-q__head { display: none; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .pa-q__choices.is-wide { grid-template-columns: repeat(4, 1fr); }
}

/* prompt-only banner (choices live in the game world) */
.pa-prompt {
  position: fixed; z-index: 20; left: 50%; top: calc(62px + var(--sat)); transform: translateX(-50%);
  width: min(640px, calc(100% - 20px)); padding: 10px 16px 12px; text-align: center;
  border-radius: 18px; background: linear-gradient(180deg, rgba(24, 31, 72, .9), rgba(14, 19, 48, .9));
  border: 1px solid var(--line-2); box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: pa-prompt-in .35s cubic-bezier(.2, 1.3, .4, 1) both; pointer-events: none;
}
@keyframes pa-prompt-in { from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.96); } to { opacity: 1; transform: translateX(-50%); } }
.pa-prompt .pa-q__ask { font-size: clamp(14px, 3.4vw, 17px); }
.pa-prompt .pa-q__expr { font-size: clamp(22px, 5.6vw, 34px); padding: 0; }
.pa-prompt .pa-q__timer { top: auto; bottom: 0; border-radius: 6px 6px 0 0; }

/* ---------------------------------------------------------- HUD bits */
.pa-hud { position: fixed; z-index: 15; display: flex; gap: 8px; pointer-events: none; }
.pa-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: rgba(10, 14, 34, .6); box-shadow: inset 0 0 0 1.5px var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-family: var(--font-display); font-weight: 600; font-size: 16px; white-space: nowrap;
}
.pa-chip b { font-size: 19px; }
.pa-chip.is-bump { animation: pa-pulse .3s ease; }
.pa-bar { position: relative; height: 12px; border-radius: 999px; background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 1.5px var(--line); overflow: hidden; }
.pa-bar > i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; transition: transform .3s ease; }

.pa-banner {
  position: fixed; z-index: 60; left: 50%; top: 42%; transform: translate(-50%, -50%);
  pointer-events: none; text-align: center; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(40px, 11vw, 96px); line-height: 1;
  color: #fff; -webkit-text-stroke: 3px rgba(0, 0, 0, .35); paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 0 40px var(--banner-glow, var(--accent));
  animation: pa-banner 1.1s cubic-bezier(.2, 1.2, .3, 1) both;
}
.pa-banner small { display: block; font-size: .32em; font-weight: 600; letter-spacing: .08em; margin-top: 10px; -webkit-text-stroke: 0; color: #e8ebff; }
@keyframes pa-banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-6deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(2deg); } 30% { transform: translate(-50%, -50%) scale(1) rotate(0); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -62%) scale(.96); } }
.pa-banner.is-hold { animation: pa-banner-in .5s cubic-bezier(.2, 1.3, .3, 1) both; }
@keyframes pa-banner-in { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 60% { transform: translate(-50%, -50%) scale(1.08); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.pa-toasts { position: fixed; z-index: 70; left: 50%; top: calc(64px + var(--sat)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.pa-toast { padding: 9px 16px; border-radius: 12px; background: rgba(12, 16, 40, .92); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 10px 30px rgba(0, 0, 0, .4); font-weight: 500; animation: pa-rise .25s ease both; max-width: 90vw; }
.pa-toast.is-good { box-shadow: inset 0 0 0 1.5px var(--good), 0 10px 30px rgba(0, 0, 0, .4); }
.pa-toast.is-bad { box-shadow: inset 0 0 0 1.5px var(--bad), 0 10px 30px rgba(0, 0, 0, .4); }
.pa-toast.is-leaving { animation: pa-fade-out .3s ease both; }

.pa-flash { position: fixed; inset: 0; z-index: 55; pointer-events: none; animation: pa-flash .45s ease-out both; }
@keyframes pa-flash { from { opacity: .55; } to { opacity: 0; } }

/* ---------------------------------------------------------- results */
.pa-results { width: min(520px, 100%); padding: 28px 24px 22px; text-align: center; animation: pa-pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.pa-results__title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(38px, 9vw, 58px); line-height: 1; color: #fff; text-shadow: 0 5px 0 rgba(0, 0, 0, .3), 0 0 30px var(--accent); }
.pa-results__sub { margin: 8px 0 0; color: var(--muted); }
.pa-stars { display: flex; justify-content: center; gap: 6px; margin: 16px 0 6px; }
.pa-star { width: 56px; height: 56px; color: rgba(255, 255, 255, .12); filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .35)); }
.pa-star.is-on { color: #ffd23f; animation: pa-star-in .5s cubic-bezier(.2, 1.6, .4, 1) both; filter: drop-shadow(0 3px 0 #b8860b) drop-shadow(0 0 16px rgba(255, 210, 63, .7)); }
.pa-star:nth-child(2) { transform: translateY(-10px) scale(1.15); }
.pa-star:nth-child(2).is-on { animation-name: pa-star-in-mid; }
@keyframes pa-star-in { from { transform: scale(0) rotate(-40deg); } }
@keyframes pa-star-in-mid { from { transform: translateY(-10px) scale(0) rotate(-40deg); } to { transform: translateY(-10px) scale(1.15); } }
.pa-statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 18px 0; }
.pa-stat { padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px var(--line); animation: pa-rise .4s ease both; }
.pa-stat__v { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.pa-stat__l { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.pa-stat.is-best .pa-stat__v { color: #ffd23f; }
.pa-results__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pa-podium { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; text-align: left; }
.pa-podium__row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); animation: pa-rise .4s ease both; }
.pa-podium__row.is-me { box-shadow: inset 0 0 0 2px var(--accent); }
.pa-podium__rank { width: 28px; font-family: var(--font-display); font-weight: 700; font-size: 20px; text-align: center; }
.pa-podium__row:nth-child(1) .pa-podium__rank { color: #ffd23f; }
.pa-podium__row:nth-child(2) .pa-podium__rank { color: #d9e2ff; }
.pa-podium__row:nth-child(3) .pa-podium__rank { color: #ff9f5a; }
.pa-podium__name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pa-podium__score { font-family: var(--font-display); font-weight: 700; font-size: 18px; }

/* ---------------------------------------------------------- avatars */
.pa-avatar {
  --pc: #4aa8ff;
  flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--pc) 65%, #fff), var(--pc));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--pc) 50%, #000), inset 0 1px 0 rgba(255, 255, 255, .5);
  color: #0a0d1f; font-family: var(--font-display); font-weight: 700; font-size: 16px;
}
.pa-avatar--lg { width: 52px; height: 52px; border-radius: 16px; font-size: 22px; }
.pa-avatar svg { width: 60%; height: 60%; }

/* ---------------------------------------------------------- forms */
.pa-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.pa-field label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pa-input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 13px; border: 0; outline: 0;
  background: rgba(0, 0, 0, .3); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line-2);
  font-size: 18px; font-weight: 500;
}
.pa-input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.pa-input--code { text-transform: uppercase; letter-spacing: .4em; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 26px; }
.pa-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.pa-swatch { width: 34px; height: 34px; border-radius: 10px; border: 0; cursor: pointer; background: var(--sw); box-shadow: 0 3px 0 color-mix(in srgb, var(--sw) 50%, #000); transition: transform .1s; }
.pa-swatch.is-on { box-shadow: 0 0 0 3px #fff, 0 3px 0 color-mix(in srgb, var(--sw) 50%, #000); transform: scale(1.08); }
.pa-slider { width: 100%; accent-color: var(--accent); }
.pa-seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 13px; background: rgba(0, 0, 0, .3); box-shadow: inset 0 0 0 1.5px var(--line); }
.pa-seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.pa-seg button.is-on { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------- lobby */
.pa-lobby { width: min(760px, 100%); padding: 22px; animation: pa-pop .4s cubic-bezier(.2, 1.4, .4, 1) both; }
.pa-lobby h2 { margin: 0; font-family: var(--font-display); font-size: clamp(26px, 6vw, 34px); }
.pa-lobby__sub { color: var(--muted); margin: 4px 0 16px; }
.pa-lobby__modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.pa-mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border-radius: 18px; border: 0; cursor: pointer; text-align: left;
  background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1.5px var(--line); transition: transform .15s, box-shadow .15s, background .15s;
}
.pa-mode:hover { transform: translateY(-3px); background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 2px var(--accent); }
.pa-mode__icon svg { width: 28px; height: 28px; }
.pa-mode__icon { font-size: 28px; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.pa-mode__name { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.pa-mode__desc { font-size: 13px; color: var(--muted); }
.pa-lobby__code { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 18px; background: color-mix(in srgb, var(--accent) 12%, rgba(0, 0, 0, .25)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); margin-bottom: 14px; }
.pa-lobby__codeval { font-family: var(--font-display); font-weight: 700; font-size: clamp(36px, 9vw, 52px); letter-spacing: .18em; line-height: 1; color: #fff; text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 60%, transparent); }
.pa-qrslot { flex: none; line-height: 0; }
.pa-qr { width: 112px; height: 112px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); image-rendering: pixelated; }
@media (max-width: 620px) { .pa-qr { width: 92px; height: 92px; } }
.pa-lobby__link { font-size: 13px; color: var(--muted); word-break: break-all; }
.pa-lobby__link b { color: var(--text); font-weight: 600; }
.pa-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pa-slot { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px var(--line); min-height: 58px; animation: pa-rise .3s ease both; }
.pa-slot.is-me { box-shadow: inset 0 0 0 2px var(--accent); }
.pa-slot.is-empty { justify-content: center; color: var(--dim); background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); border: 0; font-size: 14px; }
.pa-slot.is-off { opacity: .45; }
.pa-slot__name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pa-slot__tag { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: rgba(255, 255, 255, .1); color: var(--muted); }
.pa-slot__tag.is-host { background: color-mix(in srgb, var(--accent) 30%, transparent); color: #fff; }
.pa-slot__x { border: 0; background: rgba(255, 255, 255, .08); width: 28px; height: 28px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.pa-slot__x:hover { background: var(--bad); color: #fff; }
.pa-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.pa-team { padding: 10px; border-radius: 16px; background: color-mix(in srgb, var(--tcol) 10%, rgba(0, 0, 0, .2)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tcol) 50%, transparent); }
.pa-team__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-family: var(--font-display); font-weight: 700; color: var(--tcol); }
.pa-team .pa-slots { grid-template-columns: 1fr; margin: 0; }
.pa-lobby__row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pa-lobby__foot { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 16px; }
.pa-lobby__wait { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.pa-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); animation: pa-spin .8s linear infinite; }
.pa-lobby .pa-tiers { animation: none; }
.pa-lobby .pa-tier { padding: 10px 12px; }
.pa-lobby .pa-tier__blurb { display: none; }
.pa-lobby .pa-tier__icon { width: 32px; height: 32px; font-size: 19px; border-radius: 10px; }
.pa-lobby .pa-tier__name { font-size: 16px; }
.pa-section-label { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.pa-lobby__opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
@media (max-width: 620px) {
  .pa-lobby { padding: 16px; }
  .pa-lobby__modes { grid-template-columns: 1fr; }
  .pa-mode { flex-direction: row; align-items: center; }
  .pa-mode__icon { width: 44px; height: 44px; flex: none; }
  .pa-teams { grid-template-columns: 1fr; }
  .pa-tiers { gap: 8px; }
  .pa-tier { padding: 10px; }
  .pa-tier__blurb { display: none; }
  .pa-tier__name { font-size: 16px; }
}

/* ---------------------------------------------------------- touch controls */
.pa-stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2); opacity: 0; transition: opacity .15s; pointer-events: none; }
.pa-stick.is-on { opacity: 1; }
.pa-stick__knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, .5); box-shadow: 0 4px 12px rgba(0, 0, 0, .4); }

.pa-rotate-hint { display: none; }

/* scrollbars inside overlays */
.pa-overlay::-webkit-scrollbar, .pa-title::-webkit-scrollbar { width: 8px; }
.pa-overlay::-webkit-scrollbar-thumb, .pa-title::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 8px; }

/* short landscape phones: compact title + results so nothing overflows */
@media (max-height: 520px) {
  .pa-title { padding-top: calc(56px + var(--sat)); padding-bottom: calc(12px + var(--sab)); }
  .pa-title__inner { gap: 10px; }
  .pa-logo { font-size: clamp(36px, 9vh, 60px); }
  .pa-tagline { font-size: 14px; }
  .pa-tier { padding: 8px 10px; }
  .pa-tier__blurb { display: none; }
  .pa-tier__icon { width: 30px; height: 30px; font-size: 18px; border-radius: 9px; }
  .pa-tier__name { font-size: 15px; margin-top: 0; }
  .pa-title__actions .pa-btn--big { min-height: 50px; font-size: 20px; padding: 10px 24px; min-width: 180px; }
  .pa-results { padding: 16px 18px 14px; }
  .pa-results__title { font-size: 34px; }
  .pa-stars { margin: 8px 0 2px; }
  .pa-star { width: 40px; height: 40px; }
  .pa-statgrid { margin: 10px 0; gap: 6px; }
  .pa-stat { padding: 6px; }
  .pa-stat__v { font-size: 20px; }
  .pa-podium { margin: 10px 0; gap: 4px; }
  .pa-podium__row { padding: 5px 10px; }
  .pa-results__actions .pa-btn--big { min-height: 48px; font-size: 19px; padding: 8px 22px; }
  .pa-dialog { padding: 18px; }
}

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