:root {
  --red: #e53935; --green: #2e9e44; --yellow: #f9c80e; --blue: #1e88e5;
  --red-d: #b71c1c; --green-d: #1b6b2c; --yellow-d: #c79a00; --blue-d: #1259a8;
  --bg1: #1b2a6b; --bg2: #2a3f9a; --ink: #ffffff; --muted: #b9c3e8;
  --card: rgba(255, 255, 255, .08); --card-b: rgba(255, 255, 255, .14); --card-solid: #22337e;
  --gold: #ffc93c; --gold-d: #e0a100; --danger: #ff5a6a;
  --board-bg: #ffffff; --cell: #ffffff; --grid: #c8cfdc; --yard-inner: #ffffff; --frame: #0d1747;
  --radius: 18px; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
body[data-theme="midnight"] {
  --red: #ff4d6d; --green: #2ee59d; --yellow: #ffd23f; --blue: #4cc9f0;
  --board-bg: #10173a; --cell: #18224d; --grid: #2b3a75; --yard-inner: #0e1533; --frame: #070b20;
  --bg1: #070b20; --bg2: #141d48;
}
body[data-theme="pastel"] {
  --red: #f28b82; --green: #81c995; --yellow: #fdd663; --blue: #8ab4f8;
  --board-bg: #fffaf3; --cell: #fffdf8; --grid: #e6dccd; --yard-inner: #fffdf8; --frame: #6d5b4b;
  --bg1: #5b4a8b; --bg2: #8a6fb0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Devanagari", sans-serif; color: var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.025) 0 24px, transparent 24px 48px),
    radial-gradient(1200px 700px at 50% -10%, var(--bg2), var(--bg1));
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#app { height: 100%; position: relative; max-width: 1100px; margin: 0 auto; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding: calc(10px + var(--safe-t)) 16px calc(12px + var(--safe-b)); }
.screen.active { display: flex; animation: in .25s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
/* The scroller spans the screen so its scrollbar sits at the window edge rather than
   mid-page; the content inside stays in a centred 640px column. */
.scroll { flex: 1; overflow-y: auto; padding-bottom: 20px; margin-inline: -16px; padding-inline: 16px; }
.scroll > * { max-width: 640px; margin-inline: auto; }
.scroll > * + * { margin-top: 12px; }
.topbar { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; min-height: 48px; margin-bottom: 10px; max-width: 640px; width: 100%; margin-left: auto; margin-right: auto; }
.topbar h2 { margin: 0; text-align: center; font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--card-b); background: var(--card); display: grid; place-items: center; font-size: 24px; cursor: pointer; line-height: 1; transition: transform .12s; }
.icon-btn:active { transform: scale(.93); }
.sound-btn::before { content: "🔊"; font-size: 18px; }
.sound-btn.off::before { content: "🔇"; }
.card { background: var(--card); border: 1px solid var(--card-b); border-radius: var(--radius); padding: 16px; backdrop-filter: blur(6px); }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card h4 { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 1px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 800; font-size: 15px; cursor: pointer; transition: transform .12s, filter .2s; user-select: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .mode-card:focus-visible, .pill-btn:focus-visible, .lx-token:focus-visible, #dice:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn-primary { background: linear-gradient(180deg, #4fd06b, #23a347); box-shadow: 0 4px 0 #157a31, 0 10px 24px rgba(0,0,0,.25); color: #fff; }
.btn-secondary { background: rgba(255,255,255,.14); border: 1px solid var(--card-b); }
.btn-gold { background: linear-gradient(180deg, #ffd85c, var(--gold-d)); color: #3a2600; box-shadow: 0 4px 0 #a87800; }
.btn-danger { background: rgba(255,90,106,.15); color: #ffb3bb; border: 1px solid rgba(255,90,106,.4); }
.btn-lg { width: 100%; padding: 15px; font-size: 17px; margin-top: 10px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--gold); cursor: pointer; font-weight: 700; padding: 0 4px; }

/* ---------- home ---------- */
[data-screen="home"] { gap: 14px; overflow-y: auto; left: 0; right: 0; }
[data-screen="home"] > * { width: 100%; max-width: 640px; margin-inline: auto; }
.all-games-link { align-self: flex-start; padding: 4px 8px 8px 0; color: rgba(255,255,255,.75); text-decoration: none; font-weight: 700; font-size: 14px; }
.all-games-link:hover { color: #fff; }
.home-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.me-chip { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--card-b); border-radius: 18px; padding: 6px 14px 8px 6px; min-width: 0; }
.me-chip .avatar { grid-row: span 2; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.xpbar { display: block; height: 5px; background: rgba(0,0,0,.3); border-radius: 9px; overflow: hidden; margin-top: 4px; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ff8a3c); border-radius: inherit; transition: width .5s; }
.xpbar.big { height: 8px; flex: 1; margin: 0; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: radial-gradient(circle at 35% 30%, #fff, #dfe6ff); border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.25); flex: none; }
.avatar.xl { width: 88px; height: 88px; font-size: 50px; border-width: 4px; }
.avatar.sm { width: 34px; height: 34px; font-size: 19px; border-width: 2px; }
.net-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 99px; background: rgba(0,0,0,.25); white-space: nowrap; justify-self: end; }
.net-pill i { width: 8px; height: 8px; border-radius: 50%; background: #8b93ad; }
.net-pill.online i { background: #3ddc84; box-shadow: 0 0 8px #3ddc84; }
.net-pill.connecting i, .net-pill.reconnecting i { background: var(--gold); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.logo-wrap { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px 0; }
.logo { display: flex; gap: 6px; align-items: center; }
.lb { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 38px; font-weight: 900; border: 5px solid; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
.l-red { color: var(--red); border-color: var(--red); } .l-green { color: var(--green); border-color: var(--green); }
.l-yellow { color: var(--yellow-d); border-color: var(--yellow); } .l-blue { color: var(--blue); border-color: var(--blue); }
.lx { font-size: 50px; font-weight: 900; color: var(--gold); text-shadow: 0 4px 0 #a87800, 0 0 24px rgba(255,201,60,.5); margin-left: 4px; font-style: italic; }
.logo-dice { width: 54px; height: 54px; }
.logo-dice .lx-dice { --dz: 50px; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(6deg); } }
.daily { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(135deg, rgba(255,201,60,.22), rgba(255,138,60,.12)); border-color: rgba(255,201,60,.4); }
.daily-title { font-weight: 800; }
.daily-sub { font-size: 13px; color: #ffe7a6; }
.daily-days { display: flex; gap: 4px; margin-top: 6px; }
.daily-days i { width: 18px; height: 6px; border-radius: 4px; background: rgba(255,255,255,.2); }
.daily-days i.done { background: var(--gold); }
.daily-days i.today { background: #fff; box-shadow: 0 0 8px #fff; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card { position: relative; overflow: hidden; border-radius: 20px; padding: 16px 14px; min-height: 116px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; box-shadow: 0 6px 0 rgba(0,0,0,.22), 0 12px 24px rgba(0,0,0,.2); transition: transform .12s; }
.mode-card:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.22); }
.mode-card b { font-size: 16px; } .mode-card small { opacity: .85; font-size: 12px; }
.mc-ico { position: absolute; top: 10px; right: 12px; font-size: 34px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); }
.mc-play { background: linear-gradient(150deg, #3fa9f5, var(--blue-d)); }
.mc-friends { background: linear-gradient(150deg, #ff7a6b, var(--red-d)); }
.mc-cpu { background: linear-gradient(150deg, #5ad37a, var(--green-d)); }
.mc-local { background: linear-gradient(150deg, #ffd54a, #d99a00); color: #3a2600; }
.home-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pill-btn { background: var(--card); border: 1px solid var(--card-b); border-radius: 14px; padding: 12px; text-align: center; font-weight: 700; font-size: 14px; }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }

/* ---------- segmented / forms ---------- */
.seg { display: flex; background: rgba(0,0,0,.22); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: #1b2a6b; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.seg.small-seg button { font-size: 12px; padding: 8px 4px; }
.row-check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 6px 0; }
.join-row { display: flex; gap: 8px; }
.join-row input, .form-grid input, .form-grid select, .setting select, .setup-seat input, .setup-seat select, #pf-name {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--card-b); background: rgba(0,0,0,.25); outline: none;
}
.join-row input:focus, #pf-name:focus { border-color: var(--gold); }
#pr-code, #tour-code { text-transform: uppercase; letter-spacing: 3px; font-weight: 800; }
select option { color: #111; }
.form-grid { display: grid; gap: 10px; }
.form-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.list > * + * { border-top: 1px solid var(--card-b); }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row small { color: var(--muted); }
.settings-list .setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--card-b); cursor: pointer; }
.settings-list .setting:first-child { border-top: 0; }
.setting input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.setting select { flex: none; width: auto; }
.switch { flex: none; width: 48px; height: 28px; border-radius: 99px; background: rgba(0,0,0,.35); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform .2s; }
.setting input:checked + .switch { background: #3ddc84; }
.setting input:checked + .switch::after { transform: translateX(20px); }
.setting input:focus-visible + .switch { outline: 3px solid var(--gold); outline-offset: 2px; }
.setting small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- lobby ---------- */
.code-card { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.big-code { font-size: 40px; font-weight: 900; letter-spacing: 8px; color: var(--gold); text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.code-actions { display: flex; gap: 8px; }
.seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.seat { border-radius: 18px; padding: 14px 10px; text-align: center; background: var(--card); border: 2px solid var(--card-b); display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.seat[data-color] { border-color: var(--sc); background: linear-gradient(180deg, color-mix(in srgb, var(--sc) 30%, transparent), var(--card)); }
.seat .avatar { width: 62px; height: 62px; font-size: 34px; border-color: var(--sc, #fff); }
.seat.empty .avatar { background: rgba(255,255,255,.08); border-style: dashed; color: var(--muted); font-size: 26px; box-shadow: none; }
.seat b { font-size: 14px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: rgba(0,0,0,.3); }
.seat .tag.ready { background: #2fbf60; } .seat .tag.host { background: var(--gold); color: #3a2600; } .seat .tag.off { background: var(--danger); }
.seat-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.seat-actions select, .seat-actions button { font-size: 12px; padding: 5px 8px; border-radius: 9px; border: 1px solid var(--card-b); background: rgba(0,0,0,.25); cursor: pointer; }
.lobby-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; align-items: end; }
.lobby-actions .btn-lg { margin: 0; }

/* ---------- setup ---------- */
.setup-seats { display: grid; gap: 8px; }
.setup-seat { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 14px; background: rgba(0,0,0,.18); }
.setup-seat .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sc); box-shadow: 0 0 0 3px rgba(255,255,255,.2); }
.setup-seat select { flex: none; }

/* ---------- board ---------- */
.lx-board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 14px; box-shadow: 0 0 0 4px var(--frame), 0 18px 40px rgba(0,0,0,.45); background: var(--board-bg); overflow: visible; }
.lx-board-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 12px; }
.b-bg { fill: var(--board-bg); }
.b-yard-inner { fill: var(--yard-inner); }
.b-cell { fill: var(--cell); }
.b-grid rect { fill: none; stroke: var(--grid); stroke-width: .045; }
.b-frame { fill: none; stroke: var(--frame); stroke-width: .12; }
.fill-red { fill: var(--red); } .fill-green { fill: var(--green); } .fill-yellow { fill: var(--yellow); } .fill-blue { fill: var(--blue); }
.b-spot { stroke: rgba(0,0,0,.15); stroke-width: .06; opacity: .9; }
.b-tri { stroke: var(--frame); stroke-width: .05; }
.b-star { fill: none; stroke: #8a93a8; stroke-width: .07; stroke-linejoin: round; }
.b-star.on-color { stroke: rgba(255,255,255,.9); }
.b-arrow { fill: none; stroke-width: .1; stroke-linecap: round; stroke-linejoin: round; }
.stroke-red { stroke: var(--red); } .stroke-green { stroke: var(--green); } .stroke-yellow { stroke: var(--yellow-d); } .stroke-blue { stroke: var(--blue); }
.lx-tokens { position: absolute; inset: 0; }
.lx-token {
  --c: #999; --cd: #555; --s: 1; --step: 150ms;
  position: absolute; width: 6.2%; height: 6.2%; padding: 0; border: 0; background: none; cursor: default;
  transform: translate(-50%, -62%) scale(var(--s)); transition: left var(--step) ease, top var(--step) ease, transform .2s; z-index: 2;
}
.lx-token.no-anim { transition: none !important; }
.tk-red { --c: var(--red); --cd: var(--red-d); } .tk-green { --c: var(--green); --cd: var(--green-d); }
.tk-yellow { --c: var(--yellow); --cd: var(--yellow-d); } .tk-blue { --c: var(--blue); --cd: var(--blue-d); }
.tk-shadow { position: absolute; left: 14%; right: 14%; bottom: -4%; height: 22%; border-radius: 50%; background: rgba(0,0,0,.35); filter: blur(1px); }
.tk-body { position: absolute; left: 18%; right: 18%; top: 38%; bottom: 4%; border-radius: 40% 40% 46% 46% / 50% 50% 38% 38%; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 45%, var(--cd)); border: 1.5px solid rgba(255,255,255,.85); box-shadow: inset 0 -3px 4px rgba(0,0,0,.25); }
.tk-head { position: absolute; left: 26%; right: 26%; top: 4%; height: 48%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, color-mix(in srgb, var(--c) 70%, #fff) 30%, var(--c) 70%, var(--cd)); border: 1.5px solid rgba(255,255,255,.9); box-shadow: 0 2px 3px rgba(0,0,0,.3); }
.skin-disc .tk-body { top: 30%; left: 6%; right: 6%; bottom: 10%; border-radius: 50%; border-width: 3px; }
.skin-disc .tk-head { top: 40%; left: 32%; right: 32%; height: 30%; }
.skin-gem .tk-body { border-radius: 10%; transform: rotate(45deg) scale(.82); top: 30%; left: 16%; right: 16%; bottom: 6%; }
.skin-gem .tk-head { top: 0; height: 36%; left: 34%; right: 34%; border-radius: 30% 30% 50% 50%; }
.skin-crown .tk-head { border-radius: 10% 10% 50% 50%; background: linear-gradient(180deg, var(--gold), var(--c)); clip-path: polygon(0 30%, 20% 0, 35% 30%, 50% 0, 65% 30%, 80% 0, 100% 30%, 100% 100%, 0 100%); }
.lx-token.selectable { cursor: pointer; z-index: 5; animation: bob .7s ease-in-out infinite; }
.lx-token.selectable::before { content: ""; position: absolute; left: -12%; right: -12%; bottom: -18%; height: 44%; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 12px 3px var(--c); animation: ring 1s ease-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -78%) scale(calc(var(--s) * 1.08)); } }
@keyframes ring { from { opacity: 1; transform: scale(.7); } to { opacity: 0; transform: scale(1.4); } }
.lx-token.moving { z-index: 8; }
.lx-token.hop { animation: hop var(--step) ease; }
@keyframes hop { 50% { transform: translate(-50%, -95%) scale(calc(var(--s) * 1.12)); } }
.lx-token.captured { animation: knock .3s ease; z-index: 9; }
@keyframes knock { 30% { transform: translate(-50%, -62%) scale(1.3) rotate(-20deg); } 100% { transform: translate(-50%, -62%) scale(.6) rotate(200deg); } }
.lx-token.arrive { animation: arrive .9s ease; }
@keyframes arrive { 30% { transform: translate(-50%, -110%) scale(1.4); filter: drop-shadow(0 0 10px var(--gold)); } }
.lx-token.home { --s: .7; }
.board-box { position: relative; }
.board-toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; background: rgba(13,23,71,.92); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 900; font-size: 18px; white-space: nowrap; z-index: 20; transition: all .25s cubic-bezier(.2,1.4,.4,1); border: 2px solid var(--gold); }
.board-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
body.reduced .lx-token.selectable, body.reduced .lx-token.selectable::before, body.reduced .logo-dice .lx-dice { animation: none; }

/* ---------- dice ---------- */
.lx-dice { --dz: 54px; width: var(--dz); height: var(--dz); perspective: 300px; cursor: pointer; }
.lx-dice .cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 650ms cubic-bezier(.2,.8,.25,1.08); }
.lx-dice .face { position: absolute; inset: 0; border-radius: 22%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 15%; gap: 4%;
  background: radial-gradient(circle at 30% 25%, #fff, #e9ecf3 70%, #cfd5e2); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), inset 0 -4px 8px rgba(0,0,0,.12); backface-visibility: hidden; }
.lx-dice .face i { border-radius: 50%; }
.lx-dice .face i.on { background: radial-gradient(circle at 35% 30%, #555, #111); box-shadow: inset 0 1px 1px rgba(255,255,255,.3); }
.lx-dice .f1 i.on { background: radial-gradient(circle at 35% 30%, #ff6b6b, #b71c1c); transform: scale(1.25); }
.lx-dice .f1 { transform: rotateY(0) translateZ(calc(var(--dz) / 2)); }
.lx-dice .f6 { transform: rotateY(180deg) translateZ(calc(var(--dz) / 2)); }
.lx-dice .f2 { transform: rotateY(90deg) translateZ(calc(var(--dz) / 2)); }
.lx-dice .f5 { transform: rotateY(-90deg) translateZ(calc(var(--dz) / 2)); }
.lx-dice .f3 { transform: rotateX(90deg) translateZ(calc(var(--dz) / 2)); }
.lx-dice .f4 { transform: rotateX(-90deg) translateZ(calc(var(--dz) / 2)); }
.lx-dice.rolling { animation: shake .65s ease; }
@keyframes shake { 20% { transform: translate(-3px, -6px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-2px, -5px); } 80% { transform: translate(2px, 0); } }
.lx-dice.landed .cube { filter: drop-shadow(0 0 8px rgba(255,255,255,.7)); }
.dice-ruby .face { background: radial-gradient(circle at 30% 25%, #ff8a8a, #d32f2f 70%, #8e0000); } .dice-ruby .face i.on { background: #fff; }
.dice-ocean .face { background: radial-gradient(circle at 30% 25%, #8fe3ff, #1e88e5 70%, #0d47a1); } .dice-ocean .face i.on { background: #fff; }
.dice-gold .face { background: radial-gradient(circle at 30% 25%, #fff3b0, #ffc93c 60%, #b8860b); } .dice-gold .face i.on { background: #5a3d00; }
.dice-neon .face { background: #0b0f2a; box-shadow: inset 0 0 0 2px #2ee59d, 0 0 10px #2ee59d; } .dice-neon .face i.on { background: #2ee59d; box-shadow: 0 0 6px #2ee59d; }
.dice-frost .face { background: radial-gradient(circle at 30% 25%, #fff, #d6f1ff 60%, #8ecae6); } .dice-frost .face i.on { background: #1d6fa5; }

/* ---------- game table ---------- */
[data-screen="game"] { padding-left: 8px; padding-right: 8px; }
.game-top { max-width: none; }
.game-title { text-align: center; min-width: 0; }
.game-title h2 { font-size: 18px; }
.game-title small { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table { flex: 1; min-height: 0; display: grid; gap: 8px; align-content: center; justify-content: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "tl tr" "board board" "bl br"; --bs: min(96vw, calc(100dvh - 300px)); }
.board-box { grid-area: board; width: var(--bs); justify-self: center; }
.panel[data-pos="tl"] { grid-area: tl; } .panel[data-pos="tr"] { grid-area: tr; justify-content: flex-end; }
.panel[data-pos="bl"] { grid-area: bl; } .panel[data-pos="br"] { grid-area: br; justify-content: flex-end; }
.panel { display: flex; align-items: center; gap: 8px; min-height: 64px; visibility: hidden; min-width: 0; }
.panel.used { visibility: visible; }
.panel[data-pos="tr"], .panel[data-pos="br"] { flex-direction: row-reverse; }
.p-card { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 16px; background: rgba(0,0,0,.25); border: 2px solid transparent; min-width: 0; transition: all .25s; position: relative; }
.panel[data-pos="tr"] .p-card, .panel[data-pos="br"] .p-card { flex-direction: row-reverse; padding: 6px 6px 6px 12px; text-align: right; }
.p-card .avatar { border-color: var(--pc); position: relative; }
.p-info { min-width: 0; display: flex; flex-direction: column; }
.p-info b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
@media (max-width: 480px) { .p-info b { max-width: 78px; } .p-card { padding-right: 8px; } }
.p-info small { font-size: 11px; color: var(--muted); }
.p-home { display: flex; gap: 3px; margin-top: 3px; }
.panel[data-pos="tr"] .p-home, .panel[data-pos="br"] .p-home { justify-content: flex-end; }
.p-home i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--pc); }
.p-home i.on { background: var(--pc); }
.panel.active .p-card { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 35%, rgba(0,0,0,.3)); box-shadow: 0 0 18px color-mix(in srgb, var(--pc) 60%, transparent); }
.panel.out .p-card { opacity: .5; }
.p-ring { position: absolute; inset: -5px; border-radius: 50%; pointer-events: none; }
.p-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.p-ring circle { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.p-ring.low circle { stroke: var(--danger); }
.p-badge { position: absolute; bottom: -4px; right: -4px; font-size: 12px; background: #000a; border-radius: 99px; padding: 0 4px; }
.dice-slot { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 16px; flex: none; }
.panel.active .dice-slot { background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.dice-slot.can-roll { animation: glow 1s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: inset 0 0 0 2px #fff, 0 0 20px rgba(255,255,255,.6); } }
.dice-slot .lx-dice { --dz: 46px; }
.status-line { text-align: center; font-weight: 700; min-height: 22px; font-size: 14.5px; margin-top: 6px; }
.status-line .chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
@media (min-width: 900px) and (min-aspect-ratio: 4/3) {
  .table { grid-template-columns: 220px auto 220px; grid-template-areas: "tl board tr" "bl board br"; grid-template-rows: 1fr 1fr; --bs: min(calc(100dvh - 140px), 760px); }
  .panel { align-self: start; flex-direction: column !important; align-items: flex-start; }
  .panel[data-pos="bl"], .panel[data-pos="br"] { align-self: end; flex-direction: column-reverse !important; }
  .panel[data-pos="tr"], .panel[data-pos="br"] { align-items: flex-end; }
  .dice-slot { width: 80px; height: 80px; } .dice-slot .lx-dice { --dz: 60px; }
}

/* ---------- tournaments ---------- */
.entrants { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.entrant { display: flex; gap: 8px; align-items: center; background: rgba(0,0,0,.2); border-radius: 12px; padding: 6px 8px; font-size: 13px; min-width: 0; }
.entrant span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bracket { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 6px; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; }
.round h4 { margin: 0 0 4px; text-align: center; }
.match { background: rgba(0,0,0,.25); border-radius: 12px; overflow: hidden; border: 1px solid var(--card-b); }
.match .m-p { display: flex; gap: 6px; align-items: center; padding: 7px 8px; font-size: 13px; }
.match .m-p + .m-p { border-top: 1px solid var(--card-b); }
.match .m-p.win { background: rgba(61,220,132,.2); font-weight: 800; }
.match .m-p.lose { opacity: .5; }
.match .m-state { font-size: 11px; text-align: center; color: var(--muted); padding: 3px; background: rgba(0,0,0,.2); }

/* ---------- leaderboard ---------- */
.seg.wide { margin-bottom: 8px; }
.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 34px 40px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--card-b); }
.lb-row.me { border-color: var(--gold); background: rgba(255,201,60,.14); }
.lb-place { font-weight: 900; font-size: 18px; text-align: center; color: var(--muted); }
.lb-row:nth-child(1) .lb-place { color: #ffd700; } .lb-row:nth-child(2) .lb-place { color: #e0e0e0; } .lb-row:nth-child(3) .lb-place { color: #e5a46b; }
.lb-name b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name small { color: var(--muted); font-size: 12px; }
.lb-val { font-weight: 900; font-size: 17px; text-align: right; }
.lb-val small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head .avatar { cursor: pointer; }
.pf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#pf-name { font-size: 18px; font-weight: 800; }
.lvl-row { display: flex; align-items: center; gap: 10px; }
.lvl-row small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--card-b); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 21px; font-weight: 900; }
.stat small { color: var(--muted); font-size: 11.5px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(0,0,0,.2); font-size: 12px; }
.ach .ai { font-size: 24px; filter: grayscale(1) opacity(.4); }
.ach.got { background: rgba(255,201,60,.15); } .ach.got .ai { filter: none; }
.ach b { display: block; font-size: 13px; }
.ach small { color: var(--muted); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.pick { position: relative; border: 2px solid var(--card-b); background: rgba(0,0,0,.2); border-radius: 14px; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; min-height: 84px; justify-content: center; }
.pick.on { border-color: var(--gold); background: rgba(255,201,60,.18); }
.pick.locked { cursor: not-allowed; opacity: .55; }
.pick.locked::after { content: "🔒"; position: absolute; top: 4px; right: 6px; font-size: 12px; }
.pick .pe { font-size: 30px; }
.pick .lx-dice { --dz: 30px; pointer-events: none; }
.pick .tok-demo { position: relative; width: 30px; height: 34px; }
.pick .tok-demo .lx-token { position: absolute; left: 50%; top: 60%; width: 100%; height: 100%; transform: translate(-50%, -62%); }
.season-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.season-tier { text-align: center; font-size: 11px; padding: 8px 4px; border-radius: 10px; background: rgba(0,0,0,.2); }
.season-tier b { display: block; font-size: 14px; }
.season-tier.done { background: rgba(61,220,132,.2); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5,10,40,.7); backdrop-filter: blur(4px); animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: min(420px, 100%); background: linear-gradient(180deg, #2a3f9a, #1b2a6b); border: 2px solid rgba(255,255,255,.2); border-radius: 26px; padding: 22px; text-align: center; position: relative; overflow: hidden; animation: pop .35s cubic-bezier(.2,1.5,.4,1) both; max-height: 94vh; overflow-y: auto; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.modal-card h2 { margin: 8px 0 2px; font-size: 26px; }
.modal-card .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.results-card .btn-secondary { width: 100%; margin-top: 8px; }
.res-crown { font-size: 40px; margin-bottom: -18px; position: relative; z-index: 1; animation: crown 1.2s ease infinite; }
@keyframes crown { 50% { transform: translateY(-4px) rotate(-6deg); } }
.res-avatar { margin: 0 auto; border-color: var(--gold) !important; box-shadow: 0 0 30px rgba(255,201,60,.6); }
.res-rank { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.res-rank li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: rgba(0,0,0,.22); border-left: 5px solid var(--pc); }
.res-rank li b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-rank .pl { font-weight: 900; width: 26px; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.res-stats div { background: rgba(0,0,0,.22); border-radius: 12px; padding: 8px 4px; }
.res-stats b { display: block; font-size: 19px; }
.res-stats small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.res-notes { font-size: 13px; color: #ffe7a6; min-height: 18px; margin-bottom: 4px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.toast { position: fixed; left: 50%; top: calc(66px + var(--safe-t)); transform: translate(-50%, -16px); opacity: 0; pointer-events: none; z-index: 70; background: rgba(13,23,71,.95); border: 1px solid rgba(255,255,255,.2); padding: 10px 16px; border-radius: 99px; font-weight: 700; font-size: 14px; transition: all .25s; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.prose ol, .prose ul { margin: 0; padding-left: 20px; line-height: 1.55; }
.prose p { margin: 0; line-height: 1.5; }

@media (max-height: 720px) {
  .lb { width: 46px; height: 46px; font-size: 30px; } .lx { font-size: 40px; }
  .mode-card { min-height: 96px; }
  .table { --bs: min(96vw, calc(100dvh - 250px)); }
  .panel { min-height: 52px; } .p-card .avatar { width: 38px; height: 38px; font-size: 21px; }
  .dice-slot { width: 52px; height: 52px; } .dice-slot .lx-dice { --dz: 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
