/* RetroPanda: the Panda look (black on white, Archivo), one quiet board, nothing else.
   Coordinates are hidden until you hold the button (or the C key): html.coords. */
:root {
  --ink: #0d0d0d;
  --paper: #ffffff;
  --soft: #6b6b6b;
  --line: #0d0d0d;
  --light: #eeece6;
  --dark: #a3adba;
  --hl: rgba(255, 213, 79, 0.55);
  --good: #1d7a4c;
  --bad: #b3261e;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #f4f4f4; --paper: #0d0d0d; --soft: #a0a0a0; --line: #f4f4f4; --good: #49c48a; --bad: #ff7a70; }
  .brand img { background: #faf9f6; border-radius: 10px; padding: 3px; }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.45 var(--font); }
button { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
svg { display: block; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; margin: 0 auto; padding: 14px 16px 10px; border-bottom: 3px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 56px; width: auto; }
.brand b { display: block; font: 900 26px/1 var(--font); letter-spacing: -0.02em; text-transform: uppercase; }
.brand i { display: block; font-size: 14px; color: var(--soft); margin-top: 3px; }
.essay-link { font-weight: 800; font-size: 15px; white-space: nowrap; }
@media (max-width: 480px) { .brand img { height: 44px; } .brand b { font-size: 21px; } .brand i { display: none; } }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Lesson picker: two segmented controls (rows of joined buttons) */
.pick { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 14px 0 6px; }
.seg { display: inline-flex; align-items: center; border: 2px solid var(--line); }
.seg button { border: 0; background: transparent; min-height: 44px; padding: 0 14px; font-weight: 800; font-size: 15px; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.seg.small button { min-width: 44px; padding: 0 10px; }
.seg-label { padding: 0 10px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; border-right: 2px solid var(--line); align-self: stretch; display: flex; align-items: center; }

/* Layout: the position on the left, the four choices on the right (stacked on phones) */
.stage { display: grid; gap: 18px 36px; padding: 8px 0 24px; }
@media (min-width: 920px) { .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } .now { position: sticky; top: 12px; } }
.ask { font: 800 clamp(19px, 2.6vw, 25px)/1.2 var(--font); margin: 4px 0 12px; letter-spacing: -0.01em; }
.ask em { font-style: normal; background: var(--ink); color: var(--paper); padding: 0 6px; }

/* Boards. The gutter for coordinates is always there so nothing jumps when they appear. */
.board-wrap { display: grid; grid-template-columns: var(--g) 1fr; grid-template-rows: 1fr var(--g); --g: 16px; }
.board-wrap.big { max-width: 560px; }
.board { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; border: 2px solid var(--line); user-select: none; -webkit-user-select: none; }
.sq { position: relative; background: var(--light); }
.sq.d { background: var(--dark); }
.sq.hl::after { content: ""; position: absolute; inset: 0; background: var(--hl); }
.sq img { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; -webkit-user-drag: none; }
.ranks { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: repeat(8, 1fr); }
.files { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); }
.ranks span, .files span { display: flex; align-items: center; justify-content: center; font: 800 12px/1 var(--font); visibility: hidden; }
html.coords .ranks span, html.coords .files span { visibility: visible; }
.board-wrap.mini { --g: 11px; }
.board-wrap.mini .ranks span, .board-wrap.mini .files span { font-size: 9px; }

.under { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 0 16px; max-width: 544px; }
.tomove { font-weight: 800; display: inline-flex; align-items: center; gap: 8px; }
.tomove i { width: 14px; height: 14px; border: 2px solid var(--line); border-radius: 50%; display: inline-block; }
.tomove i.w { background: #fff; } .tomove i.b { background: #0d0d0d; }

/* Press and hold for coordinates */
.hold { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 2px solid var(--line); background: transparent; font-weight: 800; font-size: 14px; cursor: pointer;
        touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.hold svg { width: 18px; height: 18px; }
html.coords .hold { background: var(--ink); color: var(--paper); }

/* The four choices */
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opt { position: relative; border: 2px solid transparent; background: transparent; padding: 6px 6px 8px; text-align: left; cursor: pointer; display: grid; gap: 6px; transition: border-color 120ms ease-out, transform 120ms ease-out; }
.opt:hover:not([disabled]) { border-color: var(--line); }
.opt:active:not([disabled]) { transform: scale(0.985); }
.opt[disabled] { cursor: default; }
.opt .tag { display: flex; align-items: center; gap: 8px; font: 900 15px/1 var(--font); }
.opt .tag kbd { min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--line); font: 900 13px/1 var(--font); }
.opt .why { font-size: 13.5px; line-height: 1.3; min-height: 0; color: var(--soft); }
.opt.right { border-color: var(--good); }
.opt.right .tag kbd { background: var(--good); border-color: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); }
.opt.wrong .tag kbd { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.right .why { color: var(--good); font-weight: 700; }
.opt.dim { opacity: 0.55; }

.after { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; min-height: 48px; }
.verdict { margin: 0; font: 800 19px/1.25 var(--font); }
.verdict.good { color: var(--good); } .verdict.bad { color: var(--bad); }
.next { min-height: 48px; padding: 0 22px; border: 2px solid var(--line); background: var(--ink); color: var(--paper); font-weight: 900; font-size: 16px; text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; }
.next:hover { background: var(--paper); color: var(--ink); }
.score { display: flex; gap: 20px; flex-wrap: wrap; margin: 16px 0 0; padding-top: 10px; border-top: 1px dotted var(--line); font-size: 15px; }
.score b { font-variant-numeric: tabular-nums; font-weight: 900; }
.keys { font-size: 13px; color: var(--soft); margin: 8px 0 0; }
kbd { font: 800 12px/1 var(--font); border: 1.5px solid currentColor; padding: 2px 5px; }
@media (hover: none) { .keys { display: none; } }

/* Replay after answering */
.replay { margin: 14px 0 0 16px; max-width: 544px; }
.replay-bar { display: flex; align-items: center; gap: 6px; }
.replay-bar button { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--line); background: transparent; cursor: pointer; }
.replay-bar button svg { width: 20px; height: 20px; }
.replay-bar button.on { background: var(--ink); color: var(--paper); }
#r-where { margin-left: 8px; font-size: 14px; font-weight: 700; }
.line { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.line li button { border: 0; background: transparent; padding: 4px 6px; font: 800 16px/1.2 Menlo, "SF Mono", monospace; cursor: pointer; }
.line li button.cur { background: var(--ink); color: var(--paper); }
.line .no { font: 400 14px/1.2 Menlo, monospace; color: var(--soft); padding: 4px 0; align-self: center; }
.game { margin: 10px 0 0; font-style: italic; font-size: 14px; color: var(--soft); }

.foot { max-width: 1180px; margin: 12px auto 0; padding: 14px 16px 32px; border-top: 3px solid var(--line); font-size: 14px; display: grid; gap: 4px; }
.foot p { margin: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
