/* Inner pages (play, games, rules): the same device, laid out fluidly instead of in comp pixels. */

.page { --u: clamp(0.62px, 0.075vw + 0.4px, 1px); max-width: 1500px; margin: 0 auto; padding: calc(18 * var(--u)) clamp(10px, 2.5vw, 40px) 40px; }
.page .topbar { position: relative; display: flex; align-items: baseline; gap: 24px; height: auto; padding: 10px 0 22px; }
.page .topbar > * { position: static; }
.page .wordmark { position: static; font-size: clamp(20px, 2.2vw, 34px); color: var(--silk); text-decoration: none; letter-spacing: 0.08em; white-space: nowrap; }
.page .wordmark span { font-size: 0.72em; letter-spacing: 0.06em; }
.page .top-rule { flex: 1; height: 2px; background: var(--silk-dim); min-width: 20px; }
.page .nav { display: flex; gap: clamp(14px, 2.4vw, 40px); }
.page .nav a { color: var(--silk); text-decoration: none; font-size: clamp(15px, 1.5vw, 24px); letter-spacing: 0.04em; }
.page .nav a[aria-current="page"] { color: #f1e6cf; text-decoration: underline; }
.page .nav a:hover { color: #f1e6cf; }

/* ---------- play ---------- */
.play { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr); gap: clamp(14px, 2vw, 28px); align-items: start; }
.board-well { padding: clamp(8px, 1vw, 14px); border-radius: 12px; }
.board-frame { position: relative; aspect-ratio: 1; border: 4px solid var(--cream-ink); background: #e8dfc7; padding: 5px; border-radius: 3px; }
.board-frame .coords-host { position: relative; width: 100%; height: 100%; }
.side { display: grid; gap: clamp(12px, 1.4vw, 20px); }

.clocks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
.clock { position: relative; padding: 12px 14px 10px; border-radius: 6px; min-height: 104px; }
.clock h3 { margin: 0 0 6px; font: 400 clamp(14px, 1.2vw, 18px)/1 var(--f-silk); letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(31, 42, 26, 0.75); }
.clock .digits { display: block; font: 400 clamp(30px, 2.8vw, 44px)/1 var(--f-key); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.clock[data-active="true"] .digits { color: var(--lcd-ink); }
.clock[data-active="false"] .digits { color: rgba(31, 42, 26, 0.38); }
.clock[data-low="true"][data-active="true"] .digits { animation: led-blink 1s steps(1) infinite; }
.clock .flag { position: absolute; right: 12px; top: 12px; }

.thinking { padding: 10px; }
.thinking .lcd-glass { position: relative; border-radius: 6px; padding: 12px 14px; min-height: 250px; }
.thinking .status { display: flex; justify-content: space-between; gap: 12px; font: 600 clamp(18px, 1.5vw, 24px)/1.1 var(--f-lcd); letter-spacing: 0.05em; }
.thinking .status .muted { color: rgba(31, 42, 26, 0.6); }
.thinking .tree-svg { height: 210px; margin-top: 6px; }
.thinking .tree-list { list-style: none; margin: 8px 0 0; padding: 0; display: none; font-size: 22px; }
.thinking .tree-list li { color: var(--lcd-ghost); padding-left: 0; }
.thinking .tree-list li.pv { color: var(--lcd-ink); }
.thinking .tree-list li.d2 { padding-left: 1.2em; } .thinking .tree-list li.d3 { padding-left: 2.4em; }
.thinking .tree-list li.root { color: rgba(31, 42, 26, 0.62); }

.tape-wrap { padding: 12px 14px 14px; border-radius: 10px; }
.tape-wrap h3, .controls h3, .setup h3 { margin: 0 0 10px; font: 400 clamp(15px, 1.3vw, 20px)/1 var(--f-silk); letter-spacing: 0.06em; color: var(--cream-ink); }
.tape { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; scroll-behavior: smooth; scrollbar-color: var(--cream-ink-2) transparent; min-height: 54px; }
.tape:empty::before { content: "ХОДОВ ПОКА НЕТ"; color: var(--cream-ink-2); font-size: 16px; align-self: center; }
.tape .mv { flex: none; display: grid; justify-items: center; gap: 4px; }
.tape .mv small { font-size: 12px; color: var(--cream-ink-2); }
.tape .capkey { min-width: 64px; height: 34px; padding: 0 8px; font: 400 16px/1 var(--f-silk); letter-spacing: 0.02em; }
.tape .mv.bot .capkey { background: linear-gradient(#5b544a, #3e3832); color: #efe4cb; box-shadow: 0 3px 0 #211d19, inset 0 1px 0 #7a7166; }
.tape .mv.now .capkey { outline: 3px solid var(--led-on); outline-offset: 2px; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; }
.btn-silk { appearance: none; font: 400 clamp(15px, 1.2vw, 18px)/1 var(--f-silk); letter-spacing: 0.04em; padding: 12px 16px; cursor: pointer; }
.btn-silk.capkey { display: inline-flex; }
.btn-silk.dark { background: linear-gradient(#5b544a, #3e3832); color: #efe4cb; box-shadow: 0 3px 0 #211d19, inset 0 1px 0 #7a7166; }
.btn-silk:active { transform: translateY(2px); box-shadow: 0 1px 0 #8e8167; }
.btn-silk:disabled { opacity: 0.45; cursor: not-allowed; }
.controls .who { margin-left: auto; color: var(--cream-ink-2); font-size: 15px; }

/* setup panel */
.setup { padding: clamp(14px, 1.6vw, 22px); border-radius: 10px; display: grid; gap: 18px; }
.setup fieldset { border: 0; margin: 0; padding: 0; }
.setup legend { padding: 0; margin-bottom: 10px; font: 400 clamp(15px, 1.3vw, 20px)/1 var(--f-silk); letter-spacing: 0.06em; color: var(--cream-ink); }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: inline-grid; place-items: center; min-width: 74px; height: 44px; padding: 0 12px; font: 400 18px/1 var(--f-silk); }
.choice input:checked + span { background: linear-gradient(#5b544a, #3e3832); color: #efe4cb; box-shadow: 0 1px 0 #211d19, inset 0 2px 4px rgba(0, 0, 0, 0.5); transform: translateY(2px); }
.choice input:focus-visible + span { outline: 3px solid var(--led-on); outline-offset: 3px; }
.choice small { display: block; font-size: 11px; opacity: 0.7; margin-top: 2px; }
.setup .setup-title { margin: 0; padding-bottom: 12px; border-bottom: 2px solid var(--cream-ink); font: 400 clamp(18px, 1.6vw, 24px)/1 var(--f-silk); letter-spacing: 0.06em; color: var(--cream-ink); }
.setup .start-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid rgba(60, 50, 38, 0.25); }
.setup .note #change-nick { margin-left: 0.6em; }
.setup .key { padding: 14px 26px; }
.setup .key span { font: 400 24px/1 var(--f-key); letter-spacing: 0; }
.setup .note { margin: 0; color: var(--cream-ink-2); font-size: 15px; line-height: 1.5; max-width: 46ch; }
.setup .note a { color: var(--cream-ink); }
.error-line { margin: 0; background: var(--cream-ink); color: #ffd9c9; font-size: 15px; padding: 8px 12px; border-radius: 4px; }

/* end of game banner on the LCD */
#lcd.has-verdict > :not(.verdict) { display: none; }
.verdict { display: grid; min-height: 230px; place-content: center; text-align: center; gap: 12px; padding: 16px;
  background: var(--lcd) url("/assets/plates/lcd-ground.png"); border-radius: 6px; }
.verdict h2 { margin: 0; font: 600 clamp(40px, 4vw, 64px)/0.95 var(--f-lcd); font-variation-settings: "ELSH" 12; letter-spacing: 0.03em; }
.verdict p { margin: 0; font: 600 clamp(18px, 1.5vw, 24px)/1.2 var(--f-lcd); }
.verdict .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.verdict .actions a, .verdict .actions button { text-decoration: none; }

/* promotion picker */
.promo { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; background: rgba(22, 20, 18, 0.55); }
.promo div { display: flex; gap: 10px; padding: 14px; border-radius: 10px; }
.promo button { width: 72px; height: 72px; padding: 6px; }
.promo img { width: 100%; image-rendering: pixelated; }

/* ---------- chessground skin ---------- */
.cg-wrap { width: 100%; height: 100%; }
cg-board { background-color: #b3aa94;
  background-image: conic-gradient(#e6dcc3 25%, transparent 0 50%, #e6dcc3 0 75%, transparent 0);
  background-size: 25% 25%; }
cg-board square.last-move { background-color: rgba(194, 75, 41, 0.38); }
cg-board square.selected { background-color: rgba(31, 42, 26, 0.35); }
cg-board square.move-dest { background: radial-gradient(rgba(31, 42, 26, 0.55) 18%, transparent 20%); }
cg-board square.move-dest:hover { background: rgba(31, 42, 26, 0.25); }
cg-board square.oc.move-dest { background: radial-gradient(transparent 0 72%, rgba(31, 42, 26, 0.55) 74%); }
cg-board square.check { background: radial-gradient(rgba(255, 59, 34, 0.9) 0, rgba(255, 59, 34, 0.35) 45%, transparent 70%); }
cg-board piece { image-rendering: auto; }
coords { font-family: var(--f-silk); font-size: 13px; }
coords.ranks { color: var(--cream-ink); }
coords coord { color: var(--cream-ink-2) !important; }
.cg-wrap piece.pawn.white { background-image: url("/pieces/set/wP.webp"); }
.cg-wrap piece.knight.white { background-image: url("/pieces/set/wN.webp"); }
.cg-wrap piece.bishop.white { background-image: url("/pieces/set/wB.webp"); }
.cg-wrap piece.rook.white { background-image: url("/pieces/set/wR.webp"); }
.cg-wrap piece.queen.white { background-image: url("/pieces/set/wQ.webp"); }
.cg-wrap piece.king.white { background-image: url("/pieces/set/wK.webp"); }
.cg-wrap piece.pawn.black { background-image: url("/pieces/set/bP.webp"); }
.cg-wrap piece.knight.black { background-image: url("/pieces/set/bN.webp"); }
.cg-wrap piece.bishop.black { background-image: url("/pieces/set/bB.webp"); }
.cg-wrap piece.rook.black { background-image: url("/pieces/set/bR.webp"); }
.cg-wrap piece.queen.black { background-image: url("/pieces/set/bQ.webp"); }
.cg-wrap piece.king.black { background-image: url("/pieces/set/bK.webp"); }

/* ---------- archive / rules ---------- */
.sheet { padding: clamp(16px, 2vw, 28px); border-radius: 10px; }
.sheet h1 { margin: 0 0 14px; font: 400 clamp(26px, 2.6vw, 40px)/1.1 var(--f-silk); letter-spacing: 0.04em; }
.sheet h2 { margin: 28px 0 10px; font: 400 clamp(20px, 1.8vw, 28px)/1.1 var(--f-silk); letter-spacing: 0.04em; }
.sheet p, .sheet li { font-size: clamp(15px, 1.2vw, 18px); line-height: 1.6; max-width: 70ch; color: var(--cream-ink-2); }
.sheet strong { color: var(--cream-ink); font-weight: 400; }
.games-table { width: 100%; border-collapse: collapse; font-size: clamp(14px, 1.1vw, 17px); }
.games-table th { text-align: left; font-weight: 400; color: var(--cream-ink-2); border-bottom: 2px solid var(--cream-ink); padding: 8px 10px; }
.games-table td { border-bottom: 1px solid rgba(42, 38, 34, 0.2); padding: 9px 10px; font-variant-numeric: tabular-nums; }
.games-table tr:hover td { background: rgba(42, 38, 34, 0.06); }
.games-table a { color: var(--cream-ink); }
.res-human { color: #9c2b10; } .res-draw { color: var(--cream-ink); }
.empty { color: var(--cream-ink-2); }

@media (max-width: 900px) {
  .play { grid-template-columns: minmax(0, 1fr); }
  .page .topbar { flex-wrap: wrap; row-gap: 10px; }
  .page .top-rule { display: none; }
  .page .wordmark { flex: 1 0 100%; }
  .clock { min-height: 0; }
  .thinking .lcd-glass { padding: 10px 12px; }
  .thinking .tree-svg { display: none; }
  .thinking .tree-list { display: block; }
  .thinking .lcd-glass { min-height: 0; }
  .games-table .hide-sm { display: none; }
}
.sheet sup { font-size: 0.7em; line-height: 0; vertical-align: 0.5em; }
