@import url(fonts.css);

/* ==========================================================================
   Zij: the rico.uz site system.
   Lapis night, brass instrument lines, ivory ink. Flat colour, no glow.
   ========================================================================== */

:root {
    --night: #0c1130;
    --night-2: #111846;
    --night-3: #19225a;
    --lapis: #26358a;
    --lapis-hi: #3447b0;

    --brass: #c9a24b;
    --brass-hi: #e3c277;
    --brass-lo: #8f7436;
    --line: rgb(201 162 75 / 0.26);
    --line-strong: rgb(201 162 75 / 0.62);

    --ivory: #f0e9d6;
    --mist: #b3b8d6;
    --mist-dim: #8f95bb;

    --turq: #4cc9b7;
    --alert: #ff9a8a;

    --font-display: 'Noto Serif Display', 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-ui: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --gutter: clamp(16px, 4vw, 48px);
    --measure: 66ch;

    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--night);
    color: var(--ivory);
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}

::selection { background: var(--brass); color: var(--night); }

/* Browser surfaces that normally ship unthemed */
html { scrollbar-color: var(--brass-lo) var(--night); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--night); }
::-webkit-scrollbar-thumb { background: var(--brass-lo); border: 2px solid var(--night); border-radius: 8px; }
input, textarea, button { caret-color: var(--brass-hi); accent-color: var(--brass); }
a { color: inherit; text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; border-radius: 2px; }
img, svg { display: block; max-width: 100%; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; text-wrap: balance; letter-spacing: -0.015em; }
p { text-wrap: pretty; }

.wrap { width: min(100% - 2 * var(--gutter), 1280px); margin-inline: auto; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Header: a graduated rule ---------- */

.masthead {
    position: sticky; top: 0; z-index: 40;
    background: rgb(12 17 48 / 0.94);
    border-bottom: 1px solid var(--line);
}
.masthead::after {
    /* graduation ticks along the rule */
    content: ''; position: absolute; left: 0; right: 0; bottom: -7px; height: 6px;
    background:
        repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 64px),
        repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 8px);
    background-size: 100% 6px, 100% 3px;
    background-repeat: no-repeat;
    background-position: 0 0, 0 0;
    pointer-events: none;
}
.masthead .wrap { display: flex; align-items: center; gap: 24px; height: 68px; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name {
    font-family: var(--font-display); font-size: 1.45rem; font-weight: 500; letter-spacing: 0.02em; line-height: 1;
}
.brand-name b { font-weight: 500; color: var(--brass-hi); }

.nav { display: flex; gap: 28px; margin-left: 28px; font-size: 0.9rem; font-weight: 500; }
.nav a { color: var(--mist); text-decoration: none; padding: 6px 0; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
.nav a:hover { color: var(--ivory); border-color: var(--brass); }

.masthead-end { margin-left: auto; display: flex; align-items: center; gap: 18px; white-space: nowrap; }

.lang { display: inline-flex; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; }
.lang a {
    padding: 6px 9px; color: var(--mist-dim); text-decoration: none; border: 1px solid transparent;
    transition: color .2s;
}
.lang a:hover { color: var(--ivory); }
.lang a[aria-current='true'] { color: var(--brass-hi); border-color: var(--line-strong); }

.link-quiet { color: var(--mist); font-size: 0.9rem; font-weight: 500; text-decoration: none; padding: 8px 4px; }
.link-quiet:hover { color: var(--ivory); text-decoration: underline; }

/* ---------- Buttons ---------- */

.btn {
    --bg: var(--brass); --fg: var(--night); --bd: var(--brass);
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 48px; padding: 0 26px;
    background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
    font: 600 0.95rem/1 var(--font-ui); letter-spacing: 0.01em; text-decoration: none; cursor: pointer;
    transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn:hover { --bg: var(--brass-hi); --bd: var(--brass-hi); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-line { --bg: transparent; --fg: var(--ivory); --bd: var(--line-strong); }
.btn-line:hover { --bg: rgb(201 162 75 / 0.12); --bd: var(--brass-hi); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 18px; font-size: 0.88rem; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Hero ---------- */

.hero { position: relative; padding: clamp(32px, 5vw, 72px) 0 clamp(48px, 7vw, 104px); }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.2fr); gap: clamp(24px, 4vw, 64px); align-items: center; }

.hero h1 { font-size: clamp(2.6rem, 6vw, 5.6rem); line-height: 1.0; letter-spacing: -0.025em; font-weight: 500; }
.hero h1 em { font-style: italic; color: var(--brass-hi); font-weight: 400; }
.hero-lede { margin-top: 28px; max-width: 46ch; color: var(--mist); font-size: clamp(1.02rem, 1.4vw, 1.2rem); line-height: 1.65; }
.hero-actions { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 12px; }
.hero-note { margin-top: 20px; font-size: 0.85rem; color: var(--mist-dim); max-width: 44ch; }

/* The instrument plate */
.plate { position: relative; margin-inline: auto; width: min(100%, 820px); }
.plate-svg { width: 100%; height: auto; overflow: visible; }
.plate-tabs { display: flex; gap: 4px; margin-bottom: 14px; justify-content: flex-start; }
.plate-tab {
    background: none; color: var(--mist-dim); border: 1px solid transparent; padding: 8px 14px;
    font: 600 0.82rem/1 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
    transition: color .2s, border-color .2s;
}
.plate-tab:hover { color: var(--ivory); }
.plate-tab[aria-selected='true'] { color: var(--brass-hi); border-color: var(--line-strong); }
.plate-cap { margin-top: 12px; display: flex; justify-content: space-between; gap: 16px; font-size: 0.82rem; color: var(--mist-dim); }
.plate-cap button {
    background: none; border: 0; padding: 0; color: var(--brass-hi); font: inherit; font-weight: 600; cursor: pointer;
    text-decoration: underline; text-underline-offset: 0.25em;
}

/* SVG board parts */
.sq-light { fill: #dcd3b8; }
.sq-dark { fill: #2a3b94; }
.sq-hit { fill: var(--turq); opacity: 0; }
.ring-tick { stroke: var(--line-strong); stroke-width: 1; }
.ring-tick.minor { stroke: var(--line); }
.ring-label { fill: var(--brass); font: 600 9px var(--font-ui); letter-spacing: .04em; text-anchor: middle; }
.coord { fill: var(--brass-hi); font: 600 11px var(--font-ui); text-anchor: middle; }
.frame-line { fill: none; stroke: var(--brass); stroke-width: 1.2; }
.path-line { fill: none; stroke: var(--turq); stroke-width: 2.5; stroke-dasharray: 5 6; stroke-linecap: round; opacity: 0; }

.man-w { fill: var(--ivory); stroke: var(--brass-lo); stroke-width: 1.5; }
.man-b { fill: #0a0e26; stroke: var(--brass); stroke-width: 1.6; }
.man-ring-w { fill: none; stroke: var(--brass-lo); stroke-width: 1; opacity: .8; }
.man-ring-b { fill: none; stroke: var(--brass); stroke-width: 1; opacity: .6; }
.pc-w { fill: var(--ivory); stroke: #0a0e26; stroke-width: 1.3; stroke-linejoin: round; }
.pc-b { fill: #0a0e26; stroke: var(--brass); stroke-width: 1.5; stroke-linejoin: round; }

/* ---------- Sections ---------- */

.section { padding: clamp(48px, 6.5vw, 96px) 0; border-top: 1px solid var(--line); position: relative; }
.section-head { max-width: 44rem; margin-bottom: clamp(32px, 5vw, 64px); }
.section-head h2 { font-size: clamp(1.9rem, 3.8vw, 3.2rem); line-height: 1.08; }
.section-head p { margin-top: 18px; color: var(--mist); max-width: 52ch; }

/* Two games: one ruled table, not two cards */
.games { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); }
.game { padding: clamp(24px, 3.4vw, 48px); display: flex; flex-direction: column; gap: 22px; }
.game + .game { border-left: 1px solid var(--line-strong); }
.game h3 { font-size: clamp(1.5rem, 2.4vw, 2.1rem); }
.game-lede { color: var(--mist); max-width: 42ch; }
.spec { margin: 0; display: grid; grid-template-columns: auto 1fr; border-top: 1px solid var(--line); }
.spec dt, .spec dd { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.spec dt { color: var(--mist-dim); padding-right: 24px; }
.spec dd { color: var(--ivory); text-align: right; }
.game-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; }

/* Zij tables */
.zij { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(24px, 4vw, 64px); }
.table-title { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; border-bottom: 1px solid var(--brass); }
.table-title h3 { font-size: 1.35rem; }
.table-title span { font-size: 0.78rem; color: var(--brass); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 48px 1fr auto; align-items: baseline; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.row-rank { font-family: var(--font-display); font-size: 1.5rem; color: var(--brass-hi); }
.row-name { font-weight: 500; overflow-wrap: anywhere; }
.row-val { font-family: var(--font-display); font-size: 1.35rem; text-align: right; }
.row-val small { font-family: var(--font-ui); font-size: 0.72rem; color: var(--mist-dim); letter-spacing: 0.08em; margin-left: 6px; }
.row-open .row-name { color: var(--mist-dim); font-weight: 400; }
.row-open .row-rank { color: var(--brass-lo); }
.row-open .row-val { color: var(--brass-lo); }
.zij-foot { margin-top: clamp(28px, 4vw, 48px); color: var(--mist-dim); font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 8px 28px; }
.zij-foot b { color: var(--ivory); font-weight: 600; }

/* Sync: two plates, one account */
.sync { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 96px); align-items: center; }
.sync-fig { width: 100%; height: auto; }
.sync-list { list-style: none; margin: 28px 0 0; padding: 0; border-top: 1px solid var(--line); }
.sync-list li { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; font-size: 0.95rem; }
.sync-list li span:last-child { color: var(--mist-dim); }
.sync-actions { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; }

/* Close */
.close { padding: clamp(72px, 10vw, 150px) 0; border-top: 1px solid var(--line); text-align: left; }
.close h2 { font-size: clamp(2.2rem, 5vw, 4.4rem); line-height: 1.04; max-width: 16ch; }
.close-actions { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 12px; }

/* Footer */
.foot { border-top: 1px solid var(--line); padding: 32px 0 40px; color: var(--mist-dim); font-size: 0.85rem; }
.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; align-items: center; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.foot a { color: var(--mist); text-decoration: none; }
.foot a:hover { color: var(--ivory); text-decoration: underline; }

/* ---------- Auth ---------- */

.auth { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); }
.auth-aside { position: relative; overflow: hidden; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: flex-end; padding: clamp(24px, 4vw, 64px); min-height: 280px; }
.auth-aside svg { position: absolute; inset: -34% -46% auto auto; width: 130%; max-width: 900px; opacity: .5; pointer-events: none; }
.auth-aside h2 { position: relative; font-size: clamp(2rem, 3.4vw, 3.2rem); line-height: 1.08; max-width: 14ch; }
.auth-aside p { position: relative; margin-top: 16px; color: var(--mist); max-width: 40ch; }
.auth-main { padding: clamp(28px, 4vw, 64px) clamp(20px, 4vw, 56px); display: flex; flex-direction: column; justify-content: center; gap: 28px; }
.auth-main h1 { font-size: clamp(1.8rem, 2.6vw, 2.4rem); }
.auth-main .sub { margin-top: 8px; color: var(--mist); }
.stack { display: grid; gap: 14px; }
.divider { display: flex; align-items: center; gap: 14px; color: var(--mist-dim); font-size: 0.8rem; letter-spacing: .08em; text-transform: uppercase; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.field { display: grid; gap: 8px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--mist); letter-spacing: .04em; }
.input {
    width: 100%; min-height: 48px; padding: 0 14px; background: var(--night-2); color: var(--ivory);
    border: 1px solid var(--line-strong); border-radius: 0; font: 400 1rem var(--font-ui);
    transition: border-color .2s, background .2s;
}
.input::placeholder { color: var(--mist-dim); opacity: 1; }
.input:hover { border-color: var(--brass); }
.input:focus { outline: none; border-color: var(--brass-hi); background: var(--night-3); box-shadow: 0 0 0 1px var(--brass-hi); }
.field-error { color: var(--alert); font-size: 0.85rem; }
.notice { padding: 12px 14px; border: 1px solid var(--line-strong); font-size: 0.9rem; }
.notice-err { border-color: var(--alert); color: var(--alert); }
.notice-ok { border-color: var(--turq); color: var(--turq); }
.check { display: flex; gap: 10px; align-items: center; color: var(--mist); font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.alt-line { color: var(--mist); font-size: 0.92rem; }
.alt-line a { color: var(--brass-hi); font-weight: 600; }

dialog.sheet {
    border: 1px solid var(--brass); background: var(--night-2); color: var(--ivory); padding: 28px; max-width: min(440px, calc(100vw - 32px));
}
dialog.sheet::backdrop { background: rgb(6 8 24 / 0.82); }
.sheet h3 { font-size: 1.4rem; }
.sheet p { margin-top: 10px; color: var(--mist); font-size: 0.95rem; }
.sheet .btn { margin-top: 20px; }
.waiting { margin-top: 18px; display: flex; gap: 10px; align-items: center; color: var(--turq); font-size: 0.9rem; }
.waiting i { width: 8px; height: 8px; background: var(--turq); display: block; animation: beat 1.4s var(--ease) infinite; }

/* ---------- Profile ---------- */

.profile { padding: clamp(32px, 5vw, 72px) 0 clamp(56px, 8vw, 112px); flex: 1; }
.profile-head { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; padding-bottom: 32px; border-bottom: 1px solid var(--brass); }
.avatar { width: 88px; height: 88px; border: 1px solid var(--brass); display: grid; place-items: center; overflow: hidden; background: var(--night-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar span { font-family: var(--font-display); font-size: 2.4rem; color: var(--brass-hi); }
.profile-head h1 { font-size: clamp(1.8rem, 3.4vw, 2.8rem); overflow-wrap: anywhere; }
.profile-head .mail { color: var(--mist-dim); font-size: 0.92rem; margin-top: 4px; }
.purse { display: grid; gap: 4px; text-align: right; }
.purse div { font-family: var(--font-display); font-size: 1.5rem; }
.purse small { font-family: var(--font-ui); font-size: 0.75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--mist-dim); margin-left: 8px; }
.ratings { display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--line-strong); }
.rating { padding: 32px 0 32px; }
.rating + .rating { border-left: 1px solid var(--line-strong); padding-left: clamp(20px, 4vw, 56px); }
.rating h2 { font-size: 0.82rem; font-family: var(--font-ui); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); }
.rating .big { font-family: var(--font-display); font-size: clamp(3rem, 6vw, 5rem); line-height: 1; margin-top: 12px; letter-spacing: -0.02em; }
.rating .rec { margin-top: 10px; color: var(--mist-dim); font-size: 0.9rem; }
.linkbox { padding: 32px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.linkbox h2 { font-size: 1.4rem; }
.linkbox p { color: var(--mist); margin-top: 8px; max-width: 54ch; font-size: 0.95rem; }
.linked { color: var(--turq); font-weight: 600; font-size: 0.92rem; }
.linkprompt { grid-column: 1 / -1; padding: 20px; border: 1px solid var(--line-strong); background: var(--night-2); display: none; gap: 16px; }
.linkprompt.open { display: grid; }
.play-row { display: grid; grid-template-columns: 1fr 1fr; }
.play-row a { padding: 32px 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; text-decoration: none; border-bottom: 1px solid var(--line); transition: padding .3s var(--ease), color .2s; }
.play-row a + a { border-left: 1px solid var(--line-strong); padding-left: clamp(20px, 4vw, 56px); }
.play-row a:hover { color: var(--brass-hi); }
.play-row h3 { font-size: 1.6rem; }
.play-row p { color: var(--mist-dim); font-size: 0.9rem; margin-top: 4px; }
.play-row svg { width: 28px; height: 28px; color: var(--brass); transition: transform .3s var(--ease); }
.play-row a:hover svg { transform: translateX(6px); }

/* ---------- Motion ---------- */

@keyframes beat { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.reveal { animation: rise .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { animation: none; }
    .waiting i { animation: none; opacity: 1; }
    * { transition-duration: 0.01ms !important; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
    .hero .wrap { grid-template-columns: 1fr; }
    .plate { order: 2; }
    .games, .zij, .sync { grid-template-columns: 1fr; }
    .game + .game { border-left: 0; border-top: 1px solid var(--line-strong); }
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .nav { display: none; }
}

@media (max-width: 640px) {
    .masthead .wrap { height: 60px; gap: 12px; }
    .brand-name { font-size: 1.25rem; }
    .brand-mark { width: 28px; height: 28px; }
    .masthead-end { gap: 8px; }
    .masthead-end .link-quiet { display: none; }
    .lang a { padding: 6px 6px; }
    .profile-head { grid-template-columns: auto 1fr; }
    .purse { grid-column: 1 / -1; text-align: left; display: flex; gap: 24px; }
    .ratings, .play-row { grid-template-columns: 1fr; }
    .rating + .rating, .play-row a + a { border-left: 0; padding-left: 0; border-top: 1px solid var(--line-strong); }
    .linkbox { grid-template-columns: 1fr; }
    .btn { min-height: 52px; }
    .hero-actions .btn { flex: 1 1 100%; }
    .spec dd { text-align: left; }
    .spec { grid-template-columns: 1fr; }
    .spec dt { padding-bottom: 0; border-bottom: 0; }
}

svg [hidden] { display: none; }

@media (max-width: 640px) {
    .masthead-end .btn { display: none; }
    .masthead-end form .btn { display: inline-flex; }
}

/* ---------- Review pass ---------- */

/* Darker lapis squares so the brass leads */
.sq-dark { fill: #1f2b78; }
.sq-light { fill: #d6cdb1; }

/* The eight files: one unbroken rule */
.rank { display: grid; grid-template-columns: repeat(8, 1fr); border: 1px solid var(--line-strong); height: 40px; margin-top: clamp(8px, 2vw, 24px); }
.rank span {
    display: flex; align-items: flex-end; justify-content: flex-start; padding: 0 0 5px 8px;
    font: 600 0.72rem/1 var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--brass);
    border-left: 1px solid var(--line); position: relative; transition: background .4s var(--ease), color .4s var(--ease);
}
.rank span:first-child { border-left: 0; }
.rank span::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 25%); }
.rank span.on { background: var(--turq); color: var(--night); }

/* Section arcs continue the instrument */
.has-arc { overflow: hidden; }
.has-arc > .wrap { position: relative; }
.arc-bleed { position: absolute; top: -14%; right: -22%; width: min(780px, 70vw); aspect-ratio: 1; opacity: .38; pointer-events: none; }
.arc-bleed svg { width: 100%; height: 100%; }

/* Zij rows get a graduated rule */
.table-title { position: relative; }
.table-title::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -7px; height: 6px;
    background: repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 32px);
}
.rows { padding-top: 8px; }

/* Sync: two ruled plates and a joining mark */
.sync-fig { display: grid; grid-template-columns: 1fr 56px 1fr; align-items: stretch; }
.sync-plate { border: 1px solid var(--brass); background: var(--night-2); }
.sync-plate h3 { font-family: var(--font-ui); font-size: 0.8rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--mist); padding: 14px 18px; border-bottom: 1px solid var(--line-strong); }
.sync-plate ul { list-style: none; margin: 0; padding: 0; }
.sync-plate li { padding: 18px; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.sync-plate li:last-child { border-bottom: 0; }
.sync-join { align-self: center; justify-self: center; width: 28px; height: 28px; border: 1px solid var(--brass-hi); transform: rotate(45deg); position: relative; }
.sync-join::before { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; background: var(--brass-hi); }

/* Profile: ratings without the metric template */
.rating h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ivory); }
.rating h2 span { color: var(--brass); font-family: var(--font-ui); font-size: .78rem; font-weight: 600; letter-spacing: .12em; margin-left: 10px; text-transform: uppercase; }
.rating .big { font-size: clamp(2.6rem, 5vw, 4rem); margin-top: 6px; }

/* Checkbox in the system */
.check input {
    appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 0; flex: none; cursor: pointer;
    background: var(--night-2); border: 1px solid var(--line-strong); display: grid; place-content: center;
}
.check input:hover { border-color: var(--brass); }
.check input::after { content: ''; width: 10px; height: 10px; background: var(--brass-hi); transform: scale(0); transition: transform .15s var(--ease); }
.check input:checked::after { transform: scale(1); }

/* Hero plate: bleed on desktop, crop the ring on phones */
@media (min-width: 1001px) {
    .plate { width: min(100%, 900px); margin-right: calc(-1 * var(--gutter)); margin-left: auto; }
}
@media (max-width: 640px) {
    .plate-svgwrap { overflow: hidden; }
    .plate-svg { width: 150%; max-width: none; margin-left: -25%; }
    .masthead-end .link-quiet { display: inline-flex; }
    .masthead-end .btn { display: none; }
    .masthead-end form .btn { display: inline-flex; }
    .sync-fig { grid-template-columns: 1fr; gap: 12px; }
    .sync-join { margin: 4px 0; }
    .rank span { font-size: .68rem; padding-left: 5px; }
}
.hero .wrap.rank-wrap { display: block; }


/* ---------- Public pages: ratings, tournaments, puzzles, rules ---------- */

.page-title { font-size: clamp(2.2rem, 4.6vw, 3.8rem); line-height: 1.05; }
.page-top { border-top: 0; }
.nav a[aria-current='page'] { color: var(--ivory); border-color: var(--brass); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.tabs a {
    padding: 10px 18px; color: var(--mist); text-decoration: none; font-weight: 600; font-size: 0.9rem;
    border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ivory); }
.tabs a[aria-current='true'] { color: var(--brass-hi); border-color: var(--line-strong); background: var(--night-2); }

.data-head, .data-row {
    display: grid; grid-template-columns: 48px minmax(0, 1fr) 72px 72px 88px; gap: 12px; align-items: baseline;
}
.data-head { padding: 12px 0; color: var(--mist-dim); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; border-bottom: 1px solid var(--line); }
.data-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.data-head .num, .data-row .num { text-align: right; color: var(--mist); font-variant-numeric: tabular-nums; }
.data-row .row-val small { color: var(--mist-dim); }
@media (max-width: 640px) {
    .data-head, .data-row { grid-template-columns: 40px minmax(0, 1fr) 56px 72px; }
    .hide-sm { display: none; }
}

.tourney {
    display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: clamp(16px, 3vw, 40px); align-items: center;
    padding: 24px 0; border-top: 1px solid var(--line);
}
.tourney:last-of-type { border-bottom: 1px solid var(--line); }
.tourney h2 { font-size: 1.4rem; }
.tourney-meta { color: var(--mist-dim); font-size: 0.9rem; margin-top: 6px; }
.tourney-meta b { color: var(--ivory); font-weight: 600; }
.tourney-prizes dt, .tourney-prizes dd { padding: 7px 0; font-size: 0.88rem; }
.tourney-end { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.chip-status { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 5px 10px; border: 1px solid var(--line-strong); color: var(--mist); }
.chip-registration { color: var(--turquoise); border-color: var(--turquoise); }
.chip-in_progress { color: var(--brass-hi); border-color: var(--brass); }
.empty-note { color: var(--mist); margin-bottom: 24px; }
@media (max-width: 760px) {
    .tourney { grid-template-columns: 1fr; }
    .tourney-end { flex-direction: row; align-items: center; justify-content: space-between; }
}

.rules ul { margin: 0; padding-left: 1.1em; display: grid; gap: 12px; color: var(--mist); }
.rules li::marker { color: var(--brass); }

@media (max-width: 860px) {
    .masthead .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 10px 16px; }
    .nav { order: 3; width: 100%; margin-left: 0; gap: 18px; overflow-x: auto; }
}
@media (max-width: 760px) {
    .tourney-prizes { display: grid; grid-template-columns: 2rem 1fr; }
    .tourney-prizes dd { text-align: left; }
}

/* Legal pages */
.legal { max-width: 72ch; }
.legal h2 { font-family: var(--serif, 'Noto Serif Display', Georgia, serif); font-weight: 500; font-size: 1.35rem; margin: 2rem 0 .6rem; }
.legal p, .legal li { color: var(--mist, #b3b8d6); line-height: 1.7; }
.legal ul { padding-left: 1.2rem; display: grid; gap: .4rem; }
.legal-date { color: var(--mist-dim, #8f95bb); font-size: .9rem; margin-bottom: 1rem; }


/* ---------- Landing motion ----------
   One authored moment: the plate arrives like an instrument being engraved, then
   hands the first move to the visitor. Everything else is feedback or state.
   Content is visible by default; hidden "from" states exist only when scripts run
   (html.js) or inside the keyframes themselves. */

/* Headline: each word rises out from behind a ruled edge */
.hero h1 .w { display: inline-block; vertical-align: top; clip-path: inset(-0.06em -0.3em -0.14em -0.3em); }
.hero h1 .w > span { display: inline-block; animation: word-up 1s var(--ease) backwards; animation-delay: calc(var(--w) * 85ms + 60ms); }
@keyframes word-up { from { transform: translateY(112%); } }
.hero .reveal { animation-delay: calc(520ms + var(--i, 0) * 110ms); }

/* Plate arrival: ring, then board wave, then pieces, then the controls */
.js .plate:not(.in) .intro { opacity: 0; animation: intro-failsafe .01s 5s forwards; }
.plate.in .intro { animation: engrave .6s var(--ease) backwards; animation-delay: var(--t, 0ms); }
@keyframes engrave { from { opacity: 0; } }
@keyframes intro-failsafe { to { opacity: 1; } }

/* The visitor's turn */
.plate-svg.live { cursor: pointer; }
.mover { outline: none; }
.mover .hint-ring { fill: none; stroke: var(--turq); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; pointer-events: none; }
.mover.ready .hint-ring { opacity: .9; animation: ping 1.8s var(--ease) infinite; }
.mover.sel .hint-ring { opacity: 1; animation: none; transform: scale(1.25); }
.mover:focus-visible .hint-ring { stroke: var(--brass-hi); stroke-width: 3; opacity: 1; animation: none; transform: scale(1.3); }
@keyframes ping { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }

.hit { outline: none; cursor: pointer; animation: hit-in .25s var(--ease) backwards; }
.hit .sq-hit { fill: var(--turq); fill-opacity: .3; stroke: var(--turq); stroke-width: 2; stroke-opacity: .9; opacity: 1; }
.hit .hit-mark { fill: var(--turq); pointer-events: none; }
.hit:focus-visible .sq-hit { stroke: var(--brass-hi); stroke-width: 4; fill-opacity: .45; }
@keyframes hit-in { from { opacity: 0; } }

.burst { fill: none; stroke: var(--brass-hi); stroke-width: 2.5; transform-box: fill-box; transform-origin: center; pointer-events: none; }
.mate-frame { fill: none; stroke: var(--brass-hi); stroke-width: 3; pointer-events: none; animation: hit-in .4s var(--ease) backwards; }

.plate-cap > span:first-child { min-height: 3.2em; }
.plate-cap-actions { display: flex; gap: 18px; flex-shrink: 0; align-items: baseline; }
.plate-cap-actions a { color: var(--brass-hi); font-weight: 600; text-decoration: underline; text-underline-offset: .25em; }
.plate-cap-actions a[hidden] { display: none; }

/* Sync: a live signal passes between the two plates, only while they are on screen */
.sync-fig { position: relative; --bx: 72px; --by: 0px; }
.sync-beam { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; background: var(--turq); opacity: 0; pointer-events: none; }
.sync-fig.live .sync-beam { animation: beam 3.6s var(--ease) infinite; }
@keyframes beam {
    0% { transform: translate(calc(var(--bx) * -1), calc(var(--by) * -1)); opacity: 0; }
    6% { opacity: 1; }
    44% { transform: translate(var(--bx), var(--by)); opacity: 1; }
    50% { transform: translate(var(--bx), var(--by)); opacity: 0; }
    56% { transform: translate(var(--bx), var(--by)); opacity: 1; }
    94% { transform: translate(calc(var(--bx) * -1), calc(var(--by) * -1)); opacity: 1; }
    100% { transform: translate(calc(var(--bx) * -1), calc(var(--by) * -1)); opacity: 0; }
}
@media (max-width: 1000px) { .sync-fig { --bx: 0px; --by: 46px; } }

/* Rows answer the pointer */
.row { transition: background .2s var(--ease); }
.row:hover { background: rgb(201 162 75 / 0.07); }
.game { transition: background .3s var(--ease); }

/* Scroll-linked, where the browser can do it without scripts: the ruled table is drawn
   as it arrives and the instrument arcs turn slowly with the page. Elsewhere it is simply static. */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .table-title { border-bottom-color: transparent; }
        .table-title::before {
            content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--brass);
            transform-origin: left; animation: rule-draw linear both; animation-timeline: view(); animation-range: entry 10% entry 90%;
        }
        .rows .row { animation: row-in linear both; animation-timeline: view(); animation-range: entry 5% entry 80%; }
        .arc-bleed svg { will-change: transform; animation: arc-turn linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }
    }
}
@keyframes rule-draw { from { transform: scaleX(0); } }
@keyframes row-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes arc-turn { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }

@media (prefers-reduced-motion: reduce) {
    .hero h1 .w > span { animation: none; }
    .js .plate:not(.in) .intro, .plate .intro { opacity: 1 !important; animation: none !important; }
    .mover.ready .hint-ring { animation: none; opacity: .9; transform: scale(1.3); }
    .hit, .mate-frame { animation: none; }
    .sync-fig.live .sync-beam { animation: none; }
}

/* Global chat button + popup (site pages) */
.rc-fab { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #0a3a52; border: 1px solid #c9a24b; color: #e3c277; box-shadow: 0 6px 18px rgb(0 0 0 / .45); cursor: pointer; }
.rc-fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; }
.rc-chat { position: fixed; right: 16px; bottom: 80px; z-index: 60; width: min(360px, calc(100vw - 32px)); height: min(70vh, 520px); display: none; flex-direction: column; background: #051f30; border: 1px solid #c9a24b; border-radius: 16px; box-shadow: 0 12px 36px rgb(0 0 0 / .55); overflow: hidden; color: #f4ecd8; font-size: .85rem; }
.rc-chat.open { display: flex; }
.rc-chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid rgb(201 162 75 / .3); font-weight: 600; color: #e3c277; }
.rc-chat-head button { background: none; border: 0; color: inherit; font-size: 1.2rem; cursor: pointer; }
.rc-chat-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.rc-msg { max-width: 88%; padding: 6px 10px; border-radius: 12px; background: #0c2a3e; border: 1px solid rgb(201 162 75 / .15); word-break: break-word; }
.rc-msg.mine { align-self: flex-end; background: rgb(201 162 75 / .18); }
.rc-msg b { display: block; font-size: .72rem; color: #e3c277; }
.rc-chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgb(201 162 75 / .3); }
.rc-chat-form input { flex: 1; min-width: 0; background: #0c2a3e; border: 1px solid rgb(201 162 75 / .35); border-radius: 10px; padding: 8px 10px; color: inherit; }
.rc-chat-form button { background: #e3c277; color: #051f30; border: 0; border-radius: 10px; padding: 0 14px; font-weight: 700; cursor: pointer; }
.rc-chat-note { padding: 10px 14px; font-size: .75rem; color: #b9c9d3; border-top: 1px solid rgb(201 162 75 / .3); text-align: center; }
.rc-chat-form[hidden], .rc-chat-note[hidden] { display: none; }
.rc-stk-btn { background: transparent !important; font-size: 18px; padding: 0 6px !important; }
.rc-stk-host:empty { display: none; }
.rc-stk-host { padding: 0 10px; }
.rc-msg .chat-sticker { max-width: 120px; max-height: 120px; }
