/* Shakti Chess — luxury onyx / gold / rose-gold theme */
@font-face { font-family: 'Cinzel'; src: url(../fonts/cinzel.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url(../fonts/cormorant-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url(../fonts/cormorant-500i.woff2) format('woff2'); font-weight: 500; font-style: italic; font-display: swap; }

:root {
  --bg0: #07060b; --bg1: #0e0c15; --bg2: #171320;
  --gold: #e9c46a; --gold2: #f6dd9a; --gold3: #b8892f; --rose: #e8a49a; --rose2: #c97b84; --ruby: #e0525f;
  --txt: #f4ecdf; --mut: #b6aa98; --dim: #7d7466;
  --glass: rgba(255, 246, 230, 0.055); --glass2: rgba(255, 246, 230, 0.09); --line: rgba(233, 196, 106, 0.22);
  --r: 16px; --serif: 'Cinzel', 'Cormorant', Georgia, serif; --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --bs: min(calc(100vw - 12px), calc(100dvh - 300px - var(--safe-t) - var(--safe-b)));
  --light: #f0dcae; --dark: #a8773f; --lastc: rgba(255, 196, 70, 0.42); --selc: rgba(255, 214, 120, 0.55);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: var(--txt); font-family: var(--sans); overflow: hidden; overscroll-behavior: none; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
button, .ctl, .mini { touch-action: manipulation; }
body { background: radial-gradient(1200px 800px at 15% -10%, #2a1c2b 0%, transparent 60%), radial-gradient(1000px 700px at 110% 110%, #2b2214 0%, transparent 55%), linear-gradient(160deg, #0c0a12, #050409 70%); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.bg-orbs { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bg-orbs i { position: absolute; border-radius: 50%; opacity: .5; } /* soft radial gradients instead of blur(60px): no filter layers to repaint */
.bg-orbs i:nth-child(1) { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: radial-gradient(closest-side, #7a3c52, rgba(122, 60, 82, 0)); animation: drift 26s ease-in-out infinite alternate; }
.bg-orbs i:nth-child(2) { width: 40vmax; height: 40vmax; right: -14vmax; bottom: -16vmax; background: radial-gradient(closest-side, #8a6420, rgba(138, 100, 32, 0)); animation: drift 32s ease-in-out infinite alternate-reverse; }
.bg-orbs i:nth-child(3) { width: 22vmax; height: 22vmax; right: 18vw; top: 8vh; background: radial-gradient(closest-side, #3a2a5a, rgba(58, 42, 90, 0)); opacity: .4; animation: drift 40s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.08); } }
.lowfx .bg-orbs i { animation: none; }
@media (pointer: coarse), (max-width: 820px) { .bg-orbs i { animation: none; } }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); border-radius: 999px; padding: 11px 18px; background: var(--glass); color: var(--txt); font-weight: 600; letter-spacing: .02em; transition: transform .12s, background .2s, box-shadow .2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.btn:active { transform: scale(.97); }
.btn.big { padding: 15px 22px; font-size: 1.05rem; width: 100%; }
.btn.sm { padding: 7px 13px; font-size: .86rem; }
.btn.gold { background: linear-gradient(135deg, #f8e3a3, #e0b458 45%, #b8862c); color: #1c1308; border-color: rgba(255, 236, 180, .6); box-shadow: 0 6px 24px rgba(233, 196, 106, .25), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn.gold:hover { box-shadow: 0 8px 30px rgba(233, 196, 106, .4), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn.glass { background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.btn.glass:hover { background: var(--glass2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mut); }
.btn.danger { color: #ffb4b4; border-color: rgba(224, 82, 95, .45); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--gold2); display: grid; place-items: center; }
.icon-btn:hover { background: var(--glass); border-color: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
#btnSound .off { display: none; } #btnSound.muted .on { display: none; } #btnSound.muted .off { display: inline; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 1; display: none; }
.screen.active { display: grid; }
#home { place-items: center; overflow-y: auto; padding: calc(16px + var(--safe-t)) 18px calc(16px + var(--safe-b)); }
.home-inner { width: min(440px, 100%); text-align: center; animation: rise .6s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.crest img { width: 92px; height: 92px; border-radius: 26px; box-shadow: 0 10px 40px rgba(233, 196, 106, .3), 0 0 0 1px var(--line); }
.brand { font-family: var(--serif); font-weight: 700; font-size: clamp(2.1rem, 9vw, 3rem); margin: 12px 0 2px; letter-spacing: .06em;
  background: linear-gradient(180deg, #fff3cf, #e9c46a 55%, #a8772a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand span { background: linear-gradient(180deg, #ffe1d8, #e8a49a 60%, #b06a72); -webkit-background-clip: text; background-clip: text; }
.tag { font-family: 'Cormorant', serif; font-style: italic; font-weight: 500; color: var(--mut); font-size: 1.15rem; margin: 0 0 18px; }
.home-duo { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 22px; }
.duo-card { flex: 1; max-width: 160px; padding: 14px 10px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.duo-card.her { border-color: rgba(232, 164, 154, .35); }
.duo-name { font-family: var(--serif); font-weight: 600; margin-top: 8px; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-sub { font-size: .78rem; color: var(--mut); }
.vs { font-family: var(--serif); color: var(--gold); font-size: 1.3rem; text-shadow: 0 0 18px rgba(233, 196, 106, .6); }
.home-actions { display: grid; gap: 10px; }
.home-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foot { color: var(--dim); font-size: .8rem; margin-top: 18px; }

/* avatars */
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; background: linear-gradient(135deg, #3a2f22, #1b1620) center/cover no-repeat; border: 2px solid var(--gold); box-shadow: 0 0 0 3px rgba(233, 196, 106, .12), 0 4px 14px rgba(0, 0, 0, .5); display: grid; place-items: center; font-family: var(--serif); font-weight: 700; color: var(--gold2); font-size: 1.1rem; overflow: hidden; }
.avatar.her, .avatar[data-who=her] { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(232, 164, 154, .14), 0 4px 14px rgba(0, 0, 0, .5); color: #ffd9d2; background-image: linear-gradient(135deg, #4a2830, #1d1420); }
.avatar.lg { width: 76px; height: 76px; margin: 0 auto; font-size: 1.7rem; }
.avatar.xl { width: 88px; height: 88px; font-size: 2rem; }
.avatar.photo { color: transparent; }

/* ---------- game layout ---------- */
/* --evw: room reserved left of the board for the eval bar (so it never covers the a-file) */
#game { --evw: 0px; --bs: min(calc(100vw - 12px - var(--evw) - var(--safe-l) - var(--safe-r)), calc(100dvh - 300px - var(--safe-t) - var(--safe-b)));
  grid-template-columns: calc(var(--bs) + var(--evw)); grid-template-rows: auto auto var(--bs) auto auto minmax(0, 1fr);
  grid-template-areas: "top" "ctop" "board" "cbot" "ctrl" "side"; justify-content: center; align-content: start; row-gap: 6px;
  padding: calc(4px + var(--safe-t)) 0 calc(6px + var(--safe-b)); }
.topbar { grid-area: top; display: flex; align-items: center; gap: 4px; min-width: 0; }
.topbar .title { flex: 1; min-width: 0; text-align: center; line-height: 1.15; }
.t-main { display: block; font-family: var(--serif); font-weight: 600; color: var(--gold2); font-size: .98rem; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sub { display: block; font-size: .74rem; color: var(--mut); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1em; }
.pcard { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r); background: var(--glass); border: 1px solid rgba(255, 255, 255, .06); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); min-width: 0; transition: border-color .3s, box-shadow .3s; }
.pcard.top { grid-area: ctop; } .pcard.bot { grid-area: cbot; }
.pcard.turn { border-color: rgba(233, 196, 106, .55); box-shadow: 0 0 0 1px rgba(233, 196, 106, .18), 0 0 24px rgba(233, 196, 106, .14); }
.pcard.her.turn { border-color: rgba(232, 164, 154, .6); box-shadow: 0 0 24px rgba(232, 164, 154, .16); }
.pinfo { flex: 1; min-width: 0; }
.pname { font-family: var(--serif); font-weight: 600; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname small { font-family: var(--sans); color: var(--mut); font-weight: 400; font-size: .72rem; margin-left: 6px; letter-spacing: .02em; }
.pmeta { display: flex; align-items: center; gap: 6px; height: 18px; min-width: 0; }
.caps { display: flex; align-items: center; min-width: 0; overflow: hidden; }
.caps .pc { position: static; width: 17px; height: 17px; margin-right: -5px; flex: none; filter: drop-shadow(0 0 1px rgba(255, 236, 190, .75)) drop-shadow(0 0 2px rgba(255, 236, 190, .35)); }
.caps .gap { width: 9px; flex: none; }
.adv { font-size: .78rem; color: var(--gold); font-weight: 700; margin-left: 6px; }
.clock { font-variant-numeric: tabular-nums; font-family: var(--sans); font-weight: 700; font-size: 1.15rem; padding: 6px 11px; border-radius: 10px; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .08); min-width: 74px; text-align: center; color: var(--mut); }
.clock.run { color: #1b1208; background: linear-gradient(135deg, #f8e3a3, #d7a94c); border-color: transparent; }
.clock.low { color: #fff; background: linear-gradient(135deg, #ff6d6d, #b4232f); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .72; } }
.thinking { display: flex; gap: 4px; padding: 0 4px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--rose); animation: blink 1.1s infinite; }
.thinking i:nth-child(2) { animation-delay: .18s; } .thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Chat bubble: lives INSIDE her player card (over the name area), so it can never cover the board or the controls
   in any layout. No blur; a light shadow; a small tail pointing at her avatar. */
.pcard { z-index: 3; }
.bubble { position: absolute; left: 62px; right: 8px; top: 4px; bottom: 4px; z-index: 5; display: flex; align-items: center; padding: 4px 12px; border-radius: 14px;
  font-size: .84rem; font-weight: 600; line-height: 1.25; background: linear-gradient(135deg, rgb(92, 38, 58), rgb(52, 24, 40)); background-color: rgb(70, 30, 48); border: 1.5px solid rgb(240, 176, 166); color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .5);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 0 14px rgba(232, 164, 154, .16); pointer-events: auto; cursor: pointer; animation: pop .28s cubic-bezier(.2, 1.4, .5, 1) both; }
.bubble::before { content: ""; position: absolute; left: -7px; top: 50%; width: 12px; height: 12px; margin-top: -6px; background: rgb(88, 37, 56); border-left: 1.5px solid rgb(240, 176, 166); border-bottom: 1.5px solid rgb(240, 176, 166); transform: rotate(45deg); }
.bubble .t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.pcard.has-clock .bubble { right: 92px; }
.bubble.hidden { display: none; }
/* "Gauri says" chat log: a slim strip at the top of the side panel (below the controls on phones, beside the board on desktop) */
.chatlog { flex: none; border-bottom: 1px solid rgba(255, 255, 255, .06); padding: 5px 10px 6px; background: rgba(232, 164, 154, .05); }
.chatlog.hidden { display: none; }
.cl-head { font-family: var(--serif); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--rose); margin-bottom: 2px; }
.cl-lines { list-style: none; margin: 0; padding: 0; max-height: 3.9em; overflow: auto; overscroll-behavior: contain; font-size: .8rem; line-height: 1.3; color: #f3dcd6; }
.cl-lines li { padding: 1px 0; }
.cl-lines li:last-child { color: #fff; font-weight: 600; }
.bubble.me { background: linear-gradient(135deg, rgb(58, 46, 22), rgb(30, 24, 16)); border-color: rgb(233, 196, 106); color: #fff6dc; }
.bubble.out { animation: popout .16s ease forwards; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.94); } }
@keyframes popout { to { opacity: 0; transform: translateY(4px) scale(.96); } }

.controls { grid-area: ctrl; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .06); background: var(--glass); color: var(--gold2); font-size: .7rem; letter-spacing: .03em; transition: background .2s, transform .1s; }
.ctl:hover { background: var(--glass2); } .ctl:active { transform: scale(.95); }
.ctl svg { width: 21px; height: 21px; }
.ctl span { color: var(--mut); }
.ctl:disabled { opacity: .35; pointer-events: none; }

.side { grid-area: side; min-height: 0; display: flex; flex-direction: column; border-radius: var(--r); background: var(--glass); border: 1px solid rgba(255, 255, 255, .06); overflow: hidden; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; font-family: var(--serif); font-size: .8rem; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.rv-nav { display: flex; gap: 4px; }
.mini { border: 1px solid var(--line); background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 3px 9px; color: var(--gold2); font-size: .8rem; }
.movelist { overscroll-behavior: contain; list-style: none; margin: 0; padding: 6px 8px; overflow: auto; flex: 1; min-height: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px 4px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.movelist li { display: flex; gap: 2px; align-items: center; }
.movelist .no { color: var(--dim); font-size: .78rem; min-width: 22px; text-align: right; margin-right: 2px; }
.movelist .mv { padding: 2px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.movelist .mv:hover { background: var(--glass2); }
.movelist .mv.cur { background: rgba(233, 196, 106, .22); color: var(--gold2); }
.mv .ann { font-weight: 700; margin-left: 1px; }
.ann.b2 { color: #ff6b6b; } .ann.b1 { color: #ffa65a; } .ann.b0 { color: #f3d36b; } .ann.g { color: #8fe3a8; }
.review-sum { padding: 6px 12px 8px; font-size: .8rem; color: var(--mut); border-top: 1px solid rgba(255, 255, 255, .05); }

/* ---------- board ---------- */
.board-wrap { grid-area: board; position: relative; width: var(--bs); height: var(--bs); justify-self: end; }
#game.has-eval { --evw: 16px; }
.board { position: absolute; inset: 0; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 2px rgba(233, 196, 106, .55), 0 0 0 7px rgba(20, 15, 10, .9), 0 0 0 8px rgba(233, 196, 106, .28), 0 24px 60px rgba(0, 0, 0, .7), 0 0 80px rgba(233, 196, 106, .08); }
.sq-layer { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; }
.sq.light { background: var(--light); } .sq.dark { background: var(--dark); }
.board[data-theme=royal] .sq.light { background: linear-gradient(135deg, #f5e3b8, #e8cf95); } .board[data-theme=royal] .sq.dark { background: linear-gradient(135deg, #b9853f, #946227); }
.board[data-theme=onyx] { --lastc: rgba(233, 196, 106, .38); } .board[data-theme=onyx] .sq.light { background: linear-gradient(135deg, #d9d4cc, #b9b3aa); } .board[data-theme=onyx] .sq.dark { background: linear-gradient(135deg, #3a3640, #24212a); }
.board[data-theme=rose] .sq.light { background: linear-gradient(135deg, #fbe7e1, #f1cfc6); } .board[data-theme=rose] .sq.dark { background: linear-gradient(135deg, #c98e8a, #a86a6c); }
.board[data-theme=wood] .sq.light { background: #f0d9b5; } .board[data-theme=wood] .sq.dark { background: #b58863; }
.board[data-theme=emerald] .sq.light { background: linear-gradient(135deg, #f1ead2, #e2d8b6); } .board[data-theme=emerald] .sq.dark { background: linear-gradient(135deg, #2f6f5b, #1f5243); }
.board[data-theme=midnight] { --lastc: rgba(233, 196, 106, .4); } .board[data-theme=midnight] .sq.light { background: linear-gradient(135deg, #a9b3cf, #8d97b6); } .board[data-theme=midnight] .sq.dark { background: linear-gradient(135deg, #2d3554, #1d2340); }
.sq.last::before, .sq.sel::before, .sq.hint::before, .sq.hover::before { content: ''; position: absolute; inset: 0; background: var(--lastc); }
.sq.sel::before { background: var(--selc); }
.sq.hint::before { background: rgba(120, 220, 255, .35); }
.sq.hover::before { background: transparent; box-shadow: inset 0 0 0 4px rgba(255, 240, 200, .85); }
.sq.check { background: radial-gradient(circle, rgba(255, 70, 50, .95) 0%, rgba(255, 120, 40, .6) 35%, transparent 72%), var(--dark) !important; }
.sq.light.check { background: radial-gradient(circle, rgba(255, 70, 50, .95) 0%, rgba(255, 120, 40, .6) 35%, transparent 72%), var(--light) !important; }
.sq.dot::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(40, 20, 0, .32); box-shadow: 0 0 10px rgba(255, 200, 100, .3); }
.sq.cap::after { content: ''; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(40, 20, 0, .32); }
.co { position: absolute; font-size: max(9px, calc(var(--bs) * .022)); font-weight: 700; pointer-events: none; opacity: .75; }
.co.rk { left: 3px; top: 2px; } .co.fl { right: 4px; bottom: 1px; }
.sq.light .co { color: #8a6032; } .sq.dark .co { color: #f5e3b8; }
.board[data-theme=onyx] .sq.light .co, .board[data-theme=midnight] .sq.light .co { color: #3a3640; }
.pc-layer { position: absolute; inset: 0; pointer-events: none; }
.pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; background-size: 100% 100%; background-repeat: no-repeat; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); }
.pc.anim, .pc.dragging { will-change: transform; } /* GPU layer only while moving */
.pc.dragging { z-index: 20; filter: drop-shadow(0 12px 10px rgba(0, 0, 0, .55)) drop-shadow(0 0 12px rgba(255, 170, 60, .7)); }
@media (pointer: coarse), (max-width: 820px) { .pc.dragging { filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .5)); } } /* one cheap shadow on phones */
.lowfx .pc.dragging, .saver .pc.dragging { filter: none; }
.pc.ghost { z-index: 1; }
.lowfx .pc { filter: none; }
.arrow-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }
.promo-layer { position: absolute; inset: 0; background: rgba(5, 4, 8, .55); z-index: 25; backdrop-filter: blur(2px); }
.promo-btn { position: absolute; width: 12.5%; height: 12.5%; padding: 0; border: 0; border-radius: 50%; background: radial-gradient(circle, #fff3d0, #e6c071 70%); box-shadow: 0 0 0 2px var(--gold3), 0 6px 18px rgba(0, 0, 0, .6); transition: transform .12s; }
.promo-btn:hover { transform: scale(1.08); }
.promo-btn .pc { position: absolute; inset: 6%; width: 88%; height: 88%; }
.evalbar { position: absolute; left: calc(-1 * var(--evw, 16px)); top: 0; bottom: 0; width: calc(var(--evw, 16px) - 5px); z-index: 9; border-radius: 6px; overflow: hidden; background: #26222c; box-shadow: 1px 0 0 rgba(0, 0, 0, .4); }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: linear-gradient(180deg, #fff6dc, #e9c46a); transition: height .45s ease; }
.evalbar.flip .fill { top: 0; bottom: auto; }
.ev-num { margin-left: 8px; font-family: var(--sans); font-size: .74rem; font-weight: 700; color: var(--gold2); background: rgba(0, 0, 0, .35); padding: 1px 6px; border-radius: 5px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 24; padding: 12px 22px; border-radius: 14px; background: rgba(10, 8, 12, .86); border: 1px solid var(--line); font-family: var(--serif); color: var(--gold2); font-size: 1.1rem; text-align: center; pointer-events: none; animation: pop .3s both; }

/* piece sets */
[data-set=cburnett] .pc.wK{background-image:url(../pieces/cburnett/wK.svg)}
[data-set=cburnett] .pc.wQ{background-image:url(../pieces/cburnett/wQ.svg)}
[data-set=cburnett] .pc.wR{background-image:url(../pieces/cburnett/wR.svg)}
[data-set=cburnett] .pc.wB{background-image:url(../pieces/cburnett/wB.svg)}
[data-set=cburnett] .pc.wN{background-image:url(../pieces/cburnett/wN.svg)}
[data-set=cburnett] .pc.wP{background-image:url(../pieces/cburnett/wP.svg)}
[data-set=cburnett] .pc.bK{background-image:url(../pieces/cburnett/bK.svg)}
[data-set=cburnett] .pc.bQ{background-image:url(../pieces/cburnett/bQ.svg)}
[data-set=cburnett] .pc.bR{background-image:url(../pieces/cburnett/bR.svg)}
[data-set=cburnett] .pc.bB{background-image:url(../pieces/cburnett/bB.svg)}
[data-set=cburnett] .pc.bN{background-image:url(../pieces/cburnett/bN.svg)}
[data-set=cburnett] .pc.bP{background-image:url(../pieces/cburnett/bP.svg)}
[data-set=merida] .pc.wK{background-image:url(../pieces/merida/wK.svg)}
[data-set=merida] .pc.wQ{background-image:url(../pieces/merida/wQ.svg)}
[data-set=merida] .pc.wR{background-image:url(../pieces/merida/wR.svg)}
[data-set=merida] .pc.wB{background-image:url(../pieces/merida/wB.svg)}
[data-set=merida] .pc.wN{background-image:url(../pieces/merida/wN.svg)}
[data-set=merida] .pc.wP{background-image:url(../pieces/merida/wP.svg)}
[data-set=merida] .pc.bK{background-image:url(../pieces/merida/bK.svg)}
[data-set=merida] .pc.bQ{background-image:url(../pieces/merida/bQ.svg)}
[data-set=merida] .pc.bR{background-image:url(../pieces/merida/bR.svg)}
[data-set=merida] .pc.bB{background-image:url(../pieces/merida/bB.svg)}
[data-set=merida] .pc.bN{background-image:url(../pieces/merida/bN.svg)}
[data-set=merida] .pc.bP{background-image:url(../pieces/merida/bP.svg)}
[data-set=chessnut] .pc.wK{background-image:url(../pieces/chessnut/wK.svg)}
[data-set=chessnut] .pc.wQ{background-image:url(../pieces/chessnut/wQ.svg)}
[data-set=chessnut] .pc.wR{background-image:url(../pieces/chessnut/wR.svg)}
[data-set=chessnut] .pc.wB{background-image:url(../pieces/chessnut/wB.svg)}
[data-set=chessnut] .pc.wN{background-image:url(../pieces/chessnut/wN.svg)}
[data-set=chessnut] .pc.wP{background-image:url(../pieces/chessnut/wP.svg)}
[data-set=chessnut] .pc.bK{background-image:url(../pieces/chessnut/bK.svg)}
[data-set=chessnut] .pc.bQ{background-image:url(../pieces/chessnut/bQ.svg)}
[data-set=chessnut] .pc.bR{background-image:url(../pieces/chessnut/bR.svg)}
[data-set=chessnut] .pc.bB{background-image:url(../pieces/chessnut/bB.svg)}
[data-set=chessnut] .pc.bN{background-image:url(../pieces/chessnut/bN.svg)}
[data-set=chessnut] .pc.bP{background-image:url(../pieces/chessnut/bP.svg)}

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 14px; background: rgba(4, 3, 7, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.sheet { overscroll-behavior: contain; width: min(460px, 100%); max-height: calc(100dvh - 28px); overflow: auto; padding: 20px 18px 16px; border-radius: 22px; background: linear-gradient(160deg, rgba(34, 27, 38, .96), rgba(16, 13, 20, .97)); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .06); animation: rise .28s both; }
.sheet.wide { width: min(620px, 100%); }
.sheet h2 { font-family: var(--serif); font-weight: 600; color: var(--gold2); margin: 0 0 14px; font-size: 1.35rem; letter-spacing: .04em; }
.sheet h3 { font-family: var(--serif); color: var(--gold); font-size: 1rem; margin: 16px 0 6px; }
.field { margin: 12px 0; }
.field > label, .field > summary { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--mut); margin-bottom: 7px; cursor: pointer; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .06); }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; min-width: 60px; border: 0; padding: 9px 8px; border-radius: 10px; background: transparent; color: var(--mut); font-weight: 600; font-size: .9rem; transition: background .2s, color .2s; }
.seg button.on { background: linear-gradient(135deg, #f3d995, #cf9f45); color: #1d1408; }
.hint-txt { color: var(--mut); font-size: .84rem; margin: 8px 2px 0; line-height: 1.4; }
.err { color: #ff9a9a; font-size: .86rem; margin: 8px 0 0; }
input[type=text], input[type=password], input[type=number], textarea { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); outline: none; }
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233, 196, 106, .15); }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; resize: vertical; }
.custom-clock { display: flex; gap: 10px; margin-top: 8px; } .custom-clock label { flex: 1; font-size: .82rem; color: var(--mut); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.grid-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 4px; color: var(--mut); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--gold2); border-color: var(--gold); }
.tab { display: none; } .tab.on { display: block; }
.pl-edit { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 16px; background: rgba(0, 0, 0, .22); margin-bottom: 10px; }
.pl-fields { flex: 1; min-width: 0; } .pl-fields label { font-size: .8rem; color: var(--mut); display: block; }
.pl-fields input[type=text] { margin-top: 4px; }
.tgl { display: flex; align-items: center; gap: 12px; padding: 10px 2px; cursor: pointer; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.tgl input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: #3a3440; position: relative; flex: none; transition: background .2s; cursor: pointer; margin: 0; }
.tgl input::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #d8cfc2; transition: transform .2s; }
.tgl input:checked { background: linear-gradient(135deg, #f3d995, #cf9f45); } .tgl input:checked::after { transform: translateX(18px); background: #fff; }
input[type=range] { width: 100%; accent-color: var(--gold); }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch { border: 2px solid transparent; border-radius: 12px; padding: 5px; background: rgba(0, 0, 0, .25); color: var(--mut); font-size: .76rem; }
.swatch.on { border-color: var(--gold); color: var(--gold2); }
.swatch .mini-b { display: grid; grid-template-columns: repeat(4, 1fr); aspect-ratio: 2; border-radius: 6px; overflow: hidden; margin-bottom: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.stat { padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .05); text-align: center; }
.stat b { display: block; font-family: var(--serif); color: var(--gold2); font-size: 1.05rem; }
.stat span { font-size: .74rem; color: var(--mut); }
.stat .wld { font-size: .78rem; color: var(--txt); }
.hist { margin-top: 14px; display: grid; gap: 6px; }
.hrow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .22); font-size: .86rem; }
.hrow .res { width: 52px; font-weight: 700; text-align: center; border-radius: 8px; padding: 3px 0; font-size: .76rem; }
.res.win { background: rgba(120, 220, 150, .18); color: #9ff0b5; } .res.loss { background: rgba(255, 100, 100, .16); color: #ffaaaa; } .res.draw, .res.pvp { background: rgba(233, 196, 106, .15); color: var(--gold2); }
.hrow .hm { flex: 1; min-width: 0; } .hrow .hm div:last-child { color: var(--mut); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.achi { padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .05); opacity: .45; filter: grayscale(1); }
.achi.got { opacity: 1; filter: none; border-color: var(--line); box-shadow: inset 0 0 20px rgba(233, 196, 106, .08); }
.achi .ic { font-size: 1.5rem; } .achi b { display: block; font-family: var(--serif); color: var(--gold2); font-size: .9rem; margin: 4px 0 2px; } .achi span { font-size: .76rem; color: var(--mut); }
.import-box { margin-top: 14px; padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, .25); }
.cloud { margin-top: 16px; font-size: .86rem; } .cloud summary { cursor: pointer; color: var(--gold); margin-bottom: 6px; }
.cloud .fld { display: block; margin: 10px 0 6px; color: var(--mut); font-size: .82rem; } .cloud .fld input { margin-top: 4px; color: inherit; font-size: 1rem; }
.cloud .grid-btns { margin-top: 6px; grid-template-columns: 1fr; } .cloud .grid-btns .btn { padding: 10px 14px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .02em; word-break: break-all; color: var(--txt, #fff); }
.err.ok { color: #9fe3b0; }
.danger-zone { margin-top: 16px; color: var(--mut); font-size: .84rem; } .danger-zone summary { cursor: pointer; margin-bottom: 8px; }
.credits { padding-left: 18px; color: var(--mut); font-size: .86rem; line-height: 1.6; }
.sheet.over { text-align: center; }
.over-crown { font-size: 3rem; color: var(--gold); text-shadow: 0 0 30px rgba(233, 196, 106, .7); line-height: 1; }
.over-quote { font-family: 'Cormorant', serif; font-style: italic; font-size: 1.15rem; color: #ffd9d2; }
#overSub { color: var(--mut); }
.toast.upd { cursor: pointer; font-weight: 600; bottom: calc(70px + var(--safe-b)); }
.toast { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 200; padding: 11px 18px; border-radius: 14px; background: rgba(20, 16, 24, .95); border: 1px solid var(--line); color: var(--gold2); font-size: .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); max-width: calc(100vw - 30px); animation: rise .25s both; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---------- landscape / desktop ---------- */
@media (min-aspect-ratio: 1/1) and (min-width: 700px) {
  #game { --bs: min(calc(100dvh - 28px - var(--safe-t) - var(--safe-b)), calc(100vw - 440px - var(--evw) - var(--safe-l) - var(--safe-r))); }
  #game { grid-template-columns: calc(var(--bs) + var(--evw)) minmax(300px, 380px); grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "board top" "board ctop" "board side" "board ctrl" "board cbot"; column-gap: 22px; row-gap: 10px; align-content: center; justify-content: center; padding: 14px calc(14px + var(--safe-r)) 14px calc(14px + var(--safe-l)); height: 100vh; height: 100dvh; }
  .board-wrap { align-self: center; }
  .topbar { align-self: start; }
  .pcard { padding: 10px 12px; }
  .avatar { width: 54px; height: 54px; }
  .side { min-height: 120px; }
  .movelist { display: grid; grid-template-columns: auto 1fr 1fr; gap: 2px 6px; align-content: start; }
  .movelist li { display: contents; }
  .controls { grid-template-columns: repeat(3, 1fr); }
  .ctl { flex-direction: row; justify-content: center; gap: 7px; padding: 10px 6px; font-size: .82rem; }
  .bubble { left: 80px; font-size: .9rem; }
  .cl-lines { max-height: 7.8em; font-size: .86rem; }
}
/* short landscape phones */
@media (orientation: landscape) and (max-height: 520px) {
  #game { --bs: min(calc(100dvh - 16px - var(--safe-t) - var(--safe-b)), calc(100vw - 270px - var(--evw) - var(--safe-l) - var(--safe-r))); }
  #game { grid-template-columns: calc(var(--bs) + var(--evw)) minmax(240px, 380px); grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "board top" "board ctop" "board side" "board cbot" "board ctrl"; column-gap: 14px; row-gap: 6px; padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l)); align-content: center; height: 100vh; height: 100dvh; }
  .board-wrap { align-self: center; }
  .avatar { width: 38px; height: 38px; }
  .controls { grid-template-columns: repeat(6, 1fr); }
  .ctl { flex-direction: column; font-size: .64rem; padding: 5px 2px; }
  .movelist { display: flex; }
  .movelist li { display: flex; }
  .bubble { left: 54px; font-size: .8rem; padding: 2px 10px; }
  .cl-lines { max-height: 5.2em; }
}
/* very small phones */
@media (max-width: 360px) { .ctl span { font-size: .62rem; } .pname { font-size: .9rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
.lowfx .btn.glass, .lowfx .pcard, .lowfx .duo-card, .lowfx .modal, .lowfx .promo-layer { backdrop-filter: none; -webkit-backdrop-filter: none; }
/* phones: no backdrop blur at all (most expensive effect on mobile GPUs) */
@media (pointer: coarse), (max-width: 820px) {
  .btn.glass, .pcard, .duo-card, .modal, .promo-layer { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.lowfx .caps .pc { filter: none; }
.saver .bg-orbs i, .saver .clock.low, .saver .thinking i { animation: none; }
.saver .bubble { box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }

/* browsers without dynamic viewport units */
@supports not (height: 1dvh) {
  #game { --bs: min(calc(100vw - 12px - var(--evw) - var(--safe-l) - var(--safe-r)), calc(100vh - 300px - var(--safe-t) - var(--safe-b))); }
  @media (min-aspect-ratio: 1/1) and (min-width: 700px) { #game { --bs: min(calc(100vh - 28px - var(--safe-t) - var(--safe-b)), calc(100vw - 440px - var(--evw) - var(--safe-l) - var(--safe-r))); } }
  @media (orientation: landscape) and (max-height: 520px) { #game { --bs: min(calc(100vh - 16px - var(--safe-t) - var(--safe-b)), calc(100vw - 270px - var(--evw) - var(--safe-l) - var(--safe-r))); } }
  .sheet { max-height: calc(100vh - 28px); }
}
