/* Four in a Row. One stage (.game) that fills the frame; game.js sets its height (--H), the size of a
   board cell (--cs) and marks the stage .wide (side panels) or .tall (stacked, phones). Logical
   properties only, so RTL and LTR share one file; the board itself always runs left to right.
   Every colour comes from the theme variables below. */

/* ---------- themes (each block sets every variable: theme cards nest one theme inside another) ---------- */
:root, [data-theme="arena"] {
    --bg0: #090b26; --bg1: #151a54; --bg2: #3d2392; --glow: rgba(120, 140, 255, .3);
    --ui: rgba(20, 24, 72, .84); --ui2: #2a3186; --card: #1a1f5e; --line: rgba(150, 165, 255, .28); --text: #f3f5ff; --muted: #aab2ea;
    --accent: #ffcf4a; --accent2: #ff9a3c; --accent-edge: #b4560e; --ink: #2b1400;
    --board: #4653e6; --board2: #2c35b4; --board-hi: #6f7bff; --board-edge: #171c6b; --well: #0a0c2c;
    --p1a: #fff0b8; --p1b: #ffb627; --p1c: #c56f08; --p2a: #c9fff8; --p2b: #2ddfd0; --p2c: #0c8f86;
    --ok: #5ee08a; --bad: #ff5f73; --gold: #ffc533; --chip: #2a3186; --edge: #120f3a; --sil: brightness(0) invert(1) opacity(.2);
    --font: system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
}
[data-theme="wood"] {
    --bg0: #1d110a; --bg1: #3a2416; --bg2: #6b4424; --glow: rgba(255, 200, 130, .2);
    --ui: rgba(44, 26, 14, .86); --ui2: #5a3a20; --card: #33200f; --line: rgba(255, 215, 160, .28); --text: #fff5e4; --muted: #d6b792;
    --accent: #ffd27a; --accent2: #f0a03c; --accent-edge: #8f5a10; --ink: #2b1400;
    --board: #d99b58; --board2: #b47734; --board-hi: #f0bd80; --board-edge: #6b3f16; --well: #2a1708;
    --p1a: #ffffff; --p1b: #f3e2c2; --p1c: #b0915f; --p2a: #ffa494; --p2b: #e2473b; --p2c: #8f1f18;
    --ok: #8ee06a; --bad: #ff6b5e; --gold: #ffc533; --chip: #5a3a20; --edge: #20100a; --sil: brightness(0) invert(1) opacity(.2);
}
[data-theme="candy"] {
    --bg0: #ffc4e1; --bg1: #ffe6c9; --bg2: #c6efff; --glow: rgba(255, 255, 255, .75);
    --ui: rgba(255, 255, 255, .88); --ui2: #ffffff; --card: #fff7fb; --line: rgba(214, 80, 150, .3); --text: #58204d; --muted: #a05c8c;
    --accent: #ff5fa2; --accent2: #ff8f5f; --accent-edge: #b92d6b; --ink: #ffffff;
    --board: #ff86c0; --board2: #f45fa4; --board-hi: #ffb5d9; --board-edge: #b8306f; --well: #6e1c4c;
    --p1a: #fffbd0; --p1b: #ffd83d; --p1c: #cf9500; --p2a: #d4fcff; --p2b: #49d3e6; --p2c: #128fa5;
    --ok: #17a45a; --bad: #e0304f; --gold: #ffab1a; --chip: #ffdcee; --edge: #5a1244; --sil: brightness(0) opacity(.2);
}
[data-theme="ocean"] {
    --bg0: #031c2e; --bg1: #07405c; --bg2: #0e7a8f; --glow: rgba(120, 240, 255, .22);
    --ui: rgba(4, 38, 58, .86); --ui2: #0b5672; --card: #063349; --line: rgba(150, 235, 255, .28); --text: #effcff; --muted: #9fd0df;
    --accent: #ffd166; --accent2: #ff9f4a; --accent-edge: #a85a10; --ink: #2b1400;
    --board: #25c0d3; --board2: #1391ab; --board-hi: #7de9f2; --board-edge: #085064; --well: #04202e;
    --p1a: #ffd1c2; --p1b: #ff7f61; --p1c: #bf4026; --p2a: #ffffff; --p2b: #e3ecf6; --p2c: #8fa3ba;
    --ok: #6ae0a0; --bad: #ff6b7d; --gold: #ffd166; --chip: #0b5672; --edge: #02202e; --sil: brightness(0) invert(1) opacity(.2);
}
[data-theme="space"] {
    --bg0: #02030d; --bg1: #0a0f2e; --bg2: #35115f; --glow: rgba(170, 90, 255, .3);
    --ui: rgba(9, 11, 34, .86); --ui2: #1d2158; --card: #10133a; --line: rgba(175, 155, 255, .3); --text: #f4f1ff; --muted: #a6a1da;
    --accent: #c98bff; --accent2: #ff5fd2; --accent-edge: #6226ae; --ink: #ffffff;
    --board: #6a3bd0; --board2: #45209a; --board-hi: #9a6cf5; --board-edge: #1d0d4c; --well: #07031c;
    --p1a: #ffc4f4; --p1b: #ff52cb; --p1c: #a51483; --p2a: #e8ffb5; --p2b: #93ea3a; --p2c: #4b9912;
    --ok: #5ee08a; --bad: #ff6b7d; --gold: #ffc533; --chip: #1d2158; --edge: #0a0624; --sil: brightness(0) invert(1) opacity(.2);
}
[data-theme="gold"] {
    --bg0: #130509; --bg1: #390e1b; --bg2: #6a2414; --glow: rgba(255, 200, 90, .24);
    --ui: rgba(32, 8, 15, .88); --ui2: #4c1624; --card: #2a0a14; --line: rgba(255, 205, 110, .38); --text: #fff6df; --muted: #dcbb8a;
    --accent: #ffdc78; --accent2: #f0a02b; --accent-edge: #94600c; --ink: #2b1400;
    --board: #9c2540; --board2: #6a1428; --board-hi: #e9b452; --board-edge: #b8862a; --well: #1c050b;
    --p1a: #fff6c9; --p1b: #f3bb3d; --p1c: #99690b; --p2a: #ffffff; --p2b: #cfd8ec; --p2c: #77819c;
    --ok: #7ee08a; --bad: #ff6b7d; --gold: #ffd54a; --chip: #4c1624; --edge: #1c060c; --sil: brightness(0) invert(1) opacity(.2);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg0); color: var(--text); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { display: block; }
.ic { inline-size: 22px; block-size: 22px; flex: none; }

.game {
    position: relative; inline-size: 100%; block-size: var(--H, 600px); overflow: hidden; isolation: isolate;
    background: radial-gradient(120% 85% at 50% -10%, var(--bg2), transparent 62%), linear-gradient(165deg, var(--bg1), var(--bg0));
}

/* Backdrop: two soft lights, a pattern per theme and a few discs drifting up slowly. */
.scene { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.scene::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(38% 46% at 14% 6%, var(--glow), transparent 70%), radial-gradient(34% 42% at 90% 96%, var(--glow), transparent 70%);
}
.scene::after { content: ""; position: absolute; inset: 0; opacity: .55; background: radial-gradient(circle, rgba(255, 255, 255, .05) 0 9px, transparent 10px) 0 0 / 44px 44px; }
[data-theme="wood"] .scene::after { opacity: .5; background: repeating-linear-gradient(96deg, rgba(0, 0, 0, .12) 0 2px, transparent 2px 19px, rgba(255, 220, 170, .05) 19px 21px, transparent 21px 47px); }
[data-theme="candy"] .scene::after { opacity: .6; background: radial-gradient(circle at 12px 12px, #fff 5px, transparent 6px) 0 0 / 56px 56px, radial-gradient(circle at 12px 12px, #fff 3px, transparent 4px) 28px 28px / 56px 56px; }
[data-theme="ocean"] .scene::after { opacity: .5; background: radial-gradient(60% 14px at 50% 0, rgba(255, 255, 255, .1), transparent 70%) 0 0 / 120px 46px, radial-gradient(60% 14px at 50% 0, rgba(255, 255, 255, .07), transparent 70%) 60px 23px / 120px 46px; }
[data-theme="space"] .scene::after {
    opacity: .9;
    background: radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent) 0 0 / 130px 110px, radial-gradient(1px 1px at 70px 80px, #cfd6ff, transparent) 0 0 / 90px 130px, radial-gradient(2px 2px at 110px 20px, #ffd6fb, transparent) 0 0 / 210px 170px;
}
[data-theme="gold"] .scene::after { opacity: .6; background: repeating-linear-gradient(45deg, rgba(255, 205, 110, .07) 0 1px, transparent 1px 22px), repeating-linear-gradient(-45deg, rgba(255, 205, 110, .07) 0 1px, transparent 1px 22px); }
.scene i { position: absolute; inline-size: var(--z); block-size: var(--z); border-radius: 50%; opacity: .1; border: calc(var(--z) * .14) solid var(--dc); animation: f4-drift var(--d) linear var(--w) infinite; will-change: transform; }
@keyframes f4-drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(var(--x), calc(-1 * var(--H) - 160px), 0); } }

/* ---------- a disc: used on the board, in the logo, on the player chips and the theme cards ---------- */
.disc {
    --ca: var(--p1a); --cb: var(--p1b); --cc: var(--p1c);
    position: relative; display: block; flex: none; inline-size: var(--cs); block-size: var(--cs); border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, var(--ca) 0 10%, var(--cb) 56%, var(--cc) 100%);
    box-shadow: inset 0 0 0 calc(var(--cs) * .05) var(--cc), inset 0 calc(var(--cs) * -.06) calc(var(--cs) * .06) rgba(0, 0, 0, .22);
}
.disc.c2 { --ca: var(--p2a); --cb: var(--p2b); --cc: var(--p2c); }
/* A pressed ring, and each side's own mark (a star or a ring), so the two are told apart without colour. */
.disc::before {
    content: ""; position: absolute; inset: 17%; border-radius: 50%;
    box-shadow: inset 0 calc(var(--cs) * .03) calc(var(--cs) * .02) rgba(0, 0, 0, .22), 0 calc(var(--cs) * .025) 0 rgba(255, 255, 255, .4);
}
.disc::after {
    content: ""; position: absolute; inset: 29%; background: var(--cc); opacity: .62;
    -webkit-mask: var(--em) center / contain no-repeat; mask: var(--em) center / contain no-repeat;
    --em: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.6l3.2 6.6 7.2 1-5.2 5.1 1.2 7.2L12 18.1l-6.4 3.4 1.2-7.2L1.6 9.2l7.2-1z'/%3E%3C/svg%3E");
}
.disc.c2::after { --em: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='%23000' stroke-width='5'/%3E%3C/svg%3E"); }
.disc.st { background: radial-gradient(circle at 36% 30%, #e1e6ef 0 8%, #99a2b4 55%, #5a6275 100%); box-shadow: inset 0 0 0 calc(var(--cs) * .05) #4b5265, inset 0 calc(var(--cs) * -.06) calc(var(--cs) * .06) rgba(0, 0, 0, .3); }
.disc.st::before { box-shadow: none; inset: 20%; background: linear-gradient(118deg, transparent 44%, rgba(0, 0, 0, .3) 46% 51%, transparent 53%), linear-gradient(38deg, transparent 60%, rgba(0, 0, 0, .24) 62% 66%, transparent 68%), linear-gradient(80deg, transparent 22%, rgba(255, 255, 255, .3) 24% 28%, transparent 30%); }
.disc.st::after { display: none; }

/* ---------- shared pieces ---------- */
.sys { position: absolute; z-index: 30; inset-block-start: 10px; inset-inline-end: 10px; display: flex; gap: 8px; }
.rbtn {
    inline-size: 40px; block-size: 40px; border-radius: 50%; display: grid; place-items: center;
    background: var(--ui); border: 1px solid var(--line); box-shadow: 0 3px 0 rgba(0, 0, 0, .22); transition: transform .08s;
}
.rbtn:active { transform: translateY(2px) scale(.96); }
.rbtn svg { inline-size: 21px; block-size: 21px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-block-size: 50px; padding: 10px 26px; border-radius: 999px;
    font-weight: 900; font-size: 1.08rem; color: var(--ink); background: linear-gradient(180deg, var(--accent), var(--accent2));
    box-shadow: 0 5px 0 var(--accent-edge), 0 10px 22px rgba(0, 0, 0, .28), inset 0 2px 0 rgba(255, 255, 255, .45); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-edge), 0 4px 10px rgba(0, 0, 0, .28), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn.sec { color: var(--text); background: var(--ui2); border: 1px solid var(--line); box-shadow: 0 4px 0 rgba(0, 0, 0, .28); font-weight: 800; font-size: .98rem; }
.btn.sec:active { box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
.btn.pulse { animation: f4-pulse 1.6s ease-in-out infinite; }
@keyframes f4-pulse { 50% { transform: scale(1.045); } }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--ui); border: 1px solid var(--line); font-weight: 800; font-size: .92rem; white-space: nowrap; }
.pill .ic { inline-size: 17px; block-size: 17px; color: var(--gold); }
.av { position: relative; flex: none; inline-size: 56px; block-size: 56px; }
.av .face { inline-size: 100%; block-size: 100%; overflow: visible; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .22)); }
.av.live .ey { animation: f4-blink 4.6s infinite; transform-origin: 50px 54px; }
.av.live .bulb { animation: f4-bulb 1.1s ease-in-out infinite alternate; }
@keyframes f4-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.12); } }
@keyframes f4-bulb { to { opacity: .55; } }
.av.hop { animation: f4-hop .6s cubic-bezier(.3, 1.5, .5, 1); }
.av.shake { animation: f4-nope .4s; }
@keyframes f4-hop { 30% { transform: translateY(-16%) scale(1.08); } 60% { transform: translateY(0) scale(.97); } }
.stars3 { display: inline-flex; gap: 2px; color: rgba(128, 128, 150, .45); }
.stars3 .ic { inline-size: 16px; block-size: 16px; }
.stars3 .on { color: var(--gold); }
.tag { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: .7rem; font-weight: 800; white-space: nowrap; }
.tag .ic { inline-size: 11px; block-size: 11px; }
.tag.hot { background: var(--accent); color: var(--ink); }
[dir="rtl"] .flip { transform: scaleX(-1); }

/* ---------- screens ---------- */
/* Everything but the board scales with big stages (--z is set in game.js; 1 on phones). */
.screen:not(.match), .card, .pl, .mtop, .mbot, .sys, .pausebtn, .toasts { zoom: var(--z, 1); }
.screen {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 10px 14px 16px; overflow: hidden auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.screen.in > * { animation: f4-rise .32s ease-out backwards; }
.screen.in > :nth-child(2) { animation-delay: .05s; }
.screen.in > :nth-child(3) { animation-delay: .1s; }
.screen.in > :nth-child(4) { animation-delay: .15s; }
@keyframes f4-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes f4-in { from { opacity: 0; } }
.topbar { display: flex; align-items: center; gap: 10px; inline-size: 100%; min-block-size: 40px; padding-inline-end: 96px; flex: none; }
.topbar h2 { margin: 0; font-size: 1.2rem; font-weight: 900; line-height: 1.12; flex: 1; min-inline-size: 0; max-block-size: 2.3em; overflow: hidden; }
.topbar .pill { padding: 5px 10px; font-size: .86rem; }
[dir="rtl"] .topbar .rbtn svg { transform: scaleX(-1); }

/* Home */
.s-home { justify-content: center; }
.home-top { position: absolute; inset-block-start: 10px; inset-inline-start: 10px; display: flex; gap: 8px; }
.home-in { display: flex; flex-direction: column; align-items: center; gap: 14px; inline-size: 100%; margin-block: auto; padding-block-start: 46px; }
.logo { display: grid; justify-items: center; gap: 6px; --cs: clamp(40px, calc(var(--H) * .078), 62px); }
.logo-b {
    position: relative; display: flex; gap: calc(var(--cs) * .16); padding: calc(var(--cs) * .16) calc(var(--cs) * .2); border-radius: calc(var(--cs) * .42); direction: ltr;
    background: linear-gradient(180deg, var(--board), var(--board2)); border: calc(var(--cs) * .06) solid var(--board-hi); border-block-end-color: var(--board2);
    box-shadow: 0 calc(var(--cs) * .12) 0 var(--board-edge), 0 calc(var(--cs) * .34) calc(var(--cs) * .5) rgba(0, 0, 0, .35);
}
.logo-b span { position: relative; inline-size: var(--cs); block-size: var(--cs); border-radius: 50%; background: var(--well); overflow: hidden; box-shadow: inset 0 calc(var(--cs) * .08) calc(var(--cs) * .1) rgba(0, 0, 0, .55), 0 2px 0 rgba(255, 255, 255, .22); }
.logo-b .disc { animation: f4-logo .62s calc(.25s + var(--k) * .16s) cubic-bezier(.5, 0, .7, 1) backwards, f4-nod 3.2s calc(1.6s + var(--k) * .2s) ease-in-out infinite; }
@keyframes f4-logo { 0% { transform: translateY(-140%); } 70% { transform: translateY(0); } 84% { transform: translateY(-11%); } 100% { transform: translateY(0); } }
@keyframes f4-nod { 0%, 84%, 100% { transform: rotate(0); } 90% { transform: rotate(-14deg); } 95% { transform: rotate(10deg); } }
.logo-b::after {
    content: ""; position: absolute; inset-inline: 10%; inset-block-start: 50%; block-size: calc(var(--cs) * .13); margin-block-start: calc(var(--cs) * -.065); border-radius: 99px;
    background: #fff; box-shadow: 0 0 calc(var(--cs) * .3) var(--p1b); transform-origin: 0 50%; animation: f4-line .5s 1.15s ease-out backwards; opacity: .92; pointer-events: none;
}
@keyframes f4-line { from { transform: scaleX(0); opacity: 0; } }
.logo h2 {
    margin: 4px 0 0; font-size: clamp(1.6rem, calc(var(--H) * .05), 2.5rem); font-weight: 900; line-height: 1.15; text-align: center; letter-spacing: -.01em;
    background: linear-gradient(180deg, #fff 20%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .28));
}
[data-theme="candy"] .logo h2 { background-image: linear-gradient(180deg, var(--accent2), var(--accent)); filter: drop-shadow(0 2px 0 rgba(255, 255, 255, .7)); }
.logo p { margin: 0; color: var(--muted); font-weight: 700; font-size: .98rem; text-align: center; }
.crowd { display: none; margin-block-start: 10px; padding-inline-start: 12px; }
.crowd .av { inline-size: 44px; block-size: 44px; margin-inline-start: -11px; animation: f4-bob 2.4s ease-in-out infinite; }
.crowd .av:nth-child(2n) { animation-delay: -1.2s; }
.crowd .av.shut .face { filter: var(--sil); }
.wide:not(.short) .crowd, .roomy .crowd { display: flex; }
.roomy .crowd { padding: 0; gap: 3px; justify-content: center; }
.roomy .crowd .av { inline-size: min(34px, 6.6vw); block-size: min(34px, 6.6vw); margin: 0; }
@keyframes f4-bob { 50% { transform: translateY(-5px); } }
.menu-col { display: grid; gap: 10px; inline-size: 100%; justify-items: center; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; inline-size: min(100%, 440px); }
.mode {
    display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 9px; padding: 8px 10px; min-block-size: 62px; border-radius: 20px; min-inline-size: 0;
    text-align: start; background: var(--ui); border: 1px solid var(--line); box-shadow: 0 5px 0 rgba(0, 0, 0, .25); transition: transform .08s, box-shadow .08s;
}
.mode:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.mode b { display: block; font-size: 1rem; font-weight: 900; line-height: 1.2; }
.mode small { display: block; color: var(--muted); font-size: .74rem; font-weight: 600; line-height: 1.25; }
.mode .mi { inline-size: 44px; block-size: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.mode .mi .ic { inline-size: 24px; block-size: 24px; }
.mode.done .mi { background: var(--ok); color: #06301a; }
.mode.main {
    grid-column: 1 / -1; grid-template-columns: 62px 1fr auto; gap: 12px; padding: 9px 14px; min-block-size: 86px; color: var(--ink); border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 6px 0 var(--accent-edge), 0 14px 28px rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.mode.main:active { box-shadow: 0 2px 0 var(--accent-edge), inset 0 2px 0 rgba(255, 255, 255, .45); }
.mode.main b { font-size: 1.3rem; }
.mode.main small { color: inherit; opacity: .82; font-weight: 700; font-size: .84rem; }
.mode.main .av { inline-size: 62px; block-size: 62px; }
.mode .go { inline-size: 36px; block-size: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .3); }
.mode .go .ic { inline-size: 18px; block-size: 18px; }
.home-row { display: flex; gap: 9px; inline-size: min(100%, 440px); }
.home-row .btn { flex: 1; min-block-size: 46px; padding-inline: 10px; font-size: .95rem; }
.home-row .btn i { font-style: normal; opacity: .7; font-weight: 700; }

/* Champions Cup map: three stages of four rivals */
.cup { display: grid; gap: 12px; inline-size: 100%; max-inline-size: 1040px; }
.stage { display: grid; gap: 8px; padding: 10px; border-radius: 24px; background: rgba(0, 0, 0, .16); border: 1px solid var(--line); }
[data-theme="candy"] .stage { background: rgba(255, 255, 255, .4); }
.stage h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 900; color: var(--muted); }
.stage h3 i { font-style: normal; margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; }
.stage h3 .ic { inline-size: 14px; block-size: 14px; color: var(--gold); }
.cast { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 8px; }
.rival {
    position: relative; display: grid; justify-items: center; gap: 3px; padding: 12px 6px 9px; border-radius: 18px; text-align: center; min-inline-size: 0;
    background: var(--ui); border: 1px solid var(--line); box-shadow: 0 5px 0 rgba(0, 0, 0, .25); transition: transform .08s;
}
.rival:active { transform: translateY(3px); }
.rival .av { inline-size: 66px; block-size: 66px; }
.rival b { font-size: .95rem; font-weight: 900; line-height: 1.2; }
.rival .tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-block-size: 20px; }
.rival .no { position: absolute; inset-block-start: 7px; inset-inline-start: 10px; font-weight: 900; font-size: .8rem; color: var(--muted); }
.rival .bossf { position: absolute; inset-block-start: 7px; inset-inline-end: 7px; }
.rival.now { border-color: var(--accent); box-shadow: 0 5px 0 rgba(0, 0, 0, .25), 0 0 0 2px var(--accent), 0 0 26px var(--glow); }
.rival.now .av { animation: f4-bob 1.8s ease-in-out infinite; }
.rival.shut { cursor: default; }
.rival.shut > :not(.av):not(.lockic) { opacity: .6; }
.rival.shut .face { filter: var(--sil); }
.rival .lockic { position: absolute; inset-block-start: 30px; inset-inline: 0; margin-inline: auto; inline-size: 28px; block-size: 28px; color: var(--text); }

/* Setup (Quick Match and 2 Players) */
.setup { inline-size: 100%; max-inline-size: 560px; display: grid; gap: 11px; margin-block: auto; }
.field > span { display: block; margin-block-end: 5px; color: var(--muted); font-size: .8rem; font-weight: 800; letter-spacing: .02em; }
.opts { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.opts.four { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); }
.opt {
    display: grid; justify-items: center; align-content: center; gap: 3px; min-block-size: 46px; padding: 8px 4px; border-radius: 16px; text-align: center; min-inline-size: 0;
    background: var(--ui); border: 2px solid transparent; box-shadow: 0 4px 0 rgba(0, 0, 0, .22); font-weight: 800; font-size: .93rem; line-height: 1.2;
}
.opt small { color: var(--muted); font-size: .68rem; font-weight: 600; line-height: 1.25; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--ui2); box-shadow: 0 4px 0 rgba(0, 0, 0, .22), 0 0 18px var(--glow); }
.opt .dg { inline-size: 58px; }
.opt .av { inline-size: 44px; block-size: 44px; }
.opt .ic { inline-size: 20px; block-size: 20px; }
.opt .row { display: inline-flex; align-items: center; gap: 5px; font-size: 1.05rem; }
.opt .row .ic { color: var(--gold); }
.dg { inline-size: 64px; block-size: auto; }
.dg-b { fill: var(--board2); }
.dg-0 { fill: var(--well); }
.dg-1 { fill: var(--p1b); }
.dg-2 { fill: var(--p2b); }
.dg-s { fill: #8f98aa; }
.dg-x { fill: var(--bad); opacity: .85; }
.setup .btn { justify-self: center; min-inline-size: 200px; margin-block-start: 4px; }

/* Puzzles */
.pz { inline-size: 100%; max-inline-size: 760px; display: grid; gap: 10px; margin-block: auto; }
.pz .mode.day { grid-template-columns: 50px 1fr auto; min-block-size: 70px; padding-inline: 14px; }
.pz .mode.day .mi { inline-size: 50px; block-size: 50px; background: linear-gradient(180deg, var(--accent), var(--accent2)); color: var(--ink); }
.pz .mode.day.done .mi { background: var(--ok); color: #06301a; }
.pack { display: grid; gap: 8px; padding: 10px 12px 12px; border-radius: 22px; background: var(--ui); border: 1px solid var(--line); }
.pack h3 { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 1.02rem; font-weight: 900; }
.pack h3 small { color: var(--muted); font-size: .76rem; font-weight: 700; }
.pack h3 i { font-style: normal; margin-inline-start: auto; font-size: .86rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.pack h3 .ic { inline-size: 15px; block-size: 15px; }
.pack .nums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.num {
    position: relative; display: grid; place-items: center; aspect-ratio: 1.25; border-radius: 14px; font-weight: 900; font-size: 1.1rem; background: var(--chip);
    box-shadow: 0 4px 0 rgba(0, 0, 0, .22); transition: transform .08s;
}
.num:active { transform: translateY(3px); }
.num.done { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: var(--ink); }
.num.done::after { content: ""; position: absolute; inset-block-start: -5px; inset-inline-end: -5px; inline-size: 18px; block-size: 18px; border-radius: 50%; background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 76% no-repeat; box-shadow: 0 0 0 2px var(--card); }
.pack.shut { opacity: .62; }
.pack.shut .num { cursor: default; }

/* Themes */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; inline-size: 100%; max-inline-size: 560px; margin-block: auto; }
.theme {
    display: grid; gap: 6px; padding: 9px; border-radius: 20px; text-align: center; color: var(--text); justify-items: center;
    background: linear-gradient(165deg, var(--bg1), var(--bg0)); border: 2px solid var(--line); box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
}
.theme .mini { --cs: 22px; display: grid; grid-template-columns: repeat(4, var(--cs)); gap: 4px; padding: 7px 8px; border-radius: 12px; direction: ltr; background: linear-gradient(180deg, var(--board), var(--board2)); box-shadow: 0 4px 0 var(--board-edge); }
.theme .mini span { inline-size: var(--cs); block-size: var(--cs); border-radius: 50%; background: var(--well); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .5); }
.theme b { font-weight: 900; font-size: .95rem; }
.theme .state { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-block-size: 28px; inline-size: 100%; border-radius: 999px; font-weight: 800; font-size: .8rem; background: var(--chip); }
.theme .state .ic { inline-size: 14px; block-size: 14px; }
.theme.cur { border-color: var(--accent); box-shadow: 0 5px 0 rgba(0, 0, 0, .25), 0 0 22px var(--glow); }
.theme.cur .state { background: var(--accent); color: var(--ink); }
.theme.shut .mini { opacity: .45; }

/* Trophies */
.s-trophies .stats { margin-block-start: auto; }
.s-trophies .cups { margin-block-end: auto; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; inline-size: 100%; max-inline-size: 760px; }
.stat { padding: 8px 4px; border-radius: 16px; background: var(--ui); border: 1px solid var(--line); text-align: center; min-inline-size: 0; }
.stat b { display: block; font-size: 1.35rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat span { display: block; color: var(--muted); font-size: .68rem; font-weight: 700; line-height: 1.25; }
.cups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; inline-size: 100%; max-inline-size: 760px; }
.cupc { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px; background: var(--ui); border: 1px solid var(--line); }
.cupc .ci { inline-size: 42px; block-size: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--muted); }
.cupc b { display: block; font-size: .95rem; font-weight: 900; }
.cupc small { display: block; color: var(--muted); font-size: .76rem; font-weight: 600; line-height: 1.3; }
.cupc.got .ci { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: var(--ink); box-shadow: 0 0 16px var(--glow); }
.cupc:not(.got) { opacity: .66; }

/* ---------- match ---------- */
.match {
    display: grid; gap: 8px; padding: 8px 10px 10px; overflow: hidden; align-items: stretch; justify-items: stretch;
    grid-template: "top top" calc(42px * var(--z, 1)) "me op" auto "board board" minmax(0, 1fr) "bot bot" auto / minmax(0, 1fr) minmax(0, 1fr);
}
.pausebtn { position: absolute; z-index: 30; inset-block-start: 10px; inset-inline-start: 10px; }
.mtop { grid-area: top; display: grid; align-content: center; justify-items: center; padding-inline: 96px; text-align: center; line-height: 1.2; }
.mtop b { font-weight: 900; font-size: 1rem; }
.mtop span { color: var(--muted); font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pl {
    position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 18px; min-inline-size: 0;
    background: var(--ui); border: 2px solid transparent; transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.pl.me { grid-area: me; --pc: var(--p1b); --pg: color-mix(in srgb, var(--p1b) 45%, transparent); }
.pl.op { grid-area: op; flex-direction: row-reverse; text-align: end; --pc: var(--p2b); --pg: color-mix(in srgb, var(--p2b) 45%, transparent); }
.pl .av { inline-size: 50px; block-size: 50px; }
.pl-txt { flex: 1; min-inline-size: 0; display: grid; gap: 4px; }
.pl.op .pl-txt { justify-items: end; }
.pl-name { font-weight: 900; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-inline-size: 100%; }
.pl .chip { --cs: 24px; }
.pl.on { border-color: var(--pc); box-shadow: 0 0 20px var(--pg); }
.pl.on .chip { animation: f4-chip 1s ease-in-out infinite; }
@keyframes f4-chip { 50% { transform: translateY(-3px) scale(1.08); } }
.pips { display: flex; align-items: center; gap: 5px; min-block-size: 16px; }
.pips i { inline-size: 15px; block-size: 15px; border-radius: 50%; background: rgba(128, 128, 160, .32); box-shadow: inset 0 2px 2px rgba(0, 0, 0, .25); }
.pips i.on { background: var(--gold); box-shadow: 0 0 10px var(--gold), inset 0 -2px 0 rgba(0, 0, 0, .2); }
.pips i.new { animation: f4-pip .6s cubic-bezier(.3, 1.8, .5, 1); }
.pips .bm { inline-size: 17px; block-size: 17px; margin-inline-start: 3px; color: var(--text); }
.pips .bm.used { opacity: .25; }
.pips em { font-style: normal; font-weight: 800; font-size: .76rem; color: var(--muted); white-space: nowrap; }
@keyframes f4-pip { from { transform: scale(0); } 60% { transform: scale(1.5); } }
/* Move clock: a bar under the player whose turn it is. */
.pl .clock { position: absolute; inset-inline: 12px; inset-block-end: -5px; block-size: 6px; border-radius: 3px; background: rgba(0, 0, 0, .35); overflow: hidden; display: none; }
.pl.timed.on .clock { display: block; }
.pl .clock i { display: block; block-size: 100%; border-radius: 3px; background: var(--ok); transform-origin: 0 50%; animation: f4-clock var(--t, 5s) linear forwards; }
[dir="rtl"] .pl .clock i { transform-origin: 100% 50%; }
.pl.hold .clock i { animation-play-state: paused; }
@keyframes f4-clock { 60% { background: var(--gold); } 80% { background: var(--bad); } to { transform: scaleX(0); background: var(--bad); } }

.bubble {
    position: absolute; z-index: 6; inset-block-start: calc(100% + 8px); inset-inline-end: 8px; margin: 0; max-inline-size: min(230px, 62vw); inline-size: max-content;
    padding: 8px 12px; border-radius: 14px; background: #fff; color: #1d1b35; font-weight: 800; font-size: .88rem; line-height: 1.35; text-align: start;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .35); animation: f4-say .28s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none;
}
.bubble::before { content: ""; position: absolute; inset-block-start: -6px; inset-inline-end: 22px; inline-size: 14px; block-size: 14px; background: #fff; transform: rotate(45deg); border-radius: 3px; }
@keyframes f4-say { from { opacity: 0; transform: translateY(-6px) scale(.8); } }

/* The board. --cs is one cell, --pad the frame around the holes, --rw the outer rim (all set in game.js,
   whole pixels). Discs sit behind the front panel and show through its holes. */
.barea { grid-area: board; position: relative; min-inline-size: 0; min-block-size: 0; }
.bwrap {
    --cs: 40px; --pad: 4px; --rw: 3px; --cols: 7; --rows: 6; --mid: 5;
    --bw: calc(var(--cs) * var(--cols) + 2 * var(--pad) + 2 * var(--rw));
    position: absolute; inset: 0; margin: auto; direction: ltr; inline-size: var(--bw);
    block-size: calc(var(--cs) * (var(--rows) + 1) + 2 * var(--pad) + 2 * var(--rw) + var(--cs) * .16);
}
.droprow { position: absolute; left: calc(var(--rw) + var(--pad)); top: 0; inline-size: calc(var(--cs) * var(--cols)); block-size: var(--cs); pointer-events: none; }
.droprow > * { position: absolute; left: 0; top: 2%; inline-size: var(--cs); block-size: var(--cs); transform: translateX(calc(var(--c) * var(--cs))) scale(.88); transition: transform .12s ease-out, opacity .15s; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .35)); }
.droprow.off > * { opacity: 0; }
.droprow.scan > * { transition-duration: .16s; }
.droprow.bob > * { animation: f4-hover 1s ease-in-out infinite; }
@keyframes f4-hover { 50% { translate: 0 -8%; } }
.frame { position: absolute; left: var(--rw); top: calc(var(--cs) + var(--rw)); inline-size: calc(var(--cs) * var(--cols) + 2 * var(--pad)); block-size: calc(var(--cs) * var(--rows) + 2 * var(--pad)); }
.well { position: absolute; inset: 1px; border-radius: calc(var(--cs) * .26); background: var(--well); }
.discs { position: absolute; left: var(--pad); top: var(--pad); inline-size: calc(var(--cs) * var(--cols)); block-size: calc(var(--cs) * var(--rows)); }
.discs > * { position: absolute; left: calc(var(--c) * var(--cs)); top: calc(var(--r) * var(--cs)); }
.discs .disc { inline-size: calc(var(--cs) * .88); block-size: calc(var(--cs) * .88); margin: calc(var(--cs) * .06); }
.front {
    position: absolute; inset: 0; border-radius: calc(var(--cs) * .26); background: linear-gradient(180deg, rgba(255, 255, 255, .16), transparent 26%, transparent 72%, rgba(0, 0, 0, .16)), linear-gradient(180deg, var(--board), var(--board2));
    -webkit-mask: radial-gradient(circle at 50% 50%, transparent calc(var(--cs) * .39 - 1px), #000 calc(var(--cs) * .39)) var(--pad) var(--pad) / var(--cs) var(--cs);
    mask: radial-gradient(circle at 50% 50%, transparent calc(var(--cs) * .39 - 1px), #000 calc(var(--cs) * .39)) var(--pad) var(--pad) / var(--cs) var(--cs);
}
/* The lip of every hole: a shadow falling on the disc, a dark edge above and a light one below. */
.holes {
    position: absolute; inset: var(--pad); pointer-events: none;
    background:
        radial-gradient(circle at 50% 50%, transparent calc(var(--cs) * .29), rgba(0, 0, 0, .34) calc(var(--cs) * .39), transparent calc(var(--cs) * .39 + 1px)) 0 0 / var(--cs) var(--cs),
        radial-gradient(circle at 50% 55%, transparent calc(var(--cs) * .395), rgba(255, 255, 255, .3) calc(var(--cs) * .42), transparent calc(var(--cs) * .455)) 0 0 / var(--cs) var(--cs),
        radial-gradient(circle at 50% 45%, transparent calc(var(--cs) * .395), rgba(0, 0, 0, .28) calc(var(--cs) * .42), transparent calc(var(--cs) * .455)) 0 0 / var(--cs) var(--cs);
}
.rim {
    position: absolute; inset: calc(var(--rw) * -1); border: var(--rw) solid var(--board); border-color: var(--board-hi) var(--board) var(--board2); border-radius: calc(var(--cs) * .26 + var(--rw)); pointer-events: none;
    box-shadow: 0 calc(var(--cs) * .13) 0 var(--board-edge), 0 calc(var(--cs) * .32) calc(var(--cs) * .5) rgba(0, 0, 0, .42);
}
.cols {
    position: absolute; left: var(--rw); top: 0; inline-size: calc(var(--cs) * var(--cols) + 2 * var(--pad)); block-size: calc(var(--cs) * (var(--rows) + 1) + 2 * var(--pad) + var(--rw));
    display: grid; grid-template-columns: calc(var(--cs) + var(--pad)) repeat(var(--mid), var(--cs)) calc(var(--cs) + var(--pad)); z-index: 4;
}
.col { position: relative; block-size: 100%; border-radius: calc(var(--cs) * .3); }
.col:focus-visible { outline-offset: -3px; }
.col::before { content: ""; position: absolute; inset: calc(var(--cs) + var(--rw) + var(--pad)) 0 calc(var(--pad) + var(--rw)); border-radius: calc(var(--cs) * .5); opacity: 0; transition: opacity .12s; background: linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, .05)); pointer-events: none; }
.col:first-child::before { inset-inline-start: var(--pad); }
.col:last-child::before { inset-inline-end: var(--pad); }
.live .col.sel::before { opacity: 1; }
.live .col.tip::before { opacity: 1; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 70%, transparent), color-mix(in srgb, var(--accent) 12%, transparent)); animation: f4-tip 1s ease-in-out infinite; }
.arming .col.has::before { opacity: 1; background: linear-gradient(180deg, rgba(255, 80, 60, .1), rgba(255, 80, 60, .34)); }
.arming .col.has.sel::before { background: linear-gradient(180deg, rgba(255, 80, 60, .3), rgba(255, 80, 60, .62)); }
.bwrap:not(.live) .col { cursor: default; }
@keyframes f4-tip { 50% { opacity: .45; } }

/* Where the next disc would land, and where the other side is about to win (coach). */
.ghost::before, .danger::before { content: ""; position: absolute; inset: 16%; border-radius: 50%; border: calc(var(--cs) * .05) dashed var(--gc, #fff); opacity: .75; animation: f4-spin 6s linear infinite; }
.ghost, .danger { inline-size: var(--cs); block-size: var(--cs); pointer-events: none; }
.ghost[data-p="1"] { --gc: var(--p1b); }
.ghost[data-p="2"] { --gc: var(--p2b); }
.danger::before { border-color: var(--bad); border-style: solid; box-shadow: 0 0 calc(var(--cs) * .2) var(--bad), inset 0 0 calc(var(--cs) * .14) var(--bad); animation: f4-tip .8s ease-in-out infinite; opacity: 1; }
@keyframes f4-spin { to { transform: rotate(360deg); } }

/* A disc falls from above the board, behind the front panel, and bounces once. */
.disc.fall { animation: f4-fall var(--t, .42s) both; }
@keyframes f4-fall {
    0% { transform: translateY(calc((var(--r) + 1) * var(--cs) * -1 - var(--pad) - var(--rw))); animation-timing-function: cubic-bezier(.45, 0, .9, .55); }
    68% { transform: translateY(0); animation-timing-function: cubic-bezier(.2, .7, .5, 1); }
    80% { transform: translateY(calc(var(--cs) * -.13)); animation-timing-function: cubic-bezier(.5, 0, .9, .5); }
    92% { transform: translateY(0); }
    96% { transform: translateY(calc(var(--cs) * -.025)); }
    100% { transform: translateY(0); }
}
.disc.deal { animation: f4-deal .34s calc(var(--dk) * 22ms) cubic-bezier(.3, 1.5, .5, 1) backwards; }
@keyframes f4-deal { from { opacity: 0; transform: scale(.3); } }
.disc.last::after { opacity: 1; background: #fff; }
.disc.gone { animation: f4-gone .3s ease-in forwards; }
@keyframes f4-gone { 30% { transform: scale(1.2); filter: brightness(2.2); } to { transform: scale(.1); opacity: 0; } }
.disc.back { animation: f4-back .22s ease-in forwards; }
@keyframes f4-back { to { transform: translateY(calc(var(--cs) * -.9)) scale(.6); opacity: 0; } }
.frame.jolt { animation: f4-jolt .16s ease-out; }
@keyframes f4-jolt { 40% { transform: translateY(calc(var(--cs) * .035)); } }
.bwrap.lost { animation: f4-shake .45s; }
.bwrap.won { animation: f4-joy .5s .15s ease-out; }
.bwrap.quake { animation: f4-quake .5s; }
@keyframes f4-shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@keyframes f4-joy { 30% { transform: scale(1.025); } 60% { transform: scale(.995); } }
@keyframes f4-quake { 10% { transform: translate(-6px, 4px) rotate(-.6deg); } 25% { transform: translate(6px, -3px) rotate(.6deg); } 40% { transform: translate(-5px, 2px); } 55% { transform: translate(4px, -2px); } 70% { transform: translate(-2px, 1px); } }
@keyframes f4-nope { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.nope { animation: f4-nope .28s; }

/* The winning line */
.strike { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; pointer-events: none; overflow: visible; z-index: 2; }
.strike line { stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: f4-draw .4s .1s ease-out backwards; }
.strike .halo { stroke-width: calc(var(--cs) * .34); opacity: .4; }
.strike .core { stroke: #fff; stroke-width: calc(var(--cs) * .12); }
.strike .s1 { stroke: var(--p1b); }
.strike .s2 { stroke: var(--p2b); }
@keyframes f4-draw { from { stroke-dashoffset: 1; } }
.disc.win { z-index: 1; animation: f4-win .7s calc(var(--wk) * 110ms + .2s) cubic-bezier(.3, 1.6, .5, 1) backwards, f4-glow 1.1s calc(var(--wk) * 110ms + .9s) ease-in-out infinite; }
.disc.win::after { background: #fff; opacity: .95; }
@keyframes f4-win { 30% { transform: scale(1.3) rotate(40deg); } 60% { transform: scale(.94) rotate(0); } }
@keyframes f4-glow { 50% { filter: brightness(1.35) drop-shadow(0 0 calc(var(--cs) * .16) #fff); } }
.match.ended .discs .disc:not(.win):not(.st) { filter: saturate(.55) brightness(.62); transition: filter .35s; }

/* Effects over the board */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.burst { position: absolute; inline-size: 0; block-size: 0; }
.burst .ring { position: absolute; left: calc(var(--s) * -.5); top: calc(var(--s) * -.5); width: var(--s); height: var(--s); border-radius: 50%; border: 3px solid var(--bc); opacity: 0; animation: f4-ring .5s var(--dl, 0ms) ease-out; }
.burst i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--bc); opacity: 0; animation: f4-spark calc(var(--d) * 1s) var(--dl, 0ms) ease-out; }
.burst.dust i { background: rgba(255, 255, 255, .8); width: 6px; height: 6px; animation-name: f4-dust; }
.burst.fire i { width: 11px; height: 11px; }
@keyframes f4-ring { from { transform: scale(.3); opacity: .9; } to { transform: scale(1.05); opacity: 0; } }
@keyframes f4-spark { from { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(1); } to { opacity: 0; transform: rotate(var(--a)) translateX(calc(var(--s) * .62)) scale(.2); } }
@keyframes f4-dust { from { opacity: .9; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); } }
.flashcol { position: absolute; inline-size: var(--cs); inset-block: var(--pad); border-radius: calc(var(--cs) * .5); background: linear-gradient(180deg, #fff, #ffd23f 40%, #ff5a2a); animation: f4-flash .45s ease-out forwards; }
@keyframes f4-flash { from { opacity: .95; transform: scaleX(1.25); } to { opacity: 0; transform: scaleX(.5); } }
.bombfx { position: absolute; inline-size: var(--cs); block-size: var(--cs); animation: f4-bombfall var(--t, .4s) cubic-bezier(.5, 0, .9, .6) forwards; }
.bombart { inline-size: 100%; block-size: 100%; overflow: visible; }
.bombart .spark { animation: f4-bulb .12s linear infinite alternate; transform-origin: 72px 11px; }
@keyframes f4-bombfall { from { transform: translateY(var(--from)) rotate(-30deg); } to { transform: translateY(0) rotate(20deg); } }
.pop-txt {
    position: absolute; z-index: 4; pointer-events: none; white-space: nowrap; translate: -50% -50%; color: #fff; direction: inherit;
    font-weight: 900; font-size: clamp(1rem, calc(var(--cs) * .46), 1.5rem); -webkit-text-stroke: 5px var(--edge); paint-order: stroke fill;
    filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .3)); animation: f4-txt 1.15s ease-out forwards;
}
.pop-txt.p1 { color: var(--p1a); }
.pop-txt.p2 { color: var(--p2a); }
.pop-txt.warn { color: #ff9aa6; }
.pop-txt.big { font-size: clamp(1.6rem, calc(var(--cs) * .9), 3rem); color: #ffd23f; }
@keyframes f4-txt { 0% { opacity: 0; transform: translateY(6px) scale(.6); } 18% { opacity: 1; transform: translateY(-6px) scale(1.14); } 30% { transform: translateY(-10px) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-38px); } }
.hand { position: absolute; z-index: 5; inline-size: calc(var(--cs) * .9); block-size: calc(var(--cs) * .9); pointer-events: none; animation: f4-hand .9s ease-in-out infinite; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .4)); }
.hand .ic { inline-size: 100%; block-size: 100%; }
@keyframes f4-hand { 50% { transform: translate(4%, 16%) scale(.94); } }
.banner {
    position: absolute; z-index: 5; inset-inline: -3%; inset-block-start: 56%; translate: 0 -50%; padding: calc(var(--cs) * .22) 8px; text-align: center; pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(6, 8, 26, .84) 16%, rgba(6, 8, 26, .84) 84%, transparent); animation: f4-banner var(--bt, 1.3s) ease-out forwards;
}
[dir="rtl"] .banner { direction: rtl; }
.banner b { display: block; color: #fff; font-weight: 900; font-size: clamp(1.25rem, calc(var(--cs) * .66), 2.6rem); line-height: 1.15; text-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.banner.p1 b { color: var(--p1a); }
.banner.p2 b { color: var(--p2a); }
.banner span { display: block; color: #d7dcff; font-weight: 700; font-size: clamp(.8rem, calc(var(--cs) * .3), 1.1rem); }
@keyframes f4-banner { 0% { opacity: 0; transform: scaleY(.2); } 14% { opacity: 1; transform: scaleY(1.06); } 22% { transform: scaleY(1); } 82% { opacity: 1; } 100% { opacity: 0; transform: scaleY(.6); } }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 45; }
.confetti i { position: absolute; inset-block-start: -14px; inline-size: 9px; block-size: 13px; border-radius: 2px; animation: f4-drop var(--d) ease-in forwards; animation-delay: var(--w); }
.confetti i:nth-child(3n) { border-radius: 50%; block-size: 10px; inline-size: 10px; }
@keyframes f4-drop { to { transform: translate3d(var(--x), calc(var(--H) + 30px), 0) rotate(var(--r)); } }

.mbot { grid-area: bot; display: flex; align-items: center; gap: 8px; min-block-size: 48px; }
.status { flex: 1; margin: 0; text-align: center; font-weight: 800; font-size: 1.02rem; line-height: 1.25; min-inline-size: 0; }
.status.you { color: var(--p1a); }
.status.them { color: var(--p2a); }
.status.warn { color: #ff9aa6; }
[data-theme="candy"] .status.you { color: var(--p1c); }
[data-theme="candy"] .status.them { color: var(--p2c); }
[data-theme="candy"] .status.warn { color: var(--bad); }
.status .dots { display: inline-flex; gap: 4px; margin-inline-start: 6px; vertical-align: middle; }
.status .dots i { inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; animation: f4-dot 1s ease-in-out infinite; }
.status .dots i:nth-child(2) { animation-delay: .15s; }
.status .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes f4-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.tool {
    flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 3px; inline-size: 56px; block-size: 44px; border-radius: 14px; font-weight: 900; font-size: .95rem;
    background: var(--ui); border: 1px solid var(--line); box-shadow: 0 3px 0 rgba(0, 0, 0, .22); transition: transform .08s;
}
.tool .ic { inline-size: 21px; block-size: 21px; }
#hint .ic { color: var(--gold); }
.tool:active { transform: translateY(2px); }
.tool:disabled { opacity: .42; cursor: default; }
.tool.none { visibility: hidden; }
#bomb[aria-pressed="true"] { background: linear-gradient(180deg, #ff8a5c, #e23a2a); color: #fff; border-color: transparent; animation: f4-pulse 1s ease-in-out infinite; }

/* Stacked layout: the disc chip rides on the avatar and the name may take two lines. */
.tall .pl .chip { position: absolute; inset-block-end: 3px; --cs: 20px; box-shadow: 0 0 0 2px var(--card), inset 0 0 0 1px var(--cc); }
.tall .pl.me .chip { inset-inline-start: 6px; }
.tall .pl.op .chip { inset-inline-end: 6px; }
.tall .pl-name { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.15; }
.tall .pl-name.long { font-size: .8rem; }
.nm-nick, .tall .nm-full { display: none; }
.tall .nm-nick { display: inline; }

/* Tall phones have room to spare: bigger player strips. */
.roomy .pl { padding: 9px 12px; }
.roomy .pl .av { inline-size: 62px; block-size: 62px; }
.roomy .pl-name { font-size: 1.05rem; }
.roomy .status { font-size: 1.15rem; }
.roomy .mbot { min-block-size: 58px; }
.roomy .tool { block-size: 50px; inline-size: 62px; }
/* Very tall phones: the player cards stand upright, face on top, disc in the corner. */
.lofty .pl, .lofty .pl.op { flex-direction: column; text-align: center; padding: 12px 10px 10px; gap: 6px; border-radius: 22px; }
.lofty .pl .av { inline-size: 78px; block-size: 78px; }
.lofty .pl-txt, .lofty .pl.op .pl-txt { flex: none; inline-size: 100%; justify-items: center; }
.lofty .pl-name { font-size: 1.1rem; }
.lofty .pips i { inline-size: 17px; block-size: 17px; }
.lofty.tall .pl .chip { --cs: 24px; inset-block: 9px auto; }
.lofty.tall .pl.me .chip { inset-inline-start: 9px; }
.lofty.tall .pl.op .chip { inset-inline-end: 9px; }

/* Side panels on wide stages */
.wide .match { grid-template: "me top op" calc(46px * var(--z, 1)) "me board op" minmax(0, 1fr) "me bot op" auto / minmax(0, 1fr) var(--bcol, 300px) minmax(0, 1fr); column-gap: 20px; padding: 10px 16px 12px; }
.wide .mtop { padding-inline: 0; }
.wide .pl { flex-direction: column; justify-content: center; text-align: center; gap: 10px; align-self: center; justify-self: center; inline-size: min(100%, 210px); padding: 18px 12px; border-radius: 26px; }
.wide .pl .av { inline-size: clamp(64px, calc(var(--H) * .2), 118px); block-size: clamp(64px, calc(var(--H) * .2), 118px); }
.wide .pl-txt, .wide .pl.op .pl-txt { justify-items: center; flex: none; gap: 8px; inline-size: 100%; }
.wide .pl-name { font-size: 1.1rem; white-space: normal; }
.wide .pl .chip { --cs: 30px; }
.wide .pips i { inline-size: 18px; block-size: 18px; }
.wide .pl .clock { inset-inline: 18px; block-size: 7px; }
.wide .bubble { inset-block-start: calc(100% + 12px); inset-inline: 0; margin-inline: auto; max-inline-size: 100%; }
.wide .bubble::before { inset-inline: 0; margin-inline: auto; }
.wide .status { font-size: 1.12rem; }
.wide .cups { grid-template-columns: repeat(4, 1fr); max-inline-size: 1000px; }
.wide .stats { max-inline-size: 1000px; }
.short.wide .cups { grid-template-columns: repeat(3, 1fr); }
.wide .mbot { justify-self: center; inline-size: max(100%, 330px); }
.wide .home-in { flex-direction: row; justify-content: center; gap: clamp(24px, 6vw, 80px); padding-block-start: 0; }
.wide .s-home .logo { --cs: clamp(40px, calc(var(--H) * .12), 76px); }
.wide .s-home .menu-col { inline-size: min(48%, 440px); }
.wide .logo p { font-size: 1.1rem; }
.wide .cup { grid-template-columns: repeat(3, 1fr); margin-block: auto; align-items: stretch; }
.wide .stage { grid-template-rows: auto 1fr; }
.wide:not(.short) .rival { padding-block: 16px 12px; gap: 5px; }
.wide:not(.short) .rival .av { inline-size: 78px; block-size: 78px; }
.wide:not(.short) .rival .lockic { inset-block-start: 40px; }
.wide .pz { grid-template-columns: repeat(3, 1fr); align-items: start; }
.wide .pack h3 small { order: 3; flex-basis: 100%; }
.wide .pz .mode.day { grid-column: 1 / -1; justify-self: center; inline-size: min(100%, 460px); }

/* Short stages (a phone on its side) */
.short .match { gap: 4px; padding-block: 4px 6px; }
.short.wide .match { grid-template-rows: 30px minmax(0, 1fr) auto; }
.short .mtop b { font-size: .85rem; }
.short .mtop span { display: none; }
.short .mbot { min-block-size: 36px; }
.short .tool { block-size: 36px; inline-size: 50px; }
.short .status { font-size: .9rem; }
.short .pl { padding: 8px 6px; gap: 5px; }
.short .rbtn { inline-size: 34px; block-size: 34px; }
.short .sys, .short .pausebtn { inset-block-start: 5px; }
.short .mode { min-block-size: 50px; padding-block: 5px; }
.short .mode .mi { inline-size: 38px; block-size: 38px; }
.short .mode.main { min-block-size: 62px; }
.short .mode.main .av { inline-size: 50px; block-size: 50px; }
.short .modes, .short .menu-col { gap: 7px; }
.short .home-row .btn { min-block-size: 40px; }
.short .logo p { display: none; }
.short .logo h2 { font-size: 1.5rem; }
.short .screen { gap: 8px; padding-block: 6px 10px; }
.short.wide .setup { grid-template-columns: 1fr 1fr; max-inline-size: 840px; gap: 8px 14px; align-items: start; }
.short.wide .setup .btn { grid-column: 1 / -1; min-block-size: 44px; margin-block-start: 0; }
.short .opt .dg { inline-size: 44px; }
.short .opt .av { inline-size: 36px; block-size: 36px; }
.short .opt small { display: none; }
.short .stage { padding: 6px 8px 8px; gap: 5px; border-radius: 18px; }
.short .stage h3 { font-size: .8rem; }
.short .cast { gap: 6px; }
.short .rival { padding: 6px 4px 5px; gap: 1px; border-radius: 14px; }
.short .rival .av { inline-size: 44px; block-size: 44px; }
.short .rival b { font-size: .8rem; }
.short .rival .tags { display: none; }
.short .rival .lockic { inset-block-start: 14px; }
.short .rival .bossf { inset-block-start: -5px; inset-inline-end: -3px; font-size: .58rem; padding: 2px 6px; }
.short .pack { padding: 7px 9px 9px; gap: 6px; }
.short .num { font-size: .95rem; aspect-ratio: 1.5; }
.short .pz .mode.day { min-block-size: 54px; }

/* ---------- overlays ---------- */
.ov { position: absolute; inset: 0; z-index: 40; display: flex; padding: 12px; overflow: hidden auto; background: rgba(4, 5, 18, .74); animation: f4-in .2s ease-out; }
.card {
    position: relative; margin: auto; inline-size: min(100%, 400px); padding: 18px 16px 16px; border-radius: 26px; text-align: center; background: var(--card); border: 1px solid var(--line);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5), inset 0 2px 0 rgba(255, 255, 255, .1); animation: f4-card .42s cubic-bezier(.3, 1.45, .5, 1);
}
@keyframes f4-card { from { opacity: 0; transform: translateY(26px) scale(.9); } }
.card h2 { margin: 0; font-size: 1.6rem; font-weight: 900; line-height: 1.2; }
.card h2.win { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card h2.loss { color: var(--bad); }
.card .sub { margin: 4px 0 0; color: var(--muted); font-weight: 700; font-size: .92rem; line-height: 1.4; }
.card .acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-block-start: 14px; }
.card .acts .btn { flex: 1 1 130px; padding-inline: 12px; }
.card .acts .btn.wide-b { flex-basis: 100%; }
.duel { display: flex; align-items: center; justify-content: center; gap: 12px; margin-block: 4px 8px; }
.duel .av { inline-size: 82px; block-size: 82px; }
.duel .vs { font-weight: 900; font-size: 1.3rem; color: var(--accent); font-style: italic; }
.duel .sc { font-weight: 900; font-size: 2rem; font-variant-numeric: tabular-nums; direction: ltr; }
.card .quote { margin: 8px 0 0; padding: 8px 12px; border-radius: 14px; background: #fff; color: #1d1b35; font-weight: 800; font-size: .92rem; line-height: 1.4; position: relative; }
.rulebox { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 12px; margin-block-start: 10px; padding: 10px 12px; border-radius: 16px; background: var(--ui); border: 1px solid var(--line); text-align: start; }
.rulebox .dg { inline-size: 70px; }
.rulebox b { display: block; font-weight: 900; }
.rulebox b + span { display: block; color: var(--muted); font-size: .84rem; font-weight: 600; line-height: 1.35; }
.rulebox .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-block-start: 5px; }
.big3 { display: flex; justify-content: center; gap: 6px; margin-block: 8px 2px; color: rgba(128, 128, 150, .4); }
.big3 .ic { inline-size: 52px; block-size: 52px; }
.big3 .ic:nth-child(2) { inline-size: 64px; block-size: 64px; margin-block-start: -8px; }
.big3 .on { color: var(--gold); filter: drop-shadow(0 0 10px var(--gold)); animation: f4-star .55s cubic-bezier(.3, 1.8, .5, 1) backwards; }
.big3.one .ic { inline-size: 76px; block-size: 76px; margin: 0; }
@keyframes f4-star { from { transform: scale(0) rotate(-60deg); } 60% { transform: scale(1.3) rotate(8deg); } }
.goals { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 8px 0 0; padding: 0; list-style: none; }
.goals li { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--ui); border: 1px solid var(--line); font-weight: 800; font-size: .8rem; }
.goals .ic { inline-size: 14px; block-size: 14px; color: var(--muted); }
.goals .yes .ic { color: var(--ok); }
.goals li:not(.yes) { color: var(--muted); }
.tally { display: flex; justify-content: center; gap: 8px; margin-block-start: 10px; }
.tally div { flex: 1 1 0; max-inline-size: 120px; padding: 6px 4px; border-radius: 14px; background: var(--ui); border: 1px solid var(--line); }
.tally b { display: block; font-size: 1.2rem; font-weight: 900; font-variant-numeric: tabular-nums; direction: ltr; }
.tally span { display: block; color: var(--muted); font-size: .68rem; font-weight: 700; }
.news { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-block-start: 10px; }
.news p { margin: 0; padding: 5px 12px; border-radius: 999px; font-weight: 900; font-size: .84rem; color: var(--ink); background: linear-gradient(90deg, var(--accent), var(--accent2)); animation: f4-rise .4s backwards; }
/* Cards on a short stage: wider and tighter, so nothing needs a scroll. */
.short .ov { padding: 8px; }
.short .card { inline-size: min(100%, 560px); padding: 10px 14px 12px; border-radius: 22px; }
.short .card h2 { font-size: 1.25rem; }
.short .duel { margin-block: 0 4px; }
.short .duel .av { inline-size: 52px; block-size: 52px; }
.short .card .quote { margin-block-start: 5px; padding-block: 6px; }
.short .rulebox { margin-block-start: 6px; padding-block: 6px; }
.short .rulebox .dg { inline-size: 54px; }
.short .big3 { margin-block: 4px 0; }
.short .big3 .ic { inline-size: 34px; block-size: 34px; }
.short .big3 .ic:nth-child(2) { inline-size: 42px; block-size: 42px; margin-block-start: -6px; }
.short .big3.one .ic { inline-size: 48px; block-size: 48px; }
.short .goals, .short .news, .short .tally { margin-block-start: 5px; }
.short .tally div { padding-block: 3px; }
.short .card .acts { margin-block-start: 8px; flex-wrap: nowrap; }
.short .card .acts .btn, .short .card .acts .btn.wide-b { flex: 1 1 0; min-block-size: 44px; padding-inline: 8px; font-size: .95rem; }
.toasts { position: absolute; z-index: 60; inset-block-start: 56px; inset-inline: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding-inline: 8px; pointer-events: none; }
.wide .toasts { inset-block-start: 6px; padding-inline: 110px; }
.toast { display: inline-flex; align-items: center; gap: 8px; max-inline-size: 92%; padding: 8px 16px; border-radius: 999px; font-weight: 900; font-size: .9rem; color: var(--ink); background: linear-gradient(90deg, var(--accent), var(--accent2)); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: f4-toast 3s ease-out forwards; }
.toast .ic { inline-size: 18px; block-size: 18px; }
@keyframes f4-toast { 0% { opacity: 0; transform: translateY(-14px) scale(.8); } 8% { opacity: 1; transform: translateY(0) scale(1.05); } 12% { transform: scale(1); } 88% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

/* ---------- small phones ---------- */
@media (max-width: 380px) {
    .mode b { font-size: .94rem; }
    .mode small { font-size: .7rem; }
    .mode.main b { font-size: 1.16rem; }
    .mode { grid-template-columns: 38px 1fr; gap: 7px; padding-inline: 8px; }
    .mode .mi { inline-size: 38px; block-size: 38px; }
    .pl { padding: 5px 7px; gap: 6px; }
    .pl .av { inline-size: 44px; block-size: 44px; }
    .card h2 { font-size: 1.4rem; }
    .duel .av { inline-size: 70px; block-size: 70px; }
    .stat b { font-size: 1.15rem; }
    .tool { inline-size: 50px; }
    .roomy .pl { padding: 7px 8px; }
    .tall .pl .chip { --cs: 17px; inset-block-end: 2px; }
    .tall .pl.me .chip { inset-inline-start: 3px; }
    .tall .pl.op .chip { inset-inline-end: 3px; }
    .roomy .pl .av { inline-size: 52px; block-size: 52px; }
    .lofty .pl .av { inline-size: 66px; block-size: 66px; }
    .lofty.tall .pl .chip { --cs: 20px; inset-block: 7px auto; }
}
@media (max-width: 340px) {
    .roomy .pl .av { inline-size: 42px; block-size: 42px; }
    .lofty .pl .av { inline-size: 58px; block-size: 58px; }
    .pl-name, .roomy .pl-name { font-size: .86rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition: none !important; }
    .scene i, .confetti, .burst i { display: none; }
    .pl .clock i { animation-duration: var(--t, 5s) !important; }
    .pop-txt, .banner, .toast { animation-duration: 1.4s !important; }
    .toast { animation-duration: 3s !important; }
}
