:root {
  --paper: #f2ecda;
  --paper-dark: #e6dec7;
  --ink: #2b2720;
  --ink-soft: #5a5446;
  --serif: "Old Standard TT", "Times New Roman", serif;
  --display: "Playfair Display", Georgia, serif;
  --mono: "Courier Prime", "Courier New", monospace;
}

* { box-sizing: border-box; }
html { background: #d8d0bb; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.65;
}

.paper {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem 2rem 2rem;
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(0,0,0,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.04), transparent 5%, transparent 95%, rgba(0,0,0,.04));
  background-size: 4px 4px, 100% 100%;
  box-shadow: 0 0 30px rgba(0,0,0,.18);
}

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }

/* Masthead */
.masthead { text-align: center; }
.nameplate {
  display: block;
  font-family: "UnifrakturCook", "Old English Text MT", serif;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 1.1;
  margin: .2rem 0;
  text-decoration: none;
}
.nameplate:hover { background: none; color: var(--ink); }
.dateline {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem;
  border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink);
  padding: .2rem .25rem;
  font-family: var(--mono); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
}
.sections {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 2rem;
  border-bottom: 3px solid var(--ink);
  padding: .35rem 0;
  font-family: var(--display); font-weight: 700; font-size: .95rem; text-transform: uppercase; letter-spacing: .12em;
}
.sections a { text-decoration: none; padding: 0 .35rem; }

main { padding-top: 1.5rem; }

/* Headlines */
h1, h2, h3 { font-family: var(--display); font-weight: 900; line-height: 1.12; margin: 0 0 .5rem; }
h1 a, h2 a, h3 a { text-decoration: none; }
.kicker {
  margin: 0 0 .25rem;
  font-family: var(--mono); font-size: 0.9rem; letter-spacing: .12em; text-transform: uppercase;
  color: #8a2a1a;
}
.kicker a { color: inherit; }
.deck { font-style: italic; font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 .5rem; }
.byline {
  font-family: var(--mono); font-size: 0.86rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 .75rem;
}

.rule-head {
  font-size: 1rem; text-transform: uppercase; letter-spacing: .2em; text-align: center;
  border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink);
  padding: .3rem 0; margin: 2rem 0 1.25rem;
}

/* Front page */
.front { display: grid; grid-template-columns: 1.7fr 1fr; gap: 2rem; align-items: start; }
.front .lead { border-right: 1px solid var(--ink); padding-right: 2rem; }
.inside h3 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .12em; border-bottom: 1px solid var(--ink); padding-bottom: .3rem; }
.inside ul { list-style: none; margin: 0; padding: 0; }
.inside li { padding: .55rem 0; border-bottom: 1px dotted var(--ink-soft); font-family: var(--display); font-weight: 700; line-height: 1.25; }
.inside .welcome { font-style: italic; color: var(--ink-soft); margin: .6rem 0 1rem; }
.lead h2 { font-size: clamp(1.9rem, 4.5vw, 3rem); }
.more { font-family: var(--mono); font-size: 0.94rem; text-transform: uppercase; letter-spacing: .08em; }

.stories { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem 0; }
.story { padding: 0 1.25rem; border-left: 1px solid var(--ink); }
.story:nth-child(3n + 1) { border-left: 0; padding-left: 0; }
.story h3 { font-size: 1.3rem; }

/* Article */
.article h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.article > .deck { font-size: 1.3rem; }
.content { border-top: 1px solid var(--ink); padding-top: 1rem; }
.content.columns { column-count: 2; column-gap: 2.25rem; column-rule: 1px solid var(--ink); }
.content p { margin: 0 0 .9rem; text-align: justify; hyphens: auto; }
.content.columns > p:first-of-type::first-letter {
  float: left; font-family: var(--display); font-weight: 900;
  font-size: 4.2rem; line-height: .8; padding: .35rem .5rem 0 0;
}
.content h2, .content h3 {
  font-size: 1.1rem; text-transform: uppercase; letter-spacing: .1em;
  margin-top: 1.2rem; break-after: avoid;
}
.content blockquote {
  margin: 1rem 0; padding: .4rem 1rem;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  font-style: italic; font-size: 1.25rem; text-align: center; break-inside: avoid;
}
.content code { font-family: var(--mono); font-size: 0.9rem; background: var(--paper-dark); padding: 0 .25rem; }
.content pre {
  background: var(--paper-dark); color: var(--ink);
  font-family: var(--mono); font-size: 0.74rem; line-height: 1.4;
  padding: .8rem 1rem; overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  column-span: all; margin: 1rem 0;
}
.content pre code { background: none; padding: 0; }
.content img { max-width: 100%; }

.taglist { list-style: none; padding: 0; max-width: 480px; margin: 0 auto; font-size: 1.2rem; }
.taglist li { display: flex; gap: .5rem; align-items: baseline; }
.taglist .dots { flex: 1; border-bottom: 2px dotted var(--ink); }

.colophon { text-align: center; margin-top: 3rem; border-top: 3px double var(--ink); padding-top: 1rem; font-family: var(--mono); font-size: 0.9rem; text-transform: uppercase; letter-spacing: .1em; }
.colophon p { margin: .5rem 0 0; }

/* ----- Widgets: boxed newspaper features ----- */
.widget {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.35;
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink); outline-offset: 4px;
  padding: 0 1.25rem 1rem;
  margin: 2rem 4px;
  column-span: all;
}
.widget:focus { outline: 2px dashed var(--ink); outline-offset: 4px; }

.w-title {
  margin: 0 -1.25rem .75rem; padding: .25rem 1.25rem;
  background: var(--ink); color: var(--paper);
  font-family: var(--display); font-weight: 900; font-size: .85rem;
  letter-spacing: .25em; text-transform: uppercase; text-align: center;
}
.w-players {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem;
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  border-bottom: 1px solid var(--ink); padding-bottom: .3rem;
}
.w-meta {
  font-family: var(--mono); font-size: 0.86rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); margin: .25rem 0 0;
}
.w-body { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: .6rem; }
.w-board-col { flex: 0 1 400px; min-width: 260px; width: 100%; }
.w-side { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: .75rem; padding-top: 1.2rem; }

.w-controls { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 12px 0; }
.btn {
  font-family: var(--mono); font-size: 0.9rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); background: transparent; cursor: pointer;
  border: 1px solid var(--ink); padding: 0 .65rem; line-height: 1.4;
}
.btn:hover, .btn:focus-visible { background: var(--ink); color: var(--paper); outline: none; }

.w-video { position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--ink); background: #000; }
.w-video iframe, .w-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.w-moves {
  position: relative; max-height: 230px; overflow-y: auto;
  border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink);
  padding: .5rem .1rem;
  font-family: var(--serif); font-size: 1.15rem; line-height: 1.7;
}
.w-moves .mn { font-family: var(--mono); color: var(--ink-soft); }
.w-moves .mv { cursor: pointer; padding: 0 .2rem; font-weight: 700; }
.w-moves .mv:hover { text-decoration: underline; }
.w-moves .mv.on { background: var(--ink); color: var(--paper); }
.w-moves .mv.timed::after { content: "\25B6"; font-size: .55em; vertical-align: super; margin-left: 1px; }
.w-comment {
  font-style: italic; font-size: 1.2rem;
  border-left: 3px solid var(--ink); padding-left: .75rem;
}
.w-comment::first-letter { font-weight: 700; }
.w-hint {
  margin-top: .9rem; padding-top: .3rem; border-top: 1px solid var(--ink);
  font-family: var(--mono); font-size: 0.82rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft);
}

.w-status { font-family: var(--mono); font-size: 0.98rem; letter-spacing: .06em; text-transform: uppercase; min-height: 1.3em; }
.w-status.bad { color: #a3321e; }
.w-status.ok { color: #1f5a2a; font-weight: bold; }
.w-progress { font-family: var(--display); font-weight: 700; letter-spacing: .1em; }
.w-bar { height: .7rem; border: 1px solid var(--ink); background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(0,0,0,.15) 7px 8px); }
.w-bar span { display: block; height: 100%; background: var(--ink); width: 0; transition: width .3s steps(8); }
.w-score { font-family: var(--mono); font-size: 0.9rem; letter-spacing: .06em; color: var(--ink-soft); }

/* ----- Board: a newspaper cutting ----- */
.board {
  --cut: #f4eedd;
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  container-type: inline-size;
  width: calc(100% - 24px); max-width: 400px; aspect-ratio: 1;
  margin: 1.8rem 12px 1.2rem;
  border: 2px solid var(--ink);
  background: var(--cut);
  box-shadow: 0 0 0 9px var(--cut), 0 0 0 10px rgba(0,0,0,.25), 4px 7px 12px rgba(0,0,0,.35);
  outline: 2px dashed var(--ink); outline-offset: 7px;
  transform: rotate(-.7deg);
  color: var(--ink);
  text-shadow: none;
  user-select: none;
}
.board::before {
  content: "\2702"; position: absolute; top: -2.1rem; left: 14px;
  font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif; font-size: 1.3rem; line-height: 1;
}
.widget .board { max-width: none; }
.widget .w-board-col .board { margin-top: 1.9rem; }
.board .sq {
  position: relative; display: flex; align-items: center; justify-content: center;
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", sans-serif;
  font-size: clamp(1.4rem, 7vw, 2.6rem); font-size: 9.5cqw;
  line-height: 1; cursor: pointer; overflow: hidden;
}
.board .light { background: var(--cut); }
.board .dark {
  background-color: #d9d0b7;
  background-image: radial-gradient(circle, rgba(27,25,20,.85) 26%, transparent 30%);
  background-size: 5px 5px;
}
.board .sq[data-f]::after, .board .sq[data-r]::before {
  position: absolute; font-family: var(--mono); font-size: 0.66rem; line-height: 1;
  color: var(--ink); background: var(--cut); padding: 0 2px; pointer-events: none;
}
.board .sq[data-f]::after { content: attr(data-f); right: 1px; bottom: 1px; }
.board .sq[data-r]::before { content: attr(data-r); left: 1px; top: 1px; }
.board .sq span { position: relative; z-index: 1; }
.board .w { color: #fffdf4; text-shadow: 0 0 1px #000, 1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000, 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.board .b { color: #111; text-shadow: 0 0 2px #fffdf4, 1px 0 0 #fffdf4, -1px 0 0 #fffdf4, 0 1px 0 #fffdf4, 0 -1px 0 #fffdf4; }
.board .sq.last { box-shadow: inset 0 0 0 3px #a3321e; }
.board .sq.sel { box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 6px var(--cut); }
.board .sq.hint { box-shadow: inset 0 0 0 4px #a3321e, inset 0 0 0 6px var(--cut); }
.board .sq.bad { box-shadow: inset 0 0 0 4px #a3321e; background-color: #e7b9ad; background-image: none; }
.board .sq.target::after {
  content: ""; position: absolute; width: 26%; height: 26%; border-radius: 50%;
  background: var(--cut); border: 2px solid var(--ink); z-index: 2;
}

@media (max-width: 760px) {
  .paper { padding: 1rem; }
  .front { grid-template-columns: 1fr; }
  .front .lead { border-right: 0; padding-right: 0; }
  .stories { grid-template-columns: 1fr; }
  .story, .story:nth-child(3n + 1) { border-left: 0; padding: 0; border-top: 1px solid var(--ink); padding-top: 1rem; }
  .content.columns { column-count: 1; }
}
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

.archive { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 2.25rem; column-rule: 1px solid var(--ink); }
.archive li { break-inside: avoid; padding: .4rem 0; border-bottom: 1px dotted var(--ink-soft); }
.archive .when { display: block; font-family: var(--mono); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
@media (max-width: 700px) { .archive { columns: 1; } }

.motto { text-align: center; margin: 0 0 .5rem; font-style: italic; font-size: 1.2rem; letter-spacing: .08em; color: var(--ink-soft); }

/* Play the bots */
.play { margin: 1rem 0 1.5rem; }
.bot-pick { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.bot-select { font: inherit; padding: .3rem .4rem; background: var(--paper, #f4efe3); color: inherit; border: 1px solid currentColor; }
.bot-blurb { font-style: italic; margin: .5rem 0 0; }
.bot-moves { font-family: "Courier Prime", monospace; max-height: 14rem; overflow: auto; line-height: 1.6; white-space: pre-wrap; }
.bot-pgn { width: 100%; font-family: "Courier Prime", monospace; font-size: .8rem; }
.play .w-board-col .board { margin-top: .6rem; }
.bot-says { font-style: italic; border-left: 4px solid var(--ink); padding: .3rem .7rem; background: rgba(0,0,0,.04); }
a.btn { text-decoration: none; display: inline-block; }

/* Analysis board */
.board-wrap { display: flex; gap: .5rem; align-items: stretch; }
.board-wrap .board { flex: 1 1 auto; }
.eval-bar { width: 14px; border: 2px solid var(--ink); background: var(--ink); display: flex; flex-direction: column-reverse; margin-top: .6rem; }
.eval-bar span { display: block; background: #fff; height: 50%; transition: height .3s; }
.palette { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; }
.palette .tool { min-width: 2.2rem; font-size: 1.1rem; padding: .1rem .3rem; }
.palette .tool.on { background: var(--ink); color: var(--paper); }
.fen-input { flex: 1 1 14rem; font: .8rem "Courier Prime", monospace; padding: .3rem; background: var(--paper); color: inherit; border: 1px solid currentColor; }
.cast { font-family: "Courier Prime", monospace; font-size: .85rem; }
.an-info { font-family: "Courier Prime", monospace; font-weight: bold; }
.an-line { font-family: "Courier Prime", monospace; line-height: 1.6; }

/* PGN editor */
.pe-moves { font-family: "Courier Prime", monospace; line-height: 1.8; max-height: 22rem; overflow: auto; padding: .4rem .6rem; border: 1px solid var(--ink); }
.pe-moves .mn { color: var(--ink-soft); }
.pe-moves .mv { cursor: pointer; padding: 0 .2rem; font-weight: 700; }
.pe-moves .mv:hover { text-decoration: underline; }
.pe-moves .mv.on { background: var(--ink); color: var(--paper); }
.pe-moves .cm { font-style: italic; font-family: inherit; color: var(--ink-soft); }
.pe-moves .var { margin: .1rem 0 .1rem 1rem; padding-left: .5rem; border-left: 2px solid var(--ink-soft); font-size: .92em; }
.pe-text { width: 100%; box-sizing: border-box; font: .85rem "Courier Prime", monospace; padding: .3rem; background: var(--paper); color: inherit; border: 1px solid currentColor; }
.pe-hdrs { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .4rem; }
.pe-hdrs label { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; display: flex; flex-direction: column; }
.pe-hdrs input, .pe-hdrs select { font: .85rem "Courier Prime", monospace; padding: .2rem; background: var(--paper); color: inherit; border: 1px solid currentColor; }
.pe-nags .btn.on { background: var(--ink); color: var(--paper); }

/* DOS arcade */
.dos-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.dos-tabs .btn.on { background: var(--ink); color: var(--paper); }
.dos-cat { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.dos-list { max-height: 80vh; overflow: auto; }
.dos-list h3 { font-size: .95rem; margin: .5rem 0 .25rem; }
.dos-games { list-style: none; margin: 0; padding: 0; }
.dos-game { font: inherit; font-size: .9rem; background: none; border: 0; border-bottom: 1px dotted currentColor; color: inherit; cursor: pointer; padding: .2rem 0; text-align: left; width: 100%; }
.dos-game:hover, .dos-game.on { background: var(--ink); color: var(--paper); }
.dos-stage { min-width: 0; }
@media (max-width: 760px) { .dos-cat { grid-template-columns: 1fr; } }
.dos-head { display: flex; justify-content: space-between; margin-bottom: .3rem; font-size: .9rem; }
.dos-frame { width: 100%; aspect-ratio: 4 / 3; min-height: 520px; border: 3px double var(--ink); background: #000; }
.dos-box { width: 100%; aspect-ratio: 4 / 3; min-height: 520px; position: relative; }
.palette .tool.wht { color: #fff; -webkit-text-stroke: 1px var(--ink); }
.palette .tool.wht.on { background: #9a8f73; }
