/* ============================================================
 * screens.css — Shared .ui-* components + per-screen polish
 * Mobile-first; min-width queries for larger viewports.
 * Loaded LAST so it overrides earlier rules where intended.
 * ============================================================ */

/* ============================================================
 *  ICONS (SVG sprite consumer)
 * ============================================================ */
.ic {
  display: inline-block;
  vertical-align: -0.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.ic-sm { width: 16px; height: 16px; }
.ic-md { width: 20px; height: 20px; }
.ic-lg { width: 28px; height: 28px; }
.ic-xl { width: 40px; height: 40px; }
.ic-2xl { width: 64px; height: 64px; stroke-width: 1.25; }

/* swapped emoji wrapper — keep them inline with surrounding text */
.ui-emoji-swap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
 *  SHARED COMPONENTS (.ui-*)
 * ============================================================ */
.ui-card {
  position: relative;
  padding: var(--s-4);
  border-radius: var(--r-3);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-2);
  color: var(--ui-text);
}
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: var(--ui-surface-2);
  color: var(--ui-text);
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out);
}
.ui-btn:active { transform: scale(0.97); }
.ui-btn.is-primary { background: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-2)); color: #fff; }
.ui-btn.is-ghost { background: transparent; border-color: var(--ui-border-strong); }
.ui-btn.is-danger { background: var(--ui-bad); color: #fff; }
.ui-btn.is-sm { padding: var(--s-2) var(--s-3); min-height: 36px; font-size: var(--fs-sm); }
.ui-btn.is-lg { padding: var(--s-4) var(--s-6); min-height: 52px; font-size: var(--fs-lg); }

.ui-stat-tile {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-3);
  border-radius: var(--r-2);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  text-align: center;
  min-width: 0;
}
.ui-stat-tile .k { font-size: var(--fs-xs); color: var(--ui-muted); letter-spacing: var(--ls-tech); text-transform: uppercase; }
.ui-stat-tile .v { font-size: var(--fs-2xl); font-weight: 800; color: var(--ui-text); font-feature-settings: var(--num-feat); letter-spacing: var(--ls-tight); line-height: 1.1; }
.ui-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
@media (min-width: 480px) { .ui-stat-grid { grid-template-columns: repeat(4, 1fr); } }

.ui-empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--ui-muted); font-size: var(--fs-sm); }
.ui-empty .ic { color: var(--ui-muted); margin-bottom: var(--s-2); }

.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.ui-chip.is-active { background: var(--ui-accent); color: #fff; border-color: transparent; }

/* dot helpers (replaces 🟢🟡🟠🔴 emoji in difficulty chips) */
.ui-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: -1px;
  margin-right: 6px;
  box-shadow: 0 0 6px currentColor;
}
.ui-dot--green  { background: #22c55e; color: #22c55e; }
.ui-dot--yellow { background: #eab308; color: #eab308; }
.ui-dot--orange { background: #f97316; color: #f97316; }
.ui-dot--red    { background: #ef4444; color: #ef4444; }
.ui-dot--fire   { background: linear-gradient(135deg, #f97316, #dc2626); color: #f97316; }

/* common token-driven helpers */
.ui-row { display: flex; align-items: center; gap: var(--s-3); }
.ui-col { display: flex; flex-direction: column; gap: var(--s-3); }
.ui-mono { font-family: var(--font-mono); font-feature-settings: var(--num-feat); letter-spacing: var(--ls-tight); }
.ui-tech { letter-spacing: var(--ls-tech); text-transform: uppercase; font-size: var(--fs-xs); color: var(--ui-muted); }

/* ============================================================
 *  PER-SCREEN POLISH (cyber theme assumed)
 *  These selectors only fire when body.theme-cyber is set.
 * ============================================================ */

/* shared: every .screen gets a fade-in-from-grid feel */
body.theme-cyber .screen.active {
  animation: ui-fade-in 320ms var(--ease-out);
}
@keyframes ui-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Picker (welcome + user grid) ---------- */
body.theme-cyber #picker {
  padding-top: var(--s-2);
}
body.theme-cyber #picker > .picker-intro-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(34, 211, 238, 0.08)) !important;
  border: 1px solid rgba(34, 211, 238, 0.30) !important;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.10);
}
body.theme-cyber .picker-feedback-line {
  color: var(--ui-muted);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-tech);
}
body.theme-cyber .users-grid {
  gap: var(--s-3);
}

/* ---------- Setup / Rank: stacked label + grid chips ---------- */
body.theme-cyber #setup .row,
body.theme-cyber #rank .row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: var(--s-4);
}
body.theme-cyber #setup .row label,
body.theme-cyber #rank .row label {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ui-muted);
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
body.theme-cyber #setup .row label::before,
body.theme-cyber #rank .row label::before {
  content: "";
  width: 14px;
  height: 1px;
  background: linear-gradient(90deg, var(--ui-accent), transparent);
  display: inline-block;
}
body.theme-cyber #setup .row {
  gap: 10px;
  margin-bottom: 20px;
}
body.theme-cyber #setup .row + .row::before {
  content: "";
  align-self: center;
  width: min(74%, 720px);
  height: 2px;
  margin: 0 auto 4px;
  border-radius: var(--r-pill);
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--ui-accent) 38%, transparent) 18%,
    color-mix(in srgb, var(--ui-accent) 82%, white) 50%,
    color-mix(in srgb, var(--ui-accent) 38%, transparent) 82%,
    transparent
  );
  box-shadow:
    0 0 10px color-mix(in srgb, var(--ui-accent) 42%, transparent),
    0 0 22px color-mix(in srgb, var(--ui-accent-2) 24%, transparent);
  opacity: 0.9;
}
body.theme-cyber #setup .row label,
body.theme-cyber #rank .row label {
  font-size: 14px;
  letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--text) 84%, var(--ui-accent));
  font-weight: 800;
  margin-bottom: 0;
  display: inline-flex;
  gap: 8px;
  width: fit-content;
  padding: 3px 9px 3px 4px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ui-accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--ui-accent) 18%, transparent);
  line-height: 1.2;
}
body.theme-cyber #setup .row label::before,
body.theme-cyber #rank .row label::before {
  content: none;
}
body.theme-cyber #setup .row label .setup-label-icon,
body.theme-cyber #rank .row label .setup-label-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ui-accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--ui-accent) 42%, transparent);
  color: var(--ui-accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--ui-accent) 35%, transparent);
}
body.theme-cyber #setup .row label .setup-label-icon .ic,
body.theme-cyber #rank .row label .setup-label-icon .ic {
  width: 13px;
  height: 13px;
  margin: 0;
}
body.theme-cyber #setup .chips,
body.theme-cyber #rank .chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex: none;
  width: 100%;
}
@media (min-width: 480px) {
  body.theme-cyber #setup .chips,
  body.theme-cyber #rank .chips {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
body.theme-cyber #setup .chip,
body.theme-cyber #rank .chip {
  padding: 7px 6px;
  font-size: 12.5px;
  text-align: center;
  border-radius: 8px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
/* tighter for 4+ char Chinese — let them wrap to 2 lines if truly needed */
body.theme-cyber #setup .chip > .ui-emoji-swap,
body.theme-cyber #rank .chip > .ui-emoji-swap {
  margin-right: 2px;
}
body.theme-cyber #setup .chip .ic,
body.theme-cyber #rank .chip .ic {
  width: 12px;
  height: 12px;
  margin-right: 2px;
}
body.theme-cyber #setup .chip .ui-dot,
body.theme-cyber #rank .chip .ui-dot {
  width: 8px;
  height: 8px;
  margin-right: 4px;
}
body.theme-cyber #startBtn {
  font-size: var(--fs-lg);
  padding: var(--s-4) var(--s-5);
  margin-top: var(--s-3);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
body.theme-cyber .today-stats {
  border-radius: var(--r-3);
  padding: var(--s-3);
  margin-top: var(--s-3);
}
body.theme-cyber .ts-icon {
  font-size: 22px;
  margin-bottom: 4px;
}
body.theme-cyber .ts-val {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--ui-accent);
}
body.theme-cyber .tips {
  background: rgba(15, 26, 51, 0.5);
  border: 1px dashed rgba(34, 211, 238, 0.3);
  border-radius: var(--r-2);
  padding: var(--s-3);
  font-size: var(--fs-xs);
  color: var(--ui-muted);
  margin-top: var(--s-3);
}

/* ---------- Play screen ---------- */
body.theme-cyber #play .hud {
  border-radius: var(--r-2);
  padding: var(--s-2);
  background: rgba(15, 26, 51, 0.5);
  border: 1px solid rgba(34, 211, 238, 0.18);
  box-shadow: inset 0 0 12px rgba(34, 211, 238, 0.05);
}
body.theme-cyber #play .progress {
  height: 6px;
  margin: var(--s-3) 0;
}
body.theme-cyber #qBox {
  margin: var(--s-5) 0;
  padding: var(--s-4);
  text-align: center;
  position: relative;
}
body.theme-cyber .row-ctrl {
  margin-top: var(--s-3);
  gap: var(--s-2);
}

/* ---------- Result screen ---------- */
body.theme-cyber #result .result-big {
  text-align: center;
  padding: var(--s-5) 0 var(--s-4);
  position: relative;
}
body.theme-cyber #result .result-big::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(34, 211, 238, 0.15), transparent 60%);
  pointer-events: none;
  z-index: -1;
}
body.theme-cyber #result .result-big .emoji {
  font-size: 64px;
  margin-bottom: var(--s-3);
}
body.theme-cyber #result .result-big .title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  margin-bottom: var(--s-2);
}
body.theme-cyber #result .result-big .subr {
  color: var(--ui-text-soft);
  letter-spacing: var(--ls-tech);
}
body.theme-cyber #result .scoreGrid {
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
body.theme-cyber #result .scoreGrid .stat {
  padding: var(--s-3) var(--s-2);
  border-radius: var(--r-2);
}
body.theme-cyber #result .scoreGrid .stat .v {
  font-size: var(--fs-xl);
}

/* ---------- Rank / history list polish ---------- */
body.theme-cyber #rankBody .rank-row,
body.theme-cyber .history-list > * {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--r-2);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
  transition: border-color var(--dur-2) var(--ease-out);
}
body.theme-cyber #rankBody .rank-row:hover,
body.theme-cyber .history-list > *:hover {
  border-color: rgba(34, 211, 238, 0.45);
}

/* ============================================================
 *  TOPBAR — vertical: .who row on top, .nav grid below
 *  All tabs visible at once; uniform cell size = no jumping
 *  between screens.
 * ============================================================ */
.topbar {
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  gap: 10px;
  min-width: 0;
}
.topbar .who {
  flex: none;
  align-self: flex-start;
  min-width: 0;
}
.topbar .nav {
  flex: none;
  display: grid;
  /* --tab-cols set by JS = ceil(visible tab count / 2), capped 4–6.
     Always 2 rows total. */
  grid-template-columns: repeat(var(--tab-cols, 5), minmax(0, 1fr));
  gap: 6px;
  width: calc(100% + 18px);
  overflow: visible;
  -webkit-mask-image: none;
          mask-image: none;
  padding: 0;
  margin: 0 -9px;
}

.tab.has-icon {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 2px 6px;
  font-size: 15px;
  font-weight: 800;
  height: 60px;
  min-height: 60px;
  border-radius: 10px;
  text-align: center;
  line-height: 1.05;
  overflow: hidden;
}
.tab.has-icon .tab-text {
  white-space: nowrap;
  letter-spacing: 0;
  font-size: 15px;
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ic-tab {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 3px currentColor);
  transition: filter var(--dur-2) var(--ease-out),
              transform var(--dur-2) var(--ease-out);
}
.tab.active .ic-tab {
  filter: drop-shadow(0 0 5px currentColor) drop-shadow(0 0 10px currentColor);
  transform: scale(1.1);
}
.tab.has-icon:hover .ic-tab {
  filter: drop-shadow(0 0 5px currentColor) drop-shadow(0 0 10px currentColor);
}
@media (min-width: 480px) {
  .topbar .nav {
    width: calc(100% + 26px);
    margin-left: -13px;
    margin-right: -13px;
    gap: 7px;
  }
  .tab.has-icon { height: 60px; min-height: 60px; font-size: 15px; gap: 4px; padding: 7px 4px 6px; }
  .tab.has-icon .tab-text { font-size: 15px; }
  .ic-tab { width: 21px; height: 21px; }
}

/* ---------- Online presence badge ---------- */
body.theme-cyber #onlineBadge {
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-tech);
}

/* ---------- battle players bar ---------- */
body.theme-cyber .battle-players-bar {
  gap: var(--s-2);
}

/* ---------- card outer shell extra padding on small screens ---------- */
@media (max-width: 480px) {
  body.theme-cyber .card { padding: var(--s-3); }
  body.theme-cyber #qBox { padding: var(--s-3); margin: var(--s-4) 0; }
}
@media (min-width: 600px) {
  body.theme-cyber .card { padding: var(--s-5); }
}

/* ---------- ensure swapped icons inherit color in chips/buttons ---------- */
.btn .ic, .chip .ic, .tab .ic, .ui-btn .ic, .ui-emoji-swap .ic {
  color: currentColor;
  vertical-align: -0.2em;
}

/* tabs need their icons sized small */
.tab .ic { width: 14px; height: 14px; vertical-align: -0.15em; margin-right: 2px; }
.chip .ic { width: 14px; height: 14px; vertical-align: -0.15em; margin-right: 4px; }

/* h1 sparkle/party icon */
h1 .ic, h1 .ui-emoji-swap .ic { width: 28px; height: 28px; vertical-align: -0.2em; margin-right: 6px; color: var(--ui-accent); }

/* ts-icon (today-stats) */
.ts-icon .ic, .ts-icon .ui-emoji-swap .ic { width: 22px; height: 22px; color: var(--ui-accent); }

/* result hero emoji */
.result-big .emoji .ic, .result-big .emoji .ui-emoji-swap .ic {
  width: 56px;
  height: 56px;
  color: var(--ui-accent-2);
  filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.6));
}

/* draft btn / quit btn icons */
#draftBtn .ic, #quitBtn .ic, #againBtn .ic, #backBtn .ic {
  width: 14px;
  height: 14px;
  margin-right: 2px;
}

/* picker welcome card */
#picker > .picker-intro-card .ic { width: 22px; height: 22px; color: var(--ui-accent-2); }

/* keypad clear icon */
.key.clear { font-family: var(--font-mono); font-size: 22px; }

/* ============================================================
 *  CHIP ICONS — colored badge inside .chip
 * ============================================================ */
.chip .chip-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c, #22d3ee) 18%, transparent);
  color: var(--c, #22d3ee);
  border: 1px solid color-mix(in srgb, var(--c, #22d3ee) 50%, transparent);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  vertical-align: -6px;
  box-shadow: 0 0 6px color-mix(in srgb, var(--c, #22d3ee) 35%, transparent);
  flex-shrink: 0;
  transition: background var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out);
}
.chip .chip-ic .ic { width: 13px; height: 13px; color: inherit; vertical-align: 0; }
.chip.active .chip-ic {
  background: color-mix(in srgb, var(--c, #22d3ee) 38%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c, #22d3ee) 55%, transparent);
}
/* Make chips left-align so icon + label flow naturally */
body.theme-cyber .chips .chip {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  text-align: left;
}
/* ============================================================
 * PERFORMANCE LITE
 * Default-on from index.html/app.js. Keep the app visually usable while
 * removing effects that continuously cost CPU/GPU, especially on iPhone.
 * ============================================================ */
body.perf-lite,
body.perf-lite.theme-cyber {
  background: #050813 !important;
  background-attachment: scroll !important;
}

body.perf-lite.theme-cyber[class*="cosmetic-theme-"] {
  background: linear-gradient(180deg, var(--cosmetic-bg-2), var(--cosmetic-bg) 72%, #02030a) !important;
  background-attachment: scroll !important;
}

body.perf-lite::before,
body.perf-lite::after,
body.perf-lite .ui-math-bg,
body.perf-lite #bg-particles {
  display: none !important;
  content: none !important;
}

body.perf-lite *,
body.perf-lite *::before,
body.perf-lite *::after {
  animation: none !important;
  transition-duration: 0ms !important;
  transition-delay: 0ms !important;
  scroll-behavior: auto !important;
}

body.perf-lite *,
body.perf-lite *::before,
body.perf-lite *::after {
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.perf-lite .btn::after,
body.perf-lite #startBtn::after,
body.perf-lite .rank-row::after,
body.perf-lite .av.frame-rainbow::before,
body.perf-lite .big-av.frame-rainbow::before,
body.perf-lite .av.frame-matrix::before,
body.perf-lite .big-av.frame-matrix::before,
body.perf-lite .av.frame-prism::before,
body.perf-lite .big-av.frame-prism::before {
  display: none !important;
}

/* Keep earned avatar frames visible in perf-lite without restoring the
   heavier site-wide glow/animation budget. */
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-neon {
  box-shadow: 0 0 0 var(--frame-size, 2px) #22d3ee, 0 0 8px rgba(34,211,238,.55) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-rainbow {
  box-shadow: 0 0 0 var(--frame-size, 2px) rgba(255,255,255,.18) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-rainbow::before {
  display: block !important;
  animation: none !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-starry {
  box-shadow: 0 0 0 var(--frame-size, 2px) #a78bfa, 0 0 8px rgba(167,139,250,.55) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-gold {
  box-shadow: 0 0 0 var(--frame-size, 2px) #fbbf24, 0 0 8px rgba(251,191,36,.50) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-flame {
  animation: none !important;
  box-shadow: 0 0 0 var(--frame-size, 2px) #ef4444, 0 0 8px rgba(239,68,68,.50) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-ice {
  box-shadow: 0 0 0 var(--frame-size, 2px) #67e8f9, 0 0 8px rgba(103,232,249,.45) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-leaf {
  box-shadow: 0 0 0 var(--frame-size, 2px) #4ade80, 0 0 8px rgba(74,222,128,.45) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-shadow {
  box-shadow: 0 0 0 var(--frame-size, 2px) #94a3b8, 0 0 8px rgba(148,163,184,.35) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-diamond {
  box-shadow: 0 0 0 var(--frame-size, 2px) #e0f2fe, 0 0 8px rgba(125,211,252,.52) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-crown {
  box-shadow: 0 0 0 var(--frame-size, 2px) #fde047, 0 0 8px rgba(250,204,21,.52) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-matrix {
  box-shadow: 0 0 0 var(--frame-size, 2px) #22c55e, 0 0 8px rgba(34,197,94,.48) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-matrix::before {
  display: block !important;
  animation: none !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-prism {
  box-shadow: 0 0 0 var(--frame-size, 2px) rgba(255,255,255,.18) !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-prism::before {
  display: block !important;
  animation: none !important;
}
body.perf-lite :is(.av, .big-av, .rank-av, .closet-frame-preview).frame-solar {
  animation: none !important;
  box-shadow: 0 0 0 var(--frame-size, 2px) #f97316, 0 0 8px rgba(249,115,22,.48) !important;
}

/* Battle effect whitelist: keep action feedback while perf-lite removes
   site-wide decorative work. */
body.perf-lite .qd-signal-img {
  animation: qdSignalPop 0.15s ease-out !important;
  filter:
    drop-shadow(0 0 28px rgba(248,113,113,0.72))
    drop-shadow(0 18px 28px rgba(0,0,0,0.36)) !important;
}

body.perf-lite .qd-center-prompt,
body.perf-lite .qd-round-result,
body.perf-lite .qd-round-board {
  animation: qdPromptPop 0.18s ease-out !important;
  box-shadow: 0 18px 48px rgba(0,0,0,0.38) !important;
}

body.perf-lite .qd-center-prompt.ready .main {
  text-shadow: 0 0 18px rgba(34,197,94,0.45) !important;
}

body.perf-lite[data-screen="quick-draw"][data-qd-phase="trigger"]:not([data-qd-rule="blind"]) #qdStage::before {
  animation: qdFlash 0.25s ease-out forwards !important;
}

body.perf-lite[data-screen="quick-draw"][data-qd-phase="resolution"] #qdStage::after {
  animation: qdSlash 0.58s cubic-bezier(.12,.74,.18,1) forwards !important;
  filter: brightness(1.35) !important;
}

body.perf-lite[data-screen="quick-draw"] .qd-char.charging::after,
body.perf-lite[data-screen="quick-draw"] .qd-char.glowing::after {
  opacity: 1 !important;
}

body.perf-lite:not(.perf-ios)[data-screen="quick-draw"] .qd-char.charging .qd-shadow-body,
body.perf-lite:not(.perf-ios)[data-screen="quick-draw"] .qd-char.glowing .qd-shadow-body {
  filter:
    drop-shadow(0 0 20px rgba(34,197,94,0.86))
    drop-shadow(0 0 34px rgba(45,212,191,0.42))
    drop-shadow(0 12px 12px rgba(0,0,0,0.48)) !important;
}

body.perf-lite .qd-fakeout {
  animation: qdFakeFloat 1.5s linear forwards !important;
}

body.perf-lite .qd-fakeout-flash {
  animation: qdFakeFlash 0.32s ease-out forwards !important;
}

body.perf-lite .qd-fakeout-leaf img {
  filter: drop-shadow(0 0 10px rgba(251,191,36,0.45)) !important;
}

body.perf-lite .qd-fakeout-crow img {
  filter: drop-shadow(0 0 14px rgba(2,6,23,0.95)) !important;
}

body.perf-lite .qd-fakeout-question img {
  filter: drop-shadow(0 0 18px rgba(168,85,247,0.72)) !important;
}

body.perf-lite .mh-mole-btn.hit-exit {
  animation: mhHitExit 0.12s ease-in forwards !important;
}

body.perf-lite .mh-hit-effect {
  animation: mhHitFade 0.82s ease-out forwards !important;
}

body.perf-lite .mh-hit-effect.self {
  filter: drop-shadow(0 0 8px rgba(56,189,248,0.58)) !important;
}

body.perf-lite .mh-hit-effect.other {
  filter: drop-shadow(0 0 7px rgba(250,204,21,0.42)) !important;
}

body.perf-lite .mh-money-piece {
  animation: mhMoneySpray .96s cubic-bezier(.15,.78,.2,1) var(--md) forwards !important;
}

body.perf-lite .mh-money-piece.coin {
  box-shadow: 0 0 10px rgba(250,204,21,0.78), inset 0 -2px 0 rgba(120,53,15,0.22) !important;
}

body.perf-lite .mh-money-piece.bill {
  box-shadow: 0 0 10px rgba(34,197,94,0.46) !important;
}

body.perf-lite .mh-target-effect::before {
  animation: mhEffectRing .48s ease-out forwards !important;
}

body.perf-lite .mh-target-core {
  animation: mhEffectCore .62s cubic-bezier(.16,.82,.22,1) forwards !important;
  text-shadow: 0 2px 0 rgba(15,23,42,0.72) !important;
}

body.perf-lite .mh-target-piece {
  animation: mhEffectPiece .82s cubic-bezier(.14,.78,.2,1) var(--td) forwards !important;
}

body.perf-lite .mh-target-effect-normal::before {
  box-shadow: 0 0 18px rgba(251,191,36,0.38) !important;
}

body.perf-lite .mh-target-effect-fake::before {
  box-shadow: 0 0 16px rgba(120,53,15,0.32) !important;
}

body.perf-lite .mh-target-effect-bomb::before {
  box-shadow: 0 0 28px rgba(248,113,113,0.9), 0 0 52px rgba(251,146,60,0.46) !important;
}

body.perf-lite .mh-target-effect-bomb .mh-target-core {
  box-shadow: 0 0 24px rgba(248,113,113,0.76) !important;
}

body.perf-lite .mh-target-effect-boss::before {
  box-shadow: 0 0 12px rgba(220,38,38,0.36), 0 0 20px rgba(124,58,237,0.2) !important;
}

body.perf-lite .mh-target-piece.star,
body.perf-lite .mh-target-piece.spark {
  filter: drop-shadow(0 0 8px rgba(250,204,21,0.72)) !important;
}

body.perf-lite .mh-target-piece.smoke {
  filter: blur(.5px) !important;
}

body.perf-lite .rr-tile {
  transition-duration: .08s !important;
}

body.perf-lite .rr-tile.active {
  animation: rr-target-pulse .48s ease-in-out infinite alternate !important;
  filter: saturate(1.28) !important;
}

body.perf-lite .rr-tile.kind-hit.tone-green {
  box-shadow: 0 0 34px rgba(34,197,94,0.74), inset 0 -18px 28px rgba(5,46,22,0.28) !important;
}

body.perf-lite .rr-tile.kind-hit.tone-cyan {
  box-shadow: 0 0 34px rgba(34,211,238,0.74), inset 0 -18px 28px rgba(8,47,73,0.28) !important;
}

body.perf-lite .rr-tile.kind-hit.tone-amber {
  box-shadow: 0 0 34px rgba(250,204,21,0.74), inset 0 -18px 28px rgba(120,53,15,0.26) !important;
}

body.perf-lite .rr-tile.kind-hit.tone-violet {
  box-shadow: 0 0 34px rgba(167,139,250,0.7), inset 0 -18px 28px rgba(46,16,101,0.26) !important;
}

body.perf-lite .rr-tile.kind-trap,
body.perf-lite .rr-tile.kind-trap.tone-red {
  box-shadow: 0 0 36px rgba(239,68,68,0.78), inset 0 -18px 28px rgba(69,10,10,0.34) !important;
}

body.perf-lite .rr-tap-feedback {
  animation: rr-tap-feedback-pop .82s ease-out forwards !important;
}

body.perf-lite .rr-tap-feedback.hit {
  text-shadow: 0 1px 4px rgba(2,6,23,0.75), 0 0 10px rgba(34,197,94,0.34) !important;
}

body.perf-lite .rr-tap-feedback.miss {
  text-shadow: 0 1px 4px rgba(2,6,23,0.75), 0 0 10px rgba(248,113,113,0.34) !important;
}

body.perf-lite .tl-light-stack {
  box-shadow: inset 0 0 18px rgba(0,0,0,0.8), 0 14px 24px rgba(0,0,0,0.28) !important;
}

body.perf-lite .tl-lamp {
  transition-duration: .12s !important;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.9) !important;
}

body.perf-lite .tl-light-stack[data-signal="red"] .tl-lamp-red {
  box-shadow: 0 0 28px rgba(239,68,68,0.78), inset 0 -8px 12px rgba(127,29,29,0.45) !important;
}

body.perf-lite .tl-light-stack[data-signal="green"] .tl-lamp-green {
  box-shadow: 0 0 28px rgba(34,197,94,0.78), inset 0 -8px 12px rgba(20,83,45,0.45) !important;
}

body.perf-lite .tl-light-stack[data-signal="yellow"] .tl-lamp,
body.perf-lite .tl-light-stack[data-signal="pregame"] .tl-lamp {
  box-shadow: 0 0 24px rgba(250,204,21,0.66), inset 0 -8px 12px rgba(113,63,18,0.42) !important;
}

body.perf-lite .tl-car {
  transition-duration: .22s !important;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45)) !important;
}

body.perf-lite .tl-car-label,
body.perf-lite .tl-car-taunt,
body.perf-lite .tl-action {
  box-shadow: 0 3px 10px rgba(0,0,0,0.28) !important;
}

body.perf-lite .tl-car-taunt-red {
  text-shadow: 0 2px 5px rgba(0,0,0,0.35) !important;
}

body.perf-lite .tl-action:disabled {
  filter: grayscale(0.3) !important;
}

body.perf-lite .cm-mascot-stage img {
  filter: drop-shadow(0 12px 16px rgba(104,70,43,0.18)) !important;
}

body.perf-lite .cm-mascot-stage.pose-up img {
  animation: cmPoseUp var(--cm-pose-ms, 220ms) ease !important;
}

body.perf-lite .cm-mascot-stage.pose-down img {
  animation: cmPoseDown var(--cm-pose-ms, 220ms) ease !important;
}

body.perf-lite .cm-mascot-stage.pose-left img {
  animation: cmPoseLeft var(--cm-pose-ms, 220ms) ease !important;
}

body.perf-lite .cm-mascot-stage.pose-right img {
  animation: cmPoseRight var(--cm-pose-ms, 220ms) ease !important;
}

body.perf-lite .cm-mascot-stage.pose-fall img {
  animation: cmPoseFall 420ms cubic-bezier(.18,.84,.22,1) !important;
}

body.perf-lite .cm-wrong-toast,
body.perf-lite .cm-paw-btn,
body.perf-lite .cm-intro-overlay {
  transition-duration: .14s !important;
}

body.perf-lite .cm-wrong-toast,
body.perf-lite .cm-paw-btn,
body.perf-lite .cm-intro-card,
body.perf-lite .cm-intro-count {
  box-shadow: 0 8px 18px rgba(112,72,42,0.12) !important;
}

body.perf-lite .cm-paw-btn.pressed,
body.perf-lite .cm-paw-btn.pressed:disabled {
  filter: brightness(1.05) saturate(1.08) !important;
}

body.perf-lite .cm-paw-btn:disabled {
  filter: saturate(0.62) !important;
}

body.perf-lite .cm-paw-btn.pressed .cm-paw-shape {
  animation: cmPawPress 0.18s ease !important;
}

body.perf-lite .cm-intro-overlay.counting .cm-intro-count {
  animation: cmCountdownPop 0.72s ease infinite !important;
}

body.perf-lite .nc-effect-bomb {
  animation: ncBombBoom 0.9s ease-out forwards !important;
}

body.perf-lite .nc-climber-floor {
  text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
}

body.perf-lite .nc-track.is-me .nc-climber-avatar {
  box-shadow: 0 0 10px rgba(56,189,248,0.35) !important;
}

body.perf-lite .nc-climber-avatar.is-frozen {
  filter: hue-rotate(180deg) brightness(1.2) grayscale(0.4) !important;
  box-shadow: 0 0 15px rgba(186,230,253,0.8) !important;
}

body.perf-lite .nc-target-selectable .nc-climber-avatar {
  animation: nc-pulse 0.8s ease-in-out infinite alternate !important;
  box-shadow: 0 0 14px rgba(239,68,68,0.7) !important;
}

body.perf-lite .nc-card {
  transition-duration: .1s !important;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3) !important;
}

body.perf-lite .nc-attack-hint {
  animation: nc-blink 1s ease-in-out infinite alternate !important;
}

body.perf-ios {
  -webkit-overflow-scrolling: auto;
}

/* iPhone WebKit gets the same gameplay feedback, but avoids the GPU-heavy
   glow/filter layer that makes long battle rounds heat up. */
body.perf-ios .qd-signal-img,
body.perf-ios .qd-fakeout-leaf img,
body.perf-ios .qd-fakeout-crow img,
body.perf-ios .qd-fakeout-question img,
body.perf-ios .mh-hit-effect,
body.perf-ios .mh-target-piece,
body.perf-ios .rr-tile.active,
body.perf-ios .tl-car,
body.perf-ios .cm-mascot-stage img,
body.perf-ios .cm-paw-btn,
body.perf-ios .nc-climber-avatar,
body.perf-ios .nc-climber-avatar.is-frozen {
  filter: none !important;
}

body.perf-ios[data-screen="quick-draw"][data-qd-phase="resolution"] #qdStage::after {
  filter: none !important;
}

body.perf-ios .qd-center-prompt,
body.perf-ios .qd-round-result,
body.perf-ios .qd-round-board,
body.perf-ios .cm-wrong-toast,
body.perf-ios .cm-paw-btn,
body.perf-ios .cm-intro-card,
body.perf-ios .cm-intro-count,
body.perf-ios .tl-light-stack,
body.perf-ios .tl-car-label,
body.perf-ios .tl-car-taunt,
body.perf-ios .tl-action,
body.perf-ios .nc-card {
  box-shadow: 0 4px 12px rgba(0,0,0,0.18) !important;
}

body.perf-ios .mh-money-piece.coin,
body.perf-ios .mh-money-piece.bill,
body.perf-ios .mh-target-effect-normal::before,
body.perf-ios .mh-target-effect-fake::before,
body.perf-ios .mh-target-effect-bomb::before,
body.perf-ios .mh-target-effect-bomb .mh-target-core,
body.perf-ios .mh-target-effect-boss::before,
body.perf-ios .rr-tile.kind-hit,
body.perf-ios .rr-tile.kind-trap,
body.perf-ios .nc-track.is-me .nc-climber-avatar,
body.perf-ios .nc-target-selectable .nc-climber-avatar {
  box-shadow: none !important;
}
