/* StillChess: one stylesheet, no framework, no web fonts. Calm by design:
   nothing in here animates or transitions, there is one accent colour, and
   the pieces keep high contrast on every board colour. */
:root {
  color-scheme: light dark;
  --bg: #edf0ee;
  --panel: #f7f8f6;
  --text: #1e2422;
  --muted: #56605c;
  --line: #d3d9d5;
  --accent: #335f7a;
  --accent-ink: #ffffff;
  --danger: #8f3a30;
  --focus: #1f6fa8;
  --font: Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", "Segoe UI", system-ui, sans-serif;
  /* the board */
  --light: #dfe6ea;
  --dark: #9cb0bc;
  --coord: #3f4d55;
  --dot: rgb(24 34 40 / 34%);
  --hl: rgb(51 95 122 / 24%);
  --ink-w: #fdfdfb;
  --ink-b: #171c1f;
}
.play:has([value=moss]:checked) .board { --light: #e3e7da; --dark: #a5af93; --coord: #46503a; }
.play:has([value=stone]:checked) .board { --light: #e7e3dd; --dark: #aca397; --coord: #524a40; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191b;
    --panel: #1b2124;
    --text: #e2e7e5;
    --muted: #a0aba7;
    --line: #2d363a;
    --accent: #93b8cf;
    --accent-ink: #101a21;
    --danger: #e3a096;
    --focus: #9fd0f0;
    /* a dimmer board, the same piece inks */
    --light: #bcc7ce;
    --dark: #7d93a0;
    --coord: #223038;
    --hl: rgb(20 50 70 / 30%);
  }
  .play:has([value=moss]:checked) .board { --light: #c2c8b8; --dark: #87917a; --coord: #2b3322; }
  .play:has([value=stone]:checked) .board { --light: #c8c3bb; --dark: #8f877c; --coord: #352e26; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 17px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
}

main {
  flex: 1;
  width: 100%;
  max-width: 66rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

a { color: var(--accent); text-underline-offset: 0.18em; }
h1, h2 { font-weight: 500; line-height: 1.2; }
h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); margin: 0.3em 0 0.4em; letter-spacing: -0.015em; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }
p { max-width: 38em; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--panel); padding: 0.5rem 1rem; z-index: 1; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

/* Header and footer */
.top, .foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  width: 100%;
  max-width: 66rem;
  margin: 0 auto;
  padding: 0.8rem 1rem;
}
.top nav, .foot nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.1rem; }
.top nav a { color: var(--text); text-decoration: none; padding: 0.5rem 0.1rem; }
.top nav a[aria-current] { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.mark { color: var(--accent); font-size: 1.4rem; line-height: 1; }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.foot p { margin: 0; }
.foot a { color: var(--muted); }
.langs { display: inline-flex; gap: 0.4rem; text-transform: uppercase; }
.langs a[aria-current] { color: var(--text); font-weight: 600; text-decoration: none; }

/* Buttons and forms */
button, .button {
  display: inline-block;
  min-height: 2.75rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  cursor: pointer;
}
.ghost, .button.ghost { background: transparent; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--muted); font-weight: 400; text-decoration: underline; }
.button[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.inline { display: inline; margin: 0; }

label { display: block; font-weight: 600; margin: 0.9rem 0 0.35rem; }
input, textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
textarea { resize: vertical; min-height: 6rem; }
.form button { margin-top: 1.1rem; }
label.check { display: flex; align-items: center; gap: 0.6rem; font-weight: 400; margin: 0.2rem 0; min-height: 2.75rem; }
label.check input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0.6rem 0 0; }
legend { font-weight: 600; padding: 0; }

/* Layout pieces */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.narrow { max-width: 36rem; margin: 0 auto; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; align-items: center; gap: 0.6rem 1rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); font-weight: 600; margin: 0.4rem 0; }
[hidden] { display: none !important; }

/* Home */
.hero { padding: 2rem 0 0.5rem; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); font-weight: 400; }
.lead { font-size: 1.2rem; color: var(--muted); }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.points { display: grid; gap: 0.5rem 2rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin: 2rem 0 1rem; border-top: 1px solid var(--line); }
.points h2 { margin-top: 1.2rem; }
.points p { margin: 0; color: var(--muted); }

/* The board page */
.play { display: grid; gap: 1rem 2rem; grid-template-columns: minmax(0, 38rem) minmax(15rem, 1fr); align-items: start; }
@media (max-width: 54rem) { .play { grid-template-columns: minmax(0, 1fr); } }
.status { font-size: 1.15rem; margin: 0 0 0.6rem; min-height: 1.6em; }

.board {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  max-width: min(38rem, 78vh);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  container-type: inline-size;
}
.board.flipped { flex-direction: row-reverse; flex-wrap: wrap-reverse; }
.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 12.5%;
  aspect-ratio: 1;
  font-size: clamp(1.5rem, 9.5vw, 3.4rem);
  font-size: 9.6cqi;
  line-height: 1;
  font-family: "DejaVu Sans", "Segoe UI Symbol", "Apple Symbols", var(--font);
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.sq.l { background-color: var(--light); }
.sq.d { background-color: var(--dark); }
.sq.w { color: var(--ink-w); -webkit-text-stroke: 1.2px var(--ink-b); }
.sq.b { color: var(--ink-b); }
/* Last move, legal targets (a dot; a ring around a capture), selection, check. */
.sq.last { background-image: linear-gradient(var(--hl), var(--hl)); }
.sq.t { background-image: radial-gradient(circle, var(--dot) 0 15%, transparent 16%); }
.sq.t.w, .sq.t.b { background-image: radial-gradient(circle, transparent 0 66%, var(--dot) 67%); }
.sq.sel { box-shadow: inset 0 0 0 0.22rem var(--accent); }
.sq.ck { box-shadow: inset 0 0 0 0.22rem var(--danger); }
.sq.sel.ck { box-shadow: inset 0 0 0 0.22rem var(--accent), inset 0 0 0 0.44rem var(--danger); }
.sq:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; z-index: 1; }
.play:has([name=dots]:not(:checked)) .board .sq.t { background-image: none; }
.play:has([name=dots]:not(:checked)) .board .sq.t.last { background-image: linear-gradient(var(--hl), var(--hl)); }
.play:has([name=last]:not(:checked)) .board .sq.last { background-image: none; }
.play:has([name=last]:not(:checked)) .board .sq.t.last { background-image: radial-gradient(circle, var(--dot) 0 15%, transparent 16%); }
.play:has([name=last]:not(:checked)):has([name=dots]:not(:checked)) .board .sq.t.last { background-image: none; }

/* Coordinates on the edges the player sees: ranks left, files at the bottom. */
.sq::before, .sq::after {
  position: absolute;
  font: 600 0.72rem/1 var(--font);
  -webkit-text-stroke: 0;
  color: var(--coord);
}
.sq::before { top: 0.2rem; left: 0.25rem; }
.sq::after { bottom: 0.2rem; right: 0.25rem; }
.board:not(.flipped) [data-sq^="a"]::before, .board.flipped [data-sq^="h"]::before { content: attr(data-r); }
.board:not(.flipped) [data-sq$="1"]::after, .board.flipped [data-sq$="8"]::after { content: attr(data-f); }
.play:has([name=coords]:not(:checked)) .board .sq::before, .play:has([name=coords]:not(:checked)) .board .sq::after { content: none; }

.promote { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.8rem; }
.promote p { width: 100%; margin: 0; }
.promote span { font-size: 1.4rem; line-height: 1; }

.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.acts .button { text-align: center; padding-inline: 0.5rem; }
.moves { margin: 0; padding-left: 2.2rem; font-variant-numeric: tabular-nums; }
details { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
summary { cursor: pointer; font-weight: 600; min-height: 2.2rem; }
.pgn { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85rem; margin: 0.5rem 0 0; }

/* The analysis: a still bar (White's share from the left), the score and
   the best line, and the labels as words with a mark, never colour alone. */
.analysis { margin-top: 0.8rem; max-width: min(38rem, 78vh); }
.bar {
  display: block;
  width: 100%;
  height: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--ink-b);
  -webkit-appearance: none;
  appearance: none;
}
.bar::-webkit-meter-bar { background: var(--ink-b); border: 0; border-radius: 3px; height: 100%; }
.bar::-webkit-meter-optimum-value { background: var(--ink-w); }
.bar::-moz-meter-bar { background: var(--ink-w); }
.score { margin: 0.4rem 0 0; font-variant-numeric: tabular-nums; }
.analysis .small { margin: 0.2rem 0 0; }
.labels, .summary, .rows { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.rows li { padding: 0.15rem 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.level { margin-top: 0.4rem; }
.level .row { flex-wrap: nowrap; }
.level select { flex: 1; }

/* Games */
.games { list-style: none; padding: 0; margin: 0; }
.game { border-top: 1px solid var(--line); padding: 0.6rem 0; }
.game-title { margin: 0 0 0.3rem; }

/* Account, status, legal */
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #3f8a66; margin-right: 0.3rem; }
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 1.8rem; }
.prose code { font-size: 0.9em; background: var(--panel); padding: 0.1em 0.35em; border-radius: 4px; }
.prose li + li { margin-top: 0.3rem; }
