/* XO. One stage (.game) that fills the frame; game.js sets its height (--H) and the board size (--bs)
   and marks it .wide (side panels) or .tall (stacked, phones). Logical properties only, so RTL and LTR
   share one file. Every colour comes from the theme variables below. */

/* ---------- themes ---------- */
:root, [data-theme="arena"] {
    --bg0: #0a0c28; --bg1: #171c57; --bg2: #43208a; --glow: rgba(120, 140, 255, .32);
    --ui: rgba(20, 24, 70, .82); --ui2: #2a3182; --card: #1b2060; --line: rgba(150, 165, 255, .28); --text: #f3f5ff; --muted: #aab2ea;
    --accent: #ffcf4a; --accent2: #ff8a3c; --accent-edge: #b4500e; --ink: #2b1400;
    --board: #131747; --board-edge: #090b2a; --tile: #2f3794; --tile2: #222870; --tile-edge: #13174a; --grid: #cfd6ff;
    --x1: #ffe37a; --x2: #ff8a3c; --xs: #a3441a; --o1: #8bfff1; --o2: #3d8bff; --os: #1b3f9c;
    --ok: #5ee08a; --bad: #ff6b7d; --gold: #ffc533; --sil: brightness(0) invert(1) opacity(.2); --chip: var(--ui2); --edge: #14103a;
    --font: system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
}
[data-theme="chalk"] {
    --bg0: #0c2219; --bg1: #15392b; --bg2: #1f5540; --glow: rgba(190, 255, 225, .14);
    --ui: rgba(10, 34, 26, .82); --ui2: #23604a; --card: #143a2c; --line: rgba(225, 255, 240, .26); --text: #f4fff8; --muted: #a5d3bd;
    --accent: #ffe36b; --accent2: #ffb347; --accent-edge: #a36a12; --ink: #2a1c00;
    --board: #1a4635; --board-edge: #7a5330; --grid: #eefff5;
    --x1: #fff6b8; --x2: #ffd54d; --xs: rgba(0, 0, 0, .28); --o1: #d6f3ff; --o2: #86d4ff; --os: rgba(0, 0, 0, .28); --chip: var(--ui2);
}
[data-theme="candy"] {
    --bg0: #ffc7e3; --bg1: #ffe4c4; --bg2: #c4efff; --glow: rgba(255, 255, 255, .75);
    --ui: rgba(255, 255, 255, .86); --ui2: #fff; --card: #fff7fb; --line: rgba(214, 80, 150, .3); --text: #58204d; --muted: #a05c8c;
    --accent: #ff5fa2; --accent2: #ff8f5f; --accent-edge: #b92d6b; --ink: #fff;
    --board: #ffa9d2; --board-edge: #e06aa8; --tile: #ffffff; --tile2: #ffeaf5; --tile-edge: #f0a0cb; --grid: #d6509a;
    --x1: #ff86c0; --x2: #ff3d86; --xs: #a81b55; --o1: #7be8d6; --o2: #1fa9d0; --os: #0e6f8c; --sil: brightness(0) opacity(.2); --ok: #17a45a; --bad: #e0304f; --gold: #ffab1a; --chip: #ffdcee; --edge: #5a1244;
}
[data-theme="paper"] {
    --bg0: #efe4c8; --bg1: #fbf6e6; --bg2: #f4ecd2; --glow: rgba(255, 255, 255, .6);
    --ui: rgba(255, 253, 244, .92); --ui2: #fff; --card: #fffdf4; --line: rgba(50, 80, 160, .3); --text: #212e58; --muted: #66729a;
    --accent: #3d6bff; --accent2: #6aa0ff; --accent-edge: #2140ab; --ink: #fff;
    --board: #fffdf3; --board-edge: #cfc39c; --grid: #2b3a6e;
    --x1: #4a78ff; --x2: #1f3fae; --xs: rgba(20, 30, 80, .16); --o1: #ff6b6b; --o2: #cf2338; --os: rgba(80, 20, 20, .16); --sil: brightness(0) opacity(.2); --ok: #17a45a; --bad: #d42b45; --gold: #f5a300; --chip: #e4eafc; --edge: #16224f;
}
[data-theme="space"] {
    --bg0: #02030d; --bg1: #0a0f2e; --bg2: #31105a; --glow: rgba(170, 90, 255, .3);
    --ui: rgba(9, 11, 34, .84); --ui2: #1d2158; --card: #10133a; --line: rgba(175, 155, 255, .3); --text: #f4f1ff; --muted: #a6a1da;
    --accent: #c07bff; --accent2: #ff5fd2; --accent-edge: #6226ae; --ink: #fff;
    --board: #0d1036; --board-edge: #04051a; --tile: #212768; --tile2: #161a4c; --tile-edge: #0a0c2e; --grid: #d5ccff;
    --x1: #ffa8f2; --x2: #ff3dbb; --xs: #86126c; --o1: #d2ff8a; --o2: #36dc86; --os: #167542; --chip: var(--ui2);
}
[data-theme="gold"] {
    --bg0: #130509; --bg1: #390e1b; --bg2: #6a2414; --glow: rgba(255, 200, 90, .24);
    --ui: rgba(32, 8, 15, .86); --ui2: #4c1624; --card: #2a0a14; --line: rgba(255, 205, 110, .38); --text: #fff6df; --muted: #dcbb8a;
    --accent: #ffdc78; --accent2: #f0a02b; --accent-edge: #94600c; --ink: #2b1400;
    --board: #290a13; --board-edge: #c9962e; --tile: #50182a; --tile2: #3a101d; --tile-edge: #1e060d; --grid: #ffd98a;
    --x1: #fff2b8; --x2: #f0a02b; --xs: #85560a; --o1: #ffffff; --o2: #c4cfee; --os: #666f90; --chip: var(--ui2);
}

/* ---------- 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; }
.defs { position: absolute; inline-size: 0; block-size: 0; overflow: hidden; }
.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 slow drifting marks. */
.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 16% 8%, var(--glow), transparent 70%), radial-gradient(34% 42% at 88% 94%, var(--glow), transparent 70%);
}
.scene::after { content: ""; position: absolute; inset: 0; opacity: .5; background: repeating-linear-gradient(115deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 46px); }
[data-theme="chalk"] .scene::after { opacity: 1; background: radial-gradient(30% 22% at 30% 30%, rgba(255, 255, 255, .06), transparent 70%), radial-gradient(40% 26% at 72% 64%, rgba(255, 255, 255, .05), transparent 70%); }
[data-theme="candy"] .scene::after { opacity: .55; 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="paper"] .scene::after { opacity: 1; background: linear-gradient(90deg, transparent 39px, rgba(230, 70, 70, .4) 39px 41px, transparent 41px), repeating-linear-gradient(0deg, transparent 0 27px, rgba(60, 100, 200, .2) 27px 28px); }
[dir="rtl"][data-theme="paper"] .scene::after { background: linear-gradient(270deg, transparent 39px, rgba(230, 70, 70, .4) 39px 41px, transparent 41px), repeating-linear-gradient(0deg, transparent 0 27px, rgba(60, 100, 200, .2) 27px 28px); }
[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); opacity: .09; animation: xo-drift var(--d) linear var(--w) infinite; will-change: transform; }
.scene i .mk { inline-size: 100%; block-size: 100%; }
.scene i .mk-sh, .scene i .mk-hl { display: none; }
@keyframes xo-drift { from { transform: translate3d(0, 0, 0) rotate(0deg); } to { transform: translate3d(var(--x), calc(-1 * var(--H) - 160px), 0) rotate(var(--r)); } }

/* ---------- marks ---------- */
.mk { overflow: visible; }
.mk-st path, circle.mk-st, .mk-sh path, circle.mk-sh { fill: none; stroke-width: 15; stroke-linecap: round; }
.mx .mk-st path { stroke: var(--x2); stroke: url(#xo-gx); }
.mo .mk-st { stroke: var(--o2); stroke: url(#xo-go); }
.mx .mk-sh path { stroke: var(--xs); }
.mo .mk-sh { stroke: var(--os); }
.mk-hl path, path.mk-hl { fill: none; stroke: #fff; stroke-width: 4.5; stroke-linecap: round; opacity: .6; }
/* Small previews use their own theme's colours (a gradient belongs to the page's theme). */
.flat .mx .mk-st path { stroke: var(--x2); }
.flat .mo .mk-st { stroke: var(--o2); }

/* ---------- 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: 16px;
    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: xo-pulse 1.6s ease-in-out infinite; }
@keyframes xo-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; }
.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: xo-blink 4.6s infinite; transform-origin: 50px 50px; }
.av.live .bulb { animation: xo-bulb 1.4s ease-in-out infinite alternate; }
@keyframes xo-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.12); } }
@keyframes xo-bulb { to { fill: #fff3b0; } }
.av.hop { animation: xo-hop .6s cubic-bezier(.3, 1.5, .5, 1); }
.av.shake { animation: xo-nope .4s; }
@keyframes xo-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); }

/* ---------- 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: xo-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 xo-rise { from { opacity: 0; transform: translateY(14px); } }
.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.25rem; font-weight: 900; flex: 1; min-inline-size: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[dir="rtl"] .topbar .rbtn svg, [dir="rtl"] .flip { transform: scaleX(-1); }
.body { inline-size: 100%; max-inline-size: 980px; margin-block: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Home */
.s-home { justify-content: center; gap: 14px; }
.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: 16px; inline-size: 100%; margin-block: auto; padding-block-start: 44px; }
.logo { display: grid; justify-items: center; gap: 2px; }
.logo-marks { display: flex; align-items: center; gap: 4px; direction: ltr; }
.logo-marks .mk { inline-size: clamp(74px, calc(var(--H) * .17), 124px); block-size: auto; aspect-ratio: 1; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .3)); }
.logo-marks .mx { animation: xo-sway 3.6s ease-in-out infinite; }
.logo-marks .mo { animation: xo-sway 3.6s ease-in-out -1.8s infinite; }
@keyframes xo-sway { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-7px) rotate(5deg); } }
.logo p { margin: 0; color: var(--muted); font-weight: 700; font-size: .98rem; text-align: center; }
.crowd { display: none; margin-block-start: 14px; padding-inline-start: 12px; }
.crowd .av { inline-size: 46px; block-size: 46px; margin-inline-start: -12px; animation: xo-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 .av { inline-size: 40px; block-size: 40px; }
.modes { display: grid; gap: 10px; inline-size: min(100%, 430px); }
.mode {
    display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 9px 14px; min-block-size: 66px; border-radius: 20px;
    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: 1.1rem; font-weight: 900; line-height: 1.25; }
.mode small { display: block; color: var(--muted); font-size: .82rem; font-weight: 600; line-height: 1.3; }
.mode .mi { inline-size: 52px; block-size: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--chip); }
.mode .mi .ic { inline-size: 28px; block-size: 28px; }
.mode .go { inline-size: 34px; block-size: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .28); }
.mode .go .ic { inline-size: 18px; block-size: 18px; }
.mode.main {
    min-block-size: 84px; 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.28rem; }
.mode.main small { color: inherit; opacity: .8; font-weight: 700; }
.mode.main .av { inline-size: 58px; block-size: 58px; margin-inline-start: -3px; }
.home-row { display: flex; gap: 10px; inline-size: min(100%, 430px); }
.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; }

/* Tour map */
.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; inline-size: 100%; max-inline-size: 980px; }
.rival {
    position: relative; display: grid; justify-items: center; gap: 4px; padding: 14px 8px 10px; border-radius: 20px; text-align: center;
    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: 70px; block-size: 70px; }
.rival b { font-size: .98rem; font-weight: 900; line-height: 1.2; }
.rival .tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-block-size: 20px; }
.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); }
.rival .no { position: absolute; inset-block-start: 8px; inset-inline-start: 10px; font-weight: 900; font-size: .8rem; color: var(--muted); }
.rival .bossf { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; }
.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: xo-bob 1.8s ease-in-out infinite; }
@keyframes xo-bob { 50% { transform: translateY(-5px); } }
.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: 34px; inset-inline: 0; margin-inline: auto; inline-size: 30px; block-size: 30px; color: var(--text); }

/* Setup (Quick Match and 2 Players) */
.setup { inline-size: 100%; max-inline-size: 560px; display: grid; gap: 12px; 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; }
.opt {
    display: grid; justify-items: center; align-content: center; gap: 3px; min-block-size: 46px; padding: 8px 6px; border-radius: 16px; text-align: center;
    background: var(--ui); border: 2px solid transparent; box-shadow: 0 4px 0 rgba(0, 0, 0, .22); font-weight: 800; font-size: .95rem; line-height: 1.2;
}
.opt small { color: var(--muted); font-size: .7rem; 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: 54px; block-size: 54px; }
.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.1rem; }
.opt .row .ic { color: var(--gold); }
.dg-t { fill: var(--tile, var(--ui2)); opacity: .9; }
[data-theme="chalk"] .dg-t, [data-theme="paper"] .dg-t { fill: none; stroke: var(--grid); stroke-width: 1.5; opacity: .5; }
[data-theme="candy"] .dg-t { fill: var(--chip); }
.dg-x { fill: none; stroke: var(--x2); stroke-width: 5; stroke-linecap: round; }
.dg-o { fill: none; stroke: var(--o2); stroke-width: 5; }
.dg-f { opacity: .35; stroke-dasharray: 4 5; }
.setup .btn { justify-self: center; min-inline-size: 200px; margin-block-start: 4px; }

/* 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: 8px; border-radius: 20px; text-align: center; color: var(--text);
    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 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4%; padding: 5%; border-radius: 14px; background: var(--board); block-size: 96px; aspect-ratio: 1; margin-inline: auto; }
.theme .mini span { border-radius: 22%; background: linear-gradient(180deg, var(--tile), var(--tile2)); display: grid; place-items: center; }
.theme[data-board="lines"] .mini { gap: 0; }
.theme[data-board="lines"] .mini span { background: none; border-radius: 0; box-shadow: inset -1px -1px 0 var(--grid); }
.theme[data-board="lines"] .mini span:nth-child(3n) { box-shadow: inset 0 -1px 0 var(--grid); }
.theme[data-board="lines"] .mini span:nth-child(n+7) { box-shadow: inset -1px 0 0 var(--grid); }
.theme[data-board="lines"] .mini span:nth-child(9) { box-shadow: none; }
.theme .mini .mk { inline-size: 76%; block-size: 76%; }
.theme .mini .mk-sh, .theme .mini .mk-hl { display: none; }
.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; 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: 720px; }
.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: 720px; }
.cup { 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); }
.cup .ci { inline-size: 42px; block-size: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--muted); }
.cup b { display: block; font-size: .95rem; font-weight: 900; }
.cup small { display: block; color: var(--muted); font-size: .76rem; font-weight: 600; line-height: 1.3; }
.cup.got .ci { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: var(--ink); box-shadow: 0 0 16px var(--glow); }
.cup: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; }
.pl.op { grid-area: op; flex-direction: row-reverse; text-align: end; }
.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-mark { inline-size: 22px; block-size: 22px; flex: none; }
.pl-mark .mk { inline-size: 100%; block-size: 100%; }
.pl-mark .mk-sh, .pl-mark .mk-hl { display: none; }
.pl.on { border-color: var(--pc); box-shadow: 0 0 20px var(--pg); }
.pl.me { --pc: var(--x2); --pg: color-mix(in srgb, var(--x2) 45%, transparent); }
.pl.op { --pc: var(--o2); --pg: color-mix(in srgb, var(--o2) 45%, transparent); }
.pips { display: flex; gap: 5px; }
.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: xo-pip .6s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes xo-pip { from { transform: scale(0); } 60% { transform: scale(1.5); } }
/* Blitz 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: xo-clock var(--t, 5s) linear forwards; }
[dir="rtl"] .pl .clock i { transform-origin: 100% 50%; }
.pl.hold .clock i { animation-play-state: paused; }
@keyframes xo-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: xo-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 xo-say { from { opacity: 0; transform: translateY(-6px) scale(.8); } }

.barea { grid-area: board; position: relative; min-inline-size: 0; min-block-size: 0; }
.bwrap { position: absolute; inset: 0; margin: auto; inline-size: var(--bs, 300px); block-size: var(--bs, 300px); }
.board {
    --n: 3; --g: calc(var(--bs) * .03);
    position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); gap: var(--g); padding: var(--g);
    border-radius: calc(var(--bs) * .065); background: var(--board);
    box-shadow: 0 calc(var(--bs) * .022) 0 var(--board-edge), 0 calc(var(--bs) * .06) calc(var(--bs) * .1) rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .1);
}
.board[data-n="5"] { --g: calc(var(--bs) * .02); }
.cell {
    position: relative; display: grid; place-items: center; min-inline-size: 0; min-block-size: 0; border-radius: calc(var(--bs) * .045);
    background: linear-gradient(180deg, var(--tile), var(--tile2)); box-shadow: inset 0 calc(var(--bs) * -.014) 0 var(--tile-edge), inset 0 2px 0 rgba(255, 255, 255, .16);
    transition: transform .08s, filter .15s;
}
.board[data-n="5"] .cell { border-radius: calc(var(--bs) * .03); }
.cell .mk { inline-size: 76%; block-size: 76%; pointer-events: none; }
.board.live .cell:not(.mx):not(.mo):active { transform: translateY(2px) scale(.97); }
@media (hover: hover) { .board.live .cell:not(.mx):not(.mo):hover { filter: brightness(1.18); } }
.board:not(.live) .cell { cursor: default; }
.cell.mx { background: linear-gradient(180deg, color-mix(in srgb, var(--x2) 22%, var(--tile)), color-mix(in srgb, var(--x2) 12%, var(--tile2))); }
.cell.mo { background: linear-gradient(180deg, color-mix(in srgb, var(--o2) 22%, var(--tile)), color-mix(in srgb, var(--o2) 12%, var(--tile2))); }

/* A board drawn as a grid of lines (chalkboard, notebook). */
.glines { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; pointer-events: none; display: none; overflow: visible; }
.glines line { stroke: var(--grid); stroke-width: 1.7; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; opacity: .92; }
.board.deal ~ .glines line { animation: xo-draw .45s ease-out backwards; animation-delay: calc(var(--k) * 70ms); }
[data-board="lines"] .glines { display: block; }
[data-board="lines"] .board { gap: 0; padding: calc(var(--bs) * .03); box-shadow: 0 0 0 calc(var(--bs) * .018) var(--board-edge), 0 calc(var(--bs) * .06) calc(var(--bs) * .1) rgba(0, 0, 0, .3); border-radius: calc(var(--bs) * .03); }
[data-board="lines"] .cell, [data-board="lines"] .cell.mx, [data-board="lines"] .cell.mo { background: none; box-shadow: none; }
[data-theme="chalk"] .board { background: radial-gradient(60% 50% at 40% 35%, rgba(255, 255, 255, .06), transparent 70%) var(--board); }
[data-theme="paper"] .board { background: repeating-linear-gradient(0deg, transparent 0 calc(var(--bs) * .0605), rgba(60, 100, 200, .16) calc(var(--bs) * .0605) calc(var(--bs) * .064)) var(--board); }
[data-theme="chalk"] .mk-hl, [data-theme="paper"] .mk-hl { display: none; }
[data-theme="chalk"] .mk-st path, [data-theme="chalk"] circle.mk-st, [data-theme="paper"] .mk-st path, [data-theme="paper"] circle.mk-st { stroke-width: 11; }
[data-theme="chalk"] .mk-sh path, [data-theme="chalk"] circle.mk-sh, [data-theme="paper"] .mk-sh path, [data-theme="paper"] circle.mk-sh { stroke-width: 11; }

/* Placing a mark */
.cell.pop .mk-st path, .cell.pop circle.mk-st { stroke-dasharray: 1; animation: xo-draw .2s ease-out backwards; }
.cell.pop .mk-st path + path { animation-delay: .13s; }
.cell.pop circle.mk-st { animation-duration: .32s; }
.cell.pop .mk { animation: xo-pop .42s cubic-bezier(.3, 1.7, .5, 1); }
.cell.pop .mk-sh, .cell.pop .mk-hl { animation: xo-in .2s .24s backwards; }
@keyframes xo-draw { from { stroke-dashoffset: 1; } }
@keyframes xo-pop { from { transform: scale(.6) rotate(-10deg); } 60% { transform: scale(1.12) rotate(2deg); } }
@keyframes xo-in { from { opacity: 0; } }
.cell.nope { animation: xo-nope .28s; }
@keyframes xo-nope { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.board.thump { animation: xo-thump .2s ease-out; }
@keyframes xo-thump { 40% { transform: scale(.985) translateY(2px); } }
.board.deal .cell { animation: xo-deal .34s calc(var(--dk) * 28ms) cubic-bezier(.3, 1.4, .5, 1) backwards; }
@keyframes xo-deal { from { opacity: 0; transform: scale(.6) translateY(12px); } }
.cell.last::before { content: ""; position: absolute; inset: 7%; border-radius: inherit; border: 2px solid rgba(255, 255, 255, .34); border-color: color-mix(in srgb, var(--grid) 38%, transparent); pointer-events: none; }

/* Hover preview of the mark that would go here (mouse only) */
@media (hover: hover) {
    .board.live .cell:empty:hover::after {
        content: ""; position: absolute; inset: 14%; opacity: .34; background: var(--x2);
        -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat;
        --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M20 20L80 80M80 20L20 80' fill='none' stroke='%23000' stroke-width='19' stroke-linecap='round'/%3E%3C/svg%3E");
    }
    .board.live[data-turn="o"] .cell:empty:hover::after {
        background: var(--o2);
        --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='31' fill='none' stroke='%23000' stroke-width='19'/%3E%3C/svg%3E");
    }
}

/* Vanish: the mark a player is about to lose */
.cell.fade .mk { animation: xo-fade .9s ease-in-out infinite alternate; }
@keyframes xo-fade { from { opacity: .85; } to { opacity: .28; } }
.cell.fade::after { content: ""; position: absolute; inset: 9%; border-radius: inherit; border: 2px dashed rgba(255, 255, 255, .55); border-color: color-mix(in srgb, var(--grid) 70%, transparent); pointer-events: none; }
.cell .mk.gone { animation: xo-gone .32s ease-in forwards; }
@keyframes xo-gone { to { transform: scale(.2) rotate(40deg); opacity: 0; } }

/* Coach and hints */
.cell.tip::before, .cell.danger::before {
    content: ""; position: absolute; inset: 8%; border-radius: inherit; pointer-events: none;
    border: 3px solid var(--accent); box-shadow: 0 0 16px var(--accent); animation: xo-tip 1s ease-in-out infinite;
}
.cell.danger::before { border-color: var(--bad); border-style: dashed; box-shadow: none; opacity: .7; }
@keyframes xo-tip { 50% { transform: scale(.86); opacity: .45; } }
.hand { position: absolute; z-index: 5; inline-size: calc(var(--bs) * .17); block-size: calc(var(--bs) * .17); pointer-events: none; animation: xo-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 xo-hand { 50% { transform: translate(6%, 14%) scale(.94); } }

/* 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: xo-draw .38s .12s ease-out backwards; }
.strike .halo { stroke-width: calc(var(--bs) * .07); opacity: .35; }
.strike .core { stroke: #fff; stroke-width: calc(var(--bs) * .028); }
.strike .sx { stroke: var(--x2); }
.strike .so { stroke: var(--o2); }
.cell.win { z-index: 1; }
.cell.win .mk { animation: xo-win .7s calc(var(--wk) * 110ms + .25s) cubic-bezier(.3, 1.6, .5, 1) backwards, xo-bob 1.2s calc(var(--wk) * 110ms + 1s) ease-in-out infinite; }
@keyframes xo-win { 30% { transform: scale(1.35) rotate(8deg); } 60% { transform: scale(.94); } }
.match.ended .cell:not(.win) .mk { opacity: .3; transition: opacity .3s; }
.bwrap.lost { animation: xo-shake .45s; }
.bwrap.won { animation: xo-joy .5s .15s ease-out; }
.bwrap.drawn .cell .mk { animation: xo-wobble .6s ease-in-out; }
@keyframes xo-shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@keyframes xo-joy { 30% { transform: scale(1.025); } 60% { transform: scale(.995); } }
@keyframes xo-wobble { 30% { transform: rotate(-9deg) scale(.94); } 65% { transform: rotate(6deg); } }

/* 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.bx { --c: var(--x1); }
.burst.bo { --c: var(--o1); }
.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(--c); opacity: 0; animation: xo-ring .5s var(--dl, 0ms) ease-out; }
.burst i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: 0; animation: xo-spark calc(var(--d) * 1s) var(--dl, 0ms) ease-out; }
.burst.puff i { background: #fff; }
@keyframes xo-ring { from { transform: scale(.3); opacity: .9; } to { transform: scale(1.05); opacity: 0; } }
@keyframes xo-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); } }
.pop-txt {
    position: absolute; z-index: 4; pointer-events: none; white-space: nowrap; translate: -50% -50%; color: #fff;
    font-weight: 900; font-size: clamp(1rem, calc(var(--bs) * .06), 1.45rem); -webkit-text-stroke: 5px var(--edge); paint-order: stroke fill;
    filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .3)); animation: xo-txt 1.15s ease-out forwards;
}
.pop-txt.px { color: var(--x1); }
.pop-txt.po { color: var(--o1); }
.pop-txt.warn { color: #ff8f9d; }
@keyframes xo-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); } }
.banner {
    position: absolute; z-index: 5; inset-inline: -4%; inset-block-start: 50%; translate: 0 -50%; padding: calc(var(--bs) * .04) 8px; text-align: center; pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(6, 8, 26, .82) 18%, rgba(6, 8, 26, .82) 82%, transparent); animation: xo-banner var(--bt, 1.3s) ease-out forwards;
}
.banner b { display: block; color: #fff; font-weight: 900; font-size: clamp(1.25rem, calc(var(--bs) * .1), 2.6rem); line-height: 1.15; text-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.banner.px b { color: var(--x1); }
.banner.po b { color: var(--o1); }
.banner span { display: block; color: #d7dcff; font-weight: 700; font-size: clamp(.8rem, calc(var(--bs) * .045), 1.1rem); }
@keyframes xo-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); } }
.banner.stay { animation-name: xo-banner-in; animation-duration: .35s; }
@keyframes xo-banner-in { from { opacity: 0; transform: scaleY(.2); } }
.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: xo-fall var(--d) ease-in forwards; animation-delay: var(--w); }
@keyframes xo-fall { 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.05rem; line-height: 1.25; min-inline-size: 0; }
.status.you { color: var(--x1); }
.status.them { color: var(--o1); }
[data-theme="paper"] .status.you, [data-theme="candy"] .status.you { color: var(--x2); }
[data-theme="paper"] .status.them, [data-theme="candy"] .status.them { color: var(--o2); }
.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: xo-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 xo-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.hintbtn, .hint-pad { flex: none; inline-size: 62px; }
.hintbtn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; block-size: 42px; border-radius: 14px; font-weight: 900;
    background: var(--ui); border: 1px solid var(--line); box-shadow: 0 3px 0 rgba(0, 0, 0, .22); transition: transform .08s;
}
.hintbtn .ic { color: var(--gold); }
.hintbtn:active { transform: translateY(2px); }
.hintbtn:disabled { opacity: .4; cursor: default; }

/* Stacked layout: the mark rides on the avatar as a badge and the name may take two lines. */
.tall .pl-mark { position: absolute; inset-block-end: 2px; inline-size: 24px; block-size: 24px; padding: 5px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.tall .pl.me .pl-mark { inset-inline-start: 3px; }
.tall .pl.op .pl-mark { inset-inline-end: 3px; }
.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.18rem; }
.roomy .mbot { min-block-size: 58px; }

/* 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(--bs, 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-mark { inline-size: 30px; block-size: 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.15rem; white-space: nowrap; }
.wide .mbot { justify-self: center; inline-size: max-content; min-inline-size: 100%; }
.wide .home-in { flex-direction: row; justify-content: center; gap: clamp(24px, 6vw, 80px); padding-block-start: 0; }
.wide .s-home .logo-marks .mk { inline-size: clamp(70px, calc(var(--H) * .26), 150px); }
.wide .s-home .menu-col { display: grid; gap: 12px; inline-size: min(46%, 430px); }
.menu-col { display: grid; gap: 12px; inline-size: 100%; justify-items: center; }
.wide .logo p { font-size: 1.1rem; }
.wide:not(.short) .cast { grid-template-columns: repeat(5, 1fr); margin-block: auto; gap: 12px; }
.wide:not(.short) .rival { padding-block: 18px 14px; gap: 6px; }
.wide:not(.short) .rival .av { inline-size: 86px; block-size: 86px; }
.wide:not(.short) .rival .lockic { inset-block-start: 46px; }
.wide:not(.short) .rival b { font-size: 1.05rem; }

/* 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: 34px; }
.short .hintbtn { block-size: 34px; }
.short .status { font-size: .92rem; }
.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: 54px; }
.short .mode.main { min-block-size: 62px; }
.short .modes { gap: 7px; }
.short .menu-col { gap: 7px; }
.short .logo p { display: none; }
.short .screen { gap: 8px; padding-block: 6px 10px; }
.short.wide .setup { grid-template-columns: 1fr 1fr; max-inline-size: 820px; 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: 40px; block-size: 40px; }
.short .opt .av { inline-size: 36px; block-size: 36px; }
.short.wide .cast { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.short .rival { padding: 8px 6px 6px; gap: 2px; }
.short .rival .av { inline-size: 52px; block-size: 52px; }
.short .rival .lockic { inset-block-start: 20px; }

/* ---------- overlays ---------- */
.ov { position: absolute; inset: 0; z-index: 40; display: flex; padding: 12px; overflow: hidden auto; background: rgba(4, 5, 18, .74); animation: xo-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: xo-card .42s cubic-bezier(.3, 1.45, .5, 1);
}
@keyframes xo-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: 64px 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: 64px; block-size: 64px; }
.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: xo-star .55s cubic-bezier(.3, 1.8, .5, 1) backwards; }
@keyframes xo-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); }
.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: xo-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%, 540px); 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: 54px; block-size: 54px; }
.short .card .quote { margin-block-start: 5px; padding-block: 6px; }
.short .rulebox { margin-block-start: 6px; padding-block: 6px; }
.short .rulebox .dg { inline-size: 52px; block-size: 52px; }
.short .big3 { margin-block: 4px 0; }
.short .big3 .ic { inline-size: 36px; block-size: 36px; }
.short .big3 .ic:nth-child(2) { inline-size: 44px; block-size: 44px; margin-block-start: -6px; }
.short .goals, .short .news { margin-block-start: 5px; }
.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: grid; justify-items: center; gap: 6px; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 8px; 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: xo-toast 3s ease-out forwards; }
.toast .ic { inline-size: 18px; block-size: 18px; }
@keyframes xo-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: 1rem; }
    .mode.main b { font-size: 1.14rem; }
    .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; }
}

@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:not(.stay), .toast { animation-duration: 1.4s !important; }
    .toast { animation-duration: 3s !important; }
}
