/* Cuebound website. Colors are the game's HUD tokens (Assets/_Game/Scripts/UI/HudTheme.cs);
   the face is the game's bundled Barlow Semi Condensed (SIL Open Font License, fonts/OFL.txt). */

@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("/fonts/BarlowSemiCondensed-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("/fonts/BarlowSemiCondensed-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("/fonts/BarlowSemiCondensed-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

/* The game's Noto fonts for the scripts Barlow lacks (Assets/_Game/Art/Fonts/Noto,
   copied by web/build.sh). Each has a unicode-range, so a browser downloads one
   only for a page that shows that script: Russian, Arabic, Hindi. Chinese uses
   the system's own fonts (every phone and desktop has them); the game's cut-down
   Chinese fonts (1.5 MB each) lack many characters of the legal texts. */
@font-face {
  font-family: "Cuebound Noto Sans";
  src: url("/fonts/NotoSans-SemiCondensedMedium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0400-052F, U+1C80-1C8F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: "Cuebound Noto Sans";
  src: url("/fonts/NotoSans-SemiCondensedSemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0400-052F, U+1C80-1C8F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: "Cuebound Noto Sans";
  src: url("/fonts/NotoSans-SemiCondensedBold.ttf") format("truetype");
  font-weight: 700 900;
  font-display: swap;
  unicode-range: U+0400-052F, U+1C80-1C8F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: "Cuebound Noto Arabic";
  src: url("/fonts/NotoSansArabic-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Cuebound Noto Devanagari";
  src: url("/fonts/NotoSansDevanagari-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+A8E0-A8FF, U+200C-200D, U+25CC;
}

:root {
  --bg: #08100d;          /* HudTheme.Background */
  --panel: #0e1714;       /* PanelSolid */
  --panel-glass: rgba(14, 23, 20, 0.86);
  --surface: #18241f;     /* Surface */
  --line: #3a5046;        /* Line */
  --line-soft: #2c3b35;   /* SurfaceLine */
  --text: #f2ede0;        /* Text: ivory */
  --muted: #a9b5aa;       /* TextMuted */
  --dim: #66706b;         /* TextDisabled */
  --accent: #d6a84a;      /* Accent: brass */
  --on-accent: #241a05;
  --good: #4fc98a;
  --foul: #e5534b;
  --p1: #2f6fc4;
  --p2: #b8405f;
  --felt: #1d6b44;
  --radius: 14px;
  --radius-sm: 9px;
  --gutter: clamp(16px, 4vw, 40px);
  --max: 1180px;
  --font: "Barlow Semi Condensed", "Barlow", "Cuebound Noto Sans", "Cuebound Noto Arabic", "Cuebound Noto Devanagari", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: dark;
}
/* Chinese: Barlow for Latin letters and digits, then the system's Chinese fonts. */
:lang(zh-Hans) { --font: "Barlow Semi Condensed", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif; }
:lang(zh-Hant) { --font: "Barlow Semi Condensed", "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Source Han Sans TC", system-ui, sans-serif; }
/* Letter spacing breaks Arabic joining and Devanagari clusters. */
:lang(ar), :lang(ar) *, :lang(hi), :lang(hi) * { letter-spacing: 0 !important; }
body:lang(ar) { line-height: 1.65; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 18px/1.5 var(--font);
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[lang]:not(html) { font-family: var(--font); }
img, canvas, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #e9c06a; }
h1, h2, h3 { font-weight: 700; line-height: 1.05; margin: 0 0 0.4em; letter-spacing: 0.01em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.8rem; margin-bottom: 0.8em; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Header ------------------------------------------------------------ */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(to bottom, rgba(8, 16, 13, 0.92), rgba(8, 16, 13, 0.72));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(58, 80, 70, 0.45);
}
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.4rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand:hover { color: var(--text); }
.brand svg { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav a[aria-current="page"] { color: var(--on-accent); background: var(--accent); }
.nav .live-dot::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--foul);
  margin-inline-end: 7px; vertical-align: 1px; box-shadow: 0 0 0 0 rgba(229, 83, 75, 0.6); animation: pulse 1.8s infinite;
}
.nav a[aria-current="page"].live-dot::before { background: var(--on-accent); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(229, 83, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 83, 75, 0); } }

/* ---- Buttons and badges ------------------------------------------------ */

.button {
  display: inline-flex; align-items: center; gap: 10px; border: 1px solid transparent; cursor: pointer;
  font: 700 1rem/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
  padding: 15px 24px; border-radius: 999px; transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 30px rgba(214, 168, 74, 0.25); }
.button-primary:hover { background: #e3b75a; color: var(--on-accent); }
.button-ghost { background: rgba(14, 23, 20, 0.6); color: var(--text); border-color: var(--line); }
.button-ghost:hover { color: var(--text); border-color: var(--accent); }
.store-badges { display: flex; flex-wrap: wrap; gap: 12px; }
.store-badge {
  display: inline-flex; align-items: center; gap: 12px; min-width: 190px; padding-block: 9px; padding-inline: 14px 18px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(8, 16, 13, 0.6); color: var(--text);
  cursor: default; user-select: none;
}
a.store-badge { cursor: pointer; text-decoration: none; transition: border-color 0.15s; }
a.store-badge:hover, a.store-badge:focus-visible { border-color: var(--accent); color: var(--text); }
.store-badge > span { display: flex; flex-direction: column; }
.store-badge svg { width: 30px; height: 30px; flex: none; fill: currentColor; }
.store-badge small { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; }
.store-badge strong { font-size: 1.15rem; letter-spacing: 0.02em; }

/* ---- Landing ----------------------------------------------------------- */

.hero { position: relative; min-height: min(88vh, 860px); display: grid; align-items: end; isolation: isolate; overflow: hidden; }
.hero-art { position: absolute; inset: 0; z-index: -2; }
.hero-art img { width: 100%; height: 100%; object-fit: cover; object-position: 60% 50%; transform: scale(1.04); animation: drift 24s ease-in-out infinite alternate; }
@keyframes drift { to { transform: scale(1.1) translateX(-1.5%); } }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 70% 30%, rgba(8, 16, 13, 0) 0%, rgba(8, 16, 13, 0.55) 60%, rgba(8, 16, 13, 0.95) 100%),
    linear-gradient(to top, var(--bg) 2%, rgba(8, 16, 13, 0.1) 45%, rgba(8, 16, 13, 0.55) 100%);
}
/* Right to left: the text sits on the right, over the rack, so the clear
   spot moves left and the right side is darkened. The art is not mirrored. */
[dir="rtl"] .hero::after {
  background:
    radial-gradient(120% 80% at 25% 30%, rgba(8, 16, 13, 0) 0%, rgba(8, 16, 13, 0.6) 55%, rgba(8, 16, 13, 0.95) 100%),
    linear-gradient(to top, var(--bg) 2%, rgba(8, 16, 13, 0.1) 45%, rgba(8, 16, 13, 0.55) 100%);
}
.hero .wrap { padding-block: 120px 72px; }
.hero h1 { font-size: clamp(3.2rem, 11vw, 8.6rem); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.12em; text-shadow: 0 4px 40px rgba(0, 0, 0, 0.5); }
.hero h1 .brass { color: var(--accent); }
.hero .lede { font-size: clamp(1.2rem, 2.4vw, 1.6rem); max-width: 36ch; color: #e7e1d1; margin-bottom: 1.6em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 28px; }
.hero-live { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; min-height: 1.5em; }
.hero-live[hidden] { display: none; }
.hero-live .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--foul); animation: pulse 1.8s infinite; }

.section { padding-block: clamp(64px, 10vw, 120px); }
.section-head { max-width: 760px; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
.section-head p { color: var(--muted); font-size: 1.2rem; }

.disciplines { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.discipline {
  position: relative; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line-soft);
  background: var(--panel); min-height: 230px; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 22px; isolation: isolate; transition: transform 0.25s ease, border-color 0.25s ease;
}
.discipline:hover { transform: translateY(-3px); border-color: var(--line); }
.discipline img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; opacity: 0.85; transition: transform 0.6s ease; }
.discipline:hover img { transform: scale(1.05); }
.discipline::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, rgba(8, 16, 13, 0.97) 18%, rgba(8, 16, 13, 0.2) 75%); }
.discipline h3 { font-size: 1.9rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.15em; }
.discipline p { margin: 0; color: var(--muted); }
.discipline .tag { position: absolute; top: 16px; inset-inline-start: 16px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.14em; padding: 4px 9px; border-radius: 999px; background: rgba(8, 16, 13, 0.75); color: var(--muted);
  border: 1px solid var(--line-soft); white-space: nowrap;
}
.tag-launch { color: var(--accent); border-color: rgba(214, 168, 74, 0.45); }
.tag-live { color: #fff; background: var(--foul); border-color: var(--foul); }
.tag-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.tag-demo { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.tag-ended { color: var(--muted); }

.promise { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.promise-card { padding: 26px; border-radius: var(--radius); background: linear-gradient(160deg, #13201b, var(--panel)); border: 1px solid var(--line-soft); }
.promise-card svg { width: 44px; height: 44px; margin-bottom: 16px; color: var(--accent); }
.promise-card h3 { font-size: 1.5rem; }
.promise-card p { color: var(--muted); margin: 0; }

.physics { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(28px, 5vw, 64px); align-items: center; }
.physics-table {
  position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 2 / 1.08;
  background: radial-gradient(circle at 50% 40%, #13241c, #070d0b 75%); border: 1px solid var(--line-soft);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.45);
}
.physics-table canvas { width: 100%; height: 100%; }
.physics-table .tag { position: absolute; top: 14px; inset-inline-start: 14px; }
.physics-table .caption { position: absolute; bottom: 12px; left: 16px; right: 16px; color: var(--muted); font-size: 0.85rem; text-shadow: 0 1px 6px #000; }
.physics ul { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 14px; }
.physics li { padding-inline-start: 28px; position: relative; color: var(--muted); }
.physics li strong { color: var(--text); font-weight: 600; }
.physics li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.5em; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #e8e2d0 40%, #9a958a); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--line-soft); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-soft); }
.fact { background: var(--panel); padding: 26px; }
.fact strong { display: block; font-size: 2.6rem; line-height: 1; color: var(--accent); margin-bottom: 6px; }
.fact span { color: var(--muted); }

.cta { text-align: center; padding-block: clamp(70px, 10vw, 130px); background: radial-gradient(60% 100% at 50% 0%, rgba(29, 107, 68, 0.35), transparent 70%); }
.cta h2 { font-size: clamp(2.4rem, 6vw, 4.4rem); text-transform: uppercase; }
.cta p { color: var(--muted); font-size: 1.2rem; max-width: 52ch; margin: 0 auto 28px; }
.cta .store-badges { justify-content: center; margin-top: 26px; }
.cta .hero-actions { justify-content: center; margin-bottom: 0; }

/* ---- Footer ------------------------------------------------------------ */

.site-footer { border-top: 1px solid var(--line-soft); padding-block: 36px 48px; color: var(--muted); font-size: 0.95rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 30px; align-items: center; justify-content: space-between; }
.site-footer nav { display: flex; gap: 22px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ---- Live page --------------------------------------------------------- */

.live-page { padding-block: 22px 60px; }
.live-top { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.live-top h1 { font-size: clamp(2rem, 4.5vw, 3rem); text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; padding: 8px 16px; min-width: 112px; }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; }
.feed-state {
  display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-soft); background: var(--panel);
}
.feed-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.feed-state[data-state="live"]::before { background: var(--foul); animation: blink 1.2s infinite; }
.feed-state[data-state="idle"]::before { background: var(--good); }
.feed-state[data-state="offline"]::before { background: var(--accent); }

.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.stage {
  position: relative; background: radial-gradient(120% 90% at 50% 30%, #13221b 0%, #0a120f 60%, #070c0a 100%);
  border: 1px solid var(--line-soft); border-radius: 18px; padding: 16px; box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
}
.stage:fullscreen { border-radius: 0; display: flex; flex-direction: column; justify-content: center; padding: 3vh 4vw; }
.scorebar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 12px; }
.player {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center;
  padding: 10px 14px; border-radius: 14px; background: var(--panel-glass); border: 1px solid var(--line-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease; min-width: 0;
}
.player.p1 { grid-template-columns: auto 1fr auto; direction: rtl; }
.player.p1 > * { direction: ltr; }
.player .avatar { grid-row: span 2; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; position: relative; }
.player.p0 .avatar { background: var(--p1); }
.player.p1 .avatar { background: var(--p2); }
.player .name { font-weight: 700; font-size: 1.2rem; white-space: nowrap; min-width: 0; display: flex; align-items: center; gap: 6px; }
.player .name-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.player.p1 .name { justify-content: flex-end; }
.player.p1 .name, .player.p1 .detail { text-align: right; }
.player .detail { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; grid-column: 2; min-width: 0; }
.player .score { grid-row: span 2; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.4ch; text-align: center; }
.player .group { grid-column: 2; height: 16px; width: 100%; }
.player.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 30px rgba(214, 168, 74, 0.18); }
.player.is-winner { border-color: var(--good); box-shadow: 0 0 0 1px var(--good), 0 0 30px rgba(79, 201, 138, 0.2); }
.clock {
  --clock: 0; position: absolute; inset: -4px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--clock) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
}
.clock.is-low { background: conic-gradient(var(--foul) calc(var(--clock) * 1turn), transparent 0); }
.center { text-align: center; min-width: 0; }
.center .disc { font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-size: 0.95rem; }
.center .games { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.center .state { font-weight: 600; font-size: 1.02rem; max-width: 28ch; margin-inline: auto; }

.table-wrap { position: relative; aspect-ratio: 2.05 / 1.13; width: 100%; }
.stage:fullscreen .table-wrap { max-height: 78vh; margin-inline: auto; width: auto; height: 78vh; }
.table-wrap canvas { width: 100%; height: 100%; }
.stage-banner {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 2; pointer-events: none;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; padding: 5px 12px; border-radius: 999px;
  background: rgba(8, 16, 13, 0.78); border: 1px solid var(--line-soft); color: var(--muted); white-space: nowrap; max-width: 92%;
  overflow: hidden; text-overflow: ellipsis;
}
.stage-banner[data-kind="live"] { color: #ffd9d6; border-color: rgba(229, 83, 75, 0.5); }
.stage-banner[data-kind="demo"] { color: var(--accent); border-color: rgba(214, 168, 74, 0.5); }
.replay-badge {
  display: none; position: absolute; right: 18px; top: 14px; z-index: 2; font-weight: 700; letter-spacing: 0.2em;
  color: var(--on-accent); background: var(--accent); padding: 4px 12px; border-radius: 6px; font-size: 0.85rem;
}
.is-replay .replay-badge { display: block; animation: blink 1s infinite; }
.is-replay .table-wrap canvas { filter: saturate(0.85) contrast(1.05); }
.loading {
  display: none; position: absolute; inset: 0; z-index: 3; place-items: center; text-align: center; color: var(--muted);
}
.is-loading .loading { display: grid; }
.loading .spinner { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #ddd6c4 45%, #8f8a7f); animation: roll 1.1s linear infinite; }
@keyframes roll { from { transform: translateX(-30px) rotate(0); } 50% { transform: translateX(30px) rotate(180deg); } to { transform: translateX(-30px) rotate(360deg); } }

.under-table { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-top: 10px; }
.rail { height: 30px; width: 100%; border-radius: 999px; background: linear-gradient(to bottom, #1d140d, #2c1e13); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6); }
.controls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.icon-button {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-soft); background: var(--surface);
  color: var(--text); font: 600 0.85rem/1 var(--font); letter-spacing: 0.06em; text-transform: uppercase; padding: 9px 12px;
  border-radius: 10px; cursor: pointer;
}
.icon-button:hover { border-color: var(--line); }
.icon-button svg { width: 16px; height: 16px; }
.icon-button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.commentary { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; min-height: 5.6em; }
.commentary li { color: var(--muted); font-size: 0.95rem; padding-inline-start: 16px; position: relative; }
.commentary li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.commentary li.is-new { color: var(--text); animation: slide 0.35s ease; }
.commentary li.is-good::before { background: var(--good); }
.commentary li.is-foul::before { background: var(--foul); }
.commentary li.is-win { color: var(--good); font-weight: 700; }
.commentary li.is-win::before { background: var(--accent); }
.commentary li.is-muted { color: var(--dim); }
@keyframes slide { from { opacity: 0; transform: translateY(-4px); } }

.lobby { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 18px; padding: 16px; }
.lobby h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 12px; }
.lobby-list { display: grid; gap: 10px; }
.match-card {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; width: 100%; text-align: start;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--text); border-radius: 12px; padding: 8px;
  font: inherit; cursor: pointer; transition: border-color 0.2s ease, transform 0.15s ease;
}
.match-card:hover { border-color: var(--line); transform: translateY(-1px); }
.match-card.is-selected { border-color: var(--accent); background: #1d2a23; }
.match-card.is-disabled { opacity: 0.55; cursor: not-allowed; }
.match-thumb { width: 112px; height: 62px; border-radius: 6px; background: #0b1410; }
.match-head { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.match-title { font-weight: 700; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-names { display: flex; flex-wrap: wrap; column-gap: 6px; align-items: baseline; font-weight: 600; min-width: 0; line-height: 1.25; }
.match-names span:not(.vs):not(.staff-badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-names .vs { color: var(--dim); font-size: 0.8rem; }
/* The staff badge (game-design.md): gold like the game's GM pill, after the name. */
.staff-badge { flex: none; align-self: center; display: inline-block; padding: 1px 6px; border-radius: 999px; background: #f2c94c; border: 1px solid #ffe7a0; color: #2a1c00; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; line-height: 1.3; }
.match-meta { color: var(--muted); font-size: 0.8rem; }
.match-body { min-width: 0; }
.bitexact { margin-top: 14px; font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; }
.bitexact::before { content: "✓"; color: var(--good); font-weight: 700; }
.bitexact[data-ok="false"]::before { content: "!"; color: var(--foul); }
.how { margin-top: 14px; font-size: 0.85rem; color: var(--muted); }
.how kbd { font: 600 0.75rem var(--font); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--text); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; display: flex; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 999px; padding: 8px; padding-inline-start: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.toast[hidden] { display: none; }
.toast .button { padding: 10px 16px; font-size: 0.85rem; }
body.is-tv .site-header, body.is-tv .site-footer, body.is-tv .live-top h1 { display: none; }

/* ---- Prose (privacy, terms, support, account deletion) --------------------------------------------------- */

.prose { max-width: 760px; padding-block: 48px 80px; }
.prose h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); text-transform: uppercase; }
.prose h2 { font-size: 1.5rem; margin-top: 1.8em; }
.prose p, .prose li { color: #d9d4c6; }
.prose ul, .prose ol { padding-inline-start: 1.2em; }
.prose ol li { margin-bottom: 0.4em; }
.prose h3 { font-size: 1.15rem; margin-top: 1.4em; margin-bottom: 0.4em; }
.draft-note {
  border: 1px dashed var(--accent); background: rgba(214, 168, 74, 0.08); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 32px;
}
.draft-note strong { color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; }
.todo { color: var(--accent); font-weight: 600; }

/* ---- Store cards (download page) ------------------------------------------ */

.store-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; margin-block: 28px 8px; }
.store-card {
  display: flex; align-items: center; gap: 18px; padding: 22px 24px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(160deg, #13201b, var(--panel)); color: var(--text); text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
.store-card:hover, .store-card:focus-visible { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.store-card svg { width: 46px; height: 46px; flex: none; fill: currentColor; }
.store-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.store-card small { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; }
.store-card strong { font-size: 1.6rem; line-height: 1.1; letter-spacing: 0.02em; }
.store-card-meta { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }

/* ---- Android download --------------------------------------------------- */

.download-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-block: 28px; }
.download-status { margin: 0 0 18px; }
.download-card-gap .download-status { margin: 0; }
.download-status.error { color: var(--foul); }
.download-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 22px; }
.download-facts dt { color: var(--muted); font-weight: 600; }
.download-facts dd { margin: 0; min-width: 0; }
.download-facts code { font-size: 0.8rem; overflow-wrap: anywhere; color: #d9d4c6; }

/* ---- Friend invite (/f/<code>) ------------------------------------------ */

.invite-card .download-status { margin: 0; color: var(--muted); font-weight: 600; }
.prose .invite-code { margin: 4px 0 14px; font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 700; letter-spacing: 0.08em; color: var(--accent); overflow-wrap: anywhere; }
.prose .invite-note { margin: 0; }
.invite-buttons { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- Play (the game's WebGL build) -------------------------------------- */

/* The game fills the window under the header; on a phone held sideways the header
   goes away so the table gets the whole screen. */
body.play-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.play-page .site-header { position: relative; flex: none; }
.play-full {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-inline-start: 4px;
  color: var(--muted); background: transparent; border: 1px solid var(--line-soft); border-radius: 999px; cursor: pointer;
}
.play-full[hidden] { display: none; }
.play-full:hover { color: var(--text); border-color: var(--line); }
.play-stage { position: relative; flex: 1; min-height: 0; background: var(--bg); }
.play-stage canvas { width: 100%; height: 100%; max-width: none; background: var(--bg); touch-action: none; outline: none; }
.play-cover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px; text-align: center;
  background: radial-gradient(ellipse at 50% 38%, #12382a 0%, var(--bg) 72%);
  transition: opacity 0.4s;
}
.play-cover.done { opacity: 0; pointer-events: none; }
.play-ball {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--accent);
  background: radial-gradient(circle at 36% 32%, #fff 0, #ece6d6 45%, #8f8a7f 100%);
}
.play-title { margin: 0; font-size: clamp(2rem, 6vw, 3.2rem); text-transform: uppercase; letter-spacing: 0.06em; }
.play-title .brass { color: var(--accent); }
.play-bar { width: min(340px, 72vw); height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.play-bar-fill { width: 0; height: 100%; background: var(--accent); transition: width 0.2s; }
.play-status { margin: 0; color: var(--muted); font-weight: 600; }
.play-status.error { color: var(--foul); max-width: 32em; }
.play-note { margin: 6px 0 0; max-width: 36em; color: var(--dim); font-size: 0.85rem; }
.play-rotate { display: none; }
@media (orientation: portrait) and (max-width: 760px) {
  .play-rotate {
    position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    background: rgba(8, 16, 13, 0.94); color: var(--text); font-weight: 600; text-align: center; padding: 16px;
  }
  .play-rotate svg { color: var(--accent); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .play-page .site-header { display: none; }
  .play-note { display: none; }
}

/* ---- Small screens ----------------------------------------------------- */

@media (max-width: 1020px) {
  .live-layout { grid-template-columns: 1fr; }
  .lobby-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (max-width: 860px) {
  .physics { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  .site-header .wrap { gap: 10px; }
  .brand span { display: none; }
  /* Five links fit from 360 px; narrower phones scroll the menu, never the page. */
  .nav { gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 7px 7px; font-size: 0.78rem; letter-spacing: 0.04em; white-space: nowrap; flex: none; }
  .nav .nav-home { display: none; }
  .stage { padding: 10px; border-radius: 14px; }
  .scorebar { grid-template-columns: 1fr 1fr; }
  .center { grid-column: 1 / -1; grid-row: 1; }
  .player { padding: 8px 10px; gap: 0 8px; }
  .player .avatar { width: 34px; height: 34px; font-size: 0.95rem; }
  .player .name { font-size: 1rem; }
  .player .score { font-size: 1.5rem; }
  .player .detail { font-size: 0.75rem; }
  .under-table { grid-template-columns: 1fr; }
  .controls { justify-content: flex-start; }
  .stat { min-width: 0; flex: 1; padding: 6px 10px; }
  .stat strong { font-size: 1.3rem; }
  .hero .wrap { padding-block: 100px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Languages -------------------------------------------------------------- */

/* The language menu in the header: a closed <details>, so the other scripts'
   fonts load only when it opens. */
.lang-menu { position: relative; flex: none; }
.lang-menu summary {
  list-style: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; cursor: pointer;
  color: var(--muted); border: 1px solid var(--line-soft); border-radius: 999px; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { color: var(--text); border-color: var(--line); }
.lang-menu summary svg { width: 18px; height: 18px; }
.lang-list {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 30; min-width: 220px; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.lang-list a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.lang-list a:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.lang-list a[aria-current="true"] { color: var(--on-accent); background: var(--accent); }
.lang-list a[dir="rtl"] { text-align: right; }

/* The suggestion bar (js/lang.js): the same page in the browser's language. */
.lang-suggest { background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 25; }
.lang-suggest .wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-block: 10px; }
.lang-suggest span { flex: 1 1 220px; }
.lang-suggest .button { padding: 9px 16px; font-size: 0.85rem; }
.lang-suggest-close {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-soft); background: transparent; color: var(--muted);
  font: 600 1.3rem/1 var(--font); cursor: pointer;
}
.lang-suggest-close:hover { color: var(--text); border-color: var(--line); }

/* The scoreboard keeps the table's left and right in every language; each text
   takes its own direction. */
.scorebar .name-text, .scorebar .detail, .center > div, .match-names, .match-meta { unicode-bidi: plaintext; }

/* The governing-language clause at the end of the legal pages. */
.prose .governing { margin-top: 2.4em; padding-top: 1em; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 0.9rem; }
