/* QRBAK table games — the full-screen shell every game runs in (web/templates/menu/play.html, play.js).
   A night-lounge look: slow aurora behind liquid-glass panels, the venue's colour as the accent. */

@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 200 800; font-stretch: 75% 100%; font-display: swap;
  src: url('/static/fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 200 800; font-stretch: 75% 100%; font-display: swap;
  src: url('/static/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('/static/fonts/plus-jakarta-sans-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('/static/fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('/static/fonts/plus-jakarta-sans-cyrillic-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F; }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('/static/fonts/plus-jakarta-sans-vietnamese-wght-normal.woff2') format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }

:root {
  --acc: #EF3B36;
  --on-acc: #fff;
  --bg: #07080C;
  --ink: #F5F6FA;
  --ink-2: rgba(245, 246, 250, 0.72);
  --ink-3: rgba(245, 246, 250, 0.46);
  --line: rgba(255, 255, 255, 0.14);
  --glass: linear-gradient(140deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05) 46%, rgba(255, 255, 255, 0.09));
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.42), inset 0 -1px 0 rgba(255, 255, 255, 0.08), inset 1px 0 0 rgba(255, 255, 255, 0.10), inset -1px 0 0 rgba(255, 255, 255, 0.05);
  --good: #34D399;
  --bad: #FB7185;
  --warn: #FBBF24;
  --display: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --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);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
input { -webkit-user-select: text; user-select: text; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- aurora ----------------------------------------------------------------------------- */
.qg-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 80% at 50% 0%, #141826 0%, #0A0C13 55%, #07080C 100%); }
.qg-bg i { position: absolute; width: 78vmax; height: 78vmax; border-radius: 50%; filter: blur(70px); opacity: 0.5; will-change: transform; }
.qg-bg i:nth-child(1) { left: -30vmax; top: -34vmax; background: radial-gradient(circle, var(--acc) 0%, transparent 62%); animation: qgDrift1 26s ease-in-out infinite alternate; }
.qg-bg i:nth-child(2) { right: -36vmax; top: 18vmax; background: radial-gradient(circle, #4F6BFF 0%, transparent 60%); opacity: 0.34; animation: qgDrift2 32s ease-in-out infinite alternate; }
.qg-bg i:nth-child(3) { left: -8vmax; bottom: -46vmax; background: radial-gradient(circle, #B44CFF 0%, transparent 60%); opacity: 0.28; animation: qgDrift3 38s ease-in-out infinite alternate; }
.qg-bg::after { content: ''; position: absolute; inset: 0; opacity: 0.5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E"); }
@keyframes qgDrift1 { to { transform: translate3d(22vmax, 14vmax, 0) scale(1.15); } }
@keyframes qgDrift2 { to { transform: translate3d(-26vmax, -10vmax, 0) scale(0.9); } }
@keyframes qgDrift3 { to { transform: translate3d(18vmax, -18vmax, 0) scale(1.2); } }
body.is-playing .qg-bg i { animation-play-state: paused; opacity: 0.3; }

/* --- screens ---------------------------------------------------------------------------- */
#qg { position: fixed; inset: 0; z-index: 1; }
.qg-screen {
  position: absolute; inset: 0; display: none; flex-direction: column; gap: 18px;
  padding: calc(14px + var(--sat)) calc(18px + var(--sar)) calc(22px + var(--sab)) calc(18px + var(--sal));
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.qg-screen::-webkit-scrollbar { display: none; }
.qg-screen.is-on { display: flex; animation: qgIn 0.5s var(--ease) both; }
.qg-screen.is-out { display: flex; animation: qgOut 0.22s ease both; pointer-events: none; }
@keyframes qgIn { from { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.98); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes qgOut { to { opacity: 0; transform: scale(1.03); filter: blur(6px); } }
.qg-screen > * { width: 100%; max-width: 520px; margin-inline: auto; flex-shrink: 0; }
.qg-grow { flex: 1 1 auto; min-height: 8px; }
/* The main action of a long screen: stays at the bottom while the rest scrolls under it. */
.qg-dock { position: sticky; bottom: 0; z-index: 4; isolation: isolate; margin-bottom: calc(-22px - var(--sab)); padding: 22px 0 calc(22px + var(--sab)); }
.qg-dock::before { content: ''; position: absolute; z-index: -1; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(to top, rgba(7, 8, 12, 0.9) 45%, rgba(7, 8, 12, 0)); }

.glass {
  background: var(--glass); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: var(--glass-edge), 0 18px 44px rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(26px) saturate(170%); backdrop-filter: blur(26px) saturate(170%);
}

/* --- buttons ---------------------------------------------------------------------------- */
.qg-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 14px 22px; border-radius: 20px; font-weight: 750; font-size: 1.02rem; letter-spacing: -0.01em;
  color: var(--on-acc); text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--acc) 88%, #fff) 0%, var(--acc) 48%, color-mix(in srgb, var(--acc) 82%, #000) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 12px 28px color-mix(in srgb, var(--acc) 42%, transparent);
  transition: transform 0.16s var(--spring), filter 0.16s ease, opacity 0.16s ease; overflow: hidden;
}
.qg-btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.34) 48%, transparent 62%); transform: translateX(-120%); animation: qgSheen 4.2s ease-in-out infinite; pointer-events: none; }
@keyframes qgSheen { 0%, 62% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.qg-btn:active { transform: scale(0.96); filter: brightness(1.08); }
.qg-btn[disabled] { opacity: 0.45; pointer-events: none; }
.qg-btn[disabled]::after, .qg-btn.ghost::after, .qg-btn.sm::after { display: none; }
.qg-btn.ghost { color: var(--ink); background: var(--glass); border: 1px solid var(--line); box-shadow: var(--glass-edge), 0 10px 26px rgba(0, 0, 0, 0.26); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); }
.qg-btn.good { --acc: #22C55E; --on-acc: #05230F; }
.qg-btn.bad { --acc: #F43F5E; --on-acc: #fff; }
.qg-btn.warn { --acc: #F59E0B; --on-acc: #2A1700; }
.qg-btn.sm { min-height: 44px; padding: 9px 16px; border-radius: 15px; font-size: 0.92rem; }
.qg-btn.big { min-height: 68px; font-size: 1.18rem; border-radius: 24px; }
.qg-btn.block { display: flex; width: 100%; }
.qg-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.qg-ibtn { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--ink);
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  transition: transform 0.16s var(--spring); }
.qg-ibtn:active { transform: scale(0.9); }
.qg-ibtn svg { width: 22px; height: 22px; }
[dir="rtl"] .qg-ibtn.flip svg { transform: scaleX(-1); }
.qg-link { color: var(--ink-2); font-weight: 650; font-size: 0.92rem; padding: 10px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-3); }

/* --- top bar, titles --------------------------------------------------------------------- */
.qg-top { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.qg-top-title { min-width: 0; flex: 1; }
.qg-top-title small { display: block; font-size: 0.72rem; font-weight: 650; color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qg-top-title h1 { font-family: var(--display); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.qg-lead { color: var(--ink-2); font-size: 0.98rem; text-wrap: balance; }
.qg-h { font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; font-size: clamp(1.7rem, 7.4vw, 2.5rem); text-wrap: balance; }
.qg-sub { color: var(--ink-2); font-size: 1rem; text-wrap: balance; }
.qg-muted { color: var(--ink-3); font-size: 0.86rem; }
.qg-center { text-align: center; align-items: center; }

/* --- list of games (hub) ----------------------------------------------------------------- */
.qg-join { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.qg-join label { font-weight: 700; font-size: 0.92rem; }
.qg-join-row { display: flex; gap: 10px; }
.qg-join input, .qg-input {
  flex: 1; min-width: 0; height: 48px; padding: 0 16px; border-radius: 15px; border: 1px solid var(--line); outline: none;
  background: rgba(0, 0, 0, 0.32); color: var(--ink); font-weight: 700; font-size: 1.05rem; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.qg-join input { letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.qg-join input::placeholder { letter-spacing: 0; font-weight: 500; font-size: 0.9rem; color: var(--ink-3); }
.qg-input::placeholder { color: var(--ink-3); font-weight: 500; }
.qg-join input:focus, .qg-input:focus { border-color: color-mix(in srgb, var(--acc) 70%, #fff); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 0 4px color-mix(in srgb, var(--acc) 26%, transparent); }
.qg-join-err { color: var(--bad); font-size: 0.86rem; font-weight: 600; }
.qg-sec h2 { font-family: var(--display); font-size: 1.12rem; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.qg-sec h2::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
[dir="rtl"] .qg-sec h2::after { background: linear-gradient(270deg, var(--line), transparent); }
.qg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.qg-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 10px 6px 12px; border-radius: 22px;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--glass-edge), 0 10px 24px rgba(0, 0, 0, 0.26);
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  transition: transform 0.2s var(--spring); animation: qgTile 0.55s var(--ease) both; }
.qg-tile:active { transform: scale(0.94); }
.qg-tile:nth-child(3n+2) { animation-delay: 0.05s; }
.qg-tile:nth-child(3n) { animation-delay: 0.1s; }
@keyframes qgTile { from { opacity: 0; transform: translate3d(0, 16px, 0) scale(0.92); } }
.qg-tile-art { width: 100%; aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: rgba(255, 255, 255, 0.06); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.qg-tile-art img { width: 100%; height: 100%; object-fit: cover; }
.qg-tile-name { font-weight: 750; font-size: 0.82rem; line-height: 1.15; margin-top: 6px; text-wrap: balance; }
.qg-tile-meta { font-size: 0.68rem; color: var(--ink-3); font-weight: 600; }

/* --- a game's first screens --------------------------------------------------------------- */
.qg-boot { align-items: center; justify-content: center; text-align: center; }
.qg-boot-icon, .qg-hero img { width: 132px; height: 132px; border-radius: 34px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.16), 0 0 80px color-mix(in srgb, var(--acc) 40%, transparent); }
.qg-boot-name { font-family: var(--display); font-weight: 800; font-size: 1.8rem; letter-spacing: -0.03em; }
.qg-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.18); border-top-color: var(--acc); animation: qgSpin 0.8s linear infinite; }
@keyframes qgSpin { to { transform: rotate(360deg); } }
.qg-hero { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; padding-top: 4px; }
.qg-hero-art { position: relative; animation: qgFloat 5s ease-in-out infinite; }
.qg-hero-art::before { content: ''; position: absolute; inset: -22%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--acc) 55%, transparent), transparent 66%); filter: blur(18px); z-index: -1; animation: qgPulse 3.4s ease-in-out infinite; }
@keyframes qgFloat { 50% { transform: translate3d(0, -8px, 0) rotate(-1.5deg); } }
@keyframes qgPulse { 50% { opacity: 0.55; transform: scale(1.08); } }
.qg-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.qg-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); white-space: nowrap; }
.qg-pill svg { width: 15px; height: 15px; }
.qg-pill.acc { background: color-mix(in srgb, var(--acc) 26%, transparent); color: #fff; border-color: color-mix(in srgb, var(--acc) 50%, transparent); }
.qg-actions { display: flex; flex-direction: column; gap: 12px; }
.qg-choice { display: flex; align-items: center; gap: 16px; width: 100%; padding: 18px; text-align: start; border-radius: 26px; color: var(--ink);
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--glass-edge), 0 16px 36px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
  transition: transform 0.18s var(--spring), border-color 0.2s ease; animation: qgTile 0.55s var(--ease) both; }
.qg-choice:nth-child(2) { animation-delay: 0.07s; }
.qg-choice:nth-child(3) { animation-delay: 0.14s; }
.qg-choice:active { transform: scale(0.97); border-color: color-mix(in srgb, var(--acc) 60%, #fff); }
.qg-choice-ico { width: 60px; height: 60px; flex-shrink: 0; border-radius: 20px; display: flex; align-items: center; justify-content: center; color: var(--on-acc);
  background: linear-gradient(160deg, color-mix(in srgb, var(--acc) 86%, #fff), color-mix(in srgb, var(--acc) 80%, #000)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 10px 22px color-mix(in srgb, var(--acc) 40%, transparent); }
.qg-choice-ico svg { width: 30px; height: 30px; }
.qg-choice.alt .qg-choice-ico { background: linear-gradient(160deg, #6E8BFF, #3B4FD8); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 10px 22px rgba(79, 107, 255, 0.4); }
.qg-choice-txt { flex: 1; min-width: 0; }
.qg-choice-txt b { display: block; font-family: var(--display); font-size: 1.22rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
.qg-choice-txt span { display: block; color: var(--ink-2); font-size: 0.88rem; margin-top: 3px; }
.qg-choice > svg { width: 20px; height: 20px; margin-inline-start: auto; color: var(--ink-3); flex-shrink: 0; }
[dir="rtl"] .qg-choice > svg { transform: scaleX(-1); }

/* --- forms: names, options --------------------------------------------------------------- */
.qg-panel { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.qg-field { display: flex; flex-direction: column; gap: 8px; }
.qg-field > label, .qg-label { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); letter-spacing: 0.02em; }
.qg-seg { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; border-radius: 17px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.qg-seg button { flex: 1 1 auto; min-height: 40px; padding: 6px 8px; border-radius: 12px; font-weight: 700; font-size: 0.88rem; color: var(--ink-2); transition: background 0.2s ease, color 0.2s ease, transform 0.16s var(--spring); }
.qg-seg button.on { background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.14)); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 4px 10px rgba(0, 0, 0, 0.3); }
.qg-seg button:active { transform: scale(0.95); }
.qg-seg[aria-disabled="true"] { opacity: 0.6; pointer-events: none; }
.qg-stepper { display: flex; align-items: center; gap: 14px; }
.qg-stepper b { font-family: var(--display); font-size: 1.7rem; font-weight: 800; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.qg-names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qg-names .qg-input { height: 44px; font-size: 0.95rem; }

/* --- room: number, QR, players ------------------------------------------------------------ */
.qg-room { padding: 18px; display: flex; align-items: center; gap: 16px; }
.qg-qr { width: 118px; height: 118px; flex-shrink: 0; padding: 7px; background: #fff; border-radius: 18px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); }
.qg-qr img { width: 100%; height: 100%; }
.qg-room-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.qg-code { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; direction: ltr; }
.qg-roster { display: flex; flex-direction: column; gap: 8px; }
.qg-player { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 18px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); animation: qgTile 0.4s var(--ease) both; }
.qg-player.off { opacity: 0.45; }
.qg-ava { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; color: #fff; background: var(--c, #64748B); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 10px rgba(0, 0, 0, 0.3); text-transform: uppercase; }
.qg-player b { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qg-player small { font-size: 0.72rem; font-weight: 700; color: var(--ink-3); }
.qg-player .qg-ibtn { width: 34px; height: 34px; }
.qg-player .qg-ibtn svg { width: 16px; height: 16px; }
.qg-wait { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink-2); font-weight: 650; font-size: 0.95rem; padding: 12px; text-align: center; }
.qg-dots { display: inline-flex; gap: 5px; }
.qg-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); animation: qgDot 1.2s ease-in-out infinite; }
.qg-dots i:nth-child(2) { animation-delay: 0.15s; }
.qg-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes qgDot { 0%, 60%, 100% { transform: none; opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* --- the stage a game plays on -------------------------------------------------------------- */
.qg-stage { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; z-index: 5; display: flex; flex-direction: column; overflow: hidden; animation: qgIn 0.5s var(--ease) both; }
/* A landscape game on a phone held upright: the stage itself is turned, so the game is
   landscape whatever the phone's rotation lock says. */
.qg-stage.is-rot { width: 100vh; width: 100dvh; height: 100vw; transform-origin: 0 0; transform: rotate(90deg) translateY(-100%); animation: none; }
.qg-hud { position: relative; z-index: 3; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 8px calc(12px + var(--sal)); }
.qg-stage.is-rot .qg-hud { padding: 8px calc(12px + var(--sab)) 8px calc(12px + var(--sat)); }
.qg-hud .qg-ibtn { width: 40px; height: 40px; }
.qg-hud-title { flex: 1; min-width: 0; text-align: center; font-weight: 750; font-size: 0.95rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qg-hud-title small { display: block; font-size: 0.7rem; font-weight: 600; color: var(--ink-3); }
.qg-hud-chip { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 20px; font-weight: 800; font-size: 0.86rem; font-variant-numeric: tabular-nums; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--glass-edge); direction: ltr; }
.qg-hud-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); }
.qg-hud-chip.off i { background: var(--warn); box-shadow: 0 0 10px var(--warn); animation: qgBlink 1s steps(2) infinite; }
@keyframes qgBlink { 50% { opacity: 0.25; } }
.qg-root { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.qg-root > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.qg-pad { padding: 6px calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); }

/* --- turn the phone ------------------------------------------------------------------------- */
.qg-rotate { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; text-align: center; padding: 30px;
  background: rgba(7, 8, 12, 0.82); -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%); animation: qgFade 0.3s ease both; }
.qg-rotate.is-out { animation: qgFadeOut 0.35s ease both; pointer-events: none; }
@keyframes qgFade { from { opacity: 0; } }
@keyframes qgFadeOut { to { opacity: 0; } }
.qg-rotate-art { position: relative; width: 190px; height: 190px; display: flex; align-items: center; justify-content: center; }
.qg-rotate-art::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.22); animation: qgSpin 14s linear infinite; }
.qg-phone { width: 74px; height: 138px; border-radius: 18px; border: 3px solid #fff; position: relative; background: linear-gradient(160deg, color-mix(in srgb, var(--acc) 80%, #fff), color-mix(in srgb, var(--acc) 70%, #000)); box-shadow: 0 16px 40px color-mix(in srgb, var(--acc) 50%, transparent), inset 0 0 0 4px rgba(0, 0, 0, 0.25); animation: qgTurn 2.4s var(--ease) infinite; }
.qg-phone::before { content: ''; position: absolute; top: 7px; left: 50%; width: 22px; height: 5px; margin-left: -11px; border-radius: 3px; background: rgba(0, 0, 0, 0.45); }
.qg-phone::after { content: ''; position: absolute; inset: 20px 9px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.22); }
@keyframes qgTurn { 0%, 18% { transform: rotate(0deg) scale(1); } 46% { transform: rotate(90deg) scale(1.12); } 58%, 84% { transform: rotate(90deg) scale(1); } 100% { transform: rotate(0deg) scale(1); } }
.qg-rotate-arrow { position: absolute; inset: 0; color: #fff; opacity: 0.9; animation: qgArrow 2.4s var(--ease) infinite; }
.qg-rotate-arrow svg { width: 100%; height: 100%; stroke-width: 1.4; }
@keyframes qgArrow { 0%, 18% { transform: rotate(-30deg); opacity: 0; } 30% { opacity: 0.9; } 58% { transform: rotate(60deg); opacity: 0.9; } 70%, 100% { transform: rotate(60deg); opacity: 0; } }

/* --- overlays: sheets, results, hand-over ----------------------------------------------------- */
.qg-overlay { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: calc(18px + var(--sat)) 18px calc(18px + var(--sab));
  background: rgba(5, 6, 10, 0.6); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); animation: qgFade 0.25s ease both; }
.qg-overlay.is-out { animation: qgFadeOut 0.22s ease both; pointer-events: none; }
.qg-overlay.is-out .qg-sheet { animation: qgSheetOut 0.22s ease both; }
.qg-sheet { width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; scrollbar-width: none; padding: 24px 20px 20px; display: flex; flex-direction: column; gap: 14px; text-align: center; animation: qgSheet 0.5s var(--spring) both; }
.qg-sheet::-webkit-scrollbar { display: none; }
@keyframes qgSheet { from { opacity: 0; transform: translate3d(0, 30px, 0) scale(0.9); } }
@keyframes qgSheetOut { to { opacity: 0; transform: scale(0.94); } }
.qg-sheet h2 { font-family: var(--display); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; text-wrap: balance; }
.qg-sheet p { color: var(--ink-2); text-wrap: pretty; }
.qg-sheet .qg-how { text-align: start; white-space: pre-line; font-size: 0.96rem; line-height: 1.55; color: var(--ink-2); }
.qg-menu-list { display: flex; flex-direction: column; gap: 10px; }
.qg-trophy { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #2A1700; background: radial-gradient(circle at 34% 28%, #FFF3B0, #FBBF24 55%, #D97706); box-shadow: 0 18px 46px rgba(251, 191, 36, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.7); animation: qgTrophy 0.9s var(--spring) both; }
.qg-trophy svg { width: 50px; height: 50px; stroke-width: 2.2; }
.qg-trophy.lose { color: #fff; background: radial-gradient(circle at 34% 28%, #94A3B8, #475569 60%, #1E293B); box-shadow: 0 18px 46px rgba(71, 85, 105, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.4); }
.qg-trophy.draw { color: #fff; background: radial-gradient(circle at 34% 28%, #A5B4FC, #6366F1 60%, #3730A3); box-shadow: 0 18px 46px rgba(99, 102, 241, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.5); }
@keyframes qgTrophy { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.15) rotate(8deg); } 100% { transform: none; } }
.qg-scores { display: flex; flex-direction: column; gap: 6px; text-align: start; }
.qg-score { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 15px; background: rgba(255, 255, 255, 0.07); border: 1px solid transparent; font-weight: 700; animation: qgTile 0.45s var(--ease) both; }
.qg-score.win { background: color-mix(in srgb, var(--acc) 24%, transparent); border-color: color-mix(in srgb, var(--acc) 55%, transparent); }
.qg-score i { width: 24px; font-style: normal; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.qg-score b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qg-score span { font-family: var(--display); font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.qg-confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.qg-toast { position: fixed; left: 50%; bottom: calc(26px + var(--sab)); z-index: 70; max-width: min(86vw, 420px); padding: 12px 18px; border-radius: 18px; font-weight: 700; font-size: 0.92rem; text-align: center;
  background: rgba(20, 22, 30, 0.86); border: 1px solid var(--line); box-shadow: var(--glass-edge), 0 14px 34px rgba(0, 0, 0, 0.5); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transform: translate(-50%, 30px); opacity: 0; transition: transform 0.4s var(--spring), opacity 0.3s ease; pointer-events: none; }
.qg-toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.qg-noscript { position: fixed; inset: auto 0 0; padding: 16px; text-align: center; background: #111; z-index: 99; }

/* --- pieces games build their screens from ----------------------------------------------------- */
.qg-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.qg-row { display: flex; align-items: center; gap: 12px; }
.qg-fill { flex: 1 1 auto; min-height: 0; min-width: 0; }
.qg-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.qg-card { position: relative; width: 100%; padding: 26px 22px; border-radius: 30px; text-align: center; color: #14161D;
  background: linear-gradient(170deg, #FFFFFF, #EEF0F6); box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), inset 0 -6px 0 rgba(0, 0, 0, 0.07), inset 0 2px 0 #fff; }
.qg-card h3 { font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; font-size: clamp(1.9rem, 9vw, 3rem); text-wrap: balance; overflow-wrap: anywhere; }
.qg-big { font-family: var(--display); font-weight: 800; letter-spacing: -0.04em; line-height: 1; font-size: clamp(3rem, 18vw, 6rem); font-variant-numeric: tabular-nums; }
.qg-timer { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 76px; height: 40px; padding: 0 14px; border-radius: 20px; font-family: var(--display); font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--glass-edge); direction: ltr; }
.qg-timer.low { color: #fff; background: linear-gradient(180deg, #FB7185, #E11D48); border-color: transparent; animation: qgBeat 1s ease-in-out infinite; }
@keyframes qgBeat { 50% { transform: scale(1.1); } }
.qg-ring { --p: 1; width: 120px; height: 120px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 2.4rem; font-variant-numeric: tabular-nums;
  background: radial-gradient(closest-side, #0D0F16 82%, transparent 84%), conic-gradient(var(--acc) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0); }
.qg-bar { display: flex; gap: 8px; }
.qg-bar > div { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 16px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); text-align: center; transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s var(--spring); }
.qg-bar > div.on { background: color-mix(in srgb, var(--c, var(--acc)) 30%, transparent); border-color: color-mix(in srgb, var(--c, var(--acc)) 70%, #fff); transform: translateY(-2px); }
.qg-bar small { display: block; font-size: 0.72rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qg-bar b { font-family: var(--display); font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.qg-pop { animation: qgPop 0.45s var(--spring) both; }
@keyframes qgPop { from { opacity: 0; transform: scale(0.7); } }
.qg-shake { animation: qgShake 0.4s ease both; }
@keyframes qgShake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.qg-flip { animation: qgFlip 0.6s var(--ease) both; }
@keyframes qgFlip { from { transform: perspective(900px) rotateY(88deg) scale(0.92); opacity: 0; } }

@media (min-width: 560px) {
  .qg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-height: 420px) {
  .qg-hud { padding-top: calc(4px + var(--sat)); padding-bottom: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .qg-bg i, .qg-btn::after, .qg-hero-art, .qg-hero-art::before { animation: none; }
  .qg-screen.is-on, .qg-tile, .qg-choice { animation-duration: 0.01s; }
}
