/* =========================================================
   Гамбит — chess club
   Plain CSS, no build step.
   ========================================================= */

:root {
    --bg: #0b110d;
    --bg-deep: #070b08;
    --surface: #111a14;
    --surface-2: #17221b;
    --surface-3: #1d2b22;
    --cream: #f1ead9;
    --cream-dim: #d9d2c2;
    --muted: #a2a99a;
    --muted-2: #7f897d;
    --brass: #d8b26c;
    --brass-strong: #edce92;
    --brass-soft: rgba(216, 178, 108, 0.14);
    --sage: #8fa993;
    --line: rgba(241, 234, 217, 0.12);
    --line-strong: rgba(241, 234, 217, 0.22);
    --danger: #e08b7c;
    --danger-soft: rgba(224, 139, 124, 0.12);
    --success: #9ec4a4;
    --success-soft: rgba(158, 196, 164, 0.12);
    --board-light: #ece2cc;
    --board-dark: #718c76;
    --font-ui: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --font-display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.24);
    --shell: 1200px;
    --header-h: 74px;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 1000px 600px at 75% -10%, rgba(74, 108, 82, 0.18), transparent 65%),
        radial-gradient(ellipse 800px 500px at -10% 35%, rgba(216, 178, 108, 0.06), transparent 70%),
        var(--bg);
    color: var(--cream);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.45;
    background-image:
        linear-gradient(rgba(241, 234, 217, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(241, 234, 217, 0.018) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 20%, transparent 80%);
}

img,
svg {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -0.015em;
    color: var(--cream);
}

p {
    color: var(--cream-dim);
}

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

::selection {
    background: rgba(216, 178, 108, 0.32);
    color: #fff8e8;
}

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--brass);
    color: #181208;
    transform: translateY(-160%);
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.icon {
    flex: none;
}

.shell {
    width: min(var(--shell), 100%);
    margin-inline: auto;
    padding-inline: clamp(18px, 4vw, 32px);
}

.site-main {
    min-height: 60vh;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 14, 10, 0.84);
    backdrop-filter: blur(18px) saturate(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.1);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 32px;
    min-height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    flex: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(216, 178, 108, 0.45);
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(216, 178, 108, 0.2), transparent 65%),
        var(--surface);
    color: var(--brass-strong);
    font-family: var(--font-display);
    font-size: 29px;
    line-height: 1;
    padding-bottom: 2px;
    box-shadow: inset 0 0 0 4px rgba(216, 178, 108, 0.04);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-text strong {
    font-family: var(--font-display);
    font-size: 23px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand-text small {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-top: 2px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.main-nav a {
    padding: 8px 13px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 14px;
    transition: color 0.18s ease, background 0.18s ease;
}

.main-nav a:hover {
    color: var(--cream);
    background: rgba(241, 234, 217, 0.05);
}

.main-nav a.is-active {
    color: var(--cream);
    background: rgba(216, 178, 108, 0.1);
}

.header-account {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(241, 234, 217, 0.03);
    transition: border-color 0.18s ease, background 0.18s ease;
}

.account-chip:hover {
    border-color: var(--line-strong);
    background: rgba(241, 234, 217, 0.06);
}

.account-chip img,
.account-chip .avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    background: var(--surface-3);
}

.avatar-initials {
    display: grid;
    place-items: center;
    color: var(--brass-strong);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
}

.account-name {
    max-width: 130px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    color: var(--cream-dim);
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--cream);
    align-items: center;
    justify-content: center;
}

.mobile-menu {
    display: none;
    border-top: 1px solid var(--line);
    background: var(--bg-deep);
}

.mobile-menu.is-open {
    display: block;
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    padding: 12px clamp(18px, 4vw, 32px) 22px;
}

.mobile-nav a,
.mobile-nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 4px;
    border: 0;
    border-bottom: 1px solid rgba(241, 234, 217, 0.07);
    background: none;
    color: var(--cream-dim);
    font-size: 15px;
    text-align: left;
}

.mobile-nav form {
    margin: 0;
}

.mobile-nav .mobile-login {
    margin-top: 10px;
    justify-content: center;
    padding: 13px 18px;
    border: 0;
    border-radius: 999px;
    background: #d92e0d;
    color: #fff;
    font-weight: 600;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--cream);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brass-strong), var(--brass));
    color: #191307;
    box-shadow: 0 10px 30px rgba(216, 178, 108, 0.2);
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #f5dba7, var(--brass-strong));
    box-shadow: 0 14px 38px rgba(216, 178, 108, 0.27);
}

.btn-outline {
    border-color: var(--line-strong);
    color: var(--cream);
    background: rgba(241, 234, 217, 0.02);
}

.btn-outline:hover {
    border-color: rgba(216, 178, 108, 0.5);
    background: var(--brass-soft);
}

.btn-ghost {
    color: var(--muted);
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--cream);
    background: rgba(241, 234, 217, 0.05);
}

.btn-danger {
    border-color: rgba(224, 139, 124, 0.35);
    background: var(--danger-soft);
    color: #f0b1a4;
}

.btn-danger:hover {
    background: rgba(224, 139, 124, 0.2);
}

.btn-yandex {
    background: #d92e0d;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(217, 46, 13, 0.2);
}

.btn-yandex:hover {
    background: #c4280b;
}

.ya-mark {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    color: #fc3f1f;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.btn-sm {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 13px;
}

.btn-lg {
    min-height: 54px;
    padding: 15px 26px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
}

/* ---------- Typography helpers ---------- */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--brass);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 22px;
    height: 1px;
    background: var(--brass);
    opacity: 0.7;
}

.display {
    font-size: clamp(2.4rem, 5.4vw, 4.7rem);
    line-height: 0.98;
    letter-spacing: -0.03em;
}

.display em,
.hero h1 em {
    color: var(--brass-strong);
    font-style: italic;
    font-weight: 500;
}

.lead {
    max-width: 58ch;
    color: var(--muted);
    font-size: clamp(15px, 1.5vw, 17px);
    line-height: 1.7;
}

.section {
    padding-block: clamp(56px, 8vw, 96px);
}

.section-sm {
    padding-block: clamp(36px, 5vw, 60px);
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: clamp(26px, 4vw, 42px);
}

.section-head h2 {
    margin-top: 10px;
    font-size: clamp(2rem, 3.6vw, 3.2rem);
}

.section-head p {
    max-width: 44ch;
    color: var(--muted);
    font-size: 14px;
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--brass);
    font-size: 14px;
    font-weight: 500;
}

.text-link:hover {
    color: var(--brass-strong);
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 13px;
}

.mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ---------- Flash / toast ---------- */

.flash-wrap {
    width: min(var(--shell), 100%);
    margin: 18px auto -2px;
    padding-inline: clamp(18px, 4vw, 32px);
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    box-shadow: var(--shadow-soft);
    font-size: 14px;
}

.flash > .icon {
    margin-top: 2px;
}

.flash ul {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.flash ul li + li {
    margin-top: 2px;
}

.flash-success {
    border-color: rgba(158, 196, 164, 0.35);
    background: linear-gradient(180deg, rgba(158, 196, 164, 0.1), var(--surface-2));
}

.flash-success > .icon {
    color: var(--success);
}

.flash-error {
    border-color: rgba(224, 139, 124, 0.35);
    background: linear-gradient(180deg, rgba(224, 139, 124, 0.1), var(--surface-2));
}

.flash-error > .icon {
    color: var(--danger);
}

.flash-close {
    margin-left: auto;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
}

.flash-close:hover {
    color: var(--cream);
}

.toast-region {
    position: fixed;
    top: calc(var(--header-h) + 14px + env(safe-area-inset-top));
    right: calc(18px + env(safe-area-inset-right));
    bottom: auto;
    z-index: 180;
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: min(360px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    padding: 12px 15px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: rgba(24, 36, 28, 0.96);
    box-shadow: var(--shadow);
    color: var(--cream);
    font-size: 13px;
    pointer-events: auto;
    animation: toast-in 0.25s ease;
}

.toast.is-error {
    border-color: rgba(224, 139, 124, 0.45);
    color: #f2bdb2;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.noscript {
    position: fixed;
    inset: auto 16px 16px;
    z-index: 300;
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--cream);
    color: #241d10;
    text-align: center;
}

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

.hero {
    position: relative;
    padding-block: clamp(54px, 8vw, 100px) clamp(48px, 7vw, 88px);
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 600px 500px at 85% 20%, rgba(216, 178, 108, 0.08), transparent 70%),
        linear-gradient(90deg, transparent 49.9%, rgba(241, 234, 217, 0.04) 50%, transparent 50.1%);
    mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
}

.hero-grid {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.78fr);
    align-items: center;
    gap: clamp(36px, 6vw, 76px);
}

.hero-copy h1 {
    margin: 20px 0 22px;
    font-size: clamp(3.5rem, 8vw, 7.3rem);
    font-weight: 500;
    line-height: 0.86;
    letter-spacing: -0.045em;
}

.hero-copy .lead {
    max-width: 52ch;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 11px;
    margin-top: 30px;
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 24px 38px;
    margin-top: 38px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.hero-stat strong {
    display: block;
    font-family: var(--font-display);
    font-size: 30px;
    line-height: 1;
    color: var(--cream);
}

.hero-stat span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hero-visual {
    position: relative;
    min-height: 480px;
}

.hero-poster {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 28px;
    border: 1px solid rgba(216, 178, 108, 0.3);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at 75% 20%, rgba(216, 178, 108, 0.13), transparent 50%),
        linear-gradient(155deg, #1a2820 0%, #0f1812 55%, #0b120d 100%);
    box-shadow: var(--shadow);
    isolation: isolate;
}

.hero-poster::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.38;
    background-image:
        linear-gradient(45deg, rgba(241, 234, 217, 0.06) 25%, transparent 25%, transparent 75%, rgba(241, 234, 217, 0.06) 75%),
        linear-gradient(45deg, rgba(241, 234, 217, 0.06) 25%, transparent 25%, transparent 75%, rgba(241, 234, 217, 0.06) 75%);
    background-position: 0 0, 48px 48px;
    background-size: 96px 96px;
    mask-image: radial-gradient(circle at 50% 45%, #000, transparent 78%);
}

.hero-poster::after {
    content: "";
    position: absolute;
    inset: 16px;
    z-index: -1;
    border: 1px solid rgba(216, 178, 108, 0.12);
    border-radius: 22px;
    pointer-events: none;
}

.poster-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.poster-num {
    color: var(--brass);
}

.poster-knight {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: clamp(220px, 26vw, 330px);
    line-height: 1;
    color: var(--cream);
    text-shadow:
        0 2px 0 rgba(0, 0, 0, 0.25),
        0 30px 80px rgba(0, 0, 0, 0.45);
    transform: translateY(8px);
    user-select: none;
}

.poster-knight::after {
    content: "";
    position: absolute;
    width: 58%;
    height: 58%;
    border: 1px solid rgba(216, 178, 108, 0.24);
    border-radius: 50%;
    z-index: -1;
}

.poster-bottom {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.poster-bottom h2 {
    max-width: 8ch;
    font-size: 31px;
    line-height: 1;
}

.poster-bottom h2 span {
    color: var(--brass);
    font-style: italic;
}

.poster-seal {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border: 1px solid rgba(216, 178, 108, 0.4);
    border-radius: 50%;
    color: var(--brass);
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.poster-chip {
    position: absolute;
    right: 18px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(17, 26, 20, 0.9);
    backdrop-filter: blur(10px);
    color: var(--cream);
    font-size: 12px;
    box-shadow: var(--shadow-soft);
}

.poster-chip .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brass);
    box-shadow: 0 0 12px rgba(216, 178, 108, 0.7);
}

.poster-chip--top {
    top: 74px;
}

.poster-chip--bottom {
    top: 52%;
    bottom: auto;
    right: auto;
    left: 18px;
    transform: translateY(-50%);
}

/* ---------- Cards / grids ---------- */

.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.mode-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(165deg, rgba(241, 234, 217, 0.035), transparent 45%), var(--surface);
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.mode-card:hover {
    border-color: rgba(216, 178, 108, 0.36);
    transform: translateY(-3px);
}

.mode-card::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    right: -70px;
    top: -70px;
    border: 1px solid rgba(241, 234, 217, 0.07);
    border-radius: 50%;
    pointer-events: none;
}

.mode-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    margin-bottom: 26px;
    border: 1px solid rgba(216, 178, 108, 0.3);
    border-radius: 50%;
    background: var(--brass-soft);
    color: var(--brass-strong);
}

.mode-card h3 {
    margin-bottom: 10px;
    font-size: 29px;
}

.mode-card p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.mode-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

.mode-meta span {
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted-2);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.mode-card .text-link {
    margin-top: auto;
    padding-top: 24px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.panel-pad {
    padding: clamp(20px, 3vw, 30px);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.panel-head h2,
.panel-head h3 {
    font-size: 26px;
}

.panel-head p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.surface {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted-2);
}

.status-badge.is-live,
.status-badge.is-running {
    border-color: rgba(158, 196, 164, 0.3);
    color: #b9d9bd;
    background: rgba(158, 196, 164, 0.07);
}

.status-badge.is-live::before,
.status-badge.is-running::before {
    background: var(--success);
    box-shadow: 0 0 9px rgba(158, 196, 164, 0.8);
    animation: pulse 2s infinite;
}

.status-badge.is-registration {
    border-color: rgba(216, 178, 108, 0.3);
    color: var(--brass-strong);
    background: var(--brass-soft);
}

.status-badge.is-registration::before {
    background: var(--brass);
}

.status-badge.is-waiting {
    border-color: rgba(216, 178, 108, 0.24);
    color: var(--brass);
}

.status-badge.is-waiting::before {
    background: var(--brass);
    animation: pulse 2s infinite;
}

.status-badge.is-finished {
    color: var(--muted-2);
}

.status-badge.is-aborted {
    border-color: rgba(224, 139, 124, 0.3);
    color: #d8a197;
}

.status-badge.is-aborted::before {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.dot-sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--muted-2);
    flex: none;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    color: var(--muted);
    font-size: 12px;
}

.meta-row .icon {
    color: var(--muted-2);
}

/* ---------- Bot levels ---------- */

.level-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.level-pill {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(241, 234, 217, 0.02);
}

.level-pill .level-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.level-pill strong {
    font-size: 14px;
}

.level-pill span {
    color: var(--muted-2);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.level-bars {
    display: flex;
    gap: 3px;
    margin-top: 12px;
}

.level-bars i {
    height: 3px;
    flex: 1;
    border-radius: 99px;
    background: rgba(241, 234, 217, 0.1);
}

.level-bars i.is-on {
    background: var(--brass);
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.level-grid .level-choice:last-child {
    grid-column: span 2;
}

.level-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 178px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(241, 234, 217, 0.02);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.level-choice:hover {
    border-color: rgba(216, 178, 108, 0.35);
    transform: translateY(-2px);
}

.level-choice:has(input:checked) {
    border-color: var(--brass);
    background: var(--brass-soft);
    box-shadow: inset 0 0 0 1px rgba(216, 178, 108, 0.3);
}

.level-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.level-choice:has(input:focus-visible) {
    outline: 2px solid var(--brass);
    outline-offset: 3px;
}

.level-choice .level-no {
    color: var(--brass);
    font-family: var(--font-display);
    font-size: 24px;
    line-height: 1;
}

.level-choice h3 {
    font-size: 18px;
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0;
}

.level-choice p {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.level-choice .level-elo {
    display: block;
    margin-top: 3px;
    color: var(--brass-strong);
    font-size: 11px;
    letter-spacing: 0.04em;
}

/* ---------- Forms ---------- */

.form-card {
    padding: clamp(22px, 4vw, 36px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 90% 0%, rgba(216, 178, 108, 0.06), transparent 40%),
        var(--surface);
    box-shadow: var(--shadow-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field > label,
.field-label {
    color: var(--cream-dim);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.03em;
}

.field .hint {
    color: var(--muted-2);
    font-size: 11px;
    line-height: 1.5;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(7, 11, 8, 0.45);
    color: var(--cream);
    font-size: 14px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.textarea {
    min-height: 110px;
    resize: vertical;
}

.input:hover,
.select:hover,
.textarea:hover {
    border-color: var(--line-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(216, 178, 108, 0.12);
    background: rgba(7, 11, 8, 0.65);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.input::placeholder,
.textarea::placeholder {
    color: #697267;
}

.select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 19px) calc(50% - 2px),
        calc(100% - 14px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 38px;
}

.input.is-code {
    font-family: var(--font-ui);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    text-align: center;
}

.error-text {
    color: var(--danger);
    font-size: 12px;
}

.input[aria-invalid="true"],
.input.is-invalid {
    border-color: rgba(224, 139, 124, 0.6);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 26px;
}

.form-actions .btn-primary {
    min-width: 190px;
}

.form-note {
    margin-top: 18px;
    color: var(--muted-2);
    font-size: 12px;
    line-height: 1.6;
}

.segmented {
    display: flex;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(7, 11, 8, 0.35);
}

.segmented label {
    position: relative;
    flex: 1;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
}

.segmented span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    transition: background 0.16s ease, color 0.16s ease;
}

.segmented label:has(input:checked) span {
    background: var(--brass);
    color: #1a1408;
    font-weight: 600;
}

.segmented label:has(input:focus-visible) span {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.piece-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: var(--cream);
}

.piece-dot.black {
    background: #1b211b;
    border-color: rgba(241, 234, 217, 0.4);
}

.piece-dot.random {
    background: conic-gradient(var(--cream) 0 50%, #1b211b 50% 100%);
}

.time-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.time-preset {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.time-preset:hover {
    color: var(--cream);
    border-color: var(--line-strong);
}

.time-preset.is-active {
    border-color: var(--brass);
    background: var(--brass-soft);
    color: var(--brass-strong);
}

.number-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.checkbox input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--brass);
}

/* ---------- Page headers ---------- */

.page-hero {
    position: relative;
    padding-block: clamp(40px, 6vw, 68px) clamp(30px, 4vw, 44px);
    border-bottom: 1px solid var(--line);
}

.page-hero::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    width: min(40vw, 420px);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brass));
}

.page-hero h1 {
    margin-top: 14px;
    font-size: clamp(2.6rem, 5.2vw, 4.4rem);
    font-weight: 500;
    letter-spacing: -0.03em;
}

.page-hero .lead {
    margin-top: 16px;
}

.page-hero-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.page-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: none;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--muted-2);
    font-size: 12px;
}

.breadcrumbs a:hover {
    color: var(--cream);
}

.breadcrumbs span::before {
    content: "/";
    margin-right: 8px;
    color: var(--line-strong);
}

/* ---------- Home: steps / CTA ---------- */

.split {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: clamp(32px, 6vw, 80px);
    align-items: center;
}

.steps {
    display: grid;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
}

.step {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 18px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
}

.step:last-child {
    border-bottom: 0;
}

.step-no {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(216, 178, 108, 0.3);
    border-radius: 50%;
    color: var(--brass);
    font-family: var(--font-display);
    font-size: 20px;
}

.step h3 {
    font-size: 20px;
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0;
}

.step p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.cta-panel {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 28px;
    overflow: hidden;
    padding: clamp(30px, 5vw, 52px);
    border: 1px solid rgba(216, 178, 108, 0.28);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at 85% 30%, rgba(216, 178, 108, 0.14), transparent 45%),
        linear-gradient(140deg, #1b2a20, #101812);
}

.cta-panel::after {
    content: "♜";
    position: absolute;
    right: 20%;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(241, 234, 217, 0.04);
    font-family: var(--font-display);
    font-size: 240px;
    line-height: 1;
    pointer-events: none;
}

.cta-panel h2 {
    max-width: 18ch;
    font-size: clamp(2rem, 3.6vw, 3.2rem);
}

.cta-panel p {
    max-width: 48ch;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.cta-panel .btn {
    position: relative;
    z-index: 1;
}

/* ---------- Game list ---------- */

.game-list {
    display: grid;
    gap: 10px;
}

.game-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.7fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color 0.18s ease, background 0.18s ease;
}

.game-row:hover {
    border-color: rgba(216, 178, 108, 0.3);
    background: var(--surface-2);
}

.game-row-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.game-row-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 50%;
    border: 1px solid var(--line);
    color: var(--brass);
    background: var(--brass-soft);
}

.game-row h3 {
    font-size: 18px;
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-row .meta-row {
    margin-top: 3px;
}

.game-row-result {
    text-align: right;
}

.game-row-result strong {
    display: block;
    font-size: 13px;
}

.game-row-result span {
    color: var(--muted-2);
    font-size: 11px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
}

.pagination .is-disabled {
    opacity: 0.35;
}

.pagination .is-dots {
    border-color: transparent;
}

.pagination a:hover {
    border-color: var(--brass);
    color: var(--cream);
}

.pagination .is-active {
    background: var(--brass);
    border-color: var(--brass);
    color: #181208;
    font-weight: 600;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 54px 24px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--brass);
    background: var(--brass-soft);
}

.empty-state h2 {
    font-size: 26px;
}

.empty-state p {
    max-width: 40ch;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Board ---------- */

.board-stage {
    container-type: inline-size;
    width: 100%;
    padding: 9px;
    border: 1px solid rgba(216, 178, 108, 0.24);
    border-radius: 18px;
    background:
        linear-gradient(155deg, rgba(216, 178, 108, 0.16), rgba(10, 15, 11, 0.2) 45%),
        #17221b;
    box-shadow:
        0 26px 60px rgba(0, 0, 0, 0.36),
        inset 0 1px 0 rgba(241, 234, 217, 0.12);
}

.board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
    user-select: none;
    touch-action: manipulation;
}

.sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    appearance: none;
    cursor: default;
}

.board-stage[data-interactive="1"] .sq {
    cursor: pointer;
}

.sq:focus-visible {
    outline: 3px solid var(--brass);
    outline-offset: -3px;
    box-shadow: inset 0 0 0 5px rgba(11, 17, 13, 0.78);
    z-index: 5;
}

.sq-light {
    background: linear-gradient(145deg, #f0e6d1, #e5d9c0);
}

.sq-dark {
    background: linear-gradient(145deg, #7f9a84, #6d8873);
}

.sq::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: transparent;
    pointer-events: none;
    transition: background 0.12s ease;
}

.sq.is-last::before {
    background: rgba(216, 178, 108, 0.32);
}

.sq.is-selected::before {
    background: rgba(216, 178, 108, 0.46);
    box-shadow: inset 0 0 0 3px rgba(88, 66, 29, 0.55);
}

.sq.is-check::before {
    background: radial-gradient(circle, rgba(224, 88, 74, 0.8), rgba(224, 88, 74, 0.12) 72%);
}

.sq.is-hint::after,
.sq.is-capture::after {
    content: "";
    position: absolute;
    z-index: 1;
    width: 18%;
    height: 18%;
    border-radius: 50%;
    background: rgba(18, 29, 21, 0.34);
    pointer-events: none;
}

.sq.is-capture::after {
    width: 74%;
    height: 74%;
    background: transparent;
    border: 4px solid rgba(18, 29, 21, 0.34);
}

.sq-dark.is-hint::after {
    background: rgba(240, 233, 216, 0.32);
}

.sq-dark.is-capture::after {
    border-color: rgba(240, 233, 216, 0.34);
}

.sq:hover::before {
    background: rgba(241, 234, 217, 0.12);
}

.sq.is-selected:hover::before {
    background: rgba(216, 178, 108, 0.5);
}

.move-ghost {
    position: absolute;
    display: grid;
    place-items: center;
    pointer-events: none;
    will-change: transform, opacity;
}

.move-ghost .piece {
    font-size: clamp(21px, 8.2cqw, 54px);
}

.piece {
    position: relative;
    z-index: 2;
    font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", "DejaVu Sans", serif;
    font-size: clamp(21px, 8.2cqw, 54px);
    line-height: 1;
    pointer-events: none;
    transform: translateY(-1.5%);
}

.piece-w {
    color: #fbf5e7;
    text-shadow:
        0 0 1px #4a463a,
        0 1px 0 #4a463a,
        1px 0 0 #4a463a,
        -1px 0 0 #4a463a,
        0 -1px 0 #4a463a,
        0 3px 5px rgba(0, 0, 0, 0.32);
}

.piece-b {
    color: #1a211b;
    text-shadow:
        0 0 1px rgba(245, 237, 220, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.28);
}

.coord {
    position: absolute;
    z-index: 3;
    color: rgba(11, 17, 13, 0.52);
    font-size: clamp(7px, 1.5cqw, 10px);
    font-weight: 600;
    line-height: 1;
    pointer-events: none;
}

.sq-dark .coord {
    color: rgba(244, 237, 222, 0.58);
}

.coord-file {
    right: 4px;
    bottom: 3px;
}

.coord-rank {
    left: 4px;
    top: 3px;
}

.board-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.board-caption {
    color: var(--muted-2);
    font-size: 11px;
}

/* ---------- Game page ---------- */

.game-page {
    padding-block: 24px 64px;
}

.game-topline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 18px;
}

.game-topline .grow {
    flex: 1;
}

.game-code {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.game-code strong {
    color: var(--cream);
    font-size: 12px;
    letter-spacing: 0.18em;
}

.game-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 360px);
    gap: clamp(18px, 3vw, 32px);
    align-items: start;
}

.game-main {
    min-width: 0;
}

.game-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.player-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.player-card.is-turn {
    border-color: rgba(216, 178, 108, 0.4);
    background: linear-gradient(90deg, rgba(216, 178, 108, 0.08), var(--surface) 45%);
}

.player-card.is-me {
    box-shadow: inset 3px 0 0 rgba(216, 178, 108, 0.55);
}

.player-avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--brass-strong);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    min-width: 0;
}

.player-name {
    display: flex;
    align-items: center;
    gap: 7px;
    overflow: hidden;
    color: var(--cream);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.player-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    color: var(--muted-2);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.side-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(241, 234, 217, 0.55);
    flex: none;
}

.side-dot.white {
    background: #f5eddc;
}

.side-dot.black {
    background: #1a211b;
}

.clock {
    min-width: 96px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(7, 11, 8, 0.4);
    color: var(--cream-dim);
    font-size: clamp(20px, 2.4vw, 26px);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.15;
    text-align: center;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.player-card.is-turn .clock {
    border-color: rgba(216, 178, 108, 0.35);
    background: var(--brass-soft);
    color: var(--brass-strong);
}

.clock.is-low {
    color: #f3a495;
    border-color: rgba(224, 139, 124, 0.45);
    animation: low-time 1.2s infinite;
}

@keyframes low-time {
    0%, 100% { background: rgba(224, 139, 124, 0.08); }
    50% { background: rgba(224, 139, 124, 0.16); }
}

.board-area {
    position: relative;
    margin-top: 12px;
}

.game-status {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    margin-top: 14px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--cream-dim);
    font-size: 13px;
}

.game-status strong {
    color: var(--cream);
}

.game-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brass);
    box-shadow: 0 0 10px rgba(216, 178, 108, 0.6);
    flex: none;
}

.game-status.is-live .status-dot {
    background: var(--success);
    box-shadow: 0 0 10px rgba(158, 196, 164, 0.6);
    animation: pulse 2s infinite;
}

.game-status.is-waiting .status-dot {
    animation: pulse 2s infinite;
}

.game-status.is-finished .status-dot {
    background: var(--muted-2);
    box-shadow: none;
}

.game-status .thinking {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    color: var(--brass);
    font-size: 11px;
}

.thinking-dots {
    display: inline-flex;
    gap: 3px;
}

.thinking-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brass);
    animation: think 1.1s infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes think {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-3px); opacity: 1; }
}

.draw-banner,
.result-banner {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(216, 178, 108, 0.32);
    border-radius: var(--radius-md);
    background: var(--brass-soft);
    color: var(--cream);
    font-size: 13px;
}

.draw-banner.is-visible,
.result-banner.is-visible {
    display: flex;
}

.draw-banner .grow,
.result-banner .grow {
    flex: 1;
}

.result-banner {
    border-color: rgba(158, 196, 164, 0.34);
    background: linear-gradient(90deg, rgba(158, 196, 164, 0.12), var(--surface));
}

.result-banner strong {
    display: block;
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 600;
    line-height: 1.1;
}

.result-banner span {
    color: var(--muted);
    font-size: 11px;
}

.result-overlay {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 28px);
    border-radius: var(--radius-md);
    background: rgba(7, 12, 9, 0.78);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.result-overlay.is-visible {
    display: flex;
}

.result-card {
    width: min(100%, 360px);
    padding: clamp(22px, 4vw, 32px);
    border: 1px solid var(--line-strong);
    border-radius: calc(var(--radius-md) + 4px);
    background: linear-gradient(180deg, rgba(29, 43, 34, 0.98), rgba(17, 26, 20, 0.98));
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
    text-align: center;
    animation: result-card-in 0.28s ease-out both;
}

.result-emblem {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--cream);
}

.result-kicker {
    display: block;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.result-heading {
    display: block;
    margin: 8px 0 12px;
    color: var(--cream);
    font-family: var(--font-display);
    font-size: clamp(2.25rem, 5vw, 3rem);
    font-weight: 600;
    line-height: 1;
}

.result-detail {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.result-sep {
    color: var(--muted-2);
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.result-overlay.is-win .result-card {
    border-color: rgba(216, 178, 108, 0.55);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55), 0 0 60px rgba(216, 178, 108, 0.14);
}

.result-overlay.is-win .result-emblem {
    border-color: rgba(216, 178, 108, 0.45);
    background: var(--brass-soft);
    color: var(--brass-strong);
}

.result-overlay.is-win .result-heading {
    color: var(--brass-strong);
}

.result-overlay.is-loss .result-card {
    border-color: rgba(224, 139, 124, 0.5);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55), 0 0 60px rgba(224, 139, 124, 0.1);
}

.result-overlay.is-loss .result-emblem {
    border-color: rgba(224, 139, 124, 0.4);
    background: var(--danger-soft);
    color: var(--danger);
}

.result-overlay.is-loss .result-heading {
    color: var(--danger);
}

.result-overlay.is-draw .result-card {
    border-color: rgba(143, 169, 147, 0.48);
}

.result-overlay.is-draw .result-emblem {
    border-color: rgba(143, 169, 147, 0.4);
    background: rgba(143, 169, 147, 0.12);
    color: var(--sage);
}

.result-overlay.is-draw .result-heading {
    color: var(--sage);
}

.result-overlay.is-aborted .result-heading {
    color: var(--muted);
}

.result-banner.is-win {
    border-color: rgba(216, 178, 108, 0.4);
    background: linear-gradient(90deg, var(--brass-soft), var(--surface));
}

.result-banner.is-win .step-no {
    border-color: rgba(216, 178, 108, 0.45);
    color: var(--brass-strong);
}

.result-banner.is-loss {
    border-color: rgba(224, 139, 124, 0.4);
    background: linear-gradient(90deg, var(--danger-soft), var(--surface));
}

.result-banner.is-loss .step-no {
    border-color: rgba(224, 139, 124, 0.4);
    color: var(--danger);
}

.result-banner.is-draw {
    border-color: rgba(143, 169, 147, 0.4);
    background: linear-gradient(90deg, rgba(143, 169, 147, 0.12), var(--surface));
}

.result-banner.is-draw .step-no {
    border-color: rgba(143, 169, 147, 0.4);
    color: var(--sage);
}

@keyframes result-card-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .result-card {
        animation: none;
    }
}

.side-panel {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.side-panel h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.game-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.game-info-grid div {
    padding: 10px;
    border: 1px solid rgba(241, 234, 217, 0.07);
    border-radius: 9px;
    background: rgba(7, 11, 8, 0.22);
}

.game-info-grid dt {
    color: var(--muted-2);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.game-info-grid dd {
    margin: 4px 0 0;
    color: var(--cream-dim);
    font-size: 12px;
}

.moves-panel {
    display: flex;
    flex-direction: column;
    min-height: 180px;
    max-height: 380px;
    padding: 0;
    overflow: hidden;
}

.moves-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.moves-head h2 {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.moves-head span {
    color: var(--muted-2);
    font-size: 10px;
}

.moves-list {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(216, 178, 108, 0.35) transparent;
    scrollbar-width: thin;
    padding: 6px 0;
}

.move-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 13px;
}

.move-row:nth-child(odd) {
    background: rgba(241, 234, 217, 0.018);
}

.move-no {
    color: var(--muted-2);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-right: 6px;
}

.move-san {
    padding: 3px 7px;
    border-radius: 5px;
    color: var(--cream-dim);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.move-san.is-last {
    background: var(--brass-soft);
    color: var(--brass-strong);
}

.moves-empty {
    padding: 26px 16px;
    color: var(--muted-2);
    font-size: 12px;
    text-align: center;
}

.game-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.game-actions .btn {
    min-height: 42px;
    padding-inline: 10px;
    font-size: 12px;
}

.game-actions .btn-block {
    grid-column: span 2;
}

.game-actions .btn-outline {
    background: var(--surface);
}

.game-actions .btn-danger {
    background: transparent;
}

.share-button-row {
    display: flex;
    gap: 8px;
}

.share-button-row .btn {
    flex: 1;
}

.game-note {
    color: var(--muted-2);
    font-size: 10px;
    line-height: 1.5;
    text-align: center;
}

/* ---------- Waiting / join ---------- */

.lobby-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: clamp(24px, 5vw, 60px);
    align-items: center;
    padding-block: clamp(28px, 4vw, 48px) clamp(50px, 7vw, 80px);
}

.lobby-copy h1 {
    margin: 16px 0 14px;
    font-size: clamp(2.8rem, 5.5vw, 4.7rem);
    font-weight: 500;
}

.code-display {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin: 24px 0 8px;
    padding: 14px 20px;
    border: 1px solid rgba(216, 178, 108, 0.4);
    border-radius: var(--radius-md);
    background: var(--brass-soft);
    color: var(--brass-strong);
    font-size: clamp(26px, 4vw, 38px);
    font-weight: 600;
    letter-spacing: 0.22em;
    line-height: 1;
}

.code-display button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(216, 178, 108, 0.28);
    border-radius: 50%;
    background: transparent;
    color: var(--brass-strong);
}

.code-hint {
    color: var(--muted);
    font-size: 12px;
}

.lobby-card {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.lobby-card .qr-card {
    margin: 0 auto 18px;
}

.qr-card {
    display: inline-block;
    width: fit-content;
    padding: 10px;
    border-radius: 12px;
    background: #fff;
    line-height: 0;
}

.qr-card svg {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.copy-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
}

.copy-row .input {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    min-height: 42px;
    background: rgba(7, 11, 8, 0.5);
}

.copy-row .btn {
    flex: none;
}

.lobby-players {
    display: grid;
    gap: 8px;
    margin-top: 22px;
}

.lobby-player {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(241, 234, 217, 0.02);
    font-size: 13px;
}

.lobby-player .side-dot {
    width: 11px;
    height: 11px;
}

.lobby-player .waiting-label {
    color: var(--brass);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.join-options {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

/* ---------- Share dialog ---------- */

.share-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 0;
    background: transparent;
}

.share-dialog::backdrop {
    background: rgba(3, 6, 4, 0.72);
    backdrop-filter: blur(5px);
}

.share-card {
    padding: 26px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.share-card h2 {
    margin-top: 4px;
    font-size: 30px;
}

.share-card .qr-card {
    display: block;
    width: fit-content;
    margin: 20px auto;
}

.share-code {
    margin: 12px 0 4px;
    color: var(--brass-strong);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-align: center;
}

.share-card .copy-row {
    margin-top: 16px;
}

.share-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.share-actions .btn {
    flex: 1;
}

/* ---------- Tournaments ---------- */

.tournament-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.tournament-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.tournament-card:hover {
    border-color: rgba(216, 178, 108, 0.35);
    transform: translateY(-2px);
}

.tournament-cover {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    min-height: 120px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background:
        radial-gradient(circle at 80% 20%, rgba(216, 178, 108, 0.15), transparent 45%),
        linear-gradient(135deg, #1c2b21, #101813);
    overflow: hidden;
}

.tournament-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.4;
    background-image:
        linear-gradient(45deg, rgba(241, 234, 217, 0.05) 25%, transparent 25%, transparent 75%, rgba(241, 234, 217, 0.05) 75%),
        linear-gradient(45deg, rgba(241, 234, 217, 0.05) 25%, transparent 25%, transparent 75%, rgba(241, 234, 217, 0.05) 75%);
    background-size: 56px 56px;
    background-position: 0 0, 28px 28px;
    mask-image: linear-gradient(90deg, #000, transparent 85%);
}

.tournament-cover > * {
    position: relative;
    z-index: 1;
}

.tournament-glyph {
    color: rgba(216, 178, 108, 0.7);
    font-family: var(--font-display);
    font-size: 70px;
    line-height: 1;
}

.tournament-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 20px;
}

.tournament-body h2 {
    font-size: 28px;
    line-height: 1.05;
}

.tournament-body .meta-row {
    margin-top: 12px;
}

.capacity {
    margin-top: 18px;
}

.capacity-bar {
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(241, 234, 217, 0.08);
}

.capacity-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brass), var(--brass-strong));
}

.capacity-label {
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
    color: var(--muted-2);
    font-size: 10px;
    letter-spacing: 0.04em;
}

.tournament-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
}

.tournament-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 28px;
    padding-block: clamp(30px, 5vw, 52px);
    border-bottom: 1px solid var(--line);
}

.tournament-hero h1 {
    margin: 12px 0 12px;
    font-size: clamp(2.5rem, 5vw, 4.2rem);
    font-weight: 500;
}

.tournament-hero .meta-row {
    font-size: 13px;
}

.tournament-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.tournament-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
    gap: 24px;
    align-items: start;
    padding-block: 28px 64px;
}

.tournament-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.standings-wrap {
    overflow-x: auto;
    scrollbar-width: thin;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--muted-2);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(241, 234, 217, 0.06);
    color: var(--cream-dim);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: rgba(241, 234, 217, 0.025);
}

.data-table tr.is-me {
    background: rgba(216, 178, 108, 0.07);
}

.data-table tr.is-me td:first-child {
    box-shadow: inset 3px 0 0 var(--brass);
}

.rank-cell {
    color: var(--muted-2);
    font-family: var(--font-display);
    font-size: 17px;
    width: 38px;
    text-align: center;
}

.rank-cell.is-podium {
    color: var(--brass-strong);
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 150px;
}

.player-cell .mini-avatar {
    display: grid;
    place-items: center;
    width: 27px;
    height: 27px;
    flex: none;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--brass);
    font-family: var(--font-display);
    font-size: 11px;
}

.player-cell .mini-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.score-cell {
    color: var(--cream);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.bye-tag {
    padding: 2px 7px;
    border: 1px solid rgba(216, 178, 108, 0.3);
    border-radius: 99px;
    color: var(--brass);
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.rounds {
    display: grid;
    gap: 8px;
}

.round {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

.round summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    cursor: pointer;
    list-style: none;
    color: var(--cream-dim);
    font-size: 13px;
}

.round summary::-webkit-details-marker {
    display: none;
}

.round summary::after {
    content: "+";
    margin-left: auto;
    color: var(--muted);
    font-size: 17px;
}

.round[open] summary::after {
    content: "−";
}

.round[open] summary {
    border-bottom: 1px solid var(--line);
}

.round-title {
    font-weight: 600;
}

.round-count {
    color: var(--muted);
    font-size: 10px;
}

.round-current {
    border-color: rgba(216, 178, 108, 0.28);
}

.round-current summary {
    background: rgba(216, 178, 108, 0.05);
}

.pairing {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto minmax(0, 1fr) 54px;
    align-items: center;
    gap: 9px;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(241, 234, 217, 0.05);
    font-size: 12px;
}

.pairing:last-child {
    border-bottom: 0;
}

.pairing-board {
    color: var(--muted-2);
    font-size: 9px;
    text-align: center;
}

.pairing-player {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pairing-player.is-black {
    justify-content: flex-end;
    text-align: right;
}

.pairing-player.is-winner {
    color: var(--brass-strong);
    font-weight: 600;
}

.pairing-vs {
    color: var(--muted-2);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pairing-result {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 10px;
}

.pairing-result a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 32px;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--brass);
}

.pairing-result a:hover {
    background: var(--brass-soft);
}

.pairing.is-bye {
    grid-template-columns: 26px 1fr auto;
}

.pairing.is-bye .pairing-vs,
.pairing.is-bye .pairing-result {
    display: none;
}

.round-empty {
    padding: 18px;
    color: var(--muted-2);
    font-size: 12px;
}

.bracket-scroll {
    overflow-x: auto;
    padding: 2px 2px 10px;
    margin: 0 -2px;
    -webkit-overflow-scrolling: touch;
}

.bracket {
    display: flex;
    gap: 14px;
    min-width: max-content;
    padding: 2px;
}

.bracket-round {
    display: flex;
    flex: 0 0 216px;
    flex-direction: column;
}

.bracket-round-title {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.bracket-matches {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-around;
    gap: 10px;
}

.bracket-match {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

.bracket-match.is-current {
    border-color: rgba(216, 178, 108, 0.45);
    box-shadow: 0 0 0 1px rgba(216, 178, 108, 0.12);
}

.bracket-player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
}

.bracket-player + .bracket-player {
    border-top: 1px solid var(--line);
}

.bracket-player.is-winner {
    color: var(--brass-strong);
    font-weight: 600;
}

.bracket-name {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bracket-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 10px;
    border-top: 1px solid var(--line);
    color: var(--muted-2);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.bracket-meta a {
    color: var(--brass);
    font-weight: 600;
}

.rounds-after-bracket {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.tournament-rules {
    display: grid;
    gap: 12px;
}

.rule-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.rule-row .icon {
    margin-top: 2px;
    color: var(--brass);
    flex: none;
}

.participants-list {
    display: grid;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.participant-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 4px;
    border-bottom: 1px solid rgba(241, 234, 217, 0.05);
    font-size: 12px;
}

.participant-row:last-child {
    border-bottom: 0;
}

.participant-no {
    width: 22px;
    color: var(--muted-2);
    font-size: 10px;
    text-align: right;
}

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

.auth-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
    gap: clamp(30px, 6vw, 90px);
    align-items: center;
    min-height: calc(100vh - var(--header-h) - 180px);
    padding-block: clamp(40px, 7vw, 80px);
}

.auth-aside {
    position: relative;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    min-height: 460px;
    padding: clamp(26px, 4vw, 44px);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at 75% 15%, rgba(216, 178, 108, 0.12), transparent 45%),
        linear-gradient(150deg, #1a2820, #0c130e);
}

.auth-aside::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, rgba(241, 234, 217, 0.04) 25%, transparent 25%, transparent 75%, rgba(241, 234, 217, 0.04) 75%),
        linear-gradient(45deg, rgba(241, 234, 217, 0.04) 25%, transparent 25%, transparent 75%, rgba(241, 234, 217, 0.04) 75%);
    background-size: 88px 88px;
    background-position: 0 0, 44px 44px;
    mask-image: radial-gradient(circle at 60% 60%, #000, transparent 85%);
    pointer-events: none;
}

.auth-quote {
    position: relative;
    max-width: 22ch;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 4vw, 3.6rem);
    line-height: 1.02;
    color: var(--cream);
}

.auth-quote span {
    color: var(--brass);
    font-style: italic;
}

.auth-aside-foot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-card {
    padding: clamp(26px, 4vw, 40px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin-top: 12px;
    font-size: clamp(2.4rem, 4vw, 3.4rem);
    font-weight: 500;
}

.auth-card p {
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.auth-card .btn-yandex {
    margin-top: 26px;
    min-height: 54px;
    width: 100%;
}

.auth-benefits {
    display: grid;
    gap: 11px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.auth-benefits li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: var(--muted);
    font-size: 12px;
}

.auth-benefits .icon {
    color: var(--brass);
    margin-top: 2px;
    flex: none;
}

.auth-note {
    margin-top: 20px;
    color: var(--muted-2);
    font-size: 10px;
    line-height: 1.6;
}

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

.profile-head {
    display: flex;
    align-items: center;
    gap: 22px;
    padding-block: clamp(32px, 5vw, 54px);
    border-bottom: 1px solid var(--line);
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: clamp(80px, 11vw, 112px);
    height: clamp(80px, 11vw, 112px);
    flex: none;
    overflow: hidden;
    border: 1px solid rgba(216, 178, 108, 0.45);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--brass-strong);
    font-family: var(--font-display);
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 700;
    box-shadow: 0 0 0 6px rgba(216, 178, 108, 0.05);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-copy h1 {
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    font-weight: 500;
}

.profile-copy .meta-row {
    margin-top: 8px;
}

.profile-body {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.7fr);
    gap: 24px;
    padding-block: 28px 64px;
    align-items: start;
}

/* ---------- Admin ---------- */

.admin-page {
    padding-block: 30px 64px;
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.admin-tabs a {
    padding: 8px 13px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
}

.admin-tabs a:hover {
    color: var(--cream);
    background: rgba(241, 234, 217, 0.05);
}

.admin-tabs a.is-active {
    background: var(--brass-soft);
    color: var(--brass-strong);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.stat-card span {
    color: var(--muted-2);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 6px;
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 500;
    line-height: 1;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
    gap: 20px;
    align-items: start;
}

.admin-grid > *,
.game-side > *,
.tournament-side > * {
    min-width: 0;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-actions form {
    margin: 0;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

/* ---------- Dialog ---------- */

.dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 0;
    background: transparent;
}

.dialog::backdrop {
    background: rgba(3, 6, 4, 0.72);
    backdrop-filter: blur(5px);
}

.dialog-card {
    padding: 26px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.dialog-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--brass);
    background: var(--brass-soft);
}

.dialog-card h2 {
    font-size: 26px;
}

.dialog-card p {
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
}

.dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 22px;
}

/* ---------- Misc ---------- */

.notice {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(241, 234, 217, 0.025);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.notice .icon {
    margin-top: 2px;
    color: var(--brass);
    flex: none;
}

.notice strong {
    color: var(--cream-dim);
}

.divider {
    height: 1px;
    margin-block: 22px;
    background: var(--line);
}

.kbd {
    display: inline-flex;
    min-width: 20px;
    padding: 1px 5px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
    text-align: center;
}

.hidden {
    display: none !important;
}

.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;
}

.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-block: clamp(70px, 12vw, 140px);
    text-align: center;
}

.error-code {
    color: var(--brass);
    font-family: var(--font-display);
    font-size: clamp(5rem, 14vw, 11rem);
    line-height: 0.8;
    letter-spacing: -0.04em;
}

.error-page h1 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.error-page p {
    max-width: 44ch;
    color: var(--muted);
    font-size: 14px;
}

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

.site-footer {
    margin-top: 40px;
    border-top: 1px solid var(--line);
    background: rgba(7, 11, 8, 0.5);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.6fr 0.6fr;
    gap: 40px;
    padding-block: clamp(34px, 5vw, 52px);
}

.footer-brand p {
    max-width: 36ch;
    margin-top: 16px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.footer-col h2 {
    margin-bottom: 12px;
    color: var(--muted-2);
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.footer-col a {
    display: block;
    padding-block: 4px;
    color: var(--muted);
    font-size: 13px;
}

.footer-col a:hover {
    color: var(--cream);
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-block: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted-2);
    font-size: 10px;
    letter-spacing: 0.04em;
}

.footer-tech {
    text-transform: uppercase;
}

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

@media (max-width: 1080px) {
    .main-nav {
        gap: 2px;
    }

    .main-nav a {
        padding-inline: 10px;
    }

    .account-name {
        display: none;
    }

    .game-shell {
        grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
    }
}

@media (max-width: 960px) {
    .main-nav {
        display: none;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .desktop-logout,
    .admin-link {
        display: none;
    }

    .hero-grid {
        grid-template-columns: 1fr;
    }

    .hero-visual {
        min-height: 380px;
        max-width: 520px;
        width: 100%;
        margin-inline: auto;
    }

    .poster-knight {
        font-size: clamp(200px, 48vw, 290px);
    }

    .mode-grid {
        grid-template-columns: 1fr;
    }

    .mode-card {
        min-height: auto;
    }

    .split {
        grid-template-columns: 1fr;
    }

    .game-shell {
        grid-template-columns: 1fr;
    }

    .game-side {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .game-side .moves-panel {
        grid-column: span 2;
    }

    .tournament-layout {
        grid-template-columns: 1fr;
    }

    .tournament-side {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        min-height: 260px;
    }

    .auth-quote {
        font-size: clamp(2rem, 5vw, 3rem);
    }

    .profile-body,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lobby-grid {
        grid-template-columns: 1fr;
    }

    .lobby-card {
        max-width: 480px;
    }

    .footer-grid {
        grid-template-columns: 1.2fr 0.8fr 0.8fr;
        gap: 24px;
    }
}

@media (max-width: 720px) {
    :root {
        --header-h: 66px;
    }

    body {
        font-size: 15px;
    }

    .header-inner {
        gap: 14px;
    }

    .brand-text small {
        display: none;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        font-size: 25px;
    }

    .brand-text strong {
        font-size: 21px;
    }

    .login-short span:last-child {
        display: none;
    }

    .login-short {
        min-height: 42px;
        padding: 6px 10px 6px 6px;
        border-radius: 999px;
    }

    .login-short .ya-mark {
        width: 28px;
        height: 28px;
    }

    .header-account {
        gap: 4px;
    }

    .hero {
        padding-top: 44px;
    }

    .hero-copy h1 {
        font-size: clamp(3.1rem, 16vw, 4.6rem);
    }

    .hero-actions .btn {
        flex: 1;
        min-width: 150px;
    }

    .hero-stats {
        gap: 18px 26px;
    }

    .hero-visual {
        min-height: 300px;
    }

    .hero-poster {
        padding: 20px;
    }

    .poster-knight {
        font-size: clamp(185px, 52vw, 235px);
    }

    .poster-chip {
        right: 12px;
        top: 62px;
    }

    .poster-chip--bottom,
    .poster-bottom {
        display: none;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .level-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .level-choice {
        min-height: 158px;
        padding: 15px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: auto;
    }

    .form-card {
        padding: 20px;
    }

    .page-hero-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .game-page {
        padding-top: 14px;
    }

    .game-main .board-area {
        margin-inline: -10px;
    }

    .game-main .board-stage {
        padding: 4px;
        border-radius: 12px;
    }

    .game-side {
        display: flex;
    }

    .game-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .player-card {
        grid-template-columns: 36px minmax(0, 1fr) auto;
        gap: 9px;
        padding: 9px 10px;
    }

    .player-avatar {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .clock {
        min-width: 82px;
        font-size: 20px;
        padding: 6px 8px;
    }

    .board-stage {
        padding: 6px;
        border-radius: 14px;
    }

    .coord-file {
        right: 3px;
        bottom: 2px;
    }

    .coord-rank {
        left: 3px;
        top: 2px;
    }

    .tournament-grid {
        grid-template-columns: 1fr;
    }

    .tournament-hero {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .tournament-hero .dot-sep {
        display: none;
    }

    .tournament-hero .meta-row {
        gap: 7px 14px;
    }

    .tournament-hero-actions {
        width: 100%;
        min-width: 0;
    }

    .tournament-side {
        grid-template-columns: 1fr;
    }

    .game-row {
        grid-template-columns: 1fr auto;
    }

    .game-row-main {
        grid-column: span 2;
    }

    .game-row-result {
        text-align: left;
    }

    .pairing {
        grid-template-columns: 22px minmax(0, 1fr) auto;
        grid-template-areas:
            "board white result"
            "board black result";
        gap: 2px 10px;
        padding: 10px 12px;
        font-size: 11px;
    }

    .pairing-board {
        grid-area: board;
        align-self: center;
    }

    .pairing-player {
        grid-area: white;
        overflow: visible;
        white-space: normal;
        line-height: 1.35;
    }

    .pairing-player.is-black {
        grid-area: black;
        justify-content: flex-start;
        text-align: left;
    }

    .pairing-vs {
        display: none;
    }

    .pairing-result {
        grid-area: result;
        align-self: center;
    }

    .pairing.is-bye {
        grid-template-columns: 22px minmax(0, 1fr) auto;
        grid-template-areas: "board white result";
    }

    .pairing.is-bye .pairing-player.is-black {
        display: none;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .footer-brand {
        grid-column: span 2;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }

    .data-table th.hide-mobile,
    .data-table td.hide-mobile {
        display: none;
    }

    .tournament-cover {
        min-height: 100px;
    }

    .tournament-body h2 {
        font-size: 25px;
    }

    .auth-aside {
        display: none;
    }

    .auth-page {
        min-height: auto;
        padding-block: 34px 54px;
    }

    .profile-head {
        align-items: flex-start;
        gap: 16px;
    }

    .profile-avatar {
        width: 76px;
        height: 76px;
    }

    .code-display {
        letter-spacing: 0.16em;
        padding: 12px 15px;
    }
}

@media (max-width: 480px) {
    .shell {
        padding-inline: 16px;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .hero-stats {
        justify-content: space-between;
    }

    .level-strip,
    .level-grid {
        grid-template-columns: 1fr 1fr;
    }

    .section-head p {
        max-width: none;
    }

    .cta-panel {
        grid-template-columns: 1fr;
    }

    .cta-panel .btn {
        width: 100%;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }

    .footer-brand {
        grid-column: auto;
    }

    .dialog-actions {
        grid-template-columns: 1fr;
    }

    .game-side .btn {
        min-height: 44px;
    }

    .game-code {
        font-size: 9px;
    }

    .game-code strong {
        font-size: 11px;
    }

    .player-name {
        font-size: 13px;
    }

    .clock {
        min-width: 74px;
        font-size: 18px;
    }

    .move-row {
        font-size: 12px;
    }

    .pairing {
        grid-template-columns: 18px minmax(0, 1fr) auto;
    }

    .pairing.is-bye {
        grid-template-columns: 18px minmax(0, 1fr) auto;
    }
}

@media (pointer: coarse) {
    .btn-sm,
    .time-preset,
    .admin-tabs a,
    .pagination a,
    .pagination span,
    .pairing-result a {
        min-height: 44px;
    }

    .flash-close {
        min-width: 44px;
        min-height: 44px;
    }

    .code-display button {
        width: 44px;
        height: 44px;
    }

    .text-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
