/* VivoChess: friendly, tablet-first. Board colours from a classic tournament board, warmed up for children. */
/* Default look since 5 Dec 2026: "VivoChess night", the Hydra Forest style of the front page (Oli: "Yes, restyle them",
   after a viewer called the cream look "such a claude looking app"). Night purple, white type, green go buttons with a
   hard edge, gold highlights. The old cream look is the "Light" theme in Preferences. */
:root {
  --bg: #1c1243; --surface: #2b1c5f; --ink: #ffffff; --muted: #cbc2f0; --line: #4b3597;
  --accent: #36c35b; --accent-ink: #ffffff; --accent-soft: #23463a; --accent-edge: #1d7a36; --sun: #ffc83d; --berry: #ff6b6b;
  --light-sq: #f0dcb4; --dark-sq: #b58863; --last: rgba(255, 200, 61, .55); --sel: rgba(54, 195, 91, .55);
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif; --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.45;
  padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: 32px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center-text { text-align: center; }
.error { color: var(--berry); min-height: 1.2em; margin: .2rem 0; }

.top { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 8px; max-width: 1000px; margin: 0 auto; padding: 12px 0; }
.top h1 { font-size: 1.6rem; text-align: center; }
.ghost { background: none; border: 0; padding: 6px; border-radius: 12px; }
.ghost:hover { background: var(--line); }
.back { font-size: 1.6rem; }
.who { display: flex; align-items: center; gap: 6px; font-weight: 700; }

.wrap { max-width: 1000px; margin: 0 auto; }
.narrow { max-width: 560px; }
.center { min-height: 92vh; display: grid; place-content: center; gap: 18px; padding: 24px 0; }
.brand { text-align: center; } .brand h1 { font-size: 2.8rem; color: var(--accent); }
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }
.form { display: grid; gap: 12px; width: min(420px, 92vw); }
label { display: grid; gap: 4px; font-weight: 700; }
input, select { font: inherit; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0; } legend { font-weight: 700; margin-bottom: 6px; }
.primary, .secondary { border-radius: 14px; padding: 12px 18px; font-weight: 800; font-family: var(--display); font-size: 1.1rem; border: 0; }
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 var(--accent-edge, #1f5a4d); }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-edge, #1f5a4d); }
.secondary { background: var(--surface); border: 2px solid var(--line); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; }
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 14px; }
.tabs.wide { flex-wrap: wrap; justify-content: center; background: none; }
.tab { flex: 1; border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 700; }
.tab.on { background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.tabs.wide .tab { flex: 0 1 auto; border: 2px solid var(--line); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin: 8px 0 24px; }
.tile { display: grid; justify-items: center; gap: 4px; padding: 18px 10px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); }
.tile:hover { border-color: var(--accent); }
.tile .plus { font-size: 3rem; line-height: 84px; color: var(--accent); font-weight: 800; }
.avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.av { border: 3px solid transparent; border-radius: 50%; background: var(--bg); padding: 2px; }
.av.on { border-color: var(--accent); }

.hero { display: flex; gap: 18px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.hero h2 { font-size: 1.8rem; } .eyebrow { margin: 0; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.big { display: grid; justify-items: start; gap: 4px; text-align: left; min-height: 130px; }
.big:hover, .bot:not(.locked):hover, .grow:hover { border-color: var(--accent); }
.ico { font-size: 2.2rem; color: var(--accent); line-height: 1; }

.ladder { display: grid; gap: 10px; }
.bot { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; text-align: left; }
.bot-text { display: grid; gap: 2px; } .bot strong { font-family: var(--display); font-size: 1.35rem; }
.level { font-weight: 700; color: var(--accent); font-size: .9rem; }
.locked { opacity: .5; filter: grayscale(.8); cursor: not-allowed; }
.badge { background: var(--accent-soft); color: var(--accent); font-weight: 800; border-radius: 99px; padding: 4px 10px; font-size: .85rem; white-space: nowrap; }
.lock { font-size: 1.4rem; }

.vs { display: flex; align-items: center; justify-content: center; gap: 16px; font-family: var(--display); font-size: 2rem; margin: 10px 0; }
.bubble { display: inline-block; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 8px 14px; margin: 6px 0; font-weight: 600; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0; }

.game { display: grid; justify-items: center; gap: 8px; }
.opponent { display: flex; align-items: center; gap: 10px; width: min(560px, 100%); }
.opponent .bubble { margin: 2px 0 0; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); width: min(560px, 94vw, 70vh); aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 6px solid #7a5a3e; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.sq { position: relative; border: 0; padding: 0; display: grid; place-items: center; aspect-ratio: 1; }
.sq.light { background: var(--light-sq); } .sq.dark { background: var(--dark-sq); }
.sq.last::before, .sq.sel::before { content: ''; position: absolute; inset: 0; }
.sq.last::before { background: var(--last); } .sq.sel::before { background: var(--sel); }
.sq.check { background: radial-gradient(circle, #ff6b6b 0%, #d9534f 45%, transparent 75%) !important; }
.sq.hint { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: inset 0 0 0 4px #ffd54a; } to { box-shadow: inset 0 0 0 10px #ffd54a; } }
.pc { position: relative; z-index: 1; font-size: min(9vw, 54px, 6.6vh); line-height: 1; font-family: 'Segoe UI Symbol', 'DejaVu Sans', 'Noto Sans Symbols 2', serif; user-select: none; }
.pc.white { color: #fffdf6; text-shadow: 0 0 2px #2b2b2b, 0 0 2px #2b2b2b, 0 1px 2px #2b2b2b; }
.pc.black { color: #26221f; text-shadow: 0 0 1px #000; }
.dot { position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(46,125,107,.6); z-index: 2; }
.cap { position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(46,125,107,.65); z-index: 2; }
.lbl { position: absolute; font-size: .65rem; font-weight: 800; opacity: .7; color: #3d2b1c; z-index: 1; }
.lbl.f { right: 3px; bottom: 1px; } .lbl.r { left: 3px; top: 1px; }
.status { font-weight: 700; min-height: 1.4em; text-align: center; margin: 4px 0; }
.status.good { color: var(--accent); } .status.bad { color: var(--berry); }
.result { display: grid; gap: 6px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 3px solid var(--line); }
.result.win { border-color: var(--accent); } .result.loss { border-color: var(--berry); }
.result strong { font-family: var(--display); font-size: 1.4rem; }
.moves { columns: 3 120px; width: min(560px, 100%); font-size: .9rem; color: var(--muted); margin: 0; padding-left: 28px; }
.moves .cur { background: var(--sun); color: #222; border-radius: 4px; padding: 0 3px; }
.task { margin: 4px 0; text-align: center; }

.glist { list-style: none; padding: 0; display: grid; gap: 8px; }
.grow { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left; }
.grow div { display: grid; }
.pill { border-radius: 99px; padding: 4px 12px; font-weight: 800; font-size: .85rem; }
.pill.win { background: var(--accent-soft); color: var(--accent); } .pill.loss { background: #f8dcdb; color: #a33c38; } .pill.draw { background: var(--line); }

.chat { display: grid; gap: 10px; }
.chatlog { display: grid; gap: 10px; max-height: 58vh; overflow-y: auto; padding: 6px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg p { margin: 0; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); max-width: 80%; white-space: pre-wrap; }
.msg.user { justify-content: flex-end; } .msg.user p { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: .9rem; }
.chatform { display: flex; gap: 8px; } .chatform input { flex: 1; min-width: 0; }

.promo-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; }
.promo { background: var(--surface); border-radius: var(--radius); padding: 18px; text-align: center; }
.promo-row { display: flex; gap: 8px; justify-content: center; }
.promo-row button { width: 72px; height: 72px; border-radius: 12px; border: 2px solid var(--line); background: var(--light-sq); }
.promo-row .pc { font-size: 48px; }
@media (prefers-reduced-motion: reduce) { .sq.hint { animation: none; box-shadow: inset 0 0 0 6px #ffd54a; } }
@media (max-width: 520px) { .top h1 { font-size: 1.25rem; } .who span { display: none; } .bot { grid-template-columns: auto 1fr; } .bot .badge, .bot .lock { grid-column: 2; justify-self: start; } }
.tiles.two { grid-template-columns: repeat(2, minmax(140px, 220px)); justify-content: center; margin-top: 10vh; }
.world { margin-bottom: 22px; }
.world h2 { font-size: 1.5rem; margin-top: 6px; }
.world > p { margin: 2px 0 10px; }
/* Bots screen: one row per world, its four bots in four columns */
.world-row { display: grid; grid-template-columns: 150px repeat(4, minmax(0, 1fr)); gap: 10px; align-items: stretch; padding: 10px 0; border-bottom: 2px solid var(--line); }
.world-name { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.world-name h2 { font-size: 1.35rem; } .world-name p { margin: 2px 0 0; }
.bot-tile { display: grid; justify-items: center; align-content: start; gap: 2px; padding: 10px 6px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); text-align: center; min-width: 0; }
.bot-tile:hover { border-color: var(--accent); }
.bot-tile strong { font-family: var(--display); font-size: 1rem; line-height: 1.1; }
.bot-tile .level { font-size: .78rem; }
.bot-tile .badge { font-size: .7rem; padding: 2px 8px; }
@media (max-width: 640px) {
  .world-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .world-name { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: 8px; }
  .bot-tile { padding: 6px 2px; } .bot-tile svg { width: 40px; height: 40px; } .bot-tile strong { font-size: .8rem; } .bot-tile .level { font-size: .65rem; }
}
/* dragging pieces */
.board { touch-action: none; user-select: none; }
.pc.ghost { position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, -55%); line-height: 1; }
.sq.lift .pc { opacity: .3; }
/* ---- One header on every page ---- */
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; padding: 10px 0; border-bottom: 2px solid var(--line); }
.brand-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px; border-radius: 12px; font-family: var(--display); font-weight: 800; font-size: 1.35rem; color: var(--accent); }
.nav { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.navbtn { display: flex; align-items: center; gap: 6px; background: none; border: 2px solid transparent; border-radius: 12px; padding: 7px 12px; font-weight: 700; }
.navbtn:hover { background: var(--surface); }
.navbtn.on { background: var(--surface); border-color: var(--line); color: var(--accent); }
.navico { font-size: 1.15rem; line-height: 1; }
.topbar .who { display: flex; align-items: center; gap: 6px; background: none; border: 0; font-weight: 700; padding: 4px 6px; border-radius: 12px; }
.topbar .who:hover, .brand-btn:hover { background: var(--surface); }
.page-title { text-align: center; font-size: 1.6rem; margin: 14px 0 8px; }
@media (max-width: 700px) {
  .brand-btn span, .topbar .who span { display: none; }
  .navbtn { flex-direction: column; gap: 0; padding: 4px 8px; } .navlbl { font-size: .7rem; }
}

/* ---- Board pages (game, puzzles, replay): board sized to the screen, panel beside it ---- */
.play { display: grid; grid-template-columns: auto minmax(260px, 360px); gap: 24px; justify-content: center; align-items: start; max-width: 1100px; margin: 14px auto 0; }
.play .board { width: min(640px, calc(var(--vh) - 110px), 58vw); }
.board-col { min-width: 0; }
.side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.side .row-buttons { justify-content: flex-start; margin: 4px 0; }
.side .status { text-align: left; }
.side .opponent { width: auto; }
.side .moves { width: auto; max-height: 32vh; overflow-y: auto; padding-left: 26px; }
.side .tabs.wide { justify-content: flex-start; }
.side .task { text-align: left; }
@media (max-width: 900px) {
  .play { grid-template-columns: 1fr; justify-items: center; gap: 10px; }
  .play .board { width: min(94vw, calc(var(--vh) - 280px), 560px); min-width: 260px; }
  .side { width: min(560px, 100%); }
}
/* ---- Move list down the right of the board, as tall as the board (Lichess style) ---- */
.play .side { height: min(640px, calc(var(--vh) - 110px), 58vw); }
.movebox { flex: 1; min-height: 110px; overflow-y: auto; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; }
.movetable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .95rem; }
.movetable td { padding: 4px 10px; }
.movetable .mn { width: 2.6em; text-align: right; color: var(--muted); background: var(--bg); }
.movetable .mv { width: 45%; font-weight: 600; }
.movetable .mv.cur { background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.movetable .pickable { cursor: pointer; } .movetable .pickable:hover { background: var(--line); }
@media (max-width: 900px) { .play .side { height: auto; } .movebox { max-height: 26vh; flex: none; } }
.lastgame { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.lastgame div { display: grid; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 14px; }
.stat { display: grid; gap: 2px; }
.statnum { font-family: var(--display); font-size: 2.4rem; font-weight: 800; color: var(--accent); line-height: 1; }
.statlbl { font-weight: 800; }
.lesson { justify-content: center; align-content: center; min-height: 72px; }
.grid4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
/* Back button under the header */
.subbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; max-width: 1100px; margin: 10px auto 0; gap: 10px; }
.subbar .page-title { margin: 0; }
.backbtn { justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-family: var(--display); font-weight: 800; font-size: 1.05rem; }
.backbtn:hover { border-color: var(--accent); color: var(--accent); }
.play .board { width: min(640px, calc(var(--vh) - 170px), 58vw); }
.play .side { height: min(640px, calc(var(--vh) - 170px), 58vw); }
@media (max-width: 900px) { .play .board { width: min(94vw, calc(var(--vh) - 330px), 560px); } .play .side { height: auto; } }
/* Puzzles: theme menu down the left, rating card on the right, task under the board */
.play3 { grid-template-columns: 190px auto minmax(240px, 320px); }
.play3 .board { width: min(640px, calc(var(--vh) - 215px), 50vw); }
.play3 .side { height: auto; }
.theme-menu { display: flex; flex-direction: column; gap: 6px; }
.theme-menu button { text-align: left; padding: 11px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; }
.theme-menu button:hover { border-color: var(--accent); }
.theme-menu button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.task.under { text-align: center; margin: 10px 0 0; font-size: 1.1rem; }
.rating-card { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--accent); }
.rlabel { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; color: var(--muted); }
.rnum { font-family: var(--display); font-size: 3.2rem; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.rchange { font-family: var(--display); font-weight: 800; font-size: 1.2rem; min-height: 1.3em; }
.rchange.up { color: var(--accent); } .rchange.down { color: var(--berry); }
@media (max-width: 900px) {
  .play3 { grid-template-columns: 1fr; }
  .theme-menu { flex-direction: row; flex-wrap: wrap; justify-content: center; order: 0; }
  .theme-menu button { padding: 7px 10px; }
  .play3 .board { width: min(94vw, calc(var(--vh) - 380px), 560px); }
}
.play3 { max-width: 1320px; }
.play3 .board { width: min(640px, calc(var(--vh) - 215px), calc(100vw - 620px)); min-width: 300px; }
.board-col { display: flex; flex-direction: column; align-items: center; }
/* Ask Pip: chat on the left, a teaching board on the right */
.chat-layout { display: grid; grid-template-columns: minmax(0, 600px) minmax(280px, 400px); gap: 24px; justify-content: center; max-width: 1100px; margin: 10px auto 0; }
.chat-layout .chat { min-width: 0; }
.teachboard { display: flex; flex-direction: column; gap: 8px; }
.teachboard h2 { font-size: 1.3rem; }
.teachboard p { margin: 0; }
.teachboard .board { width: min(400px, 100%); }
.moments { display: grid; gap: 6px; }
.moment { text-align: left; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; }
.moment.on { border-color: var(--accent); }
.key-bad { color: #d9534f; font-weight: 800; } .key-good { color: #2e9d6b; font-weight: 800; }
.sq.mark-bad::after, .sq.mark-good::after { content: ''; position: absolute; inset: 3px; border-radius: 6px; z-index: 2; pointer-events: none; }
.sq.mark-bad::after { box-shadow: inset 0 0 0 4px #d9534f; }
.sq.mark-good::after { box-shadow: inset 0 0 0 4px #2e9d6b; }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } .teachboard { order: -1; } .teachboard .board { width: min(340px, 90vw); align-self: center; } }
/* Pieces sized to the board itself (not the window), so small boards never overflow */
.board { container-type: inline-size; }
.board .pc { font-size: 10.6cqw; }
.board .lbl { font-size: max(8px, 1.7cqw); }
/* Ask Pip refinements */
.chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip { white-space: nowrap; flex: 0 0 auto; }
.msg p { max-width: 94%; line-height: 1.5; }
.chatlog { max-height: calc(var(--vh) - 330px); }
.mvtag { font-weight: 800; border-radius: 6px; padding: 0 4px; white-space: nowrap; }
.mvtag.bad { background: rgba(217, 83, 79, .18); color: #e2625e; }
.mvtag.good { background: rgba(46, 157, 107, .2); color: #3fbf86; }
.mvtag.great { background: rgba(66, 135, 245, .2); color: #6ea6ff; }
.msg.user .mvtag { color: inherit; background: rgba(255,255,255,.2); }
.teachboard .board { width: min(380px, 100%); }
.movebox.anno { max-height: 26vh; flex: none; }
.movetable .mine { }
.nag-bb, .nag-b, .nag-d, .nag-g { margin-left: 2px; font-weight: 900; }
.nag-bb { color: #e2625e; } .nag-b { color: #f0883e; } .nag-d { color: #d6b43a; } .nag-g { color: #3fbf86; }
/* Teaching panel fits the screen: compact moments, move list takes the rest */
@media (min-width: 901px) {
  .teachboard { height: calc(var(--vh) - 180px); min-height: 500px; }
  .teachboard .board { width: min(360px, 100%, calc(var(--vh) - 500px)); min-width: 260px; }
  .moments { display: flex; flex-wrap: wrap; gap: 6px; }
  .moment { padding: 5px 10px; font-size: .9rem; }
  .movebox.anno { flex: 1; max-height: none; min-height: 70px; }
  .teachboard #tb-buttons { margin: 0; }
}
/* Chat column fits the screen too: the conversation takes whatever height is left */
@media (min-width: 901px) {
  .chat-layout .chat { display: flex; flex-direction: column; gap: 8px; height: calc(var(--vh) - 180px); min-height: 500px; }
  .chat-layout .chatlog { flex: 1; max-height: none; min-height: 0; }
  .chat-layout .chat > p { margin: 0; }
}
/* Version under the logo */
.brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.brand-text .rev { font-family: var(--body); font-weight: 600; font-size: .62rem; color: var(--muted); letter-spacing: .02em; }
@media (max-width: 700px) { .brand-btn .brand-text { display: none; } }
/* Earlier chats + new chat */
.chatbar { display: flex; gap: 8px; align-items: center; }
.chatbar select { flex: 1; min-width: 0; padding: 9px 10px; }
.chatbar .secondary { padding: 8px 14px; font-size: 1rem; white-space: nowrap; }
/* Back in the header bar; no separate title row */
.tb-left { display: flex; align-items: center; gap: 10px; }
.topbar .backbtn { padding: 6px 12px; font-size: .95rem; }
.play, .chat-layout { margin-top: 10px; }
@media (min-width: 901px) {
  .chat-layout .chat, .teachboard { height: calc(var(--vh) - 110px); }
  .teachboard .board { width: min(380px, 100%, calc(var(--vh) - 380px)); }
  .movebox.anno { flex: 1; min-height: 120px; }
}
.tb-key { margin: 0; }
@media (max-width: 700px) { .topbar .backbtn { padding: 4px 8px; font-size: .85rem; } }
/* boards get the height the old title row used */
.play .board { width: min(660px, calc(var(--vh) - 120px), 58vw); }
.play .side { height: min(660px, calc(var(--vh) - 120px), 58vw); }
.play3 .board { width: min(660px, calc(var(--vh) - 165px), calc(100vw - 620px)); }
.play3 .side { height: auto; }
@media (max-width: 900px) { .play .board { width: min(94vw, calc(var(--vh) - 290px), 560px); } .play .side { height: auto; } .play3 .board { width: min(94vw, calc(var(--vh) - 330px), 560px); } }
/* ---- Pip hub ---- */
.hub { max-width: 1100px; margin: 12px auto 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.hub .askbar, .hub .insights { grid-column: 1 / -1; }
.hub h2 { font-size: 1.2rem; margin-bottom: 8px; }
.askbar { display: flex; gap: 10px; align-items: center; }
.askbar input { flex: 1; min-width: 0; }
.ins-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.ins { display: grid; gap: 2px; align-content: start; }
.rnum.small { font-size: 2.2rem; } .rnum .of { font-size: 1rem; color: var(--muted); }
.spark { width: 100%; height: 44px; color: var(--accent); }
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.theme { display: grid; grid-template-columns: 9.5em 1fr 3em; gap: 8px; align-items: center; font-weight: 700; font-size: .92rem; }
.theme .bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.theme .bar i { display: block; height: 100%; background: var(--accent); }
.hublist { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hublist .row { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); }
.hublist .row:hover { border-color: var(--accent); }
.grow2 { display: grid; flex: 1; min-width: 0; } .grow2 strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; flex: none; }
.pz.ok { background: var(--accent-soft); color: var(--accent); } .pz.no { background: #f8dcdb; color: #a33c38; }
@media (max-width: 900px) { .hub { grid-template-columns: 1fr; } .ins-grid { grid-template-columns: 1fr 1fr 1fr; } .themes { grid-template-columns: 1fr; } }

/* ---- Analysis pages: board on the left; moves and Pip on the right ---- */
.analysis { display: grid; grid-template-columns: auto minmax(340px, 470px); gap: 22px; justify-content: center; max-width: 1240px; margin: 10px auto 0; }
.an-board { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.an-board .board { width: min(620px, calc(var(--vh) - 175px), calc(100vw - 560px)); min-width: 280px; }
.an-board .moments { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.an-side { display: flex; flex-direction: column; gap: 8px; height: calc(var(--vh) - 110px); min-height: 520px; min-width: 0; }
.an-head { display: flex; align-items: center; gap: 10px; }
.an-head div { display: grid; }
.an-side .movebox.anno { flex: 0 1 34%; min-height: 90px; max-height: none; }
.an-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.an-chat .chatlog { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }
.an-chat .msg p { max-width: 92%; }
.chatpage { max-width: 760px; margin: 10px auto 0; display: flex; flex-direction: column; gap: 8px; height: calc(var(--vh) - 110px); }
.chatpage .an-chat { flex: 1; }
/* Fold buttons (review pages): the board part and the moves part can be folded away on a phone, where they stack. */
.an-fold { display: flex; flex-direction: column; gap: 8px; align-items: center; align-self: stretch; }
.an-side .an-fold { align-items: stretch; }
.an-fold.folded { display: none; }
.foldbtn { display: none; }
@media (min-width: 901px) {
  .an-side > .an-fold { flex: 0 1 34%; min-height: 110px; }
  .an-side > .an-fold .movebox.anno { flex: 1; min-height: 0; }
}
@media (max-width: 900px) {
  .foldbtn { display: block; align-self: center; padding: 6px 16px; border-radius: 999px; border: 2px solid var(--line);
    background: var(--surface); color: inherit; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; min-height: 36px; }
  .foldbtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
}
@media (max-width: 900px) {
  .analysis { grid-template-columns: 1fr; }
  .an-board .board { width: min(92vw, 480px); }
  .an-side { height: auto; } .an-side .movebox.anno { max-height: 26vh; } .an-chat .chatlog { max-height: 50vh; }
  .chatpage { height: auto; } .chatpage .chatlog { max-height: 65vh; }
}
/* Move-mark style switch: classic ! ?, fun emoji, or both */
.an-head { flex-wrap: wrap; }
.markstyle { margin-left: auto; display: inline-flex; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.markstyle button { border: 0; background: var(--surface); padding: 4px 10px; font-weight: 800; }
.markstyle button.on { background: var(--accent); color: var(--accent-ink); }
.nagm { margin-left: 3px; font-weight: 900; }
/* ---- Explicit theme choice (menu under the player's name) overrides the system setting ---- */
:root[data-theme="light"] { --bg: #f4f1ea; --surface: #ffffff; --ink: #24303f; --muted: #6b7380; --line: #e3ddd0; --accent: #2e7d6b; --accent-soft: #dcefe9; --accent-edge: #1f5a4d; --sun: #f2b84b; --berry: #d9534f; --sel: rgba(46, 125, 107, .55); --last: rgba(242, 184, 75, .55); --radius: 16px; color-scheme: light; }
:root[data-theme="dark"] { --bg: #1b2028; --surface: #252c36; --ink: #eef1f4; --muted: #a5adba; --line: #39424f; --accent: #2e7d6b; --accent-soft: #23423b; --accent-edge: #1f5a4d; --sun: #f2b84b; --berry: #d9534f; --sel: rgba(46, 125, 107, .55); --radius: 16px; color-scheme: dark; }
/* More themes (Oli, 3 Dec 2026: "Add more themes"). Each sets every colour token, so it looks the same whatever the
   device's own light or dark setting is. */
:root[data-theme="ocean"] { --bg: #0f1e2e; --surface: #17293d; --ink: #e8f1fa; --muted: #9fb3c8; --line: #27425e; --accent: #3aa0d8; --accent-ink: #08131f; --accent-soft: #173a55; --sel: rgba(58, 160, 216, .55); color-scheme: dark; }
:root[data-theme="forest"] { --bg: #13201a; --surface: #1b2c24; --ink: #e9f3ec; --muted: #a3b8aa; --line: #2c4337; --accent: #5cc28c; --accent-ink: #0b1a12; --accent-soft: #1f3d2e; --sel: rgba(92, 194, 140, .55); color-scheme: dark; }
:root[data-theme="sunset"] { --bg: #fff4e8; --surface: #ffffff; --ink: #3a2a1e; --muted: #7d6a5c; --line: #f0dcc6; --accent: #d4572a; --accent-ink: #ffffff; --accent-soft: #fde2d4; --sel: rgba(212, 87, 42, .5); color-scheme: light; }
:root[data-theme="candy"] { --bg: #fbf0fa; --surface: #ffffff; --ink: #3b2540; --muted: #7d6884; --line: #efd9ee; --accent: #a64ca6; --accent-ink: #ffffff; --accent-soft: #f3dcf3; --sel: rgba(166, 76, 166, .5); color-scheme: light; }
:root[data-theme="contrast"] { --bg: #000000; --surface: #111111; --ink: #ffffff; --muted: #d6d6d6; --line: #777777; --accent: #ffd400; --accent-ink: #000000; --accent-soft: #3a3200; --sel: rgba(255, 212, 0, .55); color-scheme: dark; }
/* Board colours */
:root[data-board="green"] { --light-sq: #eeeed2; --dark-sq: #769656; }
:root[data-board="blue"] { --light-sq: #dee3e6; --dark-sq: #8ca2ad; }
:root[data-board="purple"] { --light-sq: #ece4f5; --dark-sq: #9a7bc4; }
:root[data-board="green"] .board { border-color: #56703f; }
:root[data-board="blue"] .board { border-color: #5f7480; }
:root[data-board="purple"] .board { border-color: #6c548f; }
/* Settings menu */
.who-wrap { position: relative; }
.caret { font-size: .8rem; color: var(--muted); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 300px; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 12px; display: grid; gap: 12px; }
.menu-sec { display: grid; gap: 6px; }
.menu-lbl { font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); font-weight: 700; font-size: .92rem; }
.opt.on { border-color: var(--accent); color: var(--accent); }
.sw2 { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
/* Preferences page (Oli, 3 Dec 2026): one card per setting, big enough to tap */
.prefspage { max-width: 760px; display: grid; gap: 12px; }
.prefspage > p { margin: 0; }
.prefsec h2 { font-size: 1.1rem; margin: 0 0 4px; }
.prefsec p { margin: 0 0 10px; }
.prefsec .opts { gap: 8px; }
.prefsec .opt { padding: 10px 14px; font-size: 1rem; cursor: pointer; }
.prefsec .sw2 { width: 20px; height: 20px; }
.menu-switch { text-align: left; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); font-weight: 800; }
.menu-switch:hover, .opt:hover { border-color: var(--accent); }
/* Analysis: game title above the board (left column) */
.an-board .an-head { align-self: stretch; }
.an-board .board { width: min(620px, calc(var(--vh) - 225px), calc(100vw - 560px)); }
@media (max-width: 900px) { .an-board .board { width: min(92vw, 480px); } }
/* Moves in Pip's replies are links to that position */
.mvtag, .mvlink { cursor: pointer; }
.mvtag.plain { background: rgba(127, 127, 127, .15); }
.mvlink { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; font-weight: 700; }
.mvtag:hover, .mvlink:hover { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 6px; }

/* Teaching on the analysis board (29 Nov): watch the expected line, or try a move */
.an-board .board { width: min(620px, calc(var(--vh) - 300px), calc(100vw - 560px)); }
@media (max-width: 900px) { .an-board .board { width: min(92vw, 480px); } }
.teachbar { align-self: stretch; display: grid; gap: 4px; justify-items: center; min-height: 0; }
.teachbar:empty { display: none; }
.teachbtns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tb { padding: 5px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; font-size: .9rem; cursor: pointer; }
.tb-bad { border-color: #d9534f66; }
.tb-good { border-color: #3a9d5d88; }
.tb-try { border-color: var(--accent); }
.tb.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.teachcap { margin: 0; text-align: center; max-width: 620px; line-height: 1.4; }
.teachcap .tcline { font-weight: 700; color: var(--text, inherit); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

/* Analysis chat uses the full width (Oli, 29 Nov: space lost left of the bubbles) */
.an-chat .msg > svg { display: none; }
.an-chat .msg p { max-width: 100%; }
.an-chat .msg.user p { max-width: 88%; }
.an-chat .chatlog { padding: 4px 2px; }

/* How you are doing on Home, under the buttons (29 Nov) */
.home-insights { margin-top: 14px; }
.home-insights:empty { display: none; }

/* Pip suggests on Home (29 Nov) */
#home-suggest:empty { display: none; }
#home-suggest { margin-top: 14px; }
.suggest h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.suggest .sug { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; margin-top: 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.suggest .sug:hover { border-color: var(--accent); }
.sug-ico { font-size: 1.3rem; width: 28px; text-align: center; color: var(--accent); }
.sug-go { font-weight: 800; color: var(--accent); white-space: nowrap; }

/* Pip memory, ratings, read aloud and dictation (29 Nov) */
.msg .bubble { display: flex; flex-direction: column; gap: 3px; max-width: 94%; min-width: 0; }
.msg .bubble p { max-width: 100%; }
.msg.user .bubble { align-items: flex-end; max-width: 88%; }
.an-chat .msg .bubble { max-width: 100%; }
.an-chat .msg.user .bubble { max-width: 88%; }
.msgtools { display: flex; gap: 4px; padding-left: 6px; }
.msgtools button { background: none; border: 1px solid transparent; border-radius: 8px; padding: 1px 6px; font-size: .95rem; cursor: pointer; opacity: .55; }
.msgtools button:hover { opacity: 1; border-color: var(--line); }
.msgtools button.on { opacity: 1; border-color: var(--accent); background: var(--surface); }
.msgtools { flex-wrap: wrap; align-items: center; }
.msgtools .mt-copy { font-size: .8rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.chatform { display: flex; gap: 6px; align-items: center; }
.chatform input { flex: 1; min-width: 0; }
.chatform .mic, .chatform .voicetoggle { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-size: 1.15rem; cursor: pointer; }
.chatform .voicetoggle { opacity: .5; }
.chatform .voicetoggle.on { opacity: 1; border-color: var(--accent); }
.chatform .mic.on { border-color: #d9534f; background: #d9534f22; animation: micpulse 1s ease-in-out infinite; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 6px #d9534f33; } }
.micnote { margin: 4px 0 0; color: #d9534f; }
.lesson { position: relative; }
.lbadge { position: absolute; top: 6px; right: 8px; font-weight: 800; font-size: 1rem; }
.lbadge.ok { color: #3a9d5d; } .lbadge.again { color: #e0a030; } .lbadge.started { color: var(--muted, #888); }
.knows ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.hub .knows, .hub .feedback { grid-column: 1 / -1; }
.fbmark { font-size: 1.2rem; }

/* Next challenge as a slim strip (Oli, 29 Nov: it took too much of the screen) */
.hero.slim { flex-wrap: nowrap; gap: 12px; padding: 10px 14px; margin-bottom: 12px; }
.hero.slim .grow2 { flex: 1; min-width: 0; }
.hero.slim .eyebrow { font-size: .7rem; }
.hero.slim strong { font-size: 1.1rem; }
.hero.slim button { flex: none; }
@media (max-width: 560px) { .hero.slim .muted { display: none; } }

/* Pip's focus inside How you're doing (29 Nov) */
.focus { border-left: 4px solid var(--accent); padding: 4px 0 4px 12px; margin: 4px 0 12px; }
.focus-note { margin: 0 0 6px; font-size: 1.05rem; line-height: 1.45; }
.focus-since { margin: 4px 0 0; }
.ktk-wrap { display: grid; gap: 4px; max-width: 420px; margin: 6px 0; }
.ktk-wrap > p { margin: 0; }
.ktk { display: grid; grid-template-columns: 70px 1fr 44px; align-items: center; gap: 8px; }
.ktk .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.ktk .bar i { display: block; height: 100%; background: var(--accent); }
#home-insights + #home-suggest { margin-top: 14px; }

/* Coaching model: goal, phases, profile grid (29 Nov) */
.goalbox { margin: 8px 0; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--accent); background: var(--surface); }
.goaltitle { margin: 0 0 6px; }
.goalstep { font-weight: 700; }
.goalbtns { margin-top: 8px; }
.ktk .linkbtn { justify-self: start; }
.phrow { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.phchip { display: inline-flex; gap: 4px; align-items: baseline; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .85rem; }
.phchip b { font-size: 1rem; }
.phasestrip { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.phasestrip:empty { display: none; }
.gridcard { grid-column: 1 / -1; }
.gridtable { width: 100%; border-collapse: separate; border-spacing: 4px; }
.gridtable th { text-align: left; font-size: .9rem; }
.gridtable thead th { text-align: center; }
.gridtable thead th span { display: block; font-weight: 400; }
.gc { text-align: center; padding: 6px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: .9rem; white-space: nowrap; }
.gc.empty { color: var(--muted, #888); }
.gc.weak { border-color: #d9534f; background: #d9534f22; }
.gc.meh { border-color: #e0a030; background: #e0a03018; }
.gc.ok { border-color: #3a9d5d88; }

/* Pip Coach screen */
.coachside { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.coachside .opponent label { display: block; margin-top: 2px; }
.coachside select { font: inherit; padding: 2px 4px; border-radius: 6px; }
.cmoves { font-size: .9rem; max-height: 72px; overflow-y: auto; line-height: 1.6; }
.cm { white-space: nowrap; margin-right: 6px; }
.clog { flex: 1; min-height: 160px; max-height: calc(var(--vh) - 430px); overflow-y: auto; display: grid; gap: 8px; align-content: start; padding: 4px; }
.cmsg { display: flex; gap: 6px; align-items: flex-end; }
.cmsg p { margin: 0; padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line); line-height: 1.45; }
.cmsg.you { justify-content: flex-end; }
.cmsg.you p { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cmsg .mt-say { background: none; border: 0; cursor: pointer; opacity: .6; padding: 0 2px; }
.cwait { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 2px solid #e0a030; background: #e0a03018; font-weight: 700; }
.cwait[hidden] { display: none; }
.coachcard svg { margin-bottom: 4px; }

.hub #pip-insights { grid-column: 1 / -1; }
.ktk { grid-template-columns: 100px 1fr auto; }
.goalbox .ktk-wrap { max-width: 520px; }

/* Move arrows on the board (Oli, 29 Nov): red = the move played, green = the better move, blue = a move from the list. */
.board { position: relative; }
.board svg.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.arw { opacity: .82; stroke: rgba(0,0,0,.25); stroke-width: .02; }
.arw-bad { fill: #d9534f; } .arw-good { fill: #2e9d6b; } .arw-move { fill: #3b82c4; } .arw-warn { fill: #e0a020; }

/* Chat: no box inside the box, and your own messages use the full width (Oli, 29 Nov: "We are losing precious space"). */
.msg .bubble { background: none; border: 0; padding: 0; margin: 0; border-radius: 0; font-weight: inherit; }
.msg.user .bubble, .an-chat .msg.user .bubble { max-width: 100%; }
.an-chat .msg.user p, .msg.user .bubble p { max-width: 100%; }

/* Play with Pip: the review box after each move, and the "Pip played ..." notes (Oli, 29 Nov). */
.cwait { display: block; font-weight: 600; }
.cwait.rv-good { border-color: #2e9d6b; background: #2e9d6b18; }
.cwait.rv-warn { border-color: #e0a020; background: #e0a02018; }
.cwait.rv-bad { border-color: #d9534f; background: #d9534f18; }
.rvhead { font-size: 1.05rem; margin-bottom: 6px; }
.rv-good .rvhead b { color: #2e9d6b; } .rv-warn .rvhead b { color: #e0a020; } .rv-bad .rvhead b { color: #d9534f; }
.rvbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.rvbtns button { padding: 6px 12px; }
.rvcap { margin: 6px 0 0; font-weight: 400; font-size: .9rem; }
.rvcap:empty { display: none; }
.cmsg.note { justify-content: center; }
.cmsg.note p { background: none; border: 0; padding: 0 6px; font-size: .85rem; opacity: .7; }

.rvwait { margin: 6px 0 0; font-weight: 400; }

/* ---- Tablet portrait (Oli, 29 Nov: "assume this will be used on a tablet, there is too much scrolling").
   Board pages fill exactly one screen: the board takes what is left after the panel, and only the chat and the
   move list scroll, inside their own boxes. --top is the header's height. ---- */
@media (max-width: 900px) {
  :root { --top: 76px; }
  .topbar { padding: 6px 0; gap: 8px; }
  .nav { flex-wrap: nowrap; gap: 2px; }
  .navbtn { padding: 5px 8px; font-size: .92rem; white-space: nowrap; }

  /* bot game, replay, Play with Pip */
  .play:not(.play3) { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 6px; height: calc(var(--vh) - var(--top) - 8px); }
  .play:not(.play3) .board-col { flex: none; }
  .play:not(.play3) .board { width: min(94vw, calc(var(--vh) - var(--top) - 380px)); min-width: 280px; }
  .play:not(.play3) .side { flex: 1; min-height: 0; height: auto; width: min(760px, 100%); overflow: hidden; }
  .play:not(.play3) .side .movebox { flex: 1; max-height: none; min-height: 48px; }
  .play .side .opponent svg { width: 40px; height: 40px; }
  .play .side .row-buttons { margin: 0; }
  /* Play with Pip: settings on one line, the talk fills the rest */
  .coachside { gap: 6px; }
  .coachside .opponent > div { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; }
  .coachside .opponent strong { flex-basis: 100%; }
  .coachside .opponent label { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
  .coachside .cmoves { max-height: 2.8em; overflow-y: auto; }
  .coachside .clog { flex: 1; min-height: 60px; max-height: none; }
  .coachside .rvbtns button { padding: 5px 10px; }
  .coachside #cbuttons button { padding: 6px 12px; }

  /* puzzles: themes in one scrolling row, rating and buttons beside each other under the board */
  .play3 { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 6px; }
  .play3 .theme-menu { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; width: 100%; padding-bottom: 2px; }
  .play3 .theme-menu button { white-space: nowrap; flex: none; }
  .play3 .board { width: min(94vw, calc(var(--vh) - var(--top) - 330px)); min-width: 280px; }
  .play3 .task.under { margin: 6px 0 0; }
  .play3 .side { width: min(760px, 100%); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
  .play3 .side .rating-card { grid-row: span 3; padding: 8px 12px; }
  .play3 .side .rnum { font-size: 2.2rem; }
  .play3 .side > p { margin: 0; }
  .play3 .side .row-buttons { margin: 0; }

  /* game analysis: board on top, moves and Pip's chat side by side underneath */
  main.analysis { display: flex; flex-direction: column; gap: 6px; height: calc(var(--vh) - var(--top) - 8px); margin-top: 6px; }
  .an-board { flex: none; gap: 5px; }
  .an-board .board { width: min(92vw, calc(var(--vh) - var(--top) - 470px)); min-width: 280px; }
  .an-board .moments button { padding: 4px 10px; }
  .an-side { flex: 1; min-height: 0; height: auto; display: grid; grid-template-columns: minmax(0, 36%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 6px 10px; }
  .an-side .movebox.anno { grid-column: 1; grid-row: 1; max-height: none; min-height: 0; flex: none; }
  .an-side .tb-key { grid-column: 1; grid-row: 2; font-size: .72rem; }
  .an-chat { grid-column: 2; grid-row: 1 / span 2; min-height: 0; }
  .an-chat .chatlog { max-height: none; }

  /* home: the five cards on one row */
  .grid4 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .grid4 .card.big { padding: 10px 8px; }
  .grid4 .card.big .muted.small { font-size: .72rem; }
}

/* ---- Play with Pip (Oli, 29 Nov): settings on one compact line, New game / I give up under the board,
   a smaller board and more room for the talk. ---- */
.underboard { justify-content: center; margin: 8px 0 0; gap: 8px; }
.underboard button { padding: 6px 14px; }
.csettings { display: flex; align-items: center; gap: 8px; }
.csettings > div { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; }
.coachside .csettings label { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.coachside .clog { flex: 1; min-height: 80px; max-height: none; }
@media (min-width: 901px) {
  /* max-content: the board column keeps the board's width; at 1024px the side used to squeeze it and the board ran 13px off the left edge (30 Nov) */
  .play.coachplay { grid-template-columns: max-content minmax(300px, 560px); gap: 18px; }
  .play.coachplay .board { width: min(560px, calc(var(--vh) - 160px), 46vw); }
  .play.coachplay .side { height: calc(var(--vh) - 96px); }
}
@media (max-width: 900px) {
  .play.coachplay .board { width: min(94vw, calc(var(--vh) - var(--top) - 480px)); }
  .coachside .opponent > div { flex-wrap: wrap; }
}
/* fit exactly: header never wraps; board pages leave room for the page margins */
.topbar .backbtn { white-space: nowrap; }
@media (min-width: 901px) { .play.coachplay .side { height: calc(var(--vh) - 110px); } }
@media (max-width: 900px) {
  .play:not(.play3), main.analysis { height: calc(var(--vh) - var(--top) - 36px); }
}
@media (min-width: 901px) { .an-side { height: calc(var(--vh) - 118px); } }
@media (max-width: 900px) { .an-board .board { width: min(92vw, calc(var(--vh) - var(--top) - 580px)); } }

/* ---- Home (Oli, 29 Nov): only what to do next. The greeting sits in the challenge bar; the training goal is one strip
   with one button; the numbers live on My progress. On a tablet the five cards are one short row. ---- */
.hero-hi { display: inline; }
.page-title.pt-home { display: none; }
.goalstrip { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 12px 16px; border-color: var(--accent); }
.goalstrip .grow2 { flex: 1; min-width: 0; }
.goalstrip strong { font-size: 1.1rem; }
.goalstrip .gsteps { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: .92rem; color: var(--muted); }
.goalstrip .gsteps .now { color: var(--ink, inherit); font-weight: 800; }
.goalstrip .gsteps .done { color: var(--accent); }
.goalstrip button { flex: none; }
#home-goal:empty { display: none; }
#home-goal + #home-suggest { margin-top: 14px; }
@media (max-width: 560px) { .goalstrip { flex-wrap: wrap; } .goalstrip button { width: 100%; } }
/* Tablet (Oli, 29 Nov, on the iPad: "scope to resize slightly"): Home is short now, so the cards keep their
   descriptions and sit on one row of five, with normal spacing. */
@media (max-width: 1200px) and (min-width: 700px) {
  main.home .grid4 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  main.home .grid4 .card.big { min-height: 118px; padding: 12px 10px; }
  main.home .grid4 .card.big .muted.small { font-size: .8rem; }
}

/* Game analysis on an iPad sideways (Oli, 29 Nov, "check scale"): the board column came to 7px more than the screen,
   so the page scrolled. dvh is the screen Safari actually shows (vh assumes its toolbar is hidden). The key stays on
   one line, and the chat fades at the top so a scrolled line reads as scrolled, not cut off. */
@media (min-width: 901px) {
  .an-board .board { width: min(620px, calc(var(--vh) - 316px), calc(100vw - 560px)); }
  .an-side { height: calc(var(--vh) - 118px); }
  .an-side .tb-key { font-size: .74rem; }
}
.an-chat .chatlog { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px); mask-image: linear-gradient(to bottom, transparent 0, #000 16px); padding-top: 10px; }

/* Activity log page (grown-ups) */
.actbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 12px 0 4px; }
.actbar h1 { font-size: 1.4rem; margin: 0; flex: 1; }
.actbar label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.actbar select { padding: 6px 10px; }
.actday { margin-top: 12px; }
.actday h2 { margin: 0 0 2px; font-size: 1.15rem; }
.acttable { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .92rem; }
.acttable td { padding: 3px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.acttable .at { width: 4.5em; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acttable .where { width: 9em; color: var(--muted); }
.acttable tr.ak-screen td { padding-top: 7px; }
.acttable tr.ak-away td, .acttable tr.ak-back td, .acttable tr.ak-open td { color: var(--muted); }
@media (max-width: 600px) { .acttable .where { display: none; } }
/* Think time per move on the analysis page */
.movetable .tsec { margin-left: 6px; font-size: .72rem; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.phchip.think { border-style: dashed; }

/* Play with Pip review box (Oli, 29 Nov): smaller buttons, a coaching line under the verdict, and the "Your move" bar
   with Hint and Take back (they left the bottom row). */
.cwait .rvbtns { gap: 5px; }
.cwait .rvbtns button, .coachside .cwait .rvbtns button { padding: 4px 10px; font-size: .82rem; border-radius: 10px; box-shadow: none; }
.cwait .rvhead { margin-bottom: 2px; font-size: 1rem; }
.rvcoach { margin: 2px 0 6px; font-size: .88rem; font-weight: 400; line-height: 1.35; }
.rv-bad .rvcoach { color: var(--ink); }
.cwait .rvwait { font-size: .78rem; margin-top: 4px; }
.rvturn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rvturn b { font-size: .95rem; }
.cwait.rv-turn { padding-top: 6px; padding-bottom: 6px; border-color: var(--line); background: var(--surface); }
.cwait.rv-turn .rvcoach { margin: 4px 0 0; }
.cwait.rv-turn .rvcoach::before { content: "⚠ "; color: #e0a020; }

/* Teach me on the board (Oli, 29 Nov): the Play with Pip layout, with step dots under the lesson name. */
.lhead { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lhead strong { font-size: 1rem; }
.ldots { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ldots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; }
.ldots i.done { background: var(--accent); }
.ldots i.now { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.ltask { margin: 0 0 6px; font-weight: 500; font-size: .95rem; line-height: 1.35; }
.lessonplay .cwait .rvcoach:empty { display: none; }
.lessonplay .cwait .rvbtns button.primary { padding: 6px 18px; font-size: .95rem; }

/* Lessons and Pip on the board (30 Nov): yellow and blue square marks, small square labels, Pip's buttons in the talk. */
.sq.mark-warn::after, .sq.mark-info::after { content: ''; position: absolute; inset: 3px; border-radius: 6px; z-index: 2; pointer-events: none; }
.sq.mark-warn::after { box-shadow: inset 0 0 0 4px #e0a020; }
.sq.mark-info::after { box-shadow: inset 0 0 0 4px #3b82c4; background: rgba(59, 130, 196, .14); }
.sq .sqtag { position: absolute; top: 2px; right: 3px; z-index: 6; min-width: 1.4em; padding: 0 .25em; border-radius: 999px;
  background: #1f2937; color: #fff; font: 800 clamp(9px, 2.6cqi, 15px)/1.35 system-ui, sans-serif; text-align: center; pointer-events: none; }
.lessonplay .cwait.rv-turn .rvcoach::before { content: none; }
.cmsg .pipacts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.cmsg .pipacts button { padding: 3px 10px; font-size: .8rem; border-radius: 10px; box-shadow: none; }
.board.demo { outline: 3px dashed #3b82c4; outline-offset: 3px; border-radius: 6px; }

/* Game analysis (Oli, 30 Nov: "make better use of the vertical space, make it one row"): the accuracy and think-time
   chips sit in the title row, right of "vs ...", as small two-line tiles: the number on top, its meaning below.
   The row never wraps: when space is short the date line under the name wraps first, then the tiles. A phone keeps
   the tiles under the title. */
.an-board .an-head { flex-wrap: nowrap; }
.an-head > div:not(.phasestrip) { flex: 0 1 auto; min-width: 0; }
.an-head > div:not(.phasestrip) strong { white-space: nowrap; }
.an-head .phasestrip { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; margin-left: auto; flex: none; max-width: calc(100% - 200px); }
.an-head .phasestrip:empty { display: none; }
.an-head .phchip { display: grid; justify-items: center; gap: 0; padding: 2px 5px; border-radius: 10px; line-height: 1.15; }
@media (max-width: 600px) { .an-board .an-head { flex-wrap: wrap; } .an-head .phasestrip { justify-content: flex-start; margin-left: 0; } }
.an-head .phchip b { font-size: .98rem; white-space: nowrap; }
.an-head .phchip i { font-style: normal; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.an-head .nw { white-space: nowrap; }
/* iPad sideways: the board column is narrower, so the tiles are a little smaller to stay on one row. */
@media (min-width: 901px) and (max-width: 1300px) {
  .an-head .phchip { padding: 1px 4px; }
  .an-head .phchip b { font-size: .86rem; }
  .an-head .phchip i { font-size: .6rem; }
  .an-head .phasestrip { gap: 2px; max-width: calc(100% - 180px); }
}
/* Home (Oli, 30 Nov: the "Next challenge" box was touching the header line): Home has no page title under the
   header, so it needs its own gap. */
main.home { margin-top: 14px; }

/* ---- My training (30 Nov 2026) ---- */
.trainpage { display: grid; gap: 14px; max-width: 900px; }
.ttoday, .tquiz, .tlink { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ttoday { border-color: var(--accent); }
.ttoday .grow2, .tquiz .grow2, .tlink .grow2 { flex: 1; min-width: 200px; }
.tlen { display: flex; gap: 8px; flex-wrap: wrap; }
.tlevel h2 { margin: 0 0 4px; font-size: 1.2rem; }
.tlevel.later summary { cursor: pointer; }
.tcomps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.tcomp { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px; }
.tcomp.next { border-color: var(--accent); }
.tcomp.soon { opacity: .6; }
.tline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.tname { font-weight: 700; }
.tacts { display: flex; gap: 6px; flex-wrap: wrap; }
.tacts button { padding: 6px 12px; font-size: .9rem; }
.tstate { font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: var(--line); color: var(--ink); white-space: nowrap; }
.ts-introduced { background: #e7eefb; color: #2b4f8c; } .ts-practising { background: #fbf1dc; color: #8a5a00; }
.ts-proficient { background: var(--accent-soft); color: var(--accent); } .ts-secure, .ts-mastered { background: var(--accent); color: var(--accent-ink); }
.tnext, .tdue { font-size: .75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.tdue { color: #8a5a00; }
.tdots { display: inline-flex; gap: 2px; }
.tdots i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--berry); }
.tdots i.ok { background: var(--accent); }
.tenjoy button { font-size: 1.6rem; padding: 4px 14px; }
.tenjoy button.on { border-color: var(--accent); background: var(--accent-soft); }
.goalstrip .gsbtns { display: flex; gap: 8px; flex: none; flex-wrap: wrap; }
@media (max-width: 560px) { .goalstrip .gsbtns { width: 100%; } .goalstrip .gsbtns button { flex: 1; } }

main.trainpage { margin-top: 14px; }
.tsoon { margin: 8px 0 0; }

/* Home: one plan, today's training (1 Dec) */
.hero.today { border-color: var(--accent); }
.hero.today .tbtns { display: flex; gap: 8px; flex: none; }
.hero.today .tstate { vertical-align: 2px; margin-left: 4px; }
#pip-suggest:empty { display: none; }
/* Pip noticed on My progress: full width, the suggestions side by side (Oli, 3 Dec: "this looks awkard"; it sat in
   one third of the row, each suggestion wrapped to four lines, and two thirds of the row were empty). */
.hub #pip-suggest { grid-column: 1 / -1; }
.hub .hubchat, .hub .convs { grid-column: 1 / -1; }
.hubchat h2, .convs h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.hubchat .chatlog { max-height: 55vh; }
/* Conversations at the top of My progress (Oli, 3 Dec 2026): recent chats to carry on, and a new one */
.convrow { display: flex; flex-wrap: wrap; gap: 8px; }
.convbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; max-width: 260px; min-width: 0; }
.convbtn strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Pip's next-step buttons under an answer (Oli, 3 Dec 2026: "The response should be a clear link to what I need to do
   next") */
.pipacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pipacts button { font-size: .9rem; padding: 6px 12px; }
/* How you're doing with the strength radar beside the numbers, one card (Oli, 3 Dec 2026: "I think we can compress the
   radar and this top part into one section"). Stacked on a narrow screen. */
.ins-body.with-radar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 18px; align-items: start; }
.ins-radar .pprog.bare .radar { width: 100%; height: auto; display: block; }
.ins-radar .pprog.bare p { margin: 4px 0 0; }
.ins-radar .rspoke { cursor: pointer; }
.areaexp { margin-top: 12px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--accent); background: var(--accent-soft); }
.areaexp h3 { margin: 0 0 4px; font-size: 1.05rem; }
.areaexp p { margin: 4px 0; }
.areaexp .tabtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
@media (max-width: 900px) { .ins-body.with-radar { grid-template-columns: 1fr; } .ins-radar { max-width: 460px; margin: 0 auto; width: 100%; } }
/* A lesson named in Pip's words opens it (Oli, 3 Dec 2026: "'before every move' is a learning section? if so it should
   be a link"). */
.lessonlink { color: var(--accent); font-weight: 700; text-decoration: underline; cursor: pointer; }
.suggest { display: flex; flex-wrap: wrap; gap: 10px; }
.suggest h2 { flex: 1 1 100%; margin: 0; }
.suggest .sug { margin-top: 0; flex: 1 1 240px; width: auto; }
@media (max-width: 560px) { .hero.today { flex-wrap: wrap; } .hero.today .tbtns { width: 100%; } .hero.today .tbtns button { flex: 1; } }

/* Header at tablet portrait with Back: the player's name hides (avatar stays), so the bar fits (was 37 px too wide at 820 px) */
@media (max-width: 900px) { .topbar .who > span:not(.caret) { display: none; } }

/* "Look before you move", step 1: the board glows and says what to do, so a tap is not mistaken for a move (1 Dec) */
#board.picking { position: relative; outline: 4px solid var(--accent); outline-offset: 3px; border-radius: 6px; animation: pickglow 1.6s ease-in-out infinite; }
#board.picking::after { content: "👆 Tap a piece · don't move yet"; position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 5; pointer-events: none;
  background: var(--accent); color: var(--accent-ink, #fff); font-weight: 800; font-size: .95rem; padding: 4px 12px; border-radius: 99px; white-space: nowrap; box-shadow: 0 2px 8px #0004; }
@keyframes pickglow { 50% { outline-color: transparent; } }
.tstep { display: inline-block; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-right: 4px; }

/* Home: today's three things and the days this week (1 Dec) */
#home-daily:empty { display: none; }
.daily { display: flex; align-items: center; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; padding: 10px 14px; margin: -4px 0 12px; }
.dtasks { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dtasks .eyebrow { font-size: .7rem; margin-right: 2px; }
.dtask { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.dtask:hover { border-color: var(--accent); }
.dtask .dtick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); display: inline-grid; place-items: center; font-size: .8rem; line-height: 1; }
.dtask.done { border-color: var(--accent); color: var(--accent); }
.dtask.done .dtick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.dall { font-weight: 800; color: var(--accent); }
.dweek { display: flex; align-items: center; gap: 8px; }
.ddays { display: inline-flex; gap: 4px; }
.ddays i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .7rem; font-weight: 800; background: var(--line); color: var(--muted); }
.ddays i.on { background: var(--accent); color: var(--accent-ink, #fff); }
.ddays i.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.ddays i.future { opacity: .45; }
.daily .dwhy { flex-basis: 100%; margin: 0; }
.dtask svg { margin: -4px 0; flex: none; }
.hero.today.donetoday { border-color: var(--line); }

/* A skill's level: "Level 3 of 5 · Practising" with a five-part bar (1 Dec) */
.tlevelb { display: inline-flex; align-items: center; gap: 6px; vertical-align: 1px; margin-left: 4px; white-space: nowrap; background: none !important; }
.tlbar { display: inline-flex; gap: 2px; }
.tlbar i { width: 12px; height: 7px; border-radius: 2px; background: var(--line); }
.tlbar i.on { background: var(--accent); }
.tlword { font-size: .78rem; font-weight: 700; color: var(--muted); }
.tlevelb.ts-secure .tlword, .tlevelb.ts-proficient .tlword { color: var(--accent); }
.pipask { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: center; margin-top: 8px; }
.pipask[hidden] { display: none; }
/* A lesson left partway: "step 3 of 5" as a small pill, not a dot (1 Dec) */
.lbadge.started { font-size: .7rem; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: #e0a03022; color: #c07a00; }
/* Bot ladder: the suggested bot is marked on Pick a bot (1 Dec) */
.bot-tile { position: relative; }
.bot-tile.suggested { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.bot-tile .sugg { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--accent-ink, #fff); font-size: .68rem; font-weight: 800; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.botwhy { margin: 6px 0 2px; }

/* Costs box on the Activity page */
.costs h2 { margin-bottom: .5rem; }
.costtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.costtiles > div { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .8rem; border-radius: 12px; background: var(--soft, rgba(127,127,127,.08)); }
.costtiles .cnum { font-size: 1.5rem; font-weight: 700; }
.costtable th { text-align: left; font-weight: 600; font-size: .85rem; padding-right: .8rem; }
.costtable td { padding-right: .8rem; }
.costs details { margin: .5rem 0; }

/* Piece sets drawn as pictures (My collection); the classic set stays the font */
.pc.pimg { display: flex; align-items: center; justify-content: center; text-shadow: none; font-size: 0 !important; }
.board .pc.pimg { width: 90%; height: 90%; }
.pc.pimg img { width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.pc.pimg.ghost { width: var(--gsize, 56px); height: var(--gsize, 56px); }
.promo-row .pc.pimg { padding: 8px; }

/* My collection */
.collpage .card { margin-bottom: 1rem; }
.coll-me { display: flex; align-items: center; gap: 1rem; }
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .6rem; margin: .5rem 0; }
.coll-grid.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.coll-item { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .6rem .4rem; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card, transparent); color: inherit; font: inherit; cursor: pointer; text-align: center; }
.coll-item small { font-size: .72rem; line-height: 1.2; }
.coll-item.on { border-color: #2e9d6b; box-shadow: 0 0 0 3px rgba(46,157,107,.25); }
.coll-item.locked svg { filter: grayscale(1) brightness(.9); opacity: .45; }
.coll-item.locked span { opacity: .75; }
.coll-sub { margin: 1rem 0 0; font-size: 1rem; }
.coll-world { margin: .5rem 0 0; }
.pset { display: flex; gap: 2px; height: 44px; align-items: center; padding: 2px 6px; border-radius: 8px; background: #f0dcb4; }
.pset img { width: 36px; height: 36px; }
.pset .pc { font-size: 30px; }
.coll-board { width: 56px; height: 56px; border-radius: 8px; display: block; }
.unlock-card { max-width: min(460px, 92vw); text-align: center; }
.unlock-card .eyebrow { font-size: 1.2rem; font-weight: 800; color: #2e9d6b; }
.unlock-faces { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: .5rem 0; }
.unlock-card .row-buttons { justify-content: center; }
.bot-tile .unlockhint { font-size: .7rem; opacity: .8; }

/* Training: the one instruction line flashes when it changes after a wrong tap */
#tmsg.nudge { animation: tnudge .5s ease; }
@keyframes tnudge { 0%, 100% { background: transparent; } 30% { background: rgba(240, 173, 78, .35); } }

/* My training: one card per level, a level test, passed levels folded */
.tlevel > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; }
.tlevel > summary::-webkit-details-marker { display: none; }
.tlevel > summary h2 { margin: 0; }
.tlevel > summary::after { content: '▾'; margin-left: auto; opacity: .6; }
.tlevel:not([open]) > summary::after { content: '▸'; }
.tlevel.passed > summary .muted { color: #2e9d6b; font-weight: 600; }
.tltest { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem; margin: .5rem 0; border-radius: 12px; border: 1px dashed var(--line); }
.tpz { font-weight: 400; white-space: nowrap; }

/* Capability radar on My training (2 Dec 2026) */
.tradar .radar { display: block; width: 100%; max-width: 540px; margin: 4px auto 8px; overflow: visible; }
.radar .rgrid { fill: none; stroke: var(--line); stroke-width: 1; }
.radar .rtick { font-size: 9px; fill: var(--muted); }
.radar .rshape { fill: var(--accent); fill-opacity: .22; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar .rdot { fill: var(--accent); }
.radar .rdot.few { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 2 2; }
.radar .rnext { fill: none; stroke: var(--berry); stroke-width: 1.5; stroke-dasharray: 5 4; }
.radar .rlab { font-size: 12px; font-weight: 700; fill: var(--ink); }
.radar .rval { font-size: 11px; fill: var(--muted); }
.radar .rval.none { font-style: italic; }
.tplaced { font-size: .72rem; font-weight: 700; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 999px; padding: 0 7px; white-space: nowrap; }
/* Radar areas: tappable spokes and the area section (2 Dec 2026) */
.radar .rspoke { cursor: pointer; }
.radar .rhit { fill: transparent; }
.radar .rspoke:hover .rhit, .radar .rspoke:focus .rhit { fill: var(--accent-soft); }
.radar .rspoke.sel .rhit { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.radar .rspoke:focus { outline: none; }
.radar .rdot { cursor: pointer; }
.tareas { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tarea { padding: 6px 12px; font-size: .85rem; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); }
.tarea.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tapanel { border-top: 2px solid var(--line); padding-top: 10px; margin-top: 4px; }
.tapanel h3 { margin: 0 0 6px; }
.tapanel h4 { margin: 0 0 6px; font-size: .9rem; }
.taskills { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 4px; }
.taskills li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.taskills li > span:first-child { font-weight: 600; min-width: 9em; }
.tagrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.tabox { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.tabox p { margin: 0 0 6px; }
.tabtns { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.tabtns .small { font-size: .85rem; padding: 6px 10px; }
/* Puzzles: themes in groups (2 Dec 2026) */
.theme-menu .pgroup { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.theme-menu .pgroup.has:not(.open) { border-color: var(--accent); }
.theme-menu .pthemes { display: flex; flex-direction: column; gap: 4px; padding-left: 10px; border-left: 3px solid var(--accent-soft); margin-left: 6px; }
.theme-menu .pthemes button { padding: 7px 10px; font-size: .88rem; font-weight: 600; }
@media (max-width: 900px) {
  /* groups in one row, the open group's themes in a second row under them */
  .play3 .theme-menu { flex-wrap: wrap; overflow-x: visible; justify-content: center; align-items: flex-start; }
  .play3 .theme-menu .pthemes { order: 9; flex-direction: row; flex-wrap: wrap; justify-content: center; flex-basis: 100%; border-left: 0; margin: 0; padding: 4px 0 0; }
  .play3 .theme-menu .pthemes button { white-space: nowrap; }
}
@media (max-width: 600px) {
  .play3 .theme-menu .pthemes { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; }
  .play3 .theme-menu .pthemes button { flex: none; }
}

/* ---- Phone (Oli, 2 Dec 2026: "I think we need a mobile version", then on the iPhone: "You can do better with the
   sizing and spacing"). Up to 600px wide: the menu is a tab bar at the bottom, within thumb reach; the header keeps
   only the logo, Back and the player; every board is the full width of the screen, and what goes with it sits under
   it. Pages scroll instead of shrinking the board to fit. ---- */
.navhome, .gshort, .tb-hi, .tb-rating { display: none; }
@media (max-width: 600px) {
  :root { --top: 54px; --tabbar: calc(60px + env(safe-area-inset-bottom)); }
  body { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: calc(var(--tabbar) + 16px); font-size: 16px; }

  /* header (Oli, 2 Dec 2026: "we are losing too much space at the top"): one slim row with no line under it. The logo
     goes (Home is in the tab bar); Back on the left, or on Home the greeting; the player on the right. */
  :root { --top: 40px; }
  .topbar { grid-template-columns: 1fr auto; padding: 2px 0 0; gap: 8px; border-bottom: 0; min-height: 38px; }
  .topbar .brand-btn { display: none; }
  .topbar .backbtn { padding: 4px 12px; font-size: .92rem; border-radius: 10px; }
  .topbar .who { padding: 0; }
  .topbar .who svg { width: 30px; height: 30px; }
  .topbar .caret { display: none; }
  .tb-hi { display: inline; font-family: var(--display); font-weight: 800; font-size: 1.15rem; color: var(--accent); }
  main.home .hero-hi { display: none; }
  /* Puzzles (Oli, 2 Dec 2026: "Should we show ratings in the header?" - yes, on Puzzles only): the puzzle rating sits in
     the header beside the player, and the rating card under the buttons goes. */
  .tb-rating { display: inline-flex; align-items: baseline; gap: 5px; margin-left: auto; font-family: var(--display); font-weight: 800; line-height: 1; }
  .tb-rating .tbr-star { color: #f2b84b; font-size: 1.05rem; }
  .tb-rating .tbr-num { color: var(--accent); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
  .tb-rating .tbr-chg { font-size: .95rem; min-height: 0; }
  main.home { margin-top: 4px; }
  .play, .chat-layout, .play3, .play:not(.play3), main.analysis, main.trainpage { margin-top: 4px; }

  /* tab bar */
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; flex-wrap: nowrap; justify-content: space-around; gap: 0;
    padding: 4px max(6px, env(safe-area-inset-left)) env(safe-area-inset-bottom); background: var(--surface); border-top: 2px solid var(--line); box-shadow: 0 -4px 14px rgba(0,0,0,.12); }
  .nav .navhome { display: flex; }
  .navbtn { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; height: 54px; padding: 0 2px; border: 0; border-radius: 12px; white-space: nowrap; font-size: .95rem; }
  .navbtn.on { background: var(--accent-soft); border: 0; }
  .navbtn.on .navlbl { color: var(--ink); font-weight: 800; }
  .navico { font-size: 1.3rem; }
  .navlbl { font-size: .72rem; }
  .menu { position: fixed; top: 58px; right: 10px; width: min(300px, calc(100vw - 20px)); max-height: calc(var(--vh) - 58px - var(--tabbar) - 10px); overflow-y: auto; }

  /* home: today's training, the day's three things, then the five places in two columns */
  main.home { margin-top: 10px; }
  .hero.slim.today { padding: 12px; gap: 10px; }
  .hero.today .tbtns button { padding: 10px 12px; font-size: 1rem; }
  .daily { padding: 10px 12px; gap: 8px; margin: 0 0 12px; }
  .dtasks { gap: 6px; }
  .dtask { padding: 4px 10px; font-size: .9rem; }
  main.home .grid4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  main.home .grid4 .card.big { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; column-gap: 10px; row-gap: 2px; align-items: center; align-content: start; min-height: 0; padding: 12px; }
  main.home .grid4 .card.big > .ico, main.home .grid4 .card.big > svg { grid-row: 1; font-size: 1.6rem; width: 32px; height: 32px; margin: 0; display: grid; place-items: center; }
  main.home .grid4 .card.big strong { font-size: 1.05rem; line-height: 1.15; }
  main.home .grid4 .card.big .muted.small { grid-column: 1 / -1; font-size: .8rem; line-height: 1.3; align-self: start; }
  main.home .grid4 .card.big:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* every board page: the board as wide as the screen */
  .play:not(.play3), main.analysis { height: auto; display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 8px; }
  .play .board, .play3 .board, .play.coachplay .board, .an-board .board, .teachboard .board { width: min(calc(100vw - 24px), 560px); min-width: 0; }
  /* One board size on every page (Oli, 3 Dec 2026: "Board should be bigger but also they should be the same size on
     each page"). Older, more specific rules (the bot game's height limit, the puzzles' height limit) made some boards
     smaller; this wins over all of them. The small History board (#hboard) keeps its own size. */
  main .board:not(#hboard) { width: min(calc(100vw - 24px), 560px) !important; min-width: 0 !important; }
  .board { border-width: 4px; border-radius: 8px; }
  .board-col { align-items: center; }
  .play:not(.play3) .side { width: 100%; overflow: visible; }
  .play:not(.play3) .side .movebox { flex: none; max-height: 22vh; min-height: 48px; }
  .coachside .clog { flex: none; min-height: 140px; max-height: 50vh; }
  /* My training on a phone: the question sits right under the board (Oli, 3 Dec: "Not clear what you want me to do
     here"; it was under the tab bar, pushed down by an empty chat box). Then the title, Pip's words, Stop for today. */
  .trainplay .board-col { display: contents; }
  .trainplay #board { align-self: center; }
  .trainplay .coachside { order: 1; }
  .trainplay .underboard { order: 2; }
  .trainplay .coachside .cwait { order: -1; }
  .trainplay .coachside .clog { min-height: 0; }
  .trainplay .coachside .clog:empty { display: none; }
  .side .row-buttons, .underboard { gap: 8px; }
  .side .row-buttons button, .underboard button { flex: 1 1 auto; padding: 10px 12px; font-size: 1rem; }

  /* game analysis: board, then moves, then Pip, one under the other */
  .an-board .an-head { flex-wrap: wrap; row-gap: 6px; }
  .an-head .phasestrip { flex: 1 1 100%; max-width: none; flex-wrap: nowrap; gap: 4px; justify-content: space-between; margin: 0; }
  .an-head .phchip { flex: 1 1 0; min-width: 0; padding: 2px 1px; }
  .an-head .phchip b { font-size: .88rem; }
  .an-head .phchip i { font-size: .58rem; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .an-side { display: flex; flex-direction: column; height: auto; }
  .an-side .movebox.anno { max-height: 26vh; min-height: 80px; }
  .an-chat .chatlog { max-height: 55vh; min-height: 140px; }

  /* puzzles: five group buttons in one row (short names), the open group's themes in one sliding row, the board,
     then the task, the buttons, and the rating with this puzzle's rating beside it */
  .play3 { gap: 8px; margin-top: 8px; align-items: stretch; }
  .play3 .theme-menu { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; overflow: visible; width: 100%; }
  .play3 .theme-menu > button { padding: 8px 2px; text-align: center; justify-content: center; font-size: .85rem; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .play3 .theme-menu .glong, .play3 .theme-menu .garrow { display: none; }
  .play3 .theme-menu .gshort { display: inline; }
  .play3 .theme-menu .pgroup.open { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
  /* the board leaves room for the task and the buttons above the tab bar (a short phone gets a slightly smaller board) */
  .play3 .board { width: min(calc(100vw - 24px), 560px, max(300px, calc(var(--vh) - 318px))); }
  .play3 .theme-menu .pthemes { order: 9; grid-column: 1 / -1; display: flex; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 5px; padding: 0 0 2px; margin: 0; border: 0; scrollbar-width: none; }
  .play3 .theme-menu .pthemes::-webkit-scrollbar { display: none; }
  .play3 .theme-menu .pthemes button { flex: none; padding: 6px 12px; font-size: .85rem; border-radius: 999px; }
  .play3 .side { width: 100%; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "status status" "btns btns" "ask ask" "info info"; gap: 8px 12px; align-items: center; }
  .play3 .side #status { grid-area: status; text-align: center; font-size: 1.1rem; margin: 2px 0 0; }
  .play3 .side .row-buttons { grid-area: btns; margin: 0; flex-wrap: nowrap; }
  .play3 .side .row-buttons button { flex: 1 1 0; min-width: 0; padding: 10px 6px; font-size: .95rem; white-space: nowrap; }
  .play3 .side #askpip { grid-area: ask; margin: 0; }
  .play3 .side .rating-card { grid-area: rate; display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-width: 2px; }
  .play3 .side .rlabel { font-size: .68rem; }
  .play3 .side .rnum { font-size: 1.7rem; }
  .play3 .side .rchange { font-size: 1rem; min-height: 0; }
  .play3 .side #pinfo { grid-area: info; margin: 0; text-align: center; }
  .play3 .side .rating-card { display: none; }

  /* Ask Pip and lessons: the board first, full width */
  .chat-layout { gap: 12px; }
  .teachboard .board { align-self: center; }
  .chatlog { max-height: 55vh; }

  /* Pick a bot */
  .world-row { gap: 6px; }

  /* My training: the session lengths on one row; the radar's words readable at phone size */
  .tlen { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; width: 100%; }
  .tlen button { padding: 10px 4px; font-size: .95rem; white-space: nowrap; }
  .ttoday .grow2 { min-width: 0; }
  .tradar .radar { margin: 0 auto 4px; }
  .radar .rlab { font-size: 14px; }
  .radar .rval { font-size: 13px; }
  .radar .rtick { font-size: 10px; }
}

/* Play with Pip's three tabs (Oli, 2 Dec 2026): Board, Progress, History above the board; the chat stays beside it. */
.ptabs { display: flex; gap: 6px; width: 100%; max-width: 660px; margin: 0 auto 8px; }
.ptabs button { flex: 1 1 0; padding: 8px 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; white-space: nowrap; }
.ptabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ptab-board { display: flex; flex-direction: column; align-items: center; }
.ptab-board[hidden], .ppanel[hidden] { display: none; }
.ppanel { width: min(640px, 58vw); max-height: calc(var(--vh) - 170px); overflow-y: auto; }
.ppanel .card { margin: 0; }
.pprog .radar { width: 100%; height: auto; display: block; }
.phist h3 { margin: 10px 0 6px; }
.phist .row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); }
.phist .row:hover { border-color: var(--accent); }
#hview { margin-bottom: 10px; }
#hview .hhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
#hboard.board { width: min(100%, 420px); margin: 0 auto; }
.hsteps { justify-content: center; margin-top: 6px; }
.hsteps button { padding: 6px 12px; }
@media (max-width: 600px) {
  .ptabs { margin-bottom: 6px; }
  .ptabs button { padding: 7px 4px; font-size: .9rem; }
  .ppanel { width: calc(100vw - 24px); max-height: 52dvh; }
  #hboard.board { width: min(100%, 300px); }
}

/* Opened from the home screen as a web app: keep clear of the status bar (2 Dec 2026) */
body { padding-top: var(--sat); }
/* --vh is the screen height left once the status bar and home bar are taken off: every page that fits one screen
   sizes from it. Before 6 Dec they used 100dvh, so on the iPad web app the bottom buttons sat under the edge
   (Oli, 6 Dec: "it's not rendering in the screen correction"). */
:root { --sat: env(safe-area-inset-top, 0px); --vh: calc(100dvh - var(--sat) - env(safe-area-inset-bottom, 0px)); }
/* The header never runs off the right edge: the nav may shrink, and below 1200px the name next to the picture goes
   (the picture stays, as it already did below 900px). On a 1080px iPad "HoneyBadger" pushed the header past the edge. */
.topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
.nav { min-width: 0; }
@media (max-width: 1200px) { .topbar .who > span:not(.caret) { display: none; } }

/* Arabic reads right to left (public/js/i18n.js sets dir="rtl"); the board, its letters and the move lists keep chess
   order, left to right. */
[dir="rtl"] .board, [dir="rtl"] .pipboard, [dir="rtl"] svg.radar { direction: ltr; }
[dir="rtl"] .mv, [dir="rtl"] .mn, [dir="rtl"] .movebox, [dir="rtl"] .mvtag { direction: ltr; unicode-bidi: isolate; }

/* One board size on every page, on every screen (Oli, 3 Dec 2026: "they should be the same size on each page", then
   "im after consisntency"). Phone: the rule in the max-width 600px block. Tablet: as wide as the screen allows, up to
   560px. Computer: the smallest of 600px, the screen height less the header and the line under the board, and the
   screen width less room for the side panels (the Puzzles page needs the most). The small History board keeps its own. */
@media (min-width: 601px) and (max-width: 900px) {
  main .board:not(#hboard) { width: min(560px, calc(100vw - 24px)) !important; min-width: 0 !important; }
}
@media (min-width: 901px) {
  main .board:not(#hboard) { width: max(320px, min(600px, calc(var(--vh) - 210px), calc(100vw - 620px))) !important; min-width: 0 !important; }
  /* Ask Pip's page: the board column takes the board's size, the chat the rest */
  .chat-layout { grid-template-columns: minmax(320px, 1fr) auto; max-width: 1240px; }
  .teachboard .board { align-self: center; }
}

/* My plan with Pip (3 Dec 2026; pip.js plan(), plan-view.js) */
.planpage { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.planpage #planbody { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.pintro { display: flex; gap: 12px; align-items: center; }
.pintro p { margin: 0; }
.pq { margin: 0 0 12px; }
.pqt { font-weight: 700; margin: 0 0 6px; }
.pqopts { display: flex; flex-wrap: wrap; gap: 8px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.pbox { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.pbox h3 { font-size: .95rem; margin: 0 0 6px; }
.pbox p { margin: 4px 0; }
.plist { margin: 0; padding-left: 18px; }
.plist li { margin: 3px 0; }
.ptable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ptable th, .ptable td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ptable th { font-weight: 600; color: var(--muted); font-size: .8rem; }
.ptable td:not(:first-child) { white-space: nowrap; }
.pcheck { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-color: var(--accent); }
.pcheck.pbox { display: block; }
.pnote { display: block; width: 100%; text-align: left; margin-bottom: 10px; }
.pwaitfor { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pevents summary { cursor: pointer; list-style: none; }
.pevents summary h3 { display: inline; }

/* Home tiles: three and three on iPad and desktop (Oli, 3 Dec 2026: "The home page has 5 and 1, lets make it 3 + 3") */
@media (min-width: 701px) { main.home .grid4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Pip on Home: one line until used, then the shared chat (app.js fillAsk) */
.homeask { padding: 10px 12px; }
.homeask .askbar { display: flex; gap: 8px; align-items: center; margin: 0; }
.homeask .askbar input { flex: 1; min-width: 0; }
.homeask .chatlog { max-height: min(55vh, 420px); overflow-y: auto; }
.homeask .homeall { margin: 6px 0 0; text-align: right; }

/* Chat boxes: several lines, Enter sends, Shift+Enter new line (app.js) */
textarea.chatbox { font: inherit; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); flex: 1; min-width: 0; resize: none; overflow-y: auto; line-height: 1.35; height: auto; max-height: 170px; box-sizing: border-box; }
textarea.chatbox:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.chatform, .askbar { align-items: flex-end; }

/* Home spacing: one even gap between every block and every tile, tiles the same height in each row,
   the "Today" label on its own line on a phone (Oli, 4 Dec 2026: "The spacing looks imprecise") */
main.home { display: flex; flex-direction: column; gap: 12px; }
main.home > .hero, main.home .daily { margin: 0; }
main.home .grid4 { gap: 12px; grid-auto-rows: 1fr; }
@media (max-width: 700px) {
  main.home .dtasks .eyebrow { flex-basis: 100%; margin: 0; }
  main.home .daily { row-gap: 10px; }
}
@media (min-width: 701px) {
  main.home .grid4 .card.big > .ico, main.home .grid4 .card.big > svg { display: grid; place-items: center; height: 38px; margin: 0; line-height: 1; }
  main.home .grid4 .card.big > svg { width: 38px; }
}

/* A bot game in progress, kept on the device: "Carry on" on Home and Play (Oli, 4 Dec 2026) */
.livegame { display: flex; align-items: center; gap: 12px; border-color: var(--sun, var(--accent)); }
.livegame .grow2 { flex: 1; min-width: 0; }
.livegame .tbtns { display: flex; gap: 8px; flex: none; }
.liveslot { display: flex; flex-direction: column; gap: 12px; }
.liveslot:empty { display: none; }
.wrap:not(.home) > .liveslot { margin-bottom: 12px; }
.livegame .eyebrow { font-size: .7rem; }
.livegame strong { font-size: 1.1rem; }
.livegame .livemeta { display: block; }
@media (max-width: 700px) {
  .livegame { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .livegame .tbtns { width: 100%; }
  .livegame #livego { flex: 1; padding: 10px 12px; font-size: 1rem; }
}

/* A move explained on the review board: arrows in different colours and a key in words (Oli, 4 Dec 2026: "show me
   the moves in arrows that pertain to 18 Qf3 ... and also show me the better moves etc using different arrows") */
.arw-their { fill: #7c8ea6; } .arw-threat { fill: #f08c1a; } .arw-mine { fill: #3b82c4; } .arw-reply { fill: #9b6bdf; }
.akey:empty { display: none; }
.akey { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 4px; }
.akey-title { margin: 0 0 2px; font-weight: 800; }
.akrow { display: flex; align-items: flex-start; gap: 10px; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; color: var(--ink); font: inherit; font-size: .92rem; line-height: 1.35; cursor: pointer; }
.akrow.on { border-color: var(--accent); background: var(--accent-soft); }
.akrow.plain { cursor: default; }
.akdot { flex: none; width: 22px; height: 8px; border-radius: 4px; margin-top: 6px; }
.ak-their { background: #7c8ea6; } .ak-threat { background: #f08c1a; } .ak-mine { background: #3b82c4; } .ak-reply { background: #9b6bdf; }
.ak-bad { background: #d9534f; } .ak-good { background: #2e9d6b; } .ak-warn { background: #e0a020; }
.akmark { font-weight: 800; color: #d9534f; }
.akhint { margin: 2px 0 0; }
.ak-open { width: 16px; height: 16px; margin: 2px 3px 0; border-radius: 4px; background: none; box-shadow: inset 0 0 0 3px #d9534f; }

/* Online sign-in and Grown-ups pages (5 Dec 2026). */
.authpage { max-width: 560px; }
.authform label { display: block; margin: .6rem 0; font-weight: 700; }
.authform label input:not([type=checkbox]), .authform label select { display: block; width: 100%; margin-top: .25rem; }
.authform label.consent, label.consent { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; line-height: 1.4; margin: .8rem 0; }
label.consent input[type=checkbox] { width: 1.3rem; height: 1.3rem; flex: 0 0 auto; margin-top: .1rem; }
.authpage .linkbtn + .linkbtn { margin-left: 1rem; }
.authpage .ok { color: var(--accent); }
.gp { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.gp .linkbtn:first-of-type { margin-left: auto; }
.authtop { padding: 14px 16px 4px; }
.authtop h1 { font-size: 1.6rem; text-align: center; margin: 0; }
.authpage .secondary, .gveil .secondary { background: var(--surface); color: var(--ink); border: 2px solid var(--line); }
.authpage form .primary + .secondary, .gveil form .primary + .secondary { margin-left: .5rem; }

.gbtn { display: flex; align-items: center; justify-content: center; gap: .6rem; width: 100%; margin: .4rem 0 .2rem; }

/* Front page (online, signed out), 5 Dec 2026: the Hydra Forest look (Oli: "cartoony brawlstars"). Night-purple game
   panels with a soft inner glow, a neon ring around Pip, glossy 3D characters (public/art), gold and green chunky
   buttons with a hard bottom edge. Scoped to .landing so the app itself is unchanged. */
html:has(.landing), body:has(.landing) { background: #170e38 radial-gradient(120% 900px at 50% 0%, #4b2d97 0%, #2a1a5e 55%, #170e38 100%) no-repeat; min-height: 100%; }
.landing { --ink: #ffffff; --muted: #d6ccff; --panel: #2b1c5f; --edge: #6c4fd1; --gold: #ffc83d; --green: #36c35b;
  max-width: 1160px; margin: 0 auto; padding: 0 16px 24px; color: var(--ink); }
.lbar { display: flex; align-items: center; gap: .55rem; padding: 18px 0 6px; font-family: var(--display); font-size: 1.45rem; font-weight: 800; }
.lbar span { font-family: var(--body); font-size: .9rem; font-weight: 600; color: var(--muted); }
.lhero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(310px, .85fr); gap: 36px; align-items: start; padding: 10px 0 26px; }
.lhero h1 { font-family: var(--display); font-weight: 800; font-size: clamp(2.3rem, 5.4vw, 3.9rem); line-height: .98; margin: 0 0 12px;
  text-shadow: 0 4px 0 #120a2e; }
.lsub { font-size: 1.08rem; line-height: 1.45; max-width: 54ch; color: var(--muted); margin: 0 0 16px; }
.lstage { display: flex; align-items: center; gap: 18px; }
.lring { width: min(220px, 40vw); aspect-ratio: 1; border-radius: 50%; padding: 7px; flex: 0 0 auto;
  background: conic-gradient(#ff5fd2, #ffc83d, #36c35b, #3ec7ff, #8a5cff, #ff5fd2); box-shadow: 0 0 40px #8a5cff88; }
.lring img { width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover; border: 5px solid #170e38; }
.lbubble { margin: 0; padding: 12px 16px; background: #fff; color: #1d1442; border-radius: 22px 22px 22px 6px; font-weight: 800;
  max-width: 30ch; box-shadow: 0 6px 0 #00000040; }
.lform { position: sticky; top: 16px; }
.landing .lcard { background: var(--panel); color: var(--ink); border: 3px solid var(--edge); border-radius: 24px; padding: 18px 20px;
  box-shadow: inset 0 0 0 2px #ffffff14, 0 10px 30px #0006; }
.landing .lcard h2 { margin-top: 0; font-family: var(--display); font-weight: 800; }
.landing .lcard .muted { color: var(--muted); }
.landing .lcard input { background: #1c1245; color: #fff; border: 2px solid var(--edge); }
.landing .primary { background: var(--green); color: #fff; border: 0; border-radius: 14px; box-shadow: 0 5px 0 #1d7a36; text-shadow: 0 2px 0 #1d7a3699; }
.landing .primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #1d7a36; }
.landing .gbtn { background: #fff; color: #1d1442; border: 0; border-radius: 14px; padding: 11px; font-weight: 800; box-shadow: 0 5px 0 #b9b0e6; }
.landing .linkbtn { color: var(--gold); font-weight: 700; }
.landing .lcard .linkbtn + .linkbtn { margin-left: 1rem; }
.landing .error { color: #ff9b9b; } .landing .ok { color: #8ff0a8; }
.lworlds { padding: 0 0 22px; }
.lworlds h2 { font-family: var(--display); font-weight: 800; font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 2px; text-shadow: 0 3px 0 #120a2e; }
.lworlds .lsub { margin: 0; }
.lworlds ol { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.lworld { border-radius: 20px; overflow: hidden; border: 3px solid #ffffff2e; box-shadow: 0 6px 0 #0005; display: flex; flex-direction: column; }
.lworld img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; object-position: 50% 30%; display: block; }
.lwbody { padding: 8px 10px 10px; flex: 1; }
.lworld h3 { font-family: var(--display); font-weight: 800; font-size: 1.2rem; margin: 0 0 2px; text-shadow: 0 2px 0 #0004; }
.lworld p { margin: 0 0 8px; font-size: .84rem; line-height: 1.3; }
.lworld.jg { background: #2d8a47; } .lworld.sf { background: #c9821c; } .lworld.fr { background: #1d5e45; }
.lworld.mt { background: #3c63a6; } .lworld.vc { background: #b93a26; }
.lfaces { display: flex; gap: 5px; }
.lface svg { width: 28px; height: 28px; background: #fff; border-radius: 50%; padding: 2px; box-shadow: 0 3px 0 #0004; }
.lmore { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 0 0 8px; }
.lmore > div { background: var(--panel); border: 3px solid var(--edge); border-radius: 20px; padding: 14px 16px; }
.lmore h3 { font-family: var(--display); font-weight: 800; font-size: 1.12rem; margin: 0 0 4px; color: var(--gold); }
.lmore p { margin: 0; color: var(--muted); line-height: 1.45; font-size: .93rem; }
.lmore > .lparents { background: var(--gold); color: #2a1a5e; border-color: #b7861b; box-shadow: 0 6px 0 #b7861b; }
.lmore > .lparents h3 { color: #2a1a5e; }
.lparents ul { margin: 0; padding-left: 1.1rem; line-height: 1.4; font-weight: 700; font-size: .9rem; }
.lfoot { padding: 18px 0 0; text-align: center; color: var(--muted); font-size: .9rem; }
.landing :focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (max-width: 900px) {
  .lhero { grid-template-columns: 1fr; gap: 16px; padding: 6px 0 20px; }
  .lform { position: static; }
  /* The worlds become one row you swipe sideways, so they add one card's height, not five. */
  .lworlds ol { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
  .lworld { flex: 0 0 180px; scroll-snap-align: start; }
  .lmore { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .lbar { padding-top: 12px; font-size: 1.25rem; }
  .lhero h1 { font-size: 2.2rem; margin-bottom: 8px; }
  .lsub { font-size: .98rem; margin-bottom: 12px; }
  .lstage { gap: 12px; }
  .lring { width: 116px; padding: 5px; }
  .lring img { border-width: 4px; }
  .lbubble { font-size: .88rem; padding: 10px 12px; }
  .landing .lcard { padding: 16px; }
  .lworld { flex: 0 0 150px; }
  .lworld p { display: none; }
  .lmore { grid-template-columns: 1fr; gap: 10px; }
  .lmore > div { padding: 12px 14px; }
}


/* ---- VivoChess night (the default theme): the game layer, as on the front page. Only when no other theme is chosen. ---- */
:root:not([data-theme]) body { background: #170e38 radial-gradient(120% 700px at 50% 0%, #4b2d97 0%, #2a1a5e 55%, #170e38 100%) no-repeat; }
:root:not([data-theme]) h1, :root:not([data-theme]) h2 { font-weight: 800; text-shadow: 0 3px 0 #120a2e; }
:root:not([data-theme]) .card, :root:not([data-theme]) .tile, :root:not([data-theme]) .bot-tile {
  border: 3px solid var(--line); box-shadow: inset 0 0 0 1px #ffffff12, 0 6px 0 #0d0726; }
:root:not([data-theme]) .tile:hover, :root:not([data-theme]) .bot-tile:hover { border-color: var(--sun); }
:root:not([data-theme]) .primary { text-shadow: 0 2px 0 #1d7a3699; }
:root:not([data-theme]) .secondary { background: #3a2785; border: 0; box-shadow: 0 4px 0 #160d3a; color: #fff; }
:root:not([data-theme]) .secondary:active { transform: translateY(2px); box-shadow: 0 2px 0 #160d3a; }
:root:not([data-theme]) input, :root:not([data-theme]) select, :root:not([data-theme]) textarea { background: #1a1140; border-color: var(--line); color: #fff; }
:root:not([data-theme]) .eyebrow { color: var(--sun); }
:root:not([data-theme]) .tab.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-edge); }
:root:not([data-theme]) .board { box-shadow: 0 8px 0 #0d0726; border: 3px solid #120a2e; }
:root:not([data-theme]) .opt.on { box-shadow: 0 0 0 3px var(--sun); }
:root:not([data-theme]) a { color: var(--sun); }

.temo { display: inline-block; width: 1.4em; text-align: center; }

/* Less scrolling (5 Dec 2026, Oli: "i like the theming, make it require scrolling less"). */
/* My progress: the log spans the page with its rows in two columns; long reference sections fold shut. */
.hub .hublog { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.hub .hublog > h2, .hub .hublog > p, .hub .hublog > .logmore { grid-column: 1 / -1; }
.hub .hublog > p { margin: 0 0 4px; }
.hub .hublog .row[hidden] { display: none; }
.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: '▸'; margin-left: auto; font-size: 1.2rem; color: var(--muted); transition: transform .15s; }
.fold[open] > summary::after { transform: rotate(90deg); }
.fold > summary h2 { margin: 0; }
.fold[open] > summary { margin-bottom: 8px; }
/* Preferences (and the grown-ups page): two columns on a wide screen, smaller option buttons. */
.prefspage { max-width: 1000px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.prefspage > :not(.prefsec) { grid-column: 1 / -1; }
.prefspage .prefsec { margin: 0; padding: 12px 14px; }
.prefsec .opt { padding: 7px 11px; font-size: .95rem; }
.prefsec p { margin: 0 0 8px; }
@media (max-width: 760px) {
  .hub .hublog { grid-template-columns: 1fr; }
  .prefspage { grid-template-columns: 1fr; gap: 10px; }
}
/* Phone: the progress page keeps to the screen width; conversations and Pip's suggestions are one row you swipe sideways. */
.hub > * { min-width: 0; }
.suggest .sugrow { display: flex; flex-wrap: wrap; gap: 10px; flex: 1 1 100%; min-width: 0; }
@media (max-width: 760px) {
  .hub { grid-template-columns: minmax(0, 1fr); }
  .convs .convrow, .suggest .sugrow { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
  .convs .convbtn { flex: 0 0 72%; max-width: none; scroll-snap-align: start; }
  .convs .convbtn.primary { flex: 0 0 auto; }
  .suggest .sugrow .sug { flex: 0 0 82%; scroll-snap-align: start; }
}
.chat { grid-template-columns: minmax(0, 1fr); } /* the chat keeps to its card on a phone */
/* A child signs in with their own username (6 Dec 2026). */
.kidbtn { display: block; width: 100%; margin: 0 0 1rem; }
.glogin { margin: .4rem 0 .8rem; }
.gp { flex-wrap: wrap; }
.gp .gplogin, .gp .glogin, .gp .gpacts { flex-basis: 100%; }
.gp .gpacts .linkbtn { margin: 0 1rem 0 0; }
.gp .gplogin .linkbtn { margin-left: .4rem; }
/* Plan with Pip (assess.js, 6 Dec 2026): the steps, Pip's words, and Pip's offer on Home. */
.assesspage #abody { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.asteps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.asteps li { flex: 1; min-width: 70px; text-align: center; font-size: .85rem; padding: 6px 8px; border-radius: 999px; border: 2px solid var(--line); color: var(--muted); }
.asteps li.on { border-color: var(--accent); color: var(--ink); font-weight: 700; }
.asteps li.done { background: var(--accent-soft); border-color: var(--accent-edge); color: var(--ink); }
.apip p { font-size: 1.05rem; line-height: 1.45; }
.aoffer { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-color: var(--accent); margin-bottom: 12px; }
.aoffer .grow2 { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.aoffer .row-buttons { margin: 0; }
.aoffer strong { white-space: normal; overflow: visible; text-overflow: clip; }

/* Home fits one phone screen (Oli, 6 Dec 2026, iPhone home-screen app: "This should fit on the Home Screen without
   scrolling"). Measured at 390x844 before: about 960 px of cards for about 670 px between the status bar and the menu.
   Phones only: the plan offer in two lines, tighter cards, and the six tiles as a 3x2 grid of icon and name (their
   one-line notes are hidden here; the next bot is in Today). */
@media (max-width: 560px) {
  main.home { gap: 8px; margin-top: 4px; }
  main.home .aoffer { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; padding: 8px 10px; }
  main.home .aoffer > svg { width: 30px; height: 30px; }
  main.home .aoffer .grow2 { min-width: 0; }
  main.home .aoffer strong { font-size: .98rem; line-height: 1.2; }
  main.home .aoffer .grow2 .muted { display: none; }
  main.home .aoffer .row-buttons { grid-column: 1 / -1; flex-wrap: nowrap; justify-content: stretch; gap: 8px; }
  main.home .aoffer .row-buttons button { flex: 1; padding: 7px 10px; font-size: .95rem; min-height: 0; }
  main.home .hero.slim.today { padding: 8px 10px; gap: 6px 10px; }
  main.home .hero.today > svg { width: 32px; height: 32px; }
  main.home .hero.today .tbtns button { padding: 7px 10px; font-size: .95rem; min-height: 0; }
  main.home .daily { padding: 8px 10px; gap: 6px 10px; row-gap: 6px; }
  main.home .daily .dtask { padding: 4px 10px; font-size: .9rem; }
  main.home .daily .dwhy { display: none; }
  main.home .homeask { padding: 6px 10px; }
  main.home .homeask .askbar > svg { width: 24px; height: 24px; }
  main.home .homeask .askbar button { padding: 7px 14px; min-height: 0; }
  main.home .grid4 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; grid-auto-rows: auto; }
  main.home .grid4 .card.big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 0; padding: 8px 4px; text-align: center; }
  main.home .grid4 .card.big > .ico, main.home .grid4 .card.big > svg { font-size: 1.35rem; width: 28px; height: 28px; }
  main.home .grid4 .card.big strong { font-size: .86rem; line-height: 1.15; }
  main.home .grid4 .card.big .muted.small { display: none; }
}
