/* app.css: the PWA shell of Monster Bouncer around the game canvas (reset, full-screen #app, the CSS boot splash: monster heads
   peeking over the brass marquee sign, toasts, safe-area utilities). The game draws on a canvas created by
   js/core/stage.js; HTML here is only the chrome around it. Colours follow the game palette (GAME-SPEC §5). */

:root {
  --bg: #0c0b24;
  --night: #1b1a4d;
  --street: #2a2760;
  --ink: #ffffff;
  --outline: #14112e;
  --brass: #d9a441;
  --brass-dark: #8a5a14;
  --amber: #ffb347;
  --velvet: #b3203a;
  --neon: #ff4fa3;
  --violet: #6a2fb0;
  --violet-soft: #a06cd5;
  --cyan: #4cc9f0;
  --pink: #ff4fa3;
  --panel: rgba(34, 31, 92, 0.94);
  --good: #22c55e;
  --bad: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --font: 'Poppins', 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'Cairo', 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

/* ---- modern reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { height: 100%; min-height: 100%; }
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

html, body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
body {
  position: fixed;
  inset: 0;
  width: 100%;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* i18n.set('ar') puts dir="rtl" / lang="ar" on <html>: Arabic leads with Cairo */
:lang(ar), [dir="rtl"] { font-family: var(--font-ar); }

/* ---- app container (the stage canvas is appended inside by main.js) ----
   Wider than 390 x 700 (tablets, desktop, a tablet in landscape) the stage is centred between side bars. They are part
   of the street, never flat black: this backdrop is the play street's own palette (night sky -> indigo facade -> cobbles,
   GAME-SPEC §5) with the party window's amber glow at its height and a violet haze off the street, and engine.js lays
   #ambient (the live scene, mirrored out of the stage edges) over it. Touches that start in a bar still reach the game
   (input.js). Phones never show bars (an iPhone SE gets a 2 px sliver of this backdrop). */
body,
#app {
  background:
    radial-gradient(46% 30% at 50% 40%, rgba(255, 179, 71, 0.15), rgba(255, 179, 71, 0) 72%),
    radial-gradient(90% 26% at 50% 104%, rgba(160, 108, 213, 0.2), rgba(160, 108, 213, 0) 70%),
    linear-gradient(180deg, #07061a 0%, #100e34 16%, #1e1a52 34%, #2a2766 50%, #1f1c50 66%, #121038 82%, #0b0a26 100%);
  background-color: var(--bg);
}
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
/* the letterbox ambience (engine.js sizes it, a bit past every screen edge, and sets the seams): the scene's light,
   blurred into colour fields, dimmed so the stage keeps the focus, fading out toward the screen edges into the backdrop
   above. Decor only: touches fall through to #app. */
#ambient {
  position: fixed;
  display: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease;
  filter: blur(34px) brightness(0.56) saturate(1.35);
  -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, var(--edgeA, 0.3)) 0%, #000 var(--seamL, 30%), #000 var(--seamR, 70%), rgba(0, 0, 0, var(--edgeA, 0.3)) 100%);
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, var(--edgeA, 0.3)) 0%, #000 var(--seamL, 30%), #000 var(--seamR, 70%), rgba(0, 0, 0, var(--edgeA, 0.3)) 100%);
}
#ambient.on { opacity: 1; }
/* the stage (stage.js gives the visible canvas id="stage") lifts off its own glow: only ever seen beside a letterbox */
#stage { box-shadow: 0 0 44px 6px rgba(4, 3, 18, 0.6); }

/* ---- boot splash: CSS-only logo (three monster heads peeking over the brass marquee sign, chasing bulbs, carrying the
   MONSTER / BOUNCER lockup of js/game/logo.js: a googly eye for the O, mint over gold, a velvet rope on brass stanchions) ---- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background:
    radial-gradient(60% 34% at 50% 44%, rgba(255, 179, 71, 0.22), rgba(255, 179, 71, 0) 70%),
    radial-gradient(70% 40% at 50% 104%, rgba(160, 108, 213, 0.22), rgba(160, 108, 213, 0) 70%),
    linear-gradient(180deg, var(--street) 0%, var(--night) 50%, var(--bg) 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}
#splash.fade { opacity: 0; visibility: hidden; pointer-events: none; }

.splash-logo {
  position: relative;
  width: 284px;
  height: 196px;
  animation: splash-pulse 2.2s ease-in-out infinite;
}
.splash-glow {
  position: absolute;
  inset: -30px -40px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 79, 163, 0.32), rgba(255, 79, 163, 0) 100%);
  filter: blur(6px);
}
/* a monster head: sticker circle with an ink outline, eyes are <b> (sclera + pupil), lower half hidden behind the sign */
.splash-mon {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 76px;
  height: 76px;
  margin-left: -38px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 34% 30%, #9be3f8 0%, #4cc9f0 42%, #2b9bc9 100%);
  box-shadow: 0 0 0 3px var(--outline), inset -5px -7px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  justify-content: center;
  gap: 4px;
  padding-top: 18px;
  animation: splash-peek 2.2s cubic-bezier(0.3, 1.6, 0.5, 1) infinite;
}
.splash-mon b {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 58% 56%, #1d1840 0 30%, #fff 33%);
  box-shadow: 0 0 0 2.5px var(--outline);
  animation: splash-blink 3.1s infinite;
}
.splash-mon--l {
  left: 26%;
  top: 22px;
  width: 58px;
  height: 64px;
  margin-left: -29px;
  border-radius: 48% 48% 40% 40%;
  background: radial-gradient(circle at 34% 30%, #ffb0b4 0%, #ff6b6b 45%, #d9434d 100%);
  padding-top: 14px;
  animation-delay: 0.25s;
}
.splash-mon--l b { width: 17px; height: 17px; }
.splash-mon--r {
  left: 75%;
  top: 18px;
  width: 64px;
  height: 64px;
  margin-left: -32px;
  border-radius: 22% 22% 18% 18%;
  background: radial-gradient(circle at 34% 30%, #ffe08a 0%, #ffc233 45%, #e39b12 100%);
  gap: 2px;
  padding-top: 15px;
  animation-delay: 0.45s;
}
.splash-mon--r b { width: 15px; height: 15px; animation-delay: 1.2s; }
.splash-sign {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 128px;
  border-radius: 24px;
  border: 7px solid var(--brass);
  background:
    repeating-linear-gradient(-62deg, rgba(255, 255, 255, 0.05) 0 22px, rgba(255, 255, 255, 0) 22px 46px),
    linear-gradient(180deg, #3a2470, #221a55);
  box-shadow:
    0 0 0 3px var(--outline),
    inset 0 0 0 2px var(--brass-dark),
    0 12px 26px rgba(6, 4, 22, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* chasing bulbs on the brass frame */
.splash-sign::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 22px;
  background:
    radial-gradient(circle, #fff3c4 0 2.2px, rgba(255, 179, 71, 0.55) 3px, rgba(255, 179, 71, 0) 5px) 0 0 / 18px 7px repeat-x,
    radial-gradient(circle, #fff3c4 0 2.2px, rgba(255, 179, 71, 0.55) 3px, rgba(255, 179, 71, 0) 5px) 0 100% / 18px 7px repeat-x;
  animation: splash-chase 0.6s linear infinite;
  pointer-events: none;
}
.splash-word {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Baloo 2', 'Poppins', system-ui, sans-serif;
  font-weight: 800;
  font-size: 45px;
  line-height: 0.88;
  letter-spacing: 0.02em;
  padding: 4px 0 15px;
  white-space: nowrap;
  /* the lockup is Latin: keep it in LTR order even after i18n puts dir="rtl" on <html> mid-fade */
  direction: ltr;
  unicode-bidi: isolate;
}
.splash-line {
  display: block;
  text-shadow:
    -2.5px -2.5px 0 var(--outline), 2.5px -2.5px 0 var(--outline), -2.5px 2.5px 0 var(--outline), 2.5px 2.5px 0 var(--outline),
    0 -2.5px 0 var(--outline), 0 2.5px 0 var(--outline), -2.5px 0 0 var(--outline), 2.5px 0 0 var(--outline),
    0 5px 0 var(--outline),
    0 0 12px rgba(255, 79, 163, 0.95), 0 0 26px rgba(255, 79, 163, 0.6);
}
.splash-line--m { color: #8fe878; }
.splash-line--b { color: #ffcf5a; margin-top: 2px; }
/* the O of MONSTER: a googly eye (sclera + pupil), outlined like the letters, blinking with the heads */
.splash-eye {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin: 0 0.02em;
  vertical-align: -0.02em;
  border-radius: 50%;
  background: radial-gradient(circle at 58% 56%, #1d1840 0 27%, #fff 30% 64%, #ddd6f6 100%);
  box-shadow: 0 0 0 2.5px var(--outline), 0 3px 0 2.5px var(--outline), 0 0 12px rgba(255, 79, 163, 0.9);
  animation: splash-blink 3.1s 0.6s infinite;
}
/* the velvet rope hanging under BOUNCER between two brass stanchion heads */
.splash-rope {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  height: 14px;
  border: 4px solid #b3203a;
  border-top: 0;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  box-shadow: 0 2px 0 var(--outline);
  pointer-events: none;
}
.splash-rope::before,
.splash-rope::after {
  content: '';
  position: absolute;
  top: -8px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #fff1c4 0 18%, var(--brass) 45%, var(--brass-dark) 100%);
  box-shadow: 0 0 0 2px var(--outline);
}
.splash-rope::before { left: -10px; }
.splash-rope::after { right: -10px; }
.splash-dots { display: flex; gap: 8px; }
.splash-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  opacity: 0.3;
  animation: splash-dot 1.2s ease-in-out infinite;
}
.splash-dots i:nth-child(2) { animation-delay: 0.15s; }
.splash-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes splash-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes splash-peek {
  0% { transform: translateY(26px); }
  18%, 78% { transform: translateY(0); }
  48% { transform: translateY(-3px) rotate(-3deg); }
  100% { transform: translateY(26px); }
}
@keyframes splash-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes splash-chase { to { background-position: 18px 0, -18px 100%; } }
@keyframes splash-dot { 0%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-5px); } }

@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-mon, .splash-mon b, .splash-eye, .splash-dots i, .splash-sign::before { animation: none; }
}

/* boot failure (index.html's watchdog adds .failed): motion stops and a retry pill replaces the dots */
#splash.failed .splash-logo, #splash.failed .splash-mon, #splash.failed .splash-eye, #splash.failed .splash-sign::before { animation: none; }
.splash-retry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 48px;
  max-width: min(92vw, 360px);
  padding: 10px 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  animation: toast-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.splash-retry:active { background: rgba(255, 255, 255, 0.22); transform: scale(0.97); }
.splash-retry b { font-weight: 700; }
.splash-retry [lang="ar"] { font-family: var(--font-ar); font-size: 13px; opacity: 0.85; }

/* ---- 'turn your phone' card: a phone held sideways letterboxes the portrait stage to a ~217 px column, so it gets this
   instead. The media query must match TUNE.rotateQuery in js/engine.js (which suspends the loop while it shows).
   Tablets in landscape are left playable on purpose: an iPad's column is 414-457 css px wide (457 x 820 on an 11-inch,
   a phone's whole screen), the bars carry the scene's ambient light, and a tablet docked in a keyboard case or a stand
   cannot turn at all.
   Art: a brass sticker phone swings from landscape to upright (overshoot), a monster peeks up from the party glow on its
   screen, an amber arrow shows the turn. Copy follows <html lang> (i18n): Baloo 2 / Cairo, outlined like the wordmark. ---- */
#rotate {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 6vw, 56px);
  padding: max(12px, var(--safe-top)) max(24px, var(--safe-right)) max(12px, var(--safe-bottom)) max(24px, var(--safe-left));
  background:
    radial-gradient(60% 80% at 50% 50%, rgba(255, 179, 71, 0.16), rgba(255, 179, 71, 0) 70%),
    radial-gradient(60% 60% at 80% 110%, rgba(160, 108, 213, 0.22), rgba(160, 108, 213, 0) 70%),
    linear-gradient(180deg, var(--street) 0%, var(--night) 55%, var(--bg) 100%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 540px) {
  #rotate { display: flex; }
}

.rot-art { position: relative; flex: 0 0 auto; width: 170px; height: 170px; }
.rot-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 79, 163, 0.3), rgba(255, 79, 163, 0) 100%);
  filter: blur(4px);
}
.rot-arrow { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; animation: rot-arrow 2.6s ease-in-out infinite; }
.rot-arrow__ink { fill: none; stroke: var(--outline); stroke-width: 12; stroke-linecap: round; }
.rot-arrow__line { fill: none; stroke: var(--amber); stroke-width: 6; stroke-linecap: round; }
.rot-arrow__head { fill: var(--amber); stroke: var(--outline); stroke-width: 3; stroke-linejoin: round; paint-order: stroke; }

/* the phone: brass sticker body (flat base, 3 px ink outline, top-left highlight, bottom-right shade) around a night screen */
.rot-phone {
  position: absolute;
  left: 53px;
  top: 33px;
  width: 64px;
  height: 112px;
  border-radius: 15px;
  background:
    radial-gradient(70% 40% at 26% 14%, rgba(255, 247, 214, 0.65), rgba(255, 247, 214, 0) 70%),
    linear-gradient(160deg, #f1c35f 0%, var(--brass) 48%, #b37f26 100%);
  box-shadow:
    0 0 0 3px var(--outline),
    inset -4px -5px 0 rgba(138, 90, 20, 0.45),
    0 10px 20px rgba(6, 4, 22, 0.5);
  transform-origin: 50% 50%;
  animation: rot-turn 2.6s cubic-bezier(0.45, 0, 0.3, 1) infinite;
}
.rot-screen {
  position: absolute;
  left: 7px;
  top: 12px;
  right: 7px;
  bottom: 14px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #12113a 0%, #1b1a4d 60%, #2a2760 100%);
  box-shadow: 0 0 0 2.5px var(--outline);
}
.rot-spill {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -40%;
  height: 80%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 179, 71, 0.85), rgba(255, 179, 71, 0) 100%);
}
.rot-speaker {
  position: absolute;
  left: 50%;
  top: 5px;
  width: 16px;
  height: 3px;
  margin-left: -8px;
  border-radius: 2px;
  background: var(--outline);
}
/* the peeking monster: cyan sticker head with two eyes (sclera + pupil), rising from the bottom of the screen */
.rot-mon {
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  border-radius: 50% 50% 44% 44%;
  background: radial-gradient(circle at 34% 30%, #9be3f8 0%, #4cc9f0 42%, #2b9bc9 100%);
  box-shadow: 0 0 0 2.5px var(--outline);
  display: flex;
  justify-content: center;
  gap: 2px;
  padding-top: 8px;
  animation: rot-peek 2.6s cubic-bezier(0.3, 1.5, 0.5, 1) infinite;
}
/* eyes look up toward the arrow; a small open grin under them */
.rot-mon b {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 62% 36%, #1d1840 0 32%, #fff 35%);
  box-shadow: 0 0 0 2px var(--outline);
}
.rot-mon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 22px;
  width: 9px;
  height: 5px;
  margin-left: -4.5px;
  border-radius: 0 0 6px 6px;
  background: #1d1840;
}
/* glass sheen across the phone screen */
.rot-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.16) 0 28%, rgba(255, 255, 255, 0) 29%);
  pointer-events: none;
}

.rot-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: 46vw; text-align: start; }
.rot-title {
  font-family: 'Baloo 2', 'Poppins', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 5.2vw, 42px);
  line-height: 1.05;
  color: #ffd98a;
  text-shadow:
    0 2px 0 #ff8a5c,
    -2px -2px 0 var(--outline), 2px -2px 0 var(--outline), -2px 2px 0 var(--outline), 2px 2px 0 var(--outline),
    0 4px 0 var(--outline),
    0 0 14px rgba(255, 79, 163, 0.75);
}
.rot-sub {
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(14px, 2vw, 17px);
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 2px 0 rgba(20, 17, 46, 0.8);
}
.rot-ar { display: none; }
html[lang="ar"] .rot-en { display: none; }
html[lang="ar"] .rot-ar { display: inline; }
html[lang="ar"] .rot-title { font-family: var(--font-ar); font-weight: 800; line-height: 1.25; }
html[lang="ar"] .rot-sub { font-family: var(--font-ar); font-weight: 700; font-size: clamp(16px, 2.4vw, 19px); }

/* landscape (wrong) -> overshoot -> upright, hold, swing back */
@keyframes rot-turn {
  0%, 14% { transform: rotate(-90deg); }
  38% { transform: rotate(9deg); }
  48%, 82% { transform: rotate(0deg); }
  100% { transform: rotate(-90deg); }
}
@keyframes rot-peek {
  0%, 40% { transform: translateY(30px); }
  56%, 80% { transform: translateY(0); }
  92%, 100% { transform: translateY(30px); }
}
@keyframes rot-arrow {
  0%, 8% { opacity: 0.35; transform: rotate(-12deg) scale(0.96); }
  30% { opacity: 1; transform: rotate(0deg) scale(1); }
  60%, 84% { opacity: 0.85; transform: rotate(0deg) scale(1); }
  100% { opacity: 0.35; transform: rotate(-12deg) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
  .rot-phone, .rot-mon, .rot-arrow { animation: none; }
}

/* ---- font warm-up (invisible text in each bundled family so the browser fetches them during the splash) ---- */
.font-warm { position: absolute; left: -9999px; top: 0; opacity: 0; pointer-events: none; font-size: 16px; }
.font-warm__baloo { font-family: 'Baloo 2', sans-serif; font-weight: 800; }
.font-warm__poppins { font-family: 'Poppins', sans-serif; font-weight: 800; }
.font-warm__cairo { font-family: 'Cairo', sans-serif; font-weight: 700; }

/* ---- utilities ---- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* HTML overlays on top of the canvas: the layer lets touches through, its children catch them */
.ui-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.ui-layer > * { pointer-events: auto; }
.scrollable { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* safe-area padding (never less than the engine minimums: 24 top, 16 bottom/sides) */
.safe-top { padding-top: max(24px, var(--safe-top)); }
.safe-bottom { padding-bottom: max(16px, var(--safe-bottom)); }
.safe-x { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
.safe-all {
  padding-top: max(24px, var(--safe-top));
  padding-right: max(16px, var(--safe-right));
  padding-bottom: max(16px, var(--safe-bottom));
  padding-left: max(16px, var(--safe-left));
}

/* ---- toasts: small HTML pills. Append a .toast to <body> (self-positioned) or into a .toast-layer (stacked). ---- */
.toast-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 88px);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 88px);
  translate: -50% 0;
  z-index: 90;
  max-width: min(92vw, 360px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--panel);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  unicode-bidi: plaintext;   /* each pill picks its own direction, whatever document.dir is */
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  /* no backdrop-filter: over a canvas repainting every frame it costs a per-frame blur on mid-range phones */
  pointer-events: none;
  animation: toast-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.toast-layer > .toast { position: static; translate: none; }
.toast.out { animation: toast-out 0.25s ease-in forwards; }
.toast--good { background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(16, 150, 80, 0.95)); }
.toast--bad { background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(180, 40, 60, 0.95)); }
.toast--accent { background: linear-gradient(135deg, rgba(106, 47, 176, 0.95), rgba(160, 108, 213, 0.95)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.96); } }

/* ---- no-JS notice ---- */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: #fff;
  font-weight: 600;
  text-align: center;
}
