:root {
  --bg: #0b0d12;
  --surface: #151922;
  --surface-2: #1d2330;
  --surface-3: #262e3e;
  --line: #343e52;
  --text: #f6f7f9;
  --muted: #c9d0dc;
  --accent: #d81f2a;
  --accent-hover: #ef2f3a;
  --accent-ink: #ffffff;
  --gold: #f4c44f;
  --ok: #43c47a;
  --ok-bg: #102a1c;
  --danger-bg: #3a1114;
  --info-bg: #13233d;
  --info: #9cc4ff;
  --sq-light: #efe0c2;
  --sq-dark: #8a5d3b;
  --on-gold: #1a1405;
  --on-ok: #04170c;
  --ok-ink: #d9f7e6;
  --danger-line: #b0303a;
  --danger-ink: #ffd6d8;
  --info-line: #5b9dff;
  --info-ink: #e6f0ff;
  --check-bg: var(--accent);
  --check-ink: var(--accent-ink);
  --input-bg: #0f1219;
  --frame: #2a1d14;
  --frame-ink: #e9d6b4;
  --album: 0.28;
  --radius: 16px;
  --radius-sm: 12px;
  --tap: 3.5rem;
  --nav-w: 15rem;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --surface-2: #e8ecf2;
  --surface-3: #d6dce6;
  --line: #5b6474;
  --text: #0b0d12;
  --muted: #2e3440;
  --accent: #b3121c;
  --accent-hover: #8f0e16;
  --accent-ink: #ffffff;
  --gold: #8a5a00;
  --on-gold: #ffffff;
  --ok: #17723a;
  --on-ok: #ffffff;
  --ok-bg: #e2f4e8;
  --ok-ink: #0b3d1f;
  --danger-bg: #fde7e8;
  --danger-line: #b3121c;
  --danger-ink: #7d0a11;
  --info-bg: #e5eeff;
  --info: #1e4fa8;
  --info-line: #1e5fd1;
  --info-ink: #0b2350;
  --input-bg: #ffffff;
  --sq-light: #f0d9b5;
  --sq-dark: #946f51;
  --frame: #5a3e28;
  --frame-ink: #fff3dc;
  --album: 0.16;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  color-scheme: light;
}

html[data-theme="yellow"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #161616;
  --surface-3: #262626;
  --line: #ffe600;
  --text: #ffe600;
  --muted: #fff3a0;
  --accent: #ffe600;
  --accent-hover: #fff27a;
  --accent-ink: #000000;
  --gold: #ffffff;
  --on-gold: #000000;
  --ok: #5ee38a;
  --on-ok: #000000;
  --ok-bg: #002910;
  --ok-ink: #c9ffd9;
  --danger-bg: #330000;
  --danger-line: #ff6b6b;
  --danger-ink: #ffc2c2;
  --info-bg: #000000;
  --info: #ffffff;
  --info-line: #ffe600;
  --info-ink: #ffffff;
  --check-bg: #ff5252;
  --check-ink: #000000;
  --input-bg: #000000;
  --sq-light: #fff5b8;
  --sq-dark: #4a6fa5;
  --frame: #000000;
  --frame-ink: #ffe600;
  --album: 0.08;
}

html[data-theme="contrast"] {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #141414;
  --surface-3: #262626;
  --line: #ffffff;
  --text: #ffffff;
  --muted: #ffffff;
  --accent: #ffffff;
  --accent-hover: #d9d9d9;
  --accent-ink: #000000;
  --gold: #ffd400;
  --on-gold: #000000;
  --ok: #00e676;
  --on-ok: #000000;
  --ok-bg: #000000;
  --ok-ink: #ffffff;
  --danger-bg: #000000;
  --danger-line: #ffffff;
  --danger-ink: #ffffff;
  --info-bg: #000000;
  --info: #ffffff;
  --info-line: #ffffff;
  --info-ink: #ffffff;
  --check-bg: #ff3030;
  --check-ink: #000000;
  --input-bg: #000000;
  --sq-light: #ffffff;
  --sq-dark: #777777;
  --frame: #000000;
  --frame-ink: #ffffff;
  --album: 0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { font-size: 20px; }
html[data-size="l"] { font-size: 18px; }
html[data-size="xl"] { font-size: 21px; }
html[data-size="xxl"] { font-size: 25px; }

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/playfair-cyrillic-italic-700.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/playfair-latin-italic-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html { height: 100%; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1, h2, h3 { line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; margin: 0; padding: 0; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.skip-link {
  position: fixed;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 60;
  background: var(--gold);
  color: #111;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 800;
}

.skip-link:not(:focus) {
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 3px;
}

/* ── Фон-альбом ─────────────────────────────────────────── */
.bg { position: fixed; inset: 0; z-index: 0; }

.bg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: saturate(0.85);
  transition: opacity 1.2s ease;
}

.bg img.is-on { opacity: var(--album); }

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 70% 0%, color-mix(in srgb, var(--bg) 35%, transparent), color-mix(in srgb, var(--bg) 92%, transparent) 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 50%, transparent), color-mix(in srgb, var(--bg) 95%, transparent));
}

body.album-off .bg img { display: none; }
body[data-screen="play"] .bg img.is-on { opacity: calc(var(--album) * 0.45); }

/* ── Заставка ───────────────────────────────────────────── */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  opacity: 1;
  transition: opacity 0.3s ease, display 0.3s allow-discrete, overlay 0.3s allow-discrete;
}

.intro[hidden] { display: none; }
.intro.is-closing { opacity: 0; }

.intro video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.intro-stage {
  position: absolute;
  inset: 0;
}

.intro-photo, .intro-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.intro-backdrop {
  object-fit: cover;
  filter: blur(28px) brightness(0.3);
  transform: scale(1.12);
}

.intro-photo {
  object-fit: contain;
  object-position: center top;
  animation: intro-drift 24s ease-in-out infinite alternate;
}

@keyframes intro-drift {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

@media (min-aspect-ratio: 3 / 2) {
  .intro-stage {
    left: calc(100vw - 75vh);
    width: 75vh;
  }
  .intro-photo {
    object-fit: cover;
    object-position: 28% 12%;
    animation: none;
  }
  .intro .intro-shade { display: none; }
  .intro .intro-card {
    top: 0;
    right: auto;
    width: calc(100vw - 75vh);
    max-width: none;
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    overflow-y: auto;
    padding-top: 1.5rem;
    background: #050608;
    box-shadow: 2rem 0 3rem -0.5rem #050608;
  }
  .intro .intro-card h1 { font-size: min(4.2vw, 7.5vh, 4.4rem); }
  .intro .intro-card .eyebrow { font-size: min(1.05rem, 2.4vh); }
  .intro .intro-card .intro-age { font-size: min(1.9rem, 4.6vh); }
  .intro .intro-lead { font-size: min(1.5rem, 3.7vh); margin: 1.2vh 0 2.4vh; }
  .intro .intro-guide { font-size: min(1.5rem, 3.6vh); margin-bottom: 2.6vh; padding: 2vh 1.4rem; }
  .intro .intro-guide h2 { font-size: min(1.8rem, 4.3vh); margin-bottom: 1vh; }
  .intro .intro-guide ol { gap: 0.8vh; }
  .intro .intro-guide p { margin-top: 1.4vh; }
  .intro .intro-card .btn-xl { font-size: min(1.4rem, 3.4vh); min-height: min(4rem, 9.5vh); }
}

@media (max-aspect-ratio: 3 / 2) {
  .intro:not([hidden]) { display: flex; flex-direction: column; }
  .intro-stage {
    position: relative;
    flex: 1 1 0;
    min-height: 12rem;
  }
  .intro-photo {
    object-fit: cover;
    object-position: 50% 45%;
  }
  .intro .intro-shade { display: none; }
  .intro .intro-card {
    position: relative;
    background: linear-gradient(180deg, transparent, #000 1.5rem);
    padding-top: 1.75rem;
    margin-top: -1.5rem;
  }
}

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

.intro-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.92) 85%);
  pointer-events: none;
}

.intro-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem clamp(1.25rem, 5vw, 4rem) calc(1.75rem + env(safe-area-inset-bottom));
  max-width: 64rem;
}

.intro-card h1 {
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  font-weight: 900;
  margin-top: 0.35rem;
}

.intro-age, .hero-age {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 0.3rem;
}

.intro-age span, .hero-age span {
  display: inline-block;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 0 0.45em;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.intro-card { color: #fff; }
.intro-card .eyebrow { color: #ffd23f; font-size: 1.05rem; }
.intro .intro-age { font-size: 1.9rem; }
.intro-lead { font-size: 1.5rem; font-weight: 800; line-height: 1.3; margin: 0.6rem 0 1.1rem; color: #fff; }

.intro-guide {
  margin: 0 0 1.25rem;
  padding: 1.1rem 1.4rem;
  max-width: 46rem;
  border: 3px solid #fff;
  border-radius: var(--radius);
  background: #000;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
}

.intro-guide h2 { font-size: 1.7rem; font-weight: 900; margin: 0 0 0.6rem; color: #ffd23f; }
.intro-guide ol { margin: 0; padding-left: 2rem; display: grid; gap: 0.5rem; }
.intro-guide li::marker { font-weight: 900; color: #ffd23f; }
.intro-guide b { color: #ffd23f; font-weight: 900; }
.intro-guide p { margin: 0.8rem 0 0; color: #fff; }

.intro .btn-xl { font-size: 1.4rem; }
.intro .btn-ghost { color: #fff; border-color: #fff; border-width: 3px; background: rgba(255, 255, 255, 0.08); }
.intro .btn-ghost:hover { background: rgba(255, 255, 255, 0.18); }

@media (max-aspect-ratio: 3 / 2) and (max-height: 820px), (max-width: 600px) and (max-height: 900px) {
  .intro-guide { display: none; }
}

.intro-actions, .hero-actions, .dialog-actions, .sticky-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.intro-pager {
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.7rem;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.intro-pager-btn {
  flex: 0 1 8rem;
  min-height: 3.2rem;
  font-size: 1.05rem;
  border-width: 3px;
}

.intro-pager-label {
  margin: 0;
  min-width: 5.5rem;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

.intro .intro-stage[hidden] { display: none; }

.intro-actions .btn { flex: 1 1 12rem; max-width: 22rem; }
.intro-actions #intro-quick { flex: 1 1 100%; max-width: none; }

.intro-progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
}

.intro-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

/* ── Кнопки ─────────────────────────────────────────────── */
.btn, .chip, .nav-item, .mode-card, .lesson-card, .level-card, .color-card, .promo {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-3);
  text-align: center;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active { transform: translateY(1px); }
.btn-xl { min-height: 4rem; font-size: 1.1rem; padding-inline: 1.6rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-light { background: var(--text); color: var(--bg); }
.btn-light:hover { background: color-mix(in srgb, var(--text) 85%, var(--bg)); }

.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); background: color-mix(in srgb, var(--text) 4%, transparent); }

.btn-quiet { background: color-mix(in srgb, var(--text) 6%, transparent); min-height: 3rem; font-size: 0.9rem; }
.btn-quiet:hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
.btn-quiet[aria-pressed="true"] { border-color: var(--gold); }

.btn-danger { background: transparent; border-color: var(--danger-line); color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger-bg); }

/* ── Оболочка ───────────────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top top"
    "nav main";
}

.topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem clamp(0.9rem, 3vw, 1.75rem);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  min-height: var(--tap);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  background: var(--accent);
}

.brand-mark .piece { width: 78%; height: 78%; }
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 1.15rem; font-weight: 900; letter-spacing: 0.02em; text-transform: uppercase; }
.brand-text small { color: var(--muted); font-weight: 700; font-size: 0.8rem; }

.text-size { display: flex; align-items: center; gap: 0.4rem; }
.text-size-label { color: var(--muted); font-weight: 800; font-size: 0.8rem; margin-right: 0.2rem; }

.chip {
  min-width: 3rem;
  min-height: 3rem;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
  font-size: 0.9rem;
}

.chip-lg { font-size: 1.1rem; }
.chip-xl { font-size: 1.35rem; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.sidenav {
  grid-area: nav;
  position: sticky;
  top: 4.4rem;
  align-self: start;
  padding: 1rem 0.75rem;
}

.sidenav ul { display: grid; gap: 0.35rem; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: var(--tap);
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 1rem;
  text-align: left;
  position: relative;
}

.nav-item:hover { background: var(--surface); color: var(--text); }

.nav-item[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 4px;
  border-radius: 4px;
  background: var(--accent);
}

.nav-icon { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; flex: none; }
.nav-icon .piece { width: 100%; height: 100%; }

main {
  grid-area: main;
  padding: 1.25rem clamp(0.9rem, 3vw, 2rem) 2rem;
  min-width: 0;
}

main:focus { outline: none; }

.screen { max-width: 76rem; }

.screen-head { margin-bottom: 1.25rem; display: grid; gap: 0.35rem; }
.screen-head h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 900; }
.screen-lead { color: var(--muted); font-weight: 700; max-width: 44rem; }

.section-title { font-size: 1.5rem; font-weight: 900; margin: 2rem 0 0.9rem; }
.block-title { font-size: 1.1rem; font-weight: 900; margin-bottom: 0.75rem; }

.alert {
  margin: 0 0 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 800;
  background: var(--danger-bg);
  border: 2px solid var(--danger-line);
  color: var(--danger-ink);
  max-width: 76rem;
}

.foot { margin-top: 2.5rem; color: var(--muted); font-weight: 800; text-align: center; }

/* ── Главная ────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2.25rem);
  align-items: stretch;
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 92%, transparent), color-mix(in srgb, var(--surface) 92%, transparent));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(1rem, 2.5vw, 1.75rem);
  box-shadow: var(--shadow);
}

.hero-media { margin: 0; display: grid; gap: 0.5rem; }

.album-stage {
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  display: grid;
  place-items: center;
}

.album-stage img { width: 100%; height: 100%; object-fit: contain; }

.album-caption { color: var(--muted); font-weight: 700; font-size: 0.85rem; }

.hero-copy { display: flex; flex-direction: column; justify-content: center; gap: 0.6rem; }
.hero-copy h1 { font-size: clamp(2.1rem, 4.6vw, 3.4rem); font-weight: 900; }
.hero-lead { color: var(--muted); font-weight: 700; font-size: 1.05rem; margin: 0.3rem 0 0.8rem; }
.hero-actions .btn { flex: 1 1 13rem; }
.hero-actions #hero-quick { flex: 1 1 100%; }

.album-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }

.resume-list { display: grid; gap: 0.6rem; margin-top: 1.25rem; }
.resume-list:empty { display: none; }

.resume-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--gold);
}

.resume-card strong { font-size: 1.05rem; }
.resume-card span { color: var(--muted); font-weight: 700; display: block; font-size: 0.85rem; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 0.9rem;
}

.mode-card, .lesson-card {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  column-gap: 0.9rem;
  row-gap: 0.25rem;
  align-items: start;
  text-align: left;
  padding: 1.1rem;
  min-height: 7rem;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.mode-card:hover, .lesson-card:hover { border-color: var(--accent); background: var(--surface-2); }

.mode-icon {
  grid-row: span 2;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 14px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
}

.mode-icon .piece { width: 80%; height: 80%; }
.mode-title { font-size: 1.15rem; font-weight: 900; }
.mode-text { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.home-foot { margin-top: 1.25rem; }

/* ── Настройка партии ───────────────────────────────────── */
.setup { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }

.color-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.color-card {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.9rem 0.5rem;
  min-height: 7rem;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
  font-size: 1rem;
}

.color-card .piece { width: 3rem; height: 3rem; }
.color-card .split { display: flex; }
.color-card .split .piece { width: 2.2rem; height: 2.6rem; }

.color-card[aria-pressed="true"], .level-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent) 6%, transparent));
  box-shadow: inset 0 0 0 1px var(--accent);
}

.level-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 0.75rem;
}

.level-card {
  display: grid;
  gap: 0.4rem;
  text-align: left;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.level-card:hover, .color-card:hover { border-color: var(--muted); }
.level-name { font-size: 1.15rem; font-weight: 900; }
.level-text { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.pips { display: flex; gap: 0.3rem; }
.pips i { width: 1.4rem; height: 0.45rem; border-radius: 4px; background: var(--surface-3); }
.pips i.on { background: var(--accent); }

.sticky-actions {
  position: sticky;
  bottom: 0;
  margin-top: 1.5rem;
  padding: 0.9rem 0 calc(0.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 35%);
}

.sticky-actions .btn-primary { flex: 1 1 16rem; max-width: 26rem; }

/* ── Онлайн ─────────────────────────────────────────────── */
.online-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1rem;
}

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

.code-input {
  width: 100%;
  min-height: 4.2rem;
  font: inherit;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
}

.code-input::placeholder { color: color-mix(in srgb, var(--muted) 55%, var(--input-bg)); }
.code-input:focus-visible { border-color: var(--gold); }
.help { color: var(--muted); font-weight: 700; font-size: 0.85rem; margin: 0.5rem 0 1rem; }

/* ── Обучение и задачи ──────────────────────────────────── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
  counter-reset: lesson;
}

.lesson-card { counter-increment: lesson; }

.lesson-card .mode-icon::before {
  content: counter(lesson);
  font-weight: 900;
  font-size: 1.3rem;
}

.lesson-card.is-done { border-color: var(--ok); }
.lesson-card .badge, .lesson-card .done { grid-column: 2; }

.famous-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.famous-card .level-tag {
  grid-column: 2;
  justify-self: start;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--gold);
  border: 2px solid var(--gold);
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
}

.done {
  justify-self: start;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--on-ok);
  background: var(--ok);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
}

.progress {
  height: 0.55rem;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  max-width: 32rem;
  margin-top: 0.4rem;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
}

.puzzle-groups { display: grid; gap: 1.5rem; }
.puzzle-groups .mode-grid { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.puzzle-groups h3 { font-size: 1.2rem; font-weight: 900; margin-bottom: 0.75rem; }

/* ── Партия ─────────────────────────────────────────────── */
.screen-play { max-width: none; }

.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 25rem);
  gap: clamp(1rem, 2.5vw, 2rem);
  align-items: start;
}

.board-col {
  display: grid;
  gap: 0.6rem;
  width: min(100%, calc(100vh - 17rem), 46rem);
  min-width: min(100%, 18rem);
  justify-self: center;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  min-height: 3.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 2px solid transparent;
}

.player-bar.is-turn { border-color: var(--accent); background: var(--surface-2); }

.avatar {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
}

.avatar.w { background: #f2ece0; }
.avatar.b { background: #1b1712; box-shadow: inset 0 0 0 2px #5a4a39; }
.avatar .piece { width: 82%; height: 82%; }

.player-meta { display: grid; line-height: 1.15; min-width: 0; }
.player-meta strong { font-size: 1.05rem; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta small { color: var(--muted); font-weight: 700; font-size: 0.8rem; }

.caps {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  min-width: 0;
}

.caps .piece { width: 1.45rem; height: 1.45rem; margin-left: -0.3rem; }
.caps .adv { margin-left: 0.4rem; font-weight: 900; color: var(--muted); font-size: 0.9rem; }

.turn-pill {
  display: none;
  flex: none;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}

.player-bar.is-turn .turn-pill { display: inline-block; }

.board-frame {
  padding: 0.5rem;
  border-radius: 14px;
  background: var(--frame);
  box-shadow: var(--shadow);
}

.board-layout {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 1.5rem;
}

.board {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.ranks, .files {
  display: grid;
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--frame-ink);
  text-align: center;
}

.ranks { grid-column: 1; grid-row: 1; grid-template-rows: repeat(8, 1fr); align-items: center; }
.files { grid-column: 2; grid-row: 2; grid-template-columns: repeat(8, 1fr); align-items: center; }

.sq {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }

.sq::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sq.last::before { background: rgba(244, 196, 79, 0.5); }
.sq.selected::before { background: rgba(244, 196, 79, 0.85); }
.sq.drop::before { background: rgba(244, 196, 79, 0.7); box-shadow: inset 0 0 0 4px var(--gold); }
.sq.dragging .piece { opacity: 0.28; }

.board.is-dragging { cursor: grabbing; }
.board.is-dragging .sq { cursor: grabbing; }

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.drag-ghost .piece { width: 92%; height: 92%; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35)); }

body.is-piece-drag { cursor: grabbing; user-select: none; }
.sq.hint::before { background: rgba(80, 160, 255, 0.55); box-shadow: inset 0 0 0 4px #1e5fd1; }
.sq.mark::before { box-shadow: inset 0 0 0 5px #1e5fd1; background: rgba(80, 160, 255, 0.25); }
.sq.check::before { background: radial-gradient(circle, rgba(255, 40, 40, 0.95) 0%, rgba(255, 40, 40, 0.6) 45%, rgba(255, 40, 40, 0) 75%); }

.sq[aria-selected="true"]:focus-within,
.board:focus-visible .sq[aria-selected="true"] { box-shadow: inset 0 0 0 4px #0b0d12, inset 0 0 0 7px var(--gold); }

.board:focus-visible { outline: 4px solid var(--gold); outline-offset: 4px; }

.sq .dot, .sq .ring { position: absolute; border-radius: 50%; pointer-events: none; z-index: 1; }
.sq .dot { width: 30%; height: 30%; background: rgba(11, 13, 18, 0.55); }
.sq .ring { width: 88%; height: 88%; border: 0.35rem solid rgba(11, 13, 18, 0.55); }

.piece { position: relative; z-index: 2; width: 88%; height: 88%; }
.piece-img { width: 96%; height: 96%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.piece * { stroke-linejoin: round; stroke-linecap: round; }
.piece.w * { fill: #fffdf7; stroke: #14110c; stroke-width: 2.6px; }
.piece.b * { fill: #17130e; stroke: #f3e6c8; stroke-width: 2.2px; }

.side { display: grid; gap: 0.9rem; align-content: start; }
.side-head { display: grid; gap: 0.25rem; }
.side-head h2 { font-size: 1.6rem; font-weight: 900; }

.status {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 900;
  font-size: 1.2rem;
  text-align: center;
}

.status.check { background: var(--check-bg); color: var(--check-ink); }
.status.think { background: #1e5fd1; color: #fff; }
.status.win { background: var(--ok); color: var(--on-ok); }
.status.wait { background: var(--gold); color: var(--on-gold); }

.code-card {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px dashed var(--gold);
  text-align: center;
}

.code-label { color: var(--muted); font-weight: 800; font-size: 0.85rem; }
.code-card .btn { margin-top: 0.5rem; }

.game-code {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.coach {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 800;
  background: var(--info-bg);
  border-left: 6px solid var(--info-line);
  color: var(--info-ink);
}

.coach.oknote { background: var(--ok-bg); border-left-color: var(--ok); color: var(--ok-ink); }

.toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.toolbar .btn-primary { grid-column: 1 / -1; }

.moves-card {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.moves-scroll { max-height: 16rem; overflow: auto; border-radius: 8px; }

.moves {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.moves th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: left;
  padding: 0.3rem 0.5rem;
}

.moves td { padding: 0.35rem 0.5rem; }
.moves tr:nth-child(even) td { background: color-mix(in srgb, var(--text) 4%, transparent); }
.moves td:first-child { color: var(--muted); width: 2.5rem; }
.moves td.is-last { background: color-mix(in srgb, var(--accent) 28%, transparent) !important; border-radius: 6px; }
.moves-empty { color: var(--muted); font-weight: 700; padding: 0.3rem 0.5rem; }
.moves-empty[hidden] { display: none; }

/* ── Диалоги ────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem;
  width: min(34rem, calc(100% - 1.5rem));
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    display 0.2s allow-discrete,
    overlay 0.2s allow-discrete;
}

dialog[open] { opacity: 1; transform: none; }

@starting-style {
  dialog[open] { opacity: 0; transform: translateY(8px) scale(0.98); }
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0);
  transition: background-color 0.2s ease, display 0.2s allow-discrete, overlay 0.2s allow-discrete;
}

dialog[open]::backdrop { background: rgba(0, 0, 0, 0.7); }

@starting-style {
  dialog[open]::backdrop { background: rgba(0, 0, 0, 0); }
}

dialog h2 { font-size: 1.6rem; font-weight: 900; margin-bottom: 0.6rem; }
dialog p { color: var(--muted); font-weight: 700; margin-bottom: 1.1rem; }
.dialog-actions .btn { flex: 1 1 10rem; }

.result-mark {
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 16px;
  background: var(--accent);
  margin-bottom: 0.9rem;
}

.result-mark .piece { width: 80%; height: 80%; }
.result-text { font-size: 1.15rem; color: var(--text) !important; }

.promo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.promo {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  min-height: 7rem;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--sq-light);
  color: #14110c;
  font-weight: 900;
  font-size: 1.05rem;
  padding: 0.6rem;
}

.promo:hover { border-color: var(--accent); }
.promo .piece { width: 3.6rem; height: 3.6rem; }

.old-browser {
  position: relative;
  z-index: 70;
  margin: 1rem;
  padding: 1rem;
  background: var(--gold);
  color: #111;
  border-radius: var(--radius-sm);
  font-weight: 800;
}

/* ── Цветовые схемы ─────────────────────────────────────── */
.chip-theme { padding-inline: 0.8rem; display: inline-flex; align-items: center; gap: 0.45rem; }
.chip-theme .dots { display: inline-flex; }
.chip-theme .dots i {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 2px solid var(--text);
  margin-left: -0.25rem;
}
.chip-theme .dots i:nth-child(1) { background: #000; margin-left: 0; }
.chip-theme .dots i:nth-child(2) { background: #fff; }
.chip-theme .dots i:nth-child(3) { background: #ffe600; }

.theme-dialog { width: min(44rem, calc(100% - 1.5rem)); }
.theme-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }

.theme-card {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.9rem;
  align-items: center;
  text-align: left;
  padding: 0.8rem;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.theme-card:hover { border-color: var(--muted); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.theme-card[aria-pressed="true"] .theme-name::after { content: " ✓"; }

.theme-swatch {
  grid-row: span 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 4.6rem;
  height: 4.6rem;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--p-text);
  background: var(--p-bg);
}

.theme-swatch b {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--p-text);
  font-weight: 900;
  font-size: 1.25rem;
  border-bottom: 4px solid var(--p-accent);
}

.theme-swatch i:nth-of-type(1) { background: var(--p-light); }
.theme-swatch i:nth-of-type(2) { background: var(--p-dark); }
.theme-dialog { max-height: calc(100dvh - 1.5rem); overflow-y: auto; }
.theme-dialog .block-title { margin-top: 0.25rem; }
#look-save { margin: -0.35rem 0 1.25rem; }

.look-card {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.85rem;
  align-items: center;
  text-align: left;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.look-card:hover { border-color: var(--muted); }
.look-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.look-card[aria-pressed="true"] .theme-name::after { content: " ✓"; }
.look-card .theme-name, .look-card .theme-text { overflow-wrap: break-word; }
.look-preview {
  grid-row: span 2;
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1.5rem 1fr;
  background: var(--p-bg);
  color: var(--p-text);
}

.look-preview b {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  font-weight: 900;
}

.look-preview .sq { border: 0; }

.piece-card {
  display: grid;
  grid-template-columns: 4.85rem minmax(0, 1fr);
  column-gap: 0.9rem;
  align-items: center;
  text-align: left;
  padding: 0.7rem;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.piece-card:hover { border-color: var(--muted); }
.piece-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.piece-card[aria-pressed="true"] .theme-name::after { content: " ✓"; }

.piece-preview {
  grid-row: span 2;
  display: grid;
  grid-template-columns: repeat(2, 2.3rem);
  grid-template-rows: repeat(2, 2.3rem);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--line);
}

.piece-preview .sq { cursor: inherit; }
.piece-card .theme-name, .piece-card .theme-text { overflow-wrap: break-word; }

@media (max-width: 520px) {
  .piece-card { grid-template-columns: minmax(0, 1fr); row-gap: 0.35rem; }
  .piece-preview { grid-row: auto; justify-self: start; margin-bottom: 0.2rem; }
}
.piece-preview .piece { width: 92%; height: 92%; }
.piece-credits { margin: 0.75rem 0 1.25rem !important; font-size: 0.8rem; }
.piece-credits a { color: var(--text); }

.theme-name { font-size: 1.15rem; font-weight: 900; }
.theme-text { color: var(--muted); font-weight: 700; font-size: 0.85rem; }

/* ── Скачать ────────────────────────────────────────────── */
.download-hero { display: grid; gap: 0.75rem; justify-items: start; margin-bottom: 1.5rem; }
.download-size { color: var(--muted); font-weight: 800; }
.os-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 1rem; }
.os-grid ol { margin: 0.5rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.45rem; font-weight: 700; }
.os-grid code, .download-note code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  font-weight: 800;
  background: var(--surface-3);
  padding: 0.05rem 0.35rem;
  border-radius: 6px;
}
.download-note { margin-top: 1.25rem; color: var(--muted); font-weight: 700; max-width: 52rem; }

/* ── Адаптивность ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .play { grid-template-columns: minmax(0, 1fr); }
  .board-col { width: min(100%, 40rem); }
  .side { max-width: 40rem; width: 100%; justify-self: center; }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "main";
  }

  .sidenav {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }

  .sidenav ul { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.2rem; }

  .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.1rem;
    font-size: min(0.72rem, 2.65vw);
    text-align: center;
  }

  .nav-item > span:last-child { max-width: 100%; overflow: hidden; text-overflow: clip; }

  .nav-item[aria-current="page"]::before {
    left: 25%;
    right: 25%;
    top: 0;
    bottom: auto;
    width: auto;
    height: 4px;
  }

  main { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
  .sticky-actions { bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .text-size-label, .brand-text small { display: none; }
}

@media (max-width: 520px) {
  .topbar { gap: 0.5rem; }
  .brand-text { display: none; }
  .chip { min-width: 2.75rem; min-height: 2.75rem; }
  .theme-chip-text { display: none; }
  .chip-theme { padding-inline: 0.6rem; }
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .color-row { gap: 0.5rem; }
  .player-meta small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .intro.is-closing { opacity: 1; }
  dialog, dialog[open] { transform: none; }
}

@media (forced-colors: active) {
  .sq { border: 1px solid CanvasText; }
  .btn, .mode-card, .level-card, .color-card, .status, .player-bar { border: 2px solid CanvasText; }
  .player-bar.is-turn { outline: 3px solid Highlight; }
}

/* ── Партия: доска на весь экран (Lenovo V570 1366×768 и ниже) ── */
body[data-screen="play"] {
  overflow: clip;
  block-size: 100vh;
  block-size: 100dvh;
}

body[data-screen="play"] .bg {
  opacity: 0;
  pointer-events: none;
}

body[data-screen="play"] .shell {
  min-block-size: 0;
  block-size: 100%;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top"
    "main";
}

body[data-screen="play"] .sidenav,
body[data-screen="play"] .foot,
body[data-screen="play"] .brand-text,
body[data-screen="play"] .text-size-label,
body[data-screen="play"] .theme-chip-text,
body[data-screen="play"] .moves-card,
body[data-screen="play"] .side-head,
body[data-screen="play"] .caps,
body[data-screen="play"] .player-meta small {
  display: none;
}

body[data-screen="play"] .topbar {
  padding-block: 0.12rem;
  padding-inline: 0.4rem;
  gap: 0.3rem;
}

body[data-screen="play"] .chip {
  min-inline-size: 2.2rem;
  min-block-size: 2.2rem;
}

body[data-screen="play"] .brand-mark {
  width: 1.85rem;
  height: 1.85rem;
}

body[data-screen="play"] main {
  padding: 0.15rem 0.35rem 0.2rem;
  min-block-size: 0;
  overflow: clip;
  display: flex;
  flex-direction: column;
}

body[data-screen="play"] #alert {
  flex: none;
  margin-block-end: 0.25rem;
}

body[data-screen="play"] .screen-play {
  flex: 1 1 0;
  min-block-size: 0;
  display: flex;
  max-inline-size: none;
}

body[data-screen="play"] .play {
  flex: 1 1 0;
  min-block-size: 0;
  inline-size: 100%;
  grid-template-columns: max-content minmax(10.5rem, 13.5rem);
  grid-template-rows: minmax(0, 1fr);
  justify-content: start;
  gap: 0.45rem;
  align-items: stretch;
}

body[data-screen="play"] .play:has(#code-card:not([hidden])) {
  grid-template-columns: max-content minmax(12rem, 16rem);
}

body[data-screen="play"] .board-col {
  display: flex;
  flex-direction: column;
  inline-size: auto;
  block-size: 100%;
  max-inline-size: none;
  min-inline-size: 0;
  min-block-size: 0;
  aspect-ratio: 1;
  justify-self: start;
  gap: 0;
}

body[data-screen="play"] .player-bar {
  display: none;
}

body[data-screen="play"] .avatar {
  width: 1.55rem;
  height: 1.55rem;
}

body[data-screen="play"] .player-meta strong {
  font-size: 0.85rem;
}

body[data-screen="play"] .turn-pill {
  font-size: 0.62rem;
  padding: 0.12rem 0.4rem;
}

body[data-screen="play"] .board-frame {
  flex: 1 1 0;
  min-block-size: 0;
  padding: 0.12rem;
  display: grid;
  place-items: center;
  overflow: clip;
  container-type: size;
  container-name: board-stage;
}

body[data-screen="play"] .board-layout {
  aspect-ratio: 1;
  inline-size: 100%;
  block-size: 100%;
}

body[data-screen="play"] .board-layout {
  grid-template-columns: 1.1rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 1.1rem;
}

body[data-screen="play"] .board {
  inline-size: auto;
  block-size: 100%;
  max-inline-size: 100%;
}

body[data-screen="play"] .ranks,
body[data-screen="play"] .files {
  font-size: 0.72rem;
}

body[data-screen="play"] .side {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-inline-size: none;
  inline-size: auto;
  min-inline-size: 0;
  min-block-size: 0;
  overflow: auto;
}

body[data-screen="play"] .status {
  font-size: 0.95rem;
  padding: 0.35rem 0.5rem;
  text-align: start;
}

body[data-screen="play"] .toolbar {
  display: flex;
  flex-direction: column;
  grid-template-columns: unset;
  gap: 0.28rem;
}

body[data-screen="play"] .toolbar .btn {
  min-block-size: 2.35rem;
  font-size: 0.92rem;
  width: 100%;
}

body[data-screen="play"] .code-card {
  padding: 0.4rem 0.5rem;
}

body[data-screen="play"] .game-code {
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
}

body[data-screen="play"] .coach {
  padding: 0.4rem 0.55rem;
  font-size: 0.95rem;
}

@media (max-height: 800px) {
  body[data-screen="play"] .player-meta {
    display: none;
  }

  body[data-screen="play"] .player-bar {
    justify-content: space-between;
  }
}

@media (max-width: 860px) {
  body[data-screen="play"] .play,
  body[data-screen="play"] .play:has(#code-card:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    justify-content: stretch;
  }

  body[data-screen="play"] .board-col {
    inline-size: 100%;
    block-size: 100%;
    aspect-ratio: unset;
    justify-self: stretch;
  }

  body[data-screen="play"] .board-layout {
    inline-size: min(100%, calc(100dvh - 12rem));
    block-size: auto;
    max-block-size: 100%;
  }

  body[data-screen="play"] .side {
    inline-size: 100%;
    max-block-size: 28vh;
  }

  body[data-screen="play"] .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  body[data-screen="play"] .toolbar .btn {
    width: auto;
    flex: 1 1 7rem;
  }
}
