/* Анги (/class, /class/<id>): your classes, joining and making one, a class's tabs. */
@layer page {
  .cls { max-width: 860px; margin: 0 auto; }
  /* The arena takes the width: a board and its panels for a kid, the boards and the table for the coach. */
  .cls[data-tab='arena'] { max-width: 1280px; }
  /* The game screen's own layout centres itself with auto margins, which in the tab's column would shrink it: it takes the width. */
  .ar-kid { width: 100%; }
  /* With no game on it the board says nobody's turn. */
  .ar-kid[data-idle='true'] .play-status { visibility: hidden; }
  .cls-note { margin: 0; }
  .cls-actions { display: grid; gap: var(--sp-4); }
  .cls-code-input, .cls-name-input { flex: 1 1 8rem; min-width: 0; }
  .cls-code-input { letter-spacing: .08em; text-transform: uppercase; }
  .cls-emoji-input { width: 4.5rem; text-align: center; }
  .cls-emoji { font-size: var(--fs-24); }
  .cls-emoji--big { font-size: var(--fs-36); }
  .cls-head { display: flex; align-items: center; gap: var(--sp-4); }
  .cls-head p { margin: var(--sp-1) 0 0; }
  .cls-name { margin: 0; }
  .cls-code { display: grid; justify-items: center; gap: var(--sp-2); text-align: center; }
  .cls-code__value { color: var(--primary); font-size: var(--fs-36); letter-spacing: .14em; }
  .cls-leave { justify-content: flex-end; }
  .cls-coach-tools { display: grid; gap: var(--sp-4); }
  .cls-code__acts { justify-content: center; }
  .cls-out__title { margin: 0; font-size: var(--fs-16); }
  .cls .list-row { flex-wrap: wrap; }
  .cls-member .list-row__main { flex: 1 1 12rem; min-width: 0; }
  .cls-member .list-row__meta { display: block; }
  .cls-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-inline-start: auto; }
  .cls-dot { display: inline-block; width: 8px; height: 8px; margin-inline-end: var(--sp-1); border-radius: var(--r-pill); background: var(--good); vertical-align: middle; }
  .cls-pw { font-size: var(--fs-36); letter-spacing: .18em; text-align: center; }
  /* The join code for the classroom board: the whole screen, as big as it goes. */
  .cls-board { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: var(--sp-6); padding: var(--sp-6); background: var(--surface); color: var(--text); font-size: var(--fs-24); text-align: center; }
  .cls-board[hidden] { display: none; }
  .cls-board__code { color: var(--primary); font-size: clamp(64px, 16vw, 220px); letter-spacing: .12em; line-height: 1; }
  /* Даалгавар: the list (a kid's status, or how many kids are done) and the coach's form. */
  .tk-bar { justify-content: flex-end; }
  .tk-row { align-items: center; }
  .tk-row__icon { flex: none; width: 22px; height: 22px; color: var(--primary); }
  .tk-row .list-row__main { flex: 1 1 14rem; min-width: 0; color: inherit; text-decoration: none; }
  .tk-row .list-row__meta { display: block; }
  .tk-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-inline-start: auto; }
  /* On the page's surface, not the chip's grey: the status colours keep 4.5:1 there. */
  .tk-status { background: var(--surface); }
  .tk-status[data-status='in_progress'] { border-color: var(--primary); color: var(--primary); }
  .tk-status[data-status='done'] { border-color: var(--good); color: var(--good); }
  .tk-status[data-status='overdue'] { border-color: var(--bad); color: var(--bad); }
  .tk-warn { display: block; color: var(--bad); font-size: var(--fs-13); }
  .tk-done { display: flex; align-items: center; gap: var(--sp-2); margin-inline-start: auto; }
  .tk-meter { position: relative; width: 96px; height: 8px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-2); }
  .tk-meter::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--done, 0%); background: var(--good); }
  .tk-progress { color: var(--muted); font-size: var(--fs-13); white-space: nowrap; }
  .tk-empty { margin: 0; padding: var(--sp-4); }
  .tk-two > .field { flex: 1 1 10rem; }
  .tk-preview { min-height: 1.4em; margin: 0; }
  .tk-due { max-width: 14rem; }
  .tk-form__acts { gap: var(--sp-2); }
  /* An assignment's results: the head, the kids' table and one kid's exercises, side by side on a wide screen. */
  .cls[data-sub='results'] { max-width: 1280px; }
  .tk-back { justify-self: start; }
  .tk-head { gap: var(--sp-2); }
  .tk-head__kind, .tk-head__title { margin: 0; }
  .tk-head__title { font-size: var(--fs-20); }
  .tk-head__chips { gap: var(--sp-2); }
  .tk-hardest { display: flex; align-items: flex-start; gap: var(--sp-2); margin: 0; }
  .tk-hardest[hidden] { display: none; }
  .tk-split { display: grid; gap: var(--sp-4); align-items: start; }
  .tk-table-wrap { overflow-x: auto; }
  .tk-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
  .tk-table th, .tk-table td { padding: var(--sp-2); border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
  .tk-table th { color: var(--muted); white-space: normal; }
  .tk-table tr.is-current { background: var(--surface-2); }
  .tk-kid { min-width: 44px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: var(--fw-bold); text-align: start; cursor: pointer; }
  .tk-flag { min-width: 6rem; color: var(--bad); font-weight: var(--fw-bold); white-space: normal; }
  /* A move as the move list draws it: the piece in front of the square, on the line. */
  .tk-move { white-space: nowrap; }
  .tk-ex { align-items: flex-start; gap: var(--sp-3); }
  .tk-ex__board { flex: none; width: 96px; }
  .tk-ex__main { display: grid; flex: 1 1 8rem; gap: var(--sp-1); min-width: 0; }
  .tk-ex__main p { margin: 0; }
  .tk-mark--ok { color: var(--good); font-weight: var(--fw-heavy); }
  .tk-mark--bad { color: var(--bad); font-weight: var(--fw-heavy); }
  /* One kid's page: the head, the rating's tile (the number, its change, the line), and the sections. */
  .cls[data-sub='kid'] { max-width: 1100px; }
  .cls-member__link { color: inherit; text-decoration: none; }
  .cls-member__link .list-row__title { text-decoration: underline; text-underline-offset: 3px; }
  .kid-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4); }
  .kid-head__who { display: grid; gap: var(--sp-1); min-width: 0; }
  .kid-head__who p, .kid-head__name { margin: 0; }
  .kid-head__name { font-size: var(--fs-20); }
  .kid-head__level { align-items: center; gap: var(--sp-2); }
  .kid-grid { display: grid; gap: var(--sp-4); align-items: start; }
  .kid-grid[hidden] { display: none; }
  .kid-rating { display: flex; align-items: baseline; gap: var(--sp-2); }
  .kid-rating__now { font-size: var(--fs-36); line-height: 1; }
  .kid-rating__delta { font-weight: var(--fw-bold); }
  .kid-rating__delta[data-dir='up'] { color: var(--good); }
  .kid-rating__delta[data-dir='down'] { color: var(--bad); }
  .kid-rating__delta[data-dir='flat'] { color: var(--muted); }
  .kid-rating__from { margin: 0; }
  .kid-spark { width: 100%; max-width: 320px; height: 48px; margin-block: var(--sp-2); overflow: visible; }
  .kid-spark polyline { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
  .kid-spark circle { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
  .kid-count, .kid-empty { margin: 0; padding: var(--sp-3) var(--sp-4); }
  .kid-themes { padding: 0 var(--sp-4) var(--sp-4); }
  .kid-themes .row { gap: var(--sp-2); }
  .kid-themes .field__label { margin: 0; }
  .kid-game__result { margin-inline-start: auto; font-weight: var(--fw-bold); }
  /* Тойм's newest assignments. */
  .cls-tasks__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
  /* Тойм's arena card. */
  .cls-arena { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-4); }
  .cls-arena__icon { width: 28px; height: 28px; color: var(--primary); }
  .cls-arena__text { flex: 1 1 14rem; min-width: 0; }
  .cls-arena__text p { margin: var(--sp-1) 0 0; }
  .cls-arena__title { margin: 0; font-size: var(--fs-18); }
  /* Арена: the coach's bar and the kid's panel. */
  .ar-bar { display: grid; gap: var(--sp-3); }
  .ar-bar__title { margin: 0; font-size: var(--fs-20); }
  .ar-chips { gap: var(--sp-2); }
  .ar-chips:empty { display: none; }
  .ar-bar__acts { align-items: flex-end; gap: var(--sp-3); }
  .ar-tc { min-width: 8rem; }
  .ar-state__title { margin: 0; font-size: var(--fs-18); }
  .ar-state__text { margin: 0; }
  .ar-state__acts { gap: var(--sp-2); }
  .ar-state__acts .btn { flex: 1 1 10rem; }
  /* The result's seconds: a bar that empties as the next game nears. */
  .ar-next { height: 8px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-2); }
  .ar-next__fill { display: block; width: var(--left, 100%); height: 100%; background: var(--primary); transition: width .25s linear; }
  .ar-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-2); text-align: center; }
  .ar-stats b { display: block; font-size: var(--fs-24); }
  .ar-stats span { color: var(--muted); font-size: var(--fs-12); }
  /* The coach's live view: the boards, and beside them the table and who is not playing. */
  .ar-live { display: grid; gap: var(--sp-4); align-items: start; }
  .ar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-3); }
  .ar-grid-empty { margin: 0; padding: var(--sp-4); }
  .ar-game { display: grid; gap: var(--sp-1); padding: var(--sp-2); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
  .ar-game:hover { border-color: var(--line-strong); }
  .ar-game__open { justify-self: start; }
  .ar-game.is-over { opacity: .85; }
  .ar-game__seat { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-width: 0; }
  .ar-game__seat b { overflow: hidden; font-size: var(--fs-13); text-overflow: ellipsis; white-space: nowrap; }
  .ar-game__clock { padding: 0 var(--sp-1); border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-13); }
  .ar-game__clock.is-active { background: var(--primary); color: var(--on-primary); }
  .ar-game__meta { margin: 0; font-size: var(--fs-12); }
  .ar-game__result { margin: 0; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm); background: var(--surface-2); font-weight: var(--fw-heavy); text-align: center; }
  .ar-table-wrap { overflow-x: auto; }
  .ar-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
  .ar-table th, .ar-table td { padding: var(--sp-1) var(--sp-3); border-bottom: 1px solid var(--line); text-align: start; }
  .ar-table .num { text-align: end; }
  .ar-person { align-items: center; }
  .ar-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--line-strong); }
  .ar-person[data-state='waiting'] .ar-dot, .ar-person[data-state='result'] .ar-dot { background: var(--warn); }
  .ar-person[data-state='paused'] .ar-dot { background: var(--muted); }
  /* Ангид харуулах: the table or the boards, large, for the room. */
  .ar-show { position: fixed; inset: 0; z-index: 60; display: grid; align-content: start; gap: var(--sp-5); overflow-y: auto; padding: var(--sp-6); background: var(--surface); color: var(--text); }
  .ar-show[hidden] { display: none; }
  .ar-show__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); }
  .ar-show__title { margin: 0; font-size: clamp(24px, 3vw, 40px); }
  .ar-show__acts { gap: var(--sp-2); }
  .ar-show__acts [aria-pressed='true'] { background: var(--primary); border-color: transparent; color: var(--on-primary); }
  .ar-show__table { width: 100%; border-collapse: collapse; font-size: clamp(20px, 2.6vw, 40px); }
  .ar-show__table th, .ar-show__table td { padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--line); text-align: start; }
  .ar-show__table .num, .ar-show__table td:nth-child(n + 3) { text-align: end; }
  .ar-show__boards .ar-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  /* One board, large: beside the grid on a wide screen, the whole screen on a phone. */
  .ar-focus { position: fixed; inset: 0; z-index: 50; display: grid; align-content: start; gap: var(--sp-3); overflow-y: auto; padding: var(--sp-4); background: var(--surface); box-shadow: var(--shadow-2); }
  .ar-focus[hidden] { display: none; }
  .ar-focus__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
  .ar-focus__title { margin: 0; font-size: var(--fs-18); }
  .ar-focus__board { width: min(100%, 560px); margin-inline: auto; }
  @media (min-width: 700px) {
    .cls-actions, .cls-coach-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kid-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ar-focus { inset: 0 0 0 auto; width: min(100%, 520px); }
  }
  @media (min-width: 1100px) {
    .ar-live { grid-template-columns: minmax(0, 1fr) 320px; }
    .tk-split { grid-template-columns: minmax(0, 1fr) 340px; }
  }
}
