/* Baaghchaal hub: modern, game-first look. Dark by default; light theme available. */
:root {
  --bg: #070d0c; --bg2: #0d1715; --ink: #f2f8f5; --muted: #9bb0a8;
  --glass: rgba(255, 255, 255, .055); --glass-b: rgba(255, 255, 255, .11); --glass-hi: rgba(255, 255, 255, .09);
  --tiger: #ff8a3d; --tiger2: #ff4f6d; --goat: #6ef3b0; --gold: #ffd36b; --cap: #ff5c70;
  --line: #e7c883; --hint: #6ef3b0;
  --accent: #ff9a40; --on-accent: #1d1203; --glow: 255, 140, 60;
  --grad: linear-gradient(135deg, #ffc75e 0%, #ff9a40 50%, #f27a3b 100%);
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  --r: 22px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fff6e6; --bg2: #f8dfb4; --ink: #0f2a23; --muted: #4f665d;
  --glass: rgba(255, 255, 255, .9); --glass-b: rgba(120, 70, 20, .16); --glass-hi: #fff;
  --tiger: #e04e08; --tiger2: #cf2456; --goat: #12855a; --gold: #a86e0c; --cap: #d1243c;
  --line: #d6b36a; --hint: #12855a;
  --accent: #e0560a; --on-accent: #fff; --glow: 224, 86, 10;
  --grad: linear-gradient(135deg, #ffb347 0%, #ff7a2b 55%, #e8480f 100%);
  --shadow: 0 2px 4px rgba(120, 70, 20, .08), 0 18px 44px rgba(150, 80, 20, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg);
  font-family: "Segoe UI Variable Display", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.08; letter-spacing: -.02em; }
p { line-height: 1.55; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* animated backdrop */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(1200px 700px at 50% -10%, var(--bg2), var(--bg)); }
.aurora i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(90px); opacity: .34; animation: drift 26s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { background: #e07a32; left: -12vmax; top: -10vmax; }
.aurora i:nth-child(2) { background: #19c28a; right: -14vmax; top: 18vh; animation-duration: 32s; animation-delay: -8s; }
.aurora i:nth-child(3) { background: #6b4bff; left: 22vw; bottom: -26vmax; opacity: .22; animation-duration: 38s; animation-delay: -15s; }
:root[data-theme="light"] .aurora i { opacity: .38; }
:root[data-theme="light"] .aurora i:nth-child(1) { background: #ff9a3c; }
:root[data-theme="light"] .aurora i:nth-child(2) { background: #3fcf9c; opacity: .3; }
:root[data-theme="light"] .aurora i:nth-child(3) { background: #ff7a8a; opacity: .28; }
@keyframes drift { to { transform: translate(7vw, 5vh) scale(1.15); } }

.glass { background: var(--glass); border: 1px solid var(--glass-b); border-radius: var(--r); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); }

/* buttons */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 13px 24px; font-weight: 700; letter-spacing: .01em; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s, box-shadow .2s, background .2s, border-color .2s; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn-primary { background: var(--grad); color: var(--on-accent); box-shadow: 0 8px 28px rgba(var(--glow), .38), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(var(--glow), .5), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn-ghost { background: var(--glass); border-color: var(--glass-b); color: var(--ink); }
.btn-ghost:hover { background: var(--glass-hi); transform: translateY(-1px); }
.btn.sm { padding: 8px 16px; font-size: .88rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--glass-b); background: var(--glass); display: grid; place-items: center; color: var(--ink); transition: background .2s; }
.icon-btn:hover { background: var(--glass-hi); }
#soundBtn[aria-pressed="true"] .mute, #soundBtn[aria-pressed="false"] .wave { display: none; }

/* nav */
.nav { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px max(16px, 3vw); background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 88%, transparent), transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.logo svg { width: 34px; height: 34px; overflow: visible; filter: drop-shadow(0 3px 8px rgba(var(--glow), .5)); }
.tabs { display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-b); }
.tabs a { padding: 8px 18px; border-radius: 999px; text-decoration: none; font-weight: 650; color: var(--muted); transition: color .2s, background .2s; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--grad); color: var(--on-accent); }
.nav-tools { display: flex; gap: 8px; }
@media (max-width: 720px) {
  .tabs { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); justify-content: space-around; z-index: 30; padding: 6px; background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
  .tabs a { flex: 1; text-align: center; padding: 11px 6px; font-size: .92rem; }
  .app { padding-bottom: 110px !important; }
}

.app { max-width: 1180px; margin: 0 auto; padding: 8px max(16px, 3vw) 40px; }
.view[hidden] { display: none !important; }
.view { animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* hero */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(20px, 4vw, 56px); align-items: center; padding: clamp(10px, 4vw, 44px) 0 clamp(20px, 3vw, 36px); }
@media (max-width: 880px) { .hero { grid-template-columns: 1fr; } .hero-board { order: -1; max-width: 420px; margin: 0 auto; width: 100%; } }
.eyebrow { margin: 0 0 14px; color: var(--gold); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; }
.hero h1 { font-size: clamp(3rem, 8.4vw, 6rem); font-weight: 900; line-height: .95; letter-spacing: -.04em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: clamp(1.02rem, 1.6vw, 1.25rem); color: var(--muted); max-width: 34em; margin: 18px 0 26px; }
.lede b { color: var(--ink); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.cta .btn { padding: 16px 32px; font-size: 1.05rem; }
.proof { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 0; margin: 26px 0 0; color: var(--muted); font-size: .9rem; }
.proof b { color: var(--ink); }
.hero-board { position: relative; padding: 14px; border-radius: 30px; transform: rotate(1.2deg); animation: floaty 7s ease-in-out infinite; }
@keyframes floaty { 50% { transform: rotate(-.6deg) translateY(-8px); } }
.hero-board svg { width: 100%; height: auto; display: block; border-radius: 20px; }
.live { position: absolute; top: 24px; right: 26px; display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 5px 10px; border-radius: 99px; background: rgba(0, 0, 0, .45); color: #fff; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #ff9a40; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* quick tiles */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 44px; }
@media (max-width: 880px) { .quick { grid-template-columns: 1fr; } }
.qtile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 20px 22px; border-radius: var(--r); text-decoration: none; background: var(--glass); border: 1px solid var(--glass-b); backdrop-filter: blur(14px); overflow: hidden; transition: transform .2s, border-color .2s, background .2s; min-height: 148px; }
a.qtile:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--glass-hi); }
.qtile::before { content: ""; position: absolute; inset: auto -30% -60% auto; width: 70%; height: 120%; background: radial-gradient(closest-side, var(--accent-glow, rgba(255,150,64,.23)), transparent); pointer-events: none; }
.q-daily { --accent-glow: rgba(255, 211, 107, .28); } .q-resume { --accent-glow: rgba(110, 243, 176, .24); } .q-journey { --accent-glow: rgba(107, 75, 255, .28); }
.qlabel { font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--gold); }
.qtile strong { font-size: 1.5rem; letter-spacing: -.02em; }
.qtile small { color: var(--muted); font-size: .9rem; line-height: 1.4; }
.qgo { margin-top: auto; font-weight: 800; color: var(--accent); }
.ring-row { display: flex; align-items: center; gap: 14px; }
.ring { width: 64px; height: 64px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 4.5; } .ring-bg { stroke: var(--glass-b); } .ring-fg { stroke: url(#); stroke: var(--goat); stroke-linecap: round; stroke-dasharray: 113; stroke-dashoffset: 113; transition: stroke-dashoffset 1s ease; }
.ring-row strong { display: block; }
.jstats { display: flex; gap: 16px; margin-top: auto; color: var(--muted); font-size: .85rem; }
.jstats b { color: var(--ink); font-size: 1.15rem; margin-right: 3px; }

.sechead { display: flex; align-items: baseline; justify-content: space-between; margin: 12px 0 16px; }
.sechead h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 850; }
.more { color: var(--accent); font-weight: 700; text-decoration: none; }
.more:hover { text-decoration: underline; }

/* variant cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 44px; }
.card { position: relative; display: flex; flex-direction: column; border-radius: var(--r); overflow: hidden; background: var(--glass); border: 1px solid var(--glass-b); backdrop-filter: blur(14px); transition: transform .25s cubic-bezier(.2, .8, .2, 1), border-color .2s, box-shadow .25s; cursor: pointer; }
.card:hover { transform: translateY(-6px); border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 24px 50px rgba(0, 0, 0, .4); }
.card .thumb { aspect-ratio: 16 / 10; display: grid; place-items: center; background: radial-gradient(120% 120% at 30% 0%, hsl(var(--h) 55% 30%), hsl(calc(var(--h) + 40) 50% 12%)); position: relative; overflow: hidden; }
:root[data-theme="light"] .card .thumb { background: radial-gradient(120% 120% at 30% 0%, hsl(var(--h) 60% 45%), hsl(calc(var(--h) + 40) 55% 25%)); }
.card .thumb svg { height: 86%; width: auto; transition: transform .4s cubic-bezier(.2, .8, .2, 1); filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .35)); }
.card:hover .thumb svg { transform: scale(1.07) rotate(-2deg); }
.card .tagline { position: absolute; left: 10px; top: 10px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; background: rgba(0, 0, 0, .5); color: #fff; }
.card .tagline.daily { background: var(--grad); color: var(--on-accent); }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { font-size: 1.2rem; font-weight: 800; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--glass-hi); color: var(--muted); }
.chip { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--glass-b); margin-top: auto; }
.chip .cg { background: var(--goat); } .chip .ct { background: var(--tiger); } .chip .cd { background: rgba(127, 127, 127, .4); }
.chiptext { font-size: .72rem; color: var(--muted); }
.card .row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.card .row .btn-primary { flex: 1; padding: 10px 14px; }
.card .row .link { background: none; border: 0; color: var(--muted); font-size: .85rem; text-decoration: underline; padding: 6px; }
.card .row .link:hover { color: var(--ink); }
.card .new { position: absolute; right: 10px; top: 10px; font-size: .68rem; font-weight: 800; padding: 4px 9px; border-radius: 99px; background: var(--goat); color: #05281a; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }
.step { padding: 20px 22px; position: relative; }
.step h3 { font-size: 1.15rem; margin: 6px 0; } .step p { margin: 0; color: var(--muted); }
.num { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: var(--on-accent); font-weight: 900; }

.pagehead { padding: clamp(10px, 3vw, 30px) 0 18px; }
.pagehead h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 900; letter-spacing: -.035em; }
.pagehead p { color: var(--muted); max-width: 44em; margin: 10px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 20px; }
.filters button { border: 1px solid var(--glass-b); background: var(--glass); border-radius: 99px; padding: 7px 16px; font-weight: 650; font-size: .88rem; color: var(--muted); transition: all .2s; }
.filters button:hover { color: var(--ink); background: var(--glass-hi); }
.filters button.on { background: var(--grad); color: var(--on-accent); border-color: transparent; }

/* play */
.vstrip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; margin: 0 -2px; scrollbar-width: none; mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 28px), transparent); }
.vstrip::-webkit-scrollbar { display: none; }
.vstrip button { flex: none; border: 1px solid var(--glass-b); background: var(--glass); border-radius: 99px; padding: 8px 16px; font-weight: 650; font-size: .9rem; color: var(--muted); white-space: nowrap; transition: all .2s; }
.vstrip button:hover { color: var(--ink); background: var(--glass-hi); }
.vstrip button[aria-selected="true"] { background: var(--grad); color: var(--on-accent); border-color: transparent; box-shadow: 0 6px 20px rgba(var(--glow), .35); }
.vhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.vhead h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); font-weight: 900; letter-spacing: -.03em; }
.vsum { margin: 4px 0 0; color: var(--muted); max-width: 52em; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .stage { grid-template-columns: minmax(0, 1fr); } }
.stage > *, .side > * { min-width: 0; }

.board-wrap { padding: 14px 14px 16px; transition: box-shadow .4s, border-color .4s; }
.board-wrap[data-turn="G"] { border-color: color-mix(in srgb, var(--goat) 45%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--goat) 20%, transparent), 0 20px 70px color-mix(in srgb, var(--goat) 16%, transparent); }
.board-wrap[data-turn="T"] { border-color: color-mix(in srgb, var(--tiger) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--tiger) 20%, transparent), 0 20px 70px color-mix(in srgb, var(--tiger) 18%, transparent); }
.turnbar { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 2px 8px 12px; font-weight: 750; font-size: 1.05rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--goat); box-shadow: 0 0 0 5px color-mix(in srgb, var(--goat) 22%, transparent); transition: background .3s; flex: none; }
.dot.t { background: var(--tiger); box-shadow: 0 0 0 5px color-mix(in srgb, var(--tiger) 22%, transparent); }
.dot.think { animation: pulse 1s ease-in-out infinite; }
.again-bar { margin-left: auto; }
#board { width: 100%; height: auto; display: block; border-radius: 20px; touch-action: manipulation; user-select: none; max-height: 78vh; }
.infoline { margin: 10px 8px 0; color: var(--gold); font-size: .92rem; min-height: 1.2em; font-weight: 700; }
.dock { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dock .btn { padding: 11px 20px; flex: 1 1 auto; }
.dock .act { border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
.dock .act.on { background: var(--gold); color: #2a1d02; }
#pitBtn.on { background: #b07a3d; color: #fff; }
.hintline { color: var(--muted); font-size: .9rem; margin: 10px 8px 0; }
#hintText { color: var(--ink); }

/* board drawing */
.board-bg { fill: url(#gBoard); }
.board-frame { fill: none; stroke: rgba(231, 200, 131, .3); stroke-width: 2; }
.lines line { stroke: var(--line); stroke-width: 2.4; stroke-linecap: round; opacity: .8; }
.node { fill: var(--line); opacity: .9; }
.hit { fill: transparent; cursor: pointer; }
.hit.idle { cursor: default; }
.hint { fill: var(--hint); opacity: .9; transform-box: fill-box; transform-origin: center; animation: hint 1.2s ease-in-out infinite; pointer-events: none; }
.hint.cap { fill: var(--cap); }
.sel-ring { fill: none; stroke: #ffd36b; stroke-width: 3.5; filter: url(#fGlow); animation: pulse 1.2s ease-in-out infinite; pointer-events: none; }
.last-ring { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 2.2; stroke-dasharray: 4 5; pointer-events: none; }
.best-from { fill: none; stroke: #ffd36b; stroke-width: 3.5; stroke-dasharray: 6 5; filter: url(#fGlow); animation: pulse 1.2s ease-in-out infinite; pointer-events: none; }
.best-to { fill: #ffd36b; opacity: .95; transform-box: fill-box; transform-origin: center; animation: hint 1.2s ease-in-out infinite; pointer-events: none; }
.best-line { stroke: #ffd36b; stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; opacity: .9; pointer-events: none; }
.piece { transition: transform .38s cubic-bezier(.3, .8, .25, 1), opacity .35s; pointer-events: none; }
.piece .body { transform-box: fill-box; transform-origin: center; filter: url(#fShadow); }
.piece.arrive .body { animation: drop .5s cubic-bezier(.2, 1.3, .3, 1); }
.piece.captured .body { animation: gone .5s ease-in forwards; }
.piece.picked .body { transform: translateY(-5px) scale(1.1); transition: transform .15s; }
.piece.stuck-tiger .body { filter: url(#fShadow) grayscale(.9) brightness(.8); }
.piece.fogged { opacity: 0; }
.piece.sea .body { filter: none; }
.mist { fill: rgba(6, 12, 11, .72); pointer-events: none; }
.seatile { fill: #08110f; fill-opacity: .96; }
.pit { fill: #050a09; stroke: #7a5230; stroke-width: 3; pointer-events: none; }
.badges { pointer-events: none; }
.zzz { font: 800 14px system-ui, sans-serif; fill: #cfe3ff; stroke: #10201c; stroke-width: 3px; paint-order: stroke; text-anchor: middle; }
.slbadge { font: 700 12px system-ui, sans-serif; fill: #ffd166; stroke: #10201c; stroke-width: 3px; paint-order: stroke; text-anchor: middle; }
.portal-ring { fill: rgba(150, 90, 255, .18); stroke: #b98cff; stroke-width: 3; stroke-dasharray: 5 4; transform-box: fill-box; transform-origin: center; animation: portalspin 6s linear infinite; }
.portal-core { fill: rgba(190, 140, 255, .55); }
@keyframes portalspin { to { transform: rotate(360deg); } }
.spark { pointer-events: none; transform-box: fill-box; transform-origin: center; animation: spark .75s ease-out forwards; }
@keyframes spark { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); } }
.timer { position: relative; height: 24px; margin: 0 0 10px; border-radius: 12px; background: var(--glass); overflow: hidden; border: 1px solid var(--glass-b); }
.timer i { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--goat); transition: width .1s linear, background .2s; }
.timer.low i { background: var(--cap); }
.timer span { position: relative; display: block; text-align: center; font-size: .8rem; font-weight: 800; line-height: 24px; color: #06130d; }

/* side */
.side { display: grid; gap: 14px; }
.duel { display: grid; gap: 10px; }
@media (max-width: 900px) { .duel { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .duel { grid-template-columns: minmax(0, 1fr); } .player { padding: 10px 12px; } }
.player { display: flex; gap: 12px; align-items: center; padding: 12px 14px; transition: transform .25s, box-shadow .25s, border-color .25s; }
.player.active { transform: translateX(-4px); }
#cardG.active { border-color: var(--goat); box-shadow: 0 0 0 3px color-mix(in srgb, var(--goat) 24%, transparent), var(--shadow); }
#cardT.active { border-color: var(--tiger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tiger) 26%, transparent), var(--shadow); }
.avatar { width: 58px; height: 58px; flex: none; background: var(--glass-hi); border-radius: 16px; display: grid; place-items: center; }
.avatar svg { width: 52px; height: 52px; overflow: visible; }
.pname { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.badge { font-size: .64rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--glass-hi); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pstat { font-size: .86rem; color: var(--muted); margin-top: 2px; }
.pstat b { color: var(--ink); font-size: 1.05rem; }
.pips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--glass-b); transition: background .3s, transform .3s; }
.pip.on { background: var(--cap); border-color: var(--cap); transform: scale(1.15); box-shadow: 0 0 10px var(--cap); }
.panel { padding: 14px; display: grid; gap: 14px; }
.flabel { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .09em; font-weight: 750; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--glass); border: 1px solid var(--glass-b); padding: 4px; border-radius: 14px; }
.seg button { border: 0; background: transparent; border-radius: 10px; padding: 9px 6px; font-size: .88rem; font-weight: 650; color: var(--muted); transition: all .2s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--grad); color: var(--on-accent); font-weight: 800; }
.cfgrow { display: flex; gap: 10px; flex-wrap: wrap; }
.cfgrow label { font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.cfgrow select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--glass-b); background: var(--bg2); color: var(--ink); }
.logtop { display: flex; justify-content: space-between; align-items: center; }
.logctl { display: flex; gap: 4px; }
.logctl button { border: 1px solid var(--glass-b); background: var(--glass); border-radius: 9px; padding: 4px 9px; font-size: .8rem; }
.logctl button:hover:not(:disabled) { background: var(--glass-hi); }
.logctl button:disabled { opacity: .35; }
.loglist { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: .9rem; border: 1px solid var(--glass-b); border-radius: 12px; }
.loglist li { display: flex; gap: 8px; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--glass-b); }
.loglist li:last-child { border-bottom: 0; }
.loglist li:hover { background: var(--glass); }
.loglist li.cur { background: color-mix(in srgb, var(--gold) 20%, transparent); font-weight: 700; }
.loglist .n { color: var(--muted); min-width: 1.6em; text-align: right; }
.loglist .g { color: var(--goat); } .loglist .t { color: var(--tiger); } .loglist .x { color: var(--cap); font-weight: 700; }

/* dialogs and result */
dialog { border: 1px solid var(--glass-b); border-radius: 24px; background: var(--bg2); color: var(--ink); max-width: 480px; padding: 24px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(5px); }
dialog h2 { margin-bottom: 8px; } dialog li { margin: 8px 0; line-height: 1.45; color: var(--muted); } dialog li b { color: var(--ink); }
dialog li.var { color: var(--ink); } dialog ul { padding-left: 18px; } dialog form { text-align: right; }
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); z-index: 50; animation: fade .3s; padding: 16px; }
.result { position: relative; padding: 28px 30px 24px; text-align: center; max-width: 400px; width: 100%; animation: pop .5s cubic-bezier(.2, 1.3, .3, 1); background: var(--bg2); }
.rart svg { width: 110px; height: 110px; overflow: visible; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(2deg); } }
.result h2 { margin: 10px 0 6px; font-size: 2rem; font-weight: 900; }
.result p { color: var(--muted); margin: 0 0 14px; }
.rstats { display: flex; justify-content: center; gap: 18px; margin-bottom: 18px; color: var(--muted); font-size: .86rem; }
.rstats b { color: var(--ink); font-size: 1.2rem; display: block; }
.rbtns { display: grid; gap: 8px; }
.result .close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; font-size: 1.5rem; color: var(--muted); }
.result .close:hover { background: var(--glass-hi); color: var(--ink); }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -14px; width: 9px; height: 16px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 60; padding: 12px 20px; border-radius: 99px; background: var(--grad); color: var(--on-accent); font-weight: 800; box-shadow: var(--shadow); animation: pop .4s cubic-bezier(.2, 1.3, .3, 1); }

/* learn */
.wiki { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 26px; align-items: start; }
@media (max-width: 800px) { .wiki { grid-template-columns: 1fr; } .toc { position: static !important; flex-direction: row !important; flex-wrap: wrap; } }
.toc { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.toc a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 10px; font-weight: 650; }
.toc a:hover { background: var(--glass); color: var(--ink); }
.wiki article section { padding: 10px 24px 22px; margin-bottom: 16px; }
.wiki h2, .lab h2 { margin: 14px 0 8px; font-size: 1.5rem; }
.wiki h3, .lab h3 { margin: 14px 0 6px; font-size: 1.08rem; }
.wiki li, .lab li { margin: 6px 0; line-height: 1.55; }
.wiki a, .lab a { color: var(--accent); }
.rules { padding-left: 20px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } }
.note { color: var(--muted); font-size: .88rem; }
.miniboard { max-width: 330px; margin: 10px 0 4px; }
.mb-bg { fill: #14231f; } .mb-lines line { stroke: var(--line); stroke-width: 2; } .mb-node { fill: var(--line); }
.mb-lbl { fill: #e9f3ee; font: 700 10px system-ui, sans-serif; stroke: #14231f; stroke-width: 3px; paint-order: stroke; }
.lab { padding: 10px 24px 24px; }
.tablewrap { overflow-x: auto; }
.bal { border-collapse: collapse; width: 100%; font-size: .88rem; }
.bal th, .bal td { padding: 7px 8px; border-bottom: 1px solid var(--glass-b); text-align: center; white-space: nowrap; }
.bal thead th { background: var(--glass); }
.bal tbody th { text-align: left; }
.bal td.n { font-variant-numeric: tabular-nums; }
.bal td.flag { text-align: left; color: var(--cap); font-weight: 650; white-space: normal; }
code { background: var(--glass-hi); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1180px; margin: 0 auto; padding: 18px max(16px, 3vw) 100px; color: var(--muted); font-size: .85rem; }
.foot a { color: var(--muted); }

@keyframes drop { 0% { transform: translateY(-40px) scale(.4); opacity: 0; } 70% { opacity: 1; } 100% { transform: none; } }
@keyframes gone { to { transform: scale(0) rotate(160deg); opacity: 0; } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes hint { 50% { transform: scale(1.35); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.7) translateX(var(--tx, 0)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* hero demo: it is a preview, tapping it starts a real game */
.hero-board { cursor: pointer; }
.live-cta { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 8px 18px; border-radius: 99px; background: var(--grad); color: var(--on-accent); font-weight: 800; font-size: .88rem; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.hero-board:hover .live-cta, .hero-board:focus-visible .live-cta { opacity: 1; transform: translateX(-50%) translateY(-4px); }
@media (hover: none) { .live-cta { opacity: 1; } }

/* home: slim entry to the full variants page */
.explore { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; padding: clamp(20px, 3vw, 34px); margin-bottom: 36px; text-decoration: none; overflow: hidden; position: relative; transition: transform .25s, border-color .2s; }
.explore:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.explore h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 900; margin: 6px 0 8px; }
.explore p { color: var(--muted); margin: 0 0 18px; max-width: 30em; }
.explore .btn { pointer-events: none; }
.explore-thumbs { display: flex; justify-content: center; padding-left: 28px; }
.et { width: clamp(84px, 11vw, 128px); aspect-ratio: 1; margin-left: -28px; border-radius: 20px; display: grid; place-items: center; background: radial-gradient(120% 120% at 30% 0%, hsl(var(--h) 55% 30%), hsl(calc(var(--h) + 40) 50% 12%)); border: 1px solid var(--glass-b); box-shadow: 0 12px 30px rgba(0, 0, 0, .4); transform: translateY(calc((var(--i) - 2) * (var(--i) - 2) * 3px)) rotate(calc((var(--i) - 2) * 4deg)); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.et svg { width: 82%; height: 82%; }
.explore:hover .et { transform: translateY(calc((var(--i) - 2) * (var(--i) - 2) * 3px - 8px)) rotate(calc((var(--i) - 2) * 6deg)); }
@media (max-width: 760px) { .explore { grid-template-columns: 1fr; } .explore-thumbs { order: -1; justify-content: flex-start; } }

/* turn banner: impossible to miss */
.turnbar { display: flex; align-items: center; gap: 14px; min-height: 76px; margin: 0 0 12px; padding: 12px 16px; border-radius: 18px; border: 1px solid var(--glass-b); background: var(--glass-hi); transition: background .3s, border-color .3s, box-shadow .3s; }
.turnbar.side-G { background: linear-gradient(100deg, color-mix(in srgb, var(--goat) 22%, transparent), color-mix(in srgb, var(--goat) 4%, transparent) 70%); border-color: color-mix(in srgb, var(--goat) 50%, transparent); }
.turnbar.side-T { background: linear-gradient(100deg, color-mix(in srgb, var(--tiger) 26%, transparent), color-mix(in srgb, var(--tiger) 5%, transparent) 70%); border-color: color-mix(in srgb, var(--tiger) 55%, transparent); }
.turnbar.side-D { background: var(--glass-hi); }
.turnbar.mine.side-G { box-shadow: 0 0 0 3px color-mix(in srgb, var(--goat) 22%, transparent), 0 10px 34px color-mix(in srgb, var(--goat) 25%, transparent); }
.turnbar.mine.side-T { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tiger) 24%, transparent), 0 10px 34px color-mix(in srgb, var(--tiger) 28%, transparent); }
.turnicon { width: 54px; height: 54px; flex: none; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .08); }
.turnicon svg { width: 46px; height: 46px; overflow: visible; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .4)); }
.turnbar.mine .turnicon { animation: nudge 1.6s ease-in-out infinite; }
.turnbar.think .turnicon { animation: pulse 1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-4px) scale(1.06); } }
.turntext { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.turntext strong { font-size: clamp(1.35rem, 3.2vw, 1.85rem); font-weight: 900; letter-spacing: -.02em; line-height: 1.05; }
.turntext span { font-size: clamp(.98rem, 1.8vw, 1.12rem); font-weight: 650; color: var(--muted); }
.turnbar.mine .turntext span { color: var(--ink); }
.turnbar.mine.side-G .turntext strong { color: var(--goat); }
.turnbar.mine.side-T .turntext strong { color: var(--tiger); }
@media (max-width: 520px) { .turnbar { gap: 10px; padding: 10px 12px; min-height: 66px; } .turnicon { width: 46px; height: 46px; } .turnicon svg { width: 40px; height: 40px; } }

/* when it is the player's turn the ACTION is the headline; "Your turn" becomes a small label above it */
.turnbar.mine .turntext { flex-direction: column; gap: 4px; }
.turnbar.mine .turntext strong { font-size: .8rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; line-height: 1; }
.turnbar.mine .turntext span { font-size: clamp(1.55rem, 4.2vw, 2.2rem); font-weight: 900; letter-spacing: -.025em; line-height: 1.05; color: var(--ink); }
.turnbar.mine { min-height: 84px; }

/* helper line + two-step graphic for moving a piece */
.turntext em { font-style: normal; font-size: clamp(.86rem, 1.5vw, .98rem); color: var(--muted); font-weight: 600; line-height: 1.35; }
.turntext em:empty { display: none; }
.turnsteps { display: flex; gap: 8px; flex: none; }
.turnsteps span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 7px; border-radius: 99px; border: 1px solid var(--glass-b); background: rgba(255, 255, 255, .05); color: var(--muted); font-weight: 750; font-size: .88rem; transition: all .25s; }
.turnsteps i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--glass-b); font-style: normal; font-weight: 900; font-size: .82rem; }
.turnsteps span.on { color: var(--ink); border-color: transparent; background: var(--grad); color: var(--on-accent); transform: scale(1.06); box-shadow: 0 6px 18px rgba(var(--glow), .35); }
.turnsteps span.on i { background: rgba(0, 0, 0, .18); }
.turnsteps span.done { color: var(--goat); border-color: color-mix(in srgb, var(--goat) 45%, transparent); }
.turnsteps span.done i { background: var(--goat); color: #05281a; }
@media (max-width: 640px) { .turnsteps { display: none; } }

/* balance: "Your turn" and the action line are close in weight; colour separates them */
.turnbar.mine .turntext { gap: 3px; }
.turnbar.mine .turntext strong { font-size: clamp(1.25rem, 3vw, 1.65rem); font-weight: 900; letter-spacing: -.01em; text-transform: none; line-height: 1.05; }
.turnbar.mine .turntext span { font-size: clamp(1.2rem, 2.8vw, 1.55rem); font-weight: 800; letter-spacing: -.015em; line-height: 1.1; color: var(--ink); }
.turnbar.mine { min-height: 88px; }

/* ================= PLAY SCREEN: fits one screen on desktop, stacks on phones ================= */
:root { --nav-h: 64px; }
.boardbox { position: relative; }
.boardbox #board { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; }
.hud { display: none; }
.vtitle { min-width: 0; }

@media (min-width: 901px) {
  body.on-play { overflow: hidden; }
  body.on-play .foot { display: none; }
  body.on-play .app { padding-bottom: 0; }
  #view-play:not([hidden]) { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-h) - 14px); min-height: 440px; }
  .vstrip { flex: none; padding-bottom: 8px; }
  .vhead { flex: none; margin: 0 0 10px; align-items: center; }
  .vhead h2 { font-size: 1.5rem; }
  .vsum { margin: 2px 0 0; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stage { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 360px; align-items: stretch; }
  .board-wrap { display: flex; flex-direction: column; min-height: 0; padding: 12px; }
  .board-wrap .turnbar { flex: none; margin-bottom: 10px; }
  .boardbox { flex: 1; min-height: 0; }
  .infoline { flex: none; margin: 8px 6px 0; min-height: 1.2em; }
  .timer { flex: none; }
  .side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px 4px 4px 0; scrollbar-width: thin; scrollbar-color: var(--glass-b) transparent; }
  .side > * { flex: none; }
  .dock { margin-top: 0; }
  .loglist { max-height: 160px; }
}
@media (min-width: 901px) and (max-height: 800px) {
  .vsum { display: none; }
  .vhead h2 { font-size: 1.25rem; }
  .turnbar, .turnbar.mine { min-height: 62px; padding: 8px 12px; gap: 10px; }
  .turnicon { width: 44px; height: 44px; } .turnicon svg { width: 38px; height: 38px; }
  .turnbar.mine .turntext strong { font-size: 1.1rem; } .turnbar.mine .turntext span { font-size: 1.25rem; }
  .turntext em { display: none; }
}

@media (max-width: 900px) {
  .vhead { margin: 0 0 8px; align-items: center; }
  .vhead h2 { font-size: 1.3rem; }
  .vsum { display: none; }
  .stage { display: flex; flex-direction: column; gap: 10px; }
  .side { display: contents; }
  .board-wrap { order: 1; padding: 10px; }
  .dock { order: 2; margin-top: 0; }
  #hintText { order: 3; margin: 0 4px; }
  .duel { display: none; }
  .panel:not(#logPanel) { order: 5; }
  #logPanel { order: 6; }
  .hud { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
  .hud span { flex: 1 1 auto; text-align: center; font-size: .82rem; font-weight: 750; color: var(--muted); padding: 6px 8px; border-radius: 99px; background: var(--glass); border: 1px solid var(--glass-b); white-space: nowrap; }
  .turnbar, .turnbar.mine { min-height: 62px; padding: 8px 12px; gap: 10px; margin-bottom: 8px; }
  .turnicon { width: 44px; height: 44px; } .turnicon svg { width: 38px; height: 38px; }
  .turnbar.mine .turntext strong { font-size: 1.05rem; } .turnbar.mine .turntext span { font-size: 1.25rem; }
  .turntext em { font-size: .8rem; }
  /* board is a square that shrinks to fit the screen height so the controls stay in view */
  .boardbox { width: min(100%, max(280px, calc(100dvh - 420px))); aspect-ratio: 1; margin: 0 auto; }
  .dock .btn { padding: 10px 14px; font-size: .92rem; }
  .infoline { margin: 6px 4px 0; }
}
@media (max-width: 420px) { .vstrip button { padding: 7px 13px; font-size: .86rem; } }

/* ---- tighter vertical use ---- */
.vbar { display: flex; align-items: center; gap: 10px; }
.vbar .vstrip { flex: 1; min-width: 0; }
.vbar .btn { flex: none; margin-bottom: 6px; }
@media (min-width: 901px) {
  #view-play:not([hidden]) { height: calc(100dvh - var(--nav-h) - 24px); }
  .vhead { margin: 0 0 8px; }
}
@media (min-width: 901px) and (max-height: 800px) { .vhead { display: none; } }
@media (max-width: 900px) {
  .stage { align-items: stretch; }
  .vhead { display: none; }
  .boardbox { width: min(100%, max(240px, calc(100dvh - 400px))); }
}

/* ================= STABLE LAYOUT: nothing above or below the board may change its size =================
   The banner has ONE fixed height in every state; text is clipped/clamped instead of growing it. */
:root { --banner-h: 104px; }
.turnbar, .turnbar.mine { height: var(--banner-h) !important; min-height: var(--banner-h) !important; max-height: var(--banner-h) !important; overflow: hidden; box-sizing: border-box; }
.turntext { overflow: hidden; justify-content: center; }
.turntext strong, .turntext span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turntext em { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.infoline { height: 1.4em; min-height: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hud { flex-wrap: nowrap; overflow: hidden; }
/* the speed-timer bar keeps its space even while hidden, but only in variants that use it */
.board-wrap:not(.has-timer) .timer { display: none !important; }
.board-wrap.has-timer .timer[hidden] { display: block !important; visibility: hidden; }
@media (min-width: 901px) and (max-height: 800px) { :root { --banner-h: 66px; } }
@media (max-width: 900px) { :root { --banner-h: 80px; } .turntext em { -webkit-line-clamp: 1; } }
@media (max-width: 420px) { .hud span { font-size: .76rem; padding: 5px 6px; } }

/* ---- action buttons live directly under the board, one fixed-height row, never pushed off screen ---- */
.board-wrap .dock { flex: none; display: flex; flex-wrap: nowrap; gap: 8px; margin: 10px 0 0; height: 48px; }
.board-wrap .dock .btn { flex: 1 1 0; min-width: 0; padding: 0 10px; height: 48px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-wrap .dock .btn[hidden] { display: none !important; }
@media (max-width: 900px) { .board-wrap .dock { height: 44px; margin-top: 8px; } .board-wrap .dock .btn { height: 44px; font-size: .88rem; padding: 0 8px; } }

/* ---- variant rule bar: the twist is always visible, in the variant's own colour, fixed height ---- */
:root { --rule-h: 50px; }
.rulebar { --h: 40; flex: none; display: flex; align-items: center; gap: 12px; height: var(--rule-h); margin: 0 0 10px; padding: 0 16px 0 14px; border-radius: 16px; overflow: hidden; background: linear-gradient(100deg, hsl(var(--h) 70% 55% / .26), hsl(var(--h) 70% 55% / .07) 70%); border: 1px solid hsl(var(--h) 70% 60% / .55); box-shadow: inset 4px 0 0 hsl(var(--h) 80% 62%); }
.rb-tag { flex: none; font-size: .68rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; background: hsl(var(--h) 80% 62%); color: #0b0f0e; }
.rb-name { flex: none; font-size: 1.05rem; font-weight: 900; letter-spacing: -.01em; }
.rb-text { min-width: 0; font-size: 1rem; font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rulebar.classic { background: var(--glass); border-color: var(--glass-b); box-shadow: none; }
.rulebar.classic .rb-tag { background: var(--glass-hi); color: var(--muted); }
.rulebar.classic .rb-text { color: var(--muted); font-weight: 600; }
@media (max-width: 900px) {
  :root { --rule-h: 64px; }
  .rulebar { flex-wrap: wrap; align-content: center; gap: 2px 10px; padding: 6px 12px; }
  .rb-tag { order: 1; } .rb-name { order: 2; font-size: 1rem; }
  .rb-text { order: 3; flex: 1 1 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .9rem; }
  .boardbox { width: min(100%, max(230px, calc(100dvh - 470px))); }
}

/* ---- logo: a proper wordmark ---- */
.logo { gap: 12px; }
.logo-tile { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; background: radial-gradient(120% 120% at 30% 0%, rgba(var(--glow), .35), rgba(255, 255, 255, .04) 70%); border: 1px solid rgba(var(--glow), .45); box-shadow: 0 6px 20px rgba(var(--glow), .25), inset 0 1px 0 rgba(255, 255, 255, .2); transition: transform .25s cubic-bezier(.2, 1.3, .3, 1); }
.logo:hover .logo-tile { transform: rotate(-6deg) scale(1.06); }
.logo .logo-tile svg { width: 32px; height: 32px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .45)); }
.logo-word { display: flex; flex-direction: column; line-height: 1; gap: 3px; }
.lw { font-size: 1.45rem; font-weight: 900; letter-spacing: -.045em; color: var(--ink); }
.lw b { font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-word small { font-size: .62rem; font-weight: 800; letter-spacing: .22em; color: var(--muted); text-transform: uppercase; }
@media (max-width: 420px) { .lw { font-size: 1.25rem; } .logo-tile { width: 38px; height: 38px; } }

/* ---- phones: the bottom tab bar must be fixed to the screen, not trapped inside the blurred header ---- */
@media (max-width: 720px) {
  .nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: color-mix(in srgb, var(--bg) 70%, transparent); }
  .tabs { bottom: max(10px, env(safe-area-inset-bottom)); }
}
/* short phones (e.g. 667px tall): compact rule bar + banner so the board and buttons stay in view */
@media (max-width: 900px) and (max-height: 720px) {
  :root { --rule-h: 40px; --banner-h: 66px; }
  .rulebar { flex-wrap: nowrap; align-content: unset; align-items: center; padding: 0 12px; }
  .rb-tag { display: none; }
  .rb-text { flex: 1 1 auto; white-space: nowrap; display: block; -webkit-line-clamp: unset; }
  .turntext em { display: none; }
  .boardbox { width: min(100%, max(220px, calc(100dvh - 420px))); }
}

/* board shrinks just enough that the buttons always clear the bottom tab bar */
@media (max-width: 900px) { .boardbox { width: min(100%, max(230px, calc(100dvh - 500px))); } }
@media (max-width: 900px) and (max-height: 720px) { .boardbox { width: min(100%, max(200px, calc(100dvh - 455px))); } }

/* install button: appears only when the browser says the app can be installed */
.install-btn { height: 40px; padding: 0 16px; border-radius: 99px; border: 1px solid rgba(var(--glow), .5); background: rgba(var(--glow), .14); color: var(--ink); font-weight: 800; font-size: .88rem; white-space: nowrap; transition: background .2s, transform .15s; }
.install-btn:hover { background: rgba(var(--glow), .26); transform: translateY(-1px); }
.install-btn[hidden] { display: none !important; }
@media (max-width: 520px) { .install-btn { padding: 0 12px; font-size: .8rem; } }

/* ================= DICE MODE ================= */
/* a die is a 3x3 grid of pip slots; the "on" ones are shown */
.d9 { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; aspect-ratio: 1; padding: 14%; border-radius: 22%; background: linear-gradient(145deg, #ffffff, #dfe6e2); border: 2px solid rgba(0, 0, 0, .18); box-shadow: 0 6px 16px rgba(0, 0, 0, .35), inset 0 -3px 0 rgba(0, 0, 0, .1); }
.d9 i { width: 62%; height: 62%; border-radius: 50%; background: #17211e; opacity: 0; transform: scale(.4); transition: opacity .12s, transform .12s; }
.d9 i.on { opacity: 1; transform: none; }
.d9.six { background: linear-gradient(145deg, #fff3c2, #ffc94d); border-color: #b9811b; }
.d9.one { background: linear-gradient(145deg, #ffe0e0, #ff9a9a); border-color: #b5413f; }
.d9.blank::after { content: "?"; grid-area: 1 / 1 / 4 / 4; font-weight: 900; font-size: 1.1em; color: #17211e; opacity: .55; }
.dicechip { flex: none; width: 46px; cursor: pointer; }
.dicechip .d9 { width: 100%; box-shadow: 0 3px 8px rgba(0, 0, 0, .35), inset 0 -2px 0 rgba(0, 0, 0, .1); }
.dicechip .d9.blank::after { font-size: 1.1rem; }
.dicechip[hidden] { display: none !important; }

/* the big die over the board: tap to roll, tumbles, lands, explains itself */
.diceStage { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; border-radius: 20px; background: rgba(6, 12, 11, .5); backdrop-filter: blur(2px); animation: fade .2s; }
.diceStage[hidden] { display: none; }
.diceStage[data-mode="landed"] { pointer-events: none; }
.dsCard { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 18px 22px; max-width: 92%; border-radius: 22px; background: color-mix(in srgb, var(--bg2) 88%, transparent); border: 1px solid var(--glass-b); box-shadow: var(--shadow); }
.dsWho { font-size: .78rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.bigdie { width: clamp(84px, 18vmin, 132px); border: 2px solid rgba(0, 0, 0, .18); cursor: pointer; }
.bigdie:disabled { cursor: default; }
.bigdie.bob { animation: dieBob 1.3s ease-in-out infinite; cursor: pointer; }
.bigdie.bob:hover { filter: brightness(1.06); }
.bigdie.rolling { animation: dieTumble .42s linear infinite; }
.bigdie.land { animation: dieLand .45s cubic-bezier(.2, 1.4, .3, 1); }
.dsTitle { font-size: clamp(1.05rem, 2.6vmin, 1.45rem); font-weight: 900; letter-spacing: .02em; }
.diceStage[data-cls="six"] .dsTitle { color: var(--gold); }
.diceStage[data-cls="one"] .dsTitle { color: var(--cap); }
.dsText { font-size: clamp(.86rem, 1.9vmin, 1rem); font-weight: 600; color: var(--muted); max-width: 22em; line-height: 1.35; }
@keyframes dieBob { 50% { transform: translateY(-8px) rotate(-4deg); } }
@keyframes dieTumble { 0% { transform: rotate(0) scale(1.04); } 25% { transform: rotate(95deg) translateY(-9px); } 50% { transform: rotate(185deg) scale(1.1); } 75% { transform: rotate(275deg) translateY(-6px); } 100% { transform: rotate(360deg) scale(1.04); } }
@keyframes dieLand { 0% { transform: scale(1.5) rotate(12deg); } 60% { transform: scale(.92); } 100% { transform: none; } }

/* the rules panel: every number explained, current one highlighted */
.dice-legend { gap: 8px; }
.dice-legend[hidden] { display: none !important; }
.lrow { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 14px; border: 1px solid transparent; transition: background .25s, border-color .25s; }
.lrow.now { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.ldice { display: flex; gap: 4px; }
.d9.mini { width: 24px; padding: 12%; border-radius: 26%; border-width: 1.5px; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.ltext { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ltext b { font-size: .95rem; }
.ltext span { font-size: .84rem; color: var(--muted); line-height: 1.3; }
@media (max-width: 900px) {
  #diceLegend { order: 4; }
  .dicechip { width: 40px; }
  .dsCard { padding: 12px 14px; gap: 5px; }
  .bigdie { width: clamp(70px, 22vmin, 104px); }
}

/* legend: fixed first column so every row lines up and the dice never touch the text */
.lrow { grid-template-columns: 116px minmax(0, 1fr); }
.ldice { flex-wrap: nowrap; }
.ldice .d9.mini { flex: none; width: 24px; }

/* dice: every size comes from --d (the die's own width); percentage padding would be measured against the PARENT */
.d9 { --d: 46px; width: var(--d); padding: calc(var(--d) * .16); }
.d9.mini { --d: 24px; padding: calc(var(--d) * .14); }
.dicechip .d9 { --d: 46px; }
.bigdie { --d: clamp(84px, 18vmin, 132px); }
.ldice .d9.mini { width: var(--d); }
@media (max-width: 900px) { .dicechip .d9 { --d: 40px; } .bigdie { --d: clamp(70px, 22vmin, 104px); } }

/* legend rows: title + dice on one line, explanation below (replaces the earlier two-column version) */
.lrow { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; grid-template-columns: none; }
.lhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lhead b { font-size: .98rem; white-space: nowrap; }
.ldice { display: flex; flex: none; gap: 5px; align-items: center; }
.ldice .d9.mini { --d: 26px; }
.ldesc { font-size: .86rem; color: var(--muted); line-height: 1.35; }
.lrow.now .ldesc { color: var(--ink); }
.lrow { align-items: stretch; text-align: left; }
