:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #2b2a26;
  --muted: #8a8578;
  --wood: #dcb35c;
  --line: #4a3f28;
  --accent: #2f6f4f;
  --danger: #b0413e;
  --chip: #ece7db;
  --border: #e2ddd0;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
a { color: inherit; }

header {
  display: flex; align-items: center; gap: 18px;
  padding: 13px 26px; background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 17px; margin: 0; }
header h1 a { text-decoration: none; }
header h1 .name-short { display: none; }
header h1 .name-zh { margin-right: 4px; }
#tabs { display: flex; gap: 4px; }
#tabs a {
  text-decoration: none; padding: 6px 14px; border-radius: 8px;
  color: var(--muted); font-size: 14px;
}
#tabs a.active { background: var(--chip); color: var(--ink); font-weight: 600; }
#tabs a:hover:not(.active) { background: #f4f0e5; }
#crumbs { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#crumbs a { text-decoration: none; }
#crumbs a:hover { text-decoration: underline; }
.engine-chip {
  margin-left: auto; font-size: 12.5px; color: var(--muted);
  background: var(--chip); padding: 5px 12px; border-radius: 999px;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.engine-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #c9c2b2; }

.auth-chip {
  font-size: 12.5px; color: var(--muted);
  background: var(--chip); padding: 5px 12px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap; cursor: pointer;
}
.auth-chip:hover { background: #e4dec9; }
.auth-chip .email { color: var(--ink); font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.auth-chip .signout { color: var(--muted); text-decoration: underline; }
.auth-chip .signout:hover { color: var(--danger); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30, 26, 16, .35);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
/* author display:flex beats the UA's [hidden]{display:none} — restate it */
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 14px; padding: 26px 28px;
  width: min(340px, 90vw); box-shadow: 0 12px 40px rgba(30, 26, 16, .25);
  display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal input {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 14px; background: var(--bg); color: var(--ink);
}
.modal .msg { font-size: 13px; color: var(--muted); min-height: 16px; }
.modal .msg.err { color: var(--danger); }
.modal .msg.ok { color: var(--accent); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.modal button {
  padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; background: var(--accent); color: #fff;
}
.modal button:disabled { opacity: .6; cursor: default; }
.modal button.ghost { background: none; color: var(--muted); font-weight: 500; }
.modal .switch { font-size: 13px; color: var(--muted); }
.modal .switch a { color: var(--accent); cursor: pointer; text-decoration: underline; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---- library ---- */
.cat-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin: 30px 0 10px;
}
.book-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.book {
  position: relative;
  background: var(--card); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(60,50,30,.07); cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid transparent;
}
.book:hover { border-color: #d4cdba; }
.book .star {
  position: absolute; top: 10px; right: 12px; font-size: 17px;
  color: #d8d0bb; cursor: pointer; line-height: 1;
}
.book .star:hover { color: #b89a4e; }
.book .star.on { color: #b89a4e; }
.book .t { font-weight: 600; padding-right: 18px; }
.book .n { color: var(--muted); font-size: 13px; }
.book .row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.badge.dan { background: #2b2a26; color: #fff; }
.bar { flex: 1; height: 5px; border-radius: 3px; background: #eee8da; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
.book .cnt { font-size: 12px; color: var(--muted); }

/* ---- book grid ---- */
.book-head { margin: 6px 0 18px; }
.book-head h2 { margin: 0 0 2px; font-size: 20px; }
.book-head .sub { color: var(--muted); font-size: 14px; }
.book-head .reset-book {
  margin-top: 10px; font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 10px;
  border: 1px solid #ddd6c6; background: #faf8f2; color: var(--ink); cursor: pointer;
}
.book-head .reset-book:hover { background: #f1ede1; }
.prob-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.cell {
  aspect-ratio: 1; border-radius: 9px; background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 2px rgba(60,50,30,.07);
  border: 1px solid transparent; color: var(--muted);
}
.cell:hover { border-color: #d4cdba; }
.cell.ok { background: var(--accent); color: #fff; }
.cell.bad { background: #f3dddc; color: var(--danger); }

/* ---- player ---- */
.player { display: flex; gap: 26px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.board-card {
  background: var(--card); border-radius: 16px; padding: 20px;
  box-shadow: 0 1px 3px rgba(60,50,30,.08), 0 8px 24px rgba(60,50,30,.06);
}
.board-card.explore { outline: 2px dashed #b89a4e; outline-offset: -8px; }
.board-card { max-width: 100%; }
svg { display: block; touch-action: manipulation; }
.board-card svg { max-width: 100%; height: auto; }

aside { width: 300px; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--card); border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(60,50,30,.08);
}
.panel h2 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 0 0 8px;
}
.meta-title { font-size: 15.5px; font-weight: 650; }
.meta-sub { color: var(--muted); font-size: 13px; }
.badges { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.badge.turn { background: #2b2a26; color: #fff; }

#status { min-height: 30px; display: flex; align-items: center; gap: 9px; font-size: 15px; }
#status.ok { color: var(--accent); font-weight: 650; }
#status.bad { color: var(--danger); font-weight: 650; }
#status.off { color: #9a6b1f; }
#status .icon { font-size: 18px; }
.source-note { margin-top: 6px; font-size: 14.5px; font-style: italic; color: #7a5a1c; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.controls button {
  font: inherit; font-size: 14px; font-weight: 600; padding: 9px 0; border-radius: 10px;
  border: 1px solid #ddd6c6; background: #faf8f2; color: var(--ink); cursor: pointer;
}
.controls button:hover { background: #f1ede1; }
.controls button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.controls button.active { background: #b89a4e; border-color: #b89a4e; color: #fff; }
.controls button:disabled { opacity: .4; cursor: default; }
.controls button.wide { grid-column: 1 / -1; }

.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-row button {
  font: inherit; font-weight: 600; border: 1px solid #ddd6c6; background: #faf8f2;
  border-radius: 10px; padding: 8px 16px; cursor: pointer;
}
.nav-row button:hover { background: #f1ede1; }
.nav-row button:disabled { opacity: .4; cursor: default; }
.nav-row .pos { color: var(--muted); font-size: 13.5px; }

.keys { color: var(--muted); font-size: 12px; line-height: 1.9; }
.keys b { display: inline-block; min-width: 22px; background: var(--chip); border-radius: 5px;
          padding: 0 5px; text-align: center; color: var(--ink); font-weight: 600; margin-right: 4px; }

.loading { text-align: center; color: var(--muted); padding: 80px 0; }

/* ---- review mode ---- */
.review-entry {
  background: var(--card); border-radius: 12px; padding: 14px 16px; margin: 4px 0 6px;
  box-shadow: 0 1px 3px rgba(60,50,30,.07); display: flex; align-items: center; gap: 14px;
  border: 1px solid transparent; cursor: pointer;
}
.review-entry:hover { border-color: #d4cdba; }
.review-entry .t { font-weight: 600; }
.review-entry .n { color: var(--muted); font-size: 13px; }

.sgf-loader { max-width: 620px; margin: 30px auto; display: flex; flex-direction: column; gap: 14px; }
.sgf-loader textarea {
  font: 13px/1.5 ui-monospace, Menlo, monospace; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); min-height: 140px; resize: vertical;
}
.sgf-loader .row { display: flex; gap: 10px; align-items: center; }
.sgf-loader button, .sgf-loader label.file {
  font: inherit; font-weight: 600; padding: 9px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid #ddd6c6; background: #faf8f2;
}
.sgf-loader button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.sgf-loader .err { color: var(--danger); font-size: 14px; }

.review-history { max-width: 620px; margin: 8px auto 30px; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--card); border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 1px 2px rgba(60,50,30,.06);
}
.history-item .hi-open { flex: 1; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.history-item .t { font-weight: 600; font-size: 14px; }
.history-item .n { color: var(--muted); font-size: 12.5px; }
.history-item .hi-rename-btn, .history-item .hi-del {
  color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 13px;
}
.history-item .hi-rename-btn:hover { color: var(--ink); background: var(--chip); }
.history-item .hi-del:hover { color: var(--danger); background: #f3dddc; }
.history-item .hi-rename {
  font: inherit; font-weight: 600; font-size: 14px; width: 100%;
  border: 1px solid var(--accent); border-radius: 6px; padding: 2px 6px;
  background: var(--card); color: var(--ink);
}

.review { display: flex; gap: 26px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.review aside { width: 360px; }

.rv-nav { display: flex; gap: 8px; align-items: center; }
.rv-nav button {
  font: inherit; font-weight: 600; border: 1px solid #ddd6c6; background: #faf8f2;
  border-radius: 9px; padding: 6px 12px; cursor: pointer; min-width: 42px;
}
.rv-nav button:hover { background: #f1ede1; }
.rv-nav .pos { color: var(--muted); font-size: 13.5px; margin-left: auto; white-space: nowrap; }

.mt-toggle {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 12px 0 0; cursor: pointer; user-select: none;
}
.mt-toggle:hover { color: var(--ink); }
.movetree {
  margin-top: 8px; height: 150px; overflow: auto;
  background: #faf8f2; border-radius: 10px; border: 1px solid #eee8da;
}
.movetree svg { display: block; }

.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  font-size: 12px; line-height: 1.5; padding: 6px 9px; border-radius: 8px;
  transform: translate(-50%, -110%); white-space: nowrap; display: none; z-index: 5;
}
.chart-note { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.mistakes { display: flex; flex-direction: column; gap: 4px; }
.mistake {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px;
}
.mistake:hover { background: #f4f0e5; }
.mistake .dot { width: 9px; height: 9px; border-radius: 50%; background: #b0413e; flex: none; }
.mistake .who { color: var(--muted); min-width: 84px; }
.mistake .loss { margin-left: auto; font-weight: 650; color: #b0413e; font-variant-numeric: tabular-nums; }
.mistake .loss.minor { color: #9a6b1f; }

.rv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.rv-actions button {
  font: inherit; font-size: 14px; font-weight: 600; padding: 9px 0; border-radius: 10px;
  border: 1px solid #ddd6c6; background: #faf8f2; cursor: pointer;
}
.rv-actions button:hover { background: #f1ede1; }
.rv-actions button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.rv-actions button.active { background: #3566b0; border-color: #3566b0; color: #fff; }
.rv-actions button:disabled { opacity: .45; cursor: default; }
.rv-actions button.wide { grid-column: 1 / -1; }
.rv-progress { color: var(--muted); font-size: 13px; margin-top: 8px; min-height: 18px; }

.move-note {
  display: block; width: 100%; box-sizing: border-box; margin-top: 8px; resize: vertical;
  font: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid #eee8da; background: #faf8f2; color: var(--ink);
}

.rec-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.rec-field {
  font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid #eee8da; background: #faf8f2; color: var(--ink);
}
.sgf-loader .row .rec-field { flex: 1; min-width: 0; }

/* ---- play on OGS ---- */
.pl-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; margin: 4px 0; }
.pl-row.to-move { background: #f4f0e5; }
.pl-stone { width: 16px; height: 16px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.35); }
.pl-stone.b { background: #1a1a1a; }
.pl-stone.w { background: #fff; }
.pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pl-clock { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.pl-clock.low { color: var(--danger); }

/* ---- phones ---- */
@media (max-width: 700px) {
  header { flex-wrap: wrap; gap: 8px 10px; padding: 10px 16px; }
  header h1 { font-size: 16px; }
  header h1 .name-full { display: none; }
  header h1 .name-short { display: inline; }
  #tabs a { padding: 5px 10px; }
  #crumbs { order: 10; flex-basis: 100%; }
  .engine-chip, .auth-chip { padding: 4px 10px; }
  .auth-chip .email { max-width: 90px; }
  main { padding: 16px 16px 40px; }
  .cat-title { margin-top: 20px; }
  .book-list { grid-template-columns: 1fr; }
  .prob-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
  .player, .review { gap: 14px; }
  .board-card { padding: 6px; border-radius: 12px; width: 100%; }
  .board-card svg { width: 100%; }
  aside, .review aside { width: 100%; }
  .keys { display: none; }
  .sgf-loader { margin: 16px auto; }
  .sgf-loader .row { flex-wrap: wrap; }
}

/* Music widget (Spotify) */
.music-toggle {
  background: var(--chip); border: none; border-radius: 999px; padding: 3px 11px;
  font-size: 15px; line-height: 1.4; cursor: pointer; color: var(--ink);
}
.music-widget {
  position: fixed; top: 58px; right: 16px; z-index: 160; width: 340px; max-height: min(560px, calc(100vh - 80px));
  overflow-y: auto; background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: 0 12px 40px rgba(30, 26, 16, .22); display: flex; flex-direction: column; gap: 10px;
}
.music-widget[hidden] { display: none; }
.mw-title { font-weight: 700; font-size: 15px; }
.mw-sub, .mw-msg { color: var(--muted); font-size: 13px; }
.mw-msg:empty { display: none; }
.mw-connect, .mw-logout {
  font: inherit; font-size: 14px; font-weight: 600; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid #ddd6c6; background: #faf8f2; color: var(--ink);
}
.mw-logout { font-size: 12px; padding: 6px 10px; align-self: flex-start; color: var(--muted); }
.mw-now { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.mw-now img, .mw-now .mw-noart { width: 44px; height: 44px; border-radius: 6px; flex: none; }
.mw-noart { display: inline-flex; align-items: center; justify-content: center; background: var(--chip); color: var(--muted); }
.mw-text { display: flex; flex-direction: column; min-width: 0; flex: 1; text-align: left; }
.mw-text b, .mw-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-text b { font-size: 14px; } .mw-text small { color: var(--muted); font-size: 12px; }
.mw-ctls { display: flex; gap: 4px; flex: none; }
.mw-ctl { width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--chip); cursor: pointer; font-size: 14px; color: var(--ink); }
.mw-search {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px;
  background: var(--bg); color: var(--ink); width: 100%; box-sizing: border-box;
}
.mw-results { display: flex; flex-direction: column; gap: 2px; }
.mw-devices { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.mw-volume { flex: 1; min-width: 80px; accent-color: var(--accent); }
.mw-select { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); font: inherit; font-size: 13px; }
.mw-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 8px 0 2px; }
.mw-item { display: flex; align-items: center; gap: 10px; padding: 6px; border: none; background: none; border-radius: 8px; cursor: pointer; font: inherit; color: var(--ink); }
.mw-item:hover { background: var(--chip); }
.mw-item img, .mw-item .mw-noart { width: 36px; height: 36px; border-radius: 4px; flex: none; }
@media (max-width: 700px) {
  .music-widget { left: 8px; right: 8px; width: auto; }
}

/* Sun Wukong toggle */
.wukong-toggle {
  background: var(--chip); border: none; border-radius: 999px; padding: 3px 8px;
  line-height: 0; cursor: pointer; display: inline-flex; align-items: center;
}
.wukong-toggle .wukong-icon { width: 22px; height: 18px; image-rendering: pixelated; }
.wukong-toggle.off { opacity: .45; filter: grayscale(1); }
/* not over a story scroll (Chapter 1 on a fresh save) */
body:has(.tk-scroll-wrap) .wukong-toggle, body:has(.tk-scroll-wrap) #wukong { visibility: hidden; }


/* Romance of the Three Kingdoms campaign */
.tk-card {
  display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; padding: 12px 16px; border-radius: 14px;
  background: linear-gradient(100deg, #7a2a22, #b5452f 60%, #c9893a); color: #fff8e6; text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.tk-card b { display: block; font-size: 16px; } .tk-card small { opacity: .88; font-size: 13px; }
.tk-card-icon { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.tk-card-go { margin-left: auto; font-size: 20px; font-weight: 700; }
.tk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 4px; }
.tk-head h2 { margin: 0; font-size: 20px; } .tk-head .zh { color: #a33a2a; }
.tk-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.tk-head-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tk-chron-btn { font: inherit; font-weight: 600; padding: 7px 12px; border-radius: 10px; border: 1px solid #d8cdb4; background: #fbf5e6; cursor: pointer; white-space: nowrap; }
.tk-worlds { display: flex; gap: 6px; margin: 10px 0 12px; flex-wrap: wrap; }
.tk-world { padding: 5px 11px; border-radius: 999px; background: #e9e3d4; font-size: 13px; font-weight: 600; color: #6d6656; text-decoration: none; }
.tk-world.on { background: #8a2f22; color: #fff8e6; } .tk-world.lock { opacity: .5; }
.tk-map { position: relative; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,.15); background: #000; line-height: 0; }
.tk-canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; cursor: pointer; }
.tk-map.tk-zoom-in { animation: tkZoomIn .43s ease-in forwards; }
.tk-map.tk-zoom-out { animation: tkZoomOut .5s ease-out; }
@keyframes tkZoomIn { to { transform: scale(5); opacity: 0; } }
@keyframes tkZoomOut { from { transform: scale(4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.tk-enter .tk-level { animation: tkLevelIn .45s ease-out; }
.tk-leave .tk-level { animation: tkLevelOut .32s ease-in forwards; }
.tk-flip .tk-level .board-card { animation: tkFlip .26s ease-in; }
@keyframes tkLevelIn { from { transform: scale(.25); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tkLevelOut { to { transform: scale(.2); opacity: 0; } }
@keyframes tkFlip { to { transform: rotateY(90deg); } }
.tk-info { margin-top: 12px; background: var(--card); border-radius: 14px; padding: 14px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; box-shadow: 0 1px 4px rgba(0,0,0,.05); min-height: 48px; }
.tk-info-text { flex: 1; min-width: 180px; } .tk-info b { font-size: 15px; } .tk-info .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tk-play { font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 10px; border: none; background: #8a2f22; color: #fff8e6; cursor: pointer; }
.tk-play:disabled { background: #c9c2b2; cursor: default; }
.tk-fork { display: flex; gap: 10px; flex-wrap: wrap; }
.tk-fork button { font: inherit; padding: 9px 14px; border-radius: 10px; border: 2px solid #8a6a3a; background: #fbf3e0; cursor: pointer; text-align: left; }
.tk-fork button.short { border-color: #c8392c; background: #fdeae6; }
.tk-fork b { display: block; font-size: 14px; } .tk-fork span { font-size: 12.5px; color: var(--muted); }
.tk-verdict:empty { display: none; }
.tk-verdict { margin-top: 10px; padding: 10px 12px; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.tk-verdict.win { background: #fff3cf; } .tk-verdict.slip { background: #fbe5e2; }
.tk-verdict button { margin-left: auto; font: inherit; font-weight: 700; padding: 7px 12px; border-radius: 8px; border: none; background: #8a2f22; color: #fff8e6; cursor: pointer; }
.tk-boss { display: flex; gap: 12px; align-items: center; background: linear-gradient(100deg, #3a1d18, #6a2d22); color: #fff3d6; }
.tk-boss canvas { width: 72px; height: 72px; image-rendering: pixelated; flex: none; background: rgba(255,255,255,.08); border-radius: 8px; }
.tk-boss b { font-size: 15px; } .tk-boss p { margin: 4px 0 0; font-style: italic; font-size: 13.5px; }
.tk-boss p.zh { font-style: normal; opacity: .85; }
.tk-say { margin-top: 6px; font: inherit; border: none; border-radius: 8px; padding: 3px 9px; background: rgba(255,255,255,.15); color: inherit; cursor: pointer; }
/* dialogue box, pinned to the bottom like a game */
.tk-dlg {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(720px, calc(100vw - 20px)); z-index: 90;
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 14px; border-radius: 12px; cursor: pointer;
  background: #fbf4e2; border: 3px solid #5a3a22; box-shadow: 0 0 0 2px #e8d4a8 inset, 0 6px 22px rgba(0,0,0,.35); color: #2a1c14;
  animation: tkDlgIn .18s ease-out;
}
@keyframes tkDlgIn { from { transform: translate(-50%, 12px); opacity: 0; } }
.tk-dlg-face { flex: none; width: 84px; height: 84px; border-radius: 8px; background: #e8d9b4; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.tk-dlg-face canvas, .tk-dlg-face img { width: 84px; height: 84px; image-rendering: pixelated; object-fit: contain; }
.tk-dlg.narr .tk-dlg-face { display: none; }
.tk-dlg-body { flex: 1; min-height: 60px; }
.tk-dlg-name { display: block; color: #8a2f22; font-size: 14px; margin-bottom: 3px; }
.tk-dlg-text { margin: 0; font-size: 15.5px; line-height: 1.45; }
.tk-dlg-zh { margin: 4px 0 0; font-size: 14px; line-height: 1.5; color: #7a5a3a; font-family: "Songti SC", "Noto Serif SC", serif; }
.tk-dlg-zh:empty { display: none; }
.tk-dlg.narr .tk-dlg-text { font-style: italic; color: #4a3a2a; }
.tk-skip { position: absolute; top: -30px; right: 0; font: inherit; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 8px; border: none; background: rgba(40,24,16,.75); color: #fff8e6; cursor: pointer; }
.tk-dlg-more { position: absolute; right: 12px; bottom: 6px; font-size: 11px; color: #8a2f22; opacity: 0; }
.tk-dlg.ready .tk-dlg-more { opacity: 1; animation: tkBob .8s ease-in-out infinite; }
@keyframes tkBob { 50% { transform: translateY(3px); } }
@media (max-width: 560px) {
  .tk-dlg-face, .tk-dlg-face canvas, .tk-dlg-face img { width: 60px; height: 60px; }
  .tk-dlg-text { font-size: 14.5px; }
}
/* storyteller scroll */
.tk-scroll-wrap { position: fixed; inset: 0; z-index: 95; background: rgba(20,12,8,.55); display: flex; align-items: center; justify-content: center; padding: 16px; animation: tkFade .2s; }
@keyframes tkFade { from { opacity: 0; } }
.tk-scroll {
  max-width: 560px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; padding: 22px 26px 18px; border-radius: 6px;
  background: linear-gradient(#f6ecd2, #efe0bc); color: #2a1c14; border-top: 10px solid #6a3a22; border-bottom: 10px solid #6a3a22;
  box-shadow: 0 10px 40px rgba(0,0,0,.45); font-family: Georgia, "Songti SC", serif; animation: tkUnroll .35s ease-out;
}
@keyframes tkUnroll { from { clip-path: inset(48% 0 48% 0); } to { clip-path: inset(0 0 0 0); } }
.tk-scroll h3 { margin: 0 0 12px; text-align: center; color: #7a2a22; font-size: 19px; letter-spacing: .02em; }
.tk-para { margin: 0 0 12px; }
.tk-scroll p { margin: 0; font-size: 15.5px; line-height: 1.55; }
.tk-scroll p.zh { margin-top: 3px; font-size: 14.5px; color: #6a4a32; }
.tk-para.by p { text-align: right; font-style: italic; color: #6a5a4a; }
.tk-scroll-go { display: block; margin: 14px auto 0; font: inherit; font-family: system-ui, sans-serif; font-weight: 700; padding: 9px 20px; border-radius: 10px; border: none; background: #8a2f22; color: #fff8e6; cursor: pointer; }
.tk-chron { display: flex; flex-direction: column; gap: 6px; font-family: system-ui, sans-serif; }
.tk-chron button { font: inherit; text-align: left; padding: 8px 12px; border-radius: 8px; border: 1px solid #d4c29a; background: #fbf5e4; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.tk-chron button.side { margin-left: 18px; }
.tk-chron button.unseen { opacity: .55; cursor: default; }
.tk-chron b { font-size: 14px; } .tk-chron span { font-size: 12px; color: var(--muted); white-space: nowrap; }

.credits { max-width: 620px; margin: 8px auto 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.credits b { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }
.credits p { margin: 0 0 4px; }
.credits a { color: inherit; }
/* ---------- Three Kingdoms: explorable world (tk-world.js, tk-town.js) ---------- */
.tk-map.tk-town { aspect-ratio: 16 / 9; max-width: calc((100vh - 16px) * 16 / 9); max-width: calc((100dvh - 16px) * 16 / 9); margin-inline: auto; outline: none; line-height: 1.4; font-family: Georgia, "Songti SC", serif; }
.tk-map.tk-town:focus-visible { box-shadow: 0 0 0 3px #e6c14a, 0 2px 12px rgba(0,0,0,.15); }
.tk-town canvas { image-rendering: pixelated; }
.town-ui [hidden] { display: none !important; }
.town-ui { position: absolute; inset: 0; pointer-events: none; color: #f4ead2; font-size: clamp(11px, 1.6vw, 15px); }
.town-goal { pointer-events: auto; cursor: pointer; position: absolute; top: 10px; left: 10px; max-width: 46ch; padding: 4px 10px; background: rgba(40, 24, 16, .82); border: 2px solid #c79a4a; border-radius: 6px; }
.town-goal-main::before { content: "◆ "; color: #e6c14a; }
.town-lead { display: flex; align-items: center; gap: 6px; margin: 0 0 3px; padding-bottom: 3px; border-bottom: 1px solid rgba(199, 154, 74, .45); font-size: .85em; color: #f0dca8; }
.town-lead:empty { display: none; }
.town-lead-face { width: 22px; height: 22px; image-rendering: pixelated; background: #e2d2ac; border: 1px solid #c79a4a; border-radius: 3px; flex: none; }
.town-keys { position: absolute; right: 10px; top: 10px; padding: 4px 8px; background: rgba(40, 24, 16, .7); border-radius: 6px; font: 11px/1.5 system-ui, sans-serif; color: #e8dcc0; }
.town-keys b { display: inline-block; min-width: 1.4em; padding: 0 3px; text-align: center; background: #f4ead2; color: #3a2416; border-radius: 3px; }
.town-hint { position: absolute; transform: translate(-50%, -100%); padding: 0 5px; background: #f4ead2; color: #3a2416; border: 2px solid #3a2416; border-radius: 4px; font: bold 10px/1.4 system-ui, sans-serif; }
.town-focus { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 14px; background: rgba(20, 12, 8, .8); border-radius: 8px; font: 14px/1.4 system-ui, sans-serif; }
@keyframes tkDlgIn { from { opacity: 0; } to { opacity: 1; } }
.town-dlg:not([hidden]) { animation: tkDlgIn .25s ease-out; }
.town-dlg { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: calc(100% - 24px); max-width: 760px; min-height: 22%; display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; background: #f4ead2; color: #2c1c12; border: 4px solid #7a3a22; border-radius: 8px; box-shadow: 0 5px 0 rgba(0, 0, 0, .35); box-sizing: border-box; }
.town-face { width: clamp(52px, 9vw, 96px); height: auto; aspect-ratio: 1; image-rendering: pixelated; background: #e2d2ac; border: 3px solid #7a3a22; border-radius: 4px; flex: none; }
.town-txt { min-width: 0; }
.town-who { font-weight: bold; color: #8a2a1a; }
.town-zh { font-size: 1.15em; }
/* a phone (apo110: dialogue too small on mobile): the box's words don't shrink with the narrow map, upright or on its side */
@media (max-width: 700px) { .town-ui .town-dlg { font-size: clamp(14px, 3.7vw, 16px); } }
@media (pointer: coarse) and (max-height: 500px) { .town-ui .town-dlg { font-size: 14px; } }
.town-en { margin-top: 4px; color: #6a5440; font-size: .92em; }
.town-more { position: absolute; right: 12px; bottom: 4px; color: #8a2a1a; animation: townBob 1s infinite; }
@keyframes townBob { 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .town-more { animation: none; } }
@media (max-width: 640px) { .town-keys { display: none; } }
.town-place { position: absolute; top: 22%; left: 0; right: 0; text-align: center; font-size: clamp(18px, 3.4vw, 30px); letter-spacing: .08em; color: #f4ead2; text-shadow: 0 2px 0 #3a2416, 0 0 12px rgba(0,0,0,.6); opacity: 0; }
.town-place.show { animation: townPlace 2.6s ease-out; }
@keyframes townPlace { 0% { opacity: 0; transform: translateY(6px); } 15%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .town-place.show { animation: none; opacity: 0; } }

/* plot vs chatter: story moments are framed, tabbed and dim the map; chatter is small and plain */
.town-gains { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 4; }
.town-gain { padding: 6px 16px; background: rgba(40, 24, 16, .88); border: 2px solid #e6c14a; border-radius: 6px; text-align: center; animation: townGain 3.6s ease-out forwards; }
.town-gain b { display: block; color: #f4d77a; font-size: 1.15em; }
.town-gain span { display: block; font-size: .9em; color: #e8dcc0; }
.town-gain.brief { animation-duration: 1.6s; }
@keyframes townGain { 0% { opacity: 0; transform: translateY(6px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
/* during a scene its Skip button takes the corner the menu sits in */
.tk-map:has(.town-skip) .tk-menu { display: none; }
.town-skip { position: absolute; top: 10px; right: 12px; z-index: 5; pointer-events: auto; padding: 4px 10px; font: bold 12px/1.4 system-ui, sans-serif; color: #f4ead2; background: rgba(40, 24, 16, .8); border: 1px solid #c79a4a; border-radius: 5px; cursor: pointer; }
.town-dim { position: absolute; inset: 0; background: radial-gradient(ellipse at center 40%, rgba(10, 6, 4, .05), rgba(10, 6, 4, .45)); }
.town-tab { display: none; position: absolute; left: 14px; top: -14px; padding: 1px 10px; background: #8a2a1a; color: #f8ead0; border: 2px solid #f4ead2; border-radius: 4px; font: bold 12px/1.5 system-ui, sans-serif; letter-spacing: .04em; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.town-dlg.story .town-tab { display: block; }
.town-dlg.story { border-color: #7a3a22; box-shadow: 0 0 0 2px #e6c14a inset, 0 5px 0 rgba(0, 0, 0, .35); }
.town-dlg.chat { max-width: 580px; min-height: 0; padding: 8px 12px; background: #e9e6df; color: #34302a; border: 2px solid #8f887a; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); font-size: .92em; }
.town-dlg.chat .town-who { color: #4a4438; }
.town-dlg.chat .town-en { color: #6c665a; }
.town-dlg.chat .town-face { width: clamp(40px, 6vw, 64px); border-width: 2px; border-color: #8f887a; background: #d8d4ca; }
.town-dlg.chat .town-more { color: #6c665a; }
.town-goal-en { display: block; margin-left: 1.3em; font-size: .85em; opacity: .8; }
.town-place-en { display: block; font-size: .5em; letter-spacing: .08em; margin-top: 2px; }
/* Chinese leads, English follows (campaign dialogue and storyteller scrolls) */
.tk-dlg-zh { margin: 0 0 3px; font-size: 16px; color: inherit; }
.tk-dlg-text { font-size: 13.5px; color: #7a5a3a; }
.tk-dlg.narr .tk-dlg-text { color: #7a5a3a; }
.tk-scroll h3 .tk-scroll-en { display: block; font-size: .72em; font-weight: normal; opacity: .75; margin-top: 2px; }
.tk-para .zh { font-size: 1.08em; }
.tk-para .en { opacity: .78; font-size: .92em; }
.meta-title .tk-en { color: var(--muted); font-weight: normal; font-size: .9em; }

/* A campaign problem as a duel inside the game window (tk.js TKOverlay): the
   world stays behind, dimmed; the board sits on a wooden frame and the game's own
   dialogue box carries the opponent's words and the result. */
.tk-duel { position: absolute; inset: 0; z-index: 20; overflow: hidden; color: #2c1c12; font-size: clamp(11px, 1.5vw, 15px); line-height: 1.4;
  background: radial-gradient(ellipse at 35% 50%, rgba(20, 12, 8, .45), rgba(12, 6, 4, .78)); animation: tkDuelIn .3s ease-out; }
.tk-duel.tk-duel-full { position: fixed; z-index: 140; font-family: Georgia, "Songti SC", serif; background: #1b130d; }
.tk-duel.tk-relaid, .tk-relaid .tk-duel-stage { animation: none; }
.tk-relaid .tk-duel-wipe { display: none; }
.tk-duel.tk-leave { animation: tkDuelOut .28s ease-in forwards; }
.tk-duel-wipe { position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(180deg, #120a06 0 10%, #3a2416 10% 12.5%); animation: tkDuelWipe .62s steps(8) forwards; }
.tk-duel-stage { position: relative; height: 100%; display: flex; gap: 2.5%; align-items: center; padding: 3% 3.5%; box-sizing: border-box; animation: tkDuelStage .62s ease-out; }
.tk-duel-full .tk-duel-stage { flex-direction: column; justify-content: center; height: auto; min-height: 100%; padding: 16px; gap: 12px; }
.tk-duel-board { flex: none; display: flex; padding: 4px; background: #e2b468; border: 4px solid #7a3a22; border-radius: 6px;
  box-shadow: 0 0 0 2px #e6c14a inset, 0 6px 0 rgba(0, 0, 0, .4); box-sizing: border-box; }
.tk-duel-board svg { display: block; }
.tk-duel-full .tk-duel-board { height: auto; max-width: 100%; width: min(100%, 520px); }
.tk-duel-full .tk-duel-board svg { width: 100%; height: auto; }
.tk-duel-board.explore { outline: 2px dashed #7a3a22; outline-offset: -8px; }
/* its words sit at the foot of the column (the first child's auto margin, not justify-content: flex-end, which
   pushed a column taller than the frame out of its top, where it can't be scrolled to: the dilemma lost) */
.tk-duel-side { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; gap: 8px; max-height: 100%; min-height: 0; overflow: hidden; }
.tk-duel-side > :first-child { margin-top: auto; }
/* too tall for the frame (a narrow column, a long dilemma): the keys stay put, the words shrink and scroll */
.tk-duel-side > .tk-duel-keys, .tk-duel-side > .tk-duel-src { flex: none; }
.tk-duel-side > .tk-duel-dilemma, .tk-duel-side > .tk-duel-dlgrow { flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.tk-duel-full .tk-duel-side { width: min(100%, 520px); flex: none; }
/* the protagonist at the board (a book with "lead_portrait"), on the left: its own column left of the board
   on a wide screen; on a phone (the stacked layout) a small portrait left of the dialogue box instead */
.tk-duel-dlgrow { display: flex; align-items: flex-end; gap: 10px; }
.tk-duel-dlgrow > .town-dlg { flex: 1; min-width: 0; }
/* the column only keeps the board clear; the cut-out itself stands in the frame's bottom-left corner, flush with
   its foot (the figure is cut at the waist, so a gap under it read as cut off), as tall as the frame allows and
   in front of the board's edge (the user: "bring the portrait in front of the go board"; taps pass through it to the board) */
.tk-duel-leadcol { flex: 0 0 20%; align-self: stretch; min-width: 0; }
.tk-duel-lead { position: absolute; left: 0; bottom: 0; height: 94%; max-width: 32%; object-fit: contain; object-position: bottom left;
  z-index: 2; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .45)); pointer-events: none; animation: tkPortraitIn .35s ease-out; }
.has-lead > .tk-duel-board, .has-lead > .tk-duel-side { position: relative; z-index: 1; }
.tk-duel-big .tk-duel-lead { z-index: 0; }   /* a full 19x19 board: the portrait behind it (the user) */
.tk-duel-lead-sm { display: none; }
.tk-duel-full .tk-duel-leadcol { display: none; }
.tk-duel-full .tk-duel-lead-sm { display: block; flex: none; width: 76px; max-height: 120px; object-fit: contain; object-position: bottom;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .45)); pointer-events: none; }
.tk-duel .town-dlg.tk-duel-dlg { position: relative; left: auto; bottom: auto; transform: none; width: 100%; max-width: none; min-height: 0; margin-top: 16px; }
.tk-duel-en { font-weight: normal; color: #6a5440; font-size: .85em; }
.tk-duel-dlg.chat .tk-duel-en { color: #6c665a; }
.tk-duel-status:empty { display: none; }
.tk-duel-status { margin-top: 6px; font: bold .9em/1.4 system-ui, sans-serif; }
.tk-duel-status .icon { margin-right: 4px; }
.tk-duel-status.ok { color: #2e6b2a; } .tk-duel-status.bad { color: #9a2a1a; }
.tk-duel-next:empty { display: none; }
.tk-duel-next { margin-top: 8px; text-align: right; }
.tk-duel-go { padding: 3px 12px; font: bold 1em/1.5 inherit; font-family: inherit; color: #f8ead0; background: #8a2a1a; border: 2px solid #3a2416; border-radius: 4px; box-shadow: 0 3px 0 #3a2416; cursor: pointer; }
.tk-duel-go b { display: inline-block; font-weight: normal; opacity: .8; animation: townBob 1s infinite; }
.tk-duel-dlg.win { box-shadow: 0 0 0 2px #e6c14a inset, 0 0 0 4px #e6c14a, 0 5px 0 rgba(0, 0, 0, .35); }
.tk-duel-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-duel-key { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 3px; font: .85em/1.5 system-ui, sans-serif; color: #f4ead2; background: rgba(40, 24, 16, .85); border: 2px solid #c79a4a; border-radius: 6px; cursor: pointer; }
.tk-duel-key:hover, .tk-duel-key:focus-visible { background: #5a3420; outline: none; }
.tk-duel-key b { min-width: 1.4em; padding: 0 3px; text-align: center; background: #f4ead2; color: #3a2416; border-radius: 3px; font-size: .9em; }
.tk-duel-src { font: .75em/1.4 system-ui, sans-serif; color: #e8dcc0; opacity: .75; }
.tk-duel-src a { color: inherit; }
.tk-duel-stage.tk-flip .tk-duel-board { animation: tkFlip .26s ease-in; }
@keyframes tkDuelIn { from { opacity: 0; } }
@keyframes tkDuelOut { to { opacity: 0; } }
@keyframes tkDuelWipe { 0% { clip-path: inset(0 100% 0 0); } 45% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(0 0 0 100%); } }
@keyframes tkDuelStage { 0%, 50% { opacity: 0; transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .tk-duel, .tk-duel.tk-leave, .tk-duel-stage, .tk-duel-go b { animation: none; } .tk-duel-wipe { display: none; } }

/* ---- Three Kingdoms world map (tk-travel.js) ---- */
.tkt-veil { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(12, 8, 4, .55); }
.tkt-box { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 14px 16px; background: #f4ead2; color: #2c1c12; border: 4px solid #7a3a22; border-radius: 10px; box-shadow: 0 0 0 2px #e6c14a inset, 0 8px 0 rgba(0, 0, 0, .3); box-sizing: border-box; }
.tkt-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.tkt-head b { font-size: 1.1em; color: #8a2a1a; }
.tkt-x { border: 0; background: none; font-size: 26px; line-height: 1; color: #7a3a22; cursor: pointer; }
.tkt-wrap { position: relative; aspect-ratio: 16 / 9; background: radial-gradient(ellipse at 50% 45%, #efe2bf, #dcc795); border: 2px solid #b8945a; border-radius: 6px; }
.tkt-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.tkt-road { stroke: #8a6a3a; stroke-width: 3; stroke-dasharray: 7 6; stroke-linecap: round; }
.tkt-pins { position: absolute; inset: 0; }
.tkt-pin { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 3px 8px; font: inherit; font-size: 12px; line-height: 1.25; text-align: center; border-radius: 6px; border: 2px solid #8a6a3a; background: #fbf4e2; color: #3a2416; }
.tkt-pin b { font-size: 13px; color: #8a2a1a; }
.tkt-pin i { font-style: normal; font-size: 11px; }
.tkt-pin.open { cursor: pointer; border-color: #3f7d4c; box-shadow: 0 2px 0 #2e5a3a; }
.tkt-pin.open:hover, .tkt-pin.open:focus-visible { background: #e6f2dc; outline: none; }
.tkt-pin.here { border-color: #c8392c; background: #fff0d8; box-shadow: 0 0 0 3px rgba(200, 57, 44, .25); }
.tkt-pin.lock { opacity: .55; filter: grayscale(.6); }
.tkt-note { margin: 8px 2px 0; font-size: 13px; color: #6a5440; }
@media (max-width: 600px) { .tkt-pin { min-width: 0; padding: 2px 4px; font-size: 10px; } .tkt-pin b { font-size: 11px; } }

/* The campaign's buttons, in a menu inside the game window (tk.js viewTK). */
.tk-map .tk-menu { position: absolute; top: 8px; right: 8px; z-index: 15; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font: 12px/1.4 system-ui, sans-serif; }
.tk-menu-btn { padding: 3px 10px; font: 600 12px/1.5 system-ui, sans-serif; color: #f4ead2; background: rgba(40, 24, 16, .85); border: 2px solid #c79a4a; border-radius: 6px; cursor: pointer; }
.tk-menu-btn:hover, .tk-menu-btn:focus-visible { background: #5a3420; outline: none; }
.tk-menu-panel { max-width: 230px; max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); overflow-y: auto; box-sizing: border-box; padding: 8px; background: rgba(40, 24, 16, .93); border: 2px solid #c79a4a; border-radius: 8px; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.tk-menu-panel[hidden] { display: none; }
.tk-menu-panel .tk-head-btns { flex-direction: column; align-items: stretch; gap: 5px; }
.tk-menu-panel .tk-chron-btn { padding: 4px 10px; font: 600 12px/1.4 system-ui, sans-serif; text-align: left; color: #3a2416; background: #f4ead2; border: 1px solid #7a3a22; border-radius: 4px; }
.tk-menu-panel .tk-chron-btn:hover { background: #fff6dc; }
.tk-menu-panel .tk-chron-btn[hidden] { display: none; }
.tk-menu-keys { margin-top: 7px; color: #e8dcc0; font-size: 11px; }
.tk-map:has(.tk-menu) .town-keys { display: none; }
.town-guide { position: absolute; image-rendering: pixelated; pointer-events: none; }
.town-guide[hidden] { display: none; }
.town-guide-say { position: absolute; transform: translate(-50%, -100%); padding: 1px 7px; white-space: nowrap; font: bold 11px/1.5 system-ui, sans-serif; color: #3a2416; background: #fff6dc; border: 2px solid #c8902a; border-radius: 8px; pointer-events: none; }
.town-guide-say[hidden] { display: none; }

/* boss fights (tk-cutscene.js): the boss's name card and the victory banner */
.tk-bosscard { position: absolute; left: 0; top: 30%; z-index: 4; pointer-events: none; padding: 10px 48px 10px 26px;
  background: linear-gradient(90deg, rgba(110, 14, 10, .95) 0%, rgba(70, 8, 6, .9) 70%, rgba(70, 8, 6, 0) 100%);
  border-top: 2px solid #e6c14a; border-bottom: 2px solid #e6c14a; color: #f8ead0; animation: tkBossCard 3s cubic-bezier(.2, .9, .2, 1) forwards; }
.tk-bosscard b { display: block; font: 900 clamp(28px, 5vw, 46px)/1.05 "Noto Serif SC", "Songti SC", serif; letter-spacing: .12em; color: #fff3cf; text-shadow: 0 2px 0 #3a0604, 0 0 14px rgba(255, 120, 60, .6); }
.tk-bosscard span { display: block; font: bold clamp(13px, 1.8vw, 17px)/1.3 Georgia, serif; letter-spacing: .18em; text-transform: uppercase; color: #f4d77a; }
.tk-bosscard i { display: block; margin-top: 2px; font: italic clamp(12px, 1.6vw, 15px)/1.3 Georgia, serif; color: #e8c8b0; }
@keyframes tkBossCard { 0% { transform: translateX(-105%); } 14%, 82% { transform: none; opacity: 1; } 100% { transform: translateX(-8%); opacity: 0; } }
.tk-victory { position: absolute; left: 50%; top: 9%; z-index: 4; pointer-events: none; text-align: center; transform: translateX(-50%); padding: 10px 44px 12px; background: radial-gradient(ellipse at center, rgba(30, 14, 4, .78) 0%, rgba(30, 14, 4, .5) 55%, rgba(30, 14, 4, 0) 75%); animation: tkVictory 3.4s ease-out forwards; }
.tk-victory::before { content: ""; position: absolute; left: 50%; top: 50%; width: 360px; height: 360px; margin: -180px 0 0 -180px; z-index: -1;
  background: repeating-conic-gradient(rgba(255, 220, 120, .28) 0 8deg, rgba(255, 220, 120, 0) 8deg 22deg); border-radius: 50%;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 70%); mask: radial-gradient(circle, #000 20%, transparent 70%); animation: tkRays 3.4s linear forwards; }
.tk-victory b { display: block; font: 900 clamp(40px, 8vw, 72px)/1 "Noto Serif SC", "Songti SC", serif; letter-spacing: .2em; color: #ffe08a; text-shadow: 0 3px 0 #7a3a10, 0 0 22px rgba(255, 200, 80, .7); }
.tk-victory span { display: block; margin-top: 4px; font: bold clamp(14px, 2vw, 20px)/1.2 Georgia, serif; letter-spacing: .4em; text-transform: uppercase; color: #fff3cf; text-shadow: 0 2px 0 #3a2410, 0 0 6px #1a0c04; }
@keyframes tkVictory { 0% { opacity: 0; transform: translateX(-50%) scale(1.8); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) scale(1); } }
@keyframes tkRays { from { transform: rotate(0); } to { transform: rotate(40deg); } }

/* A boss duel (tk.js tkDuelBuild): the board in a red lacquer frame, his name above it. */
.tk-duel.tk-duel-boss { background: radial-gradient(ellipse at 35% 50%, rgba(70, 8, 4, .55), rgba(20, 2, 0, .88)); }
.tk-duel-boss .tk-duel-board { position: relative; background: #e2b468; border-color: #8a1a10; box-shadow: 0 0 0 2px #e6c14a inset, 0 0 0 3px #3a0804, 0 0 18px 4px rgba(200, 40, 20, .55), 0 6px 0 rgba(0, 0, 0, .5); animation: tkBossPulse 2.4s ease-in-out infinite; }
.tk-duel-bossname { position: absolute; left: 50%; top: 0; transform: translate(-50%, -62%); z-index: 1; padding: 3px 16px; white-space: nowrap; text-align: center;
  color: #ffe9a8; background: linear-gradient(#a8241a, #6a0e08); border: 2px solid #e6c14a; border-radius: 4px; box-shadow: 0 3px 0 rgba(0, 0, 0, .45); font-family: Georgia, "Songti SC", serif; }
.tk-duel-bossname b { display: block; font-size: 1.25em; letter-spacing: .12em; }
.tk-duel-bossname span { display: block; font-size: .75em; opacity: .85; letter-spacing: .04em; }
/* A decision board (tk.js tkDuelBuild): the dilemma named over the board while the problem is open. */
.tk-duel-dilemma { margin: 0 0 8px; padding: 6px 12px; text-align: center; text-wrap: balance;
  color: #3a2410; background: #f4e6c4; border: 2px solid #8a6a3a; border-radius: 4px; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); font-family: Georgia, "Songti SC", serif; }
.tk-duel-dilemma b { display: block; font-size: 17px; letter-spacing: .06em; word-break: keep-all; overflow-wrap: anywhere; }
.tk-duel-dilemma span { display: block; font-size: 14px; opacity: .9; }
@keyframes tkBossPulse { 50% { box-shadow: 0 0 0 2px #e6c14a inset, 0 0 0 3px #3a0804, 0 0 26px 8px rgba(220, 50, 20, .7), 0 6px 0 rgba(0, 0, 0, .5); } }
@media (prefers-reduced-motion: reduce) { .tk-duel-boss .tk-duel-board { animation: none; } }

/* A soft vignette over the explorable world (tk-world.js), under the dialogue and menus. */
.tk-map.tk-town .town-ui { box-shadow: inset 0 0 70px rgba(24, 12, 4, .32); }
/* A problem resting after a wrong move (tk.js tkRestLock): the position stays in view,
   stones can't be played yet, and a small chip counts down. */
.board-card, .tk-duel-board { position: relative; }
.tk-rest { position: absolute; inset: 0; z-index: 2; cursor: not-allowed; }
.tk-rest-chip { position: absolute; top: 6px; left: 6px; padding: 2px 9px; font: 600 12px/1.5 system-ui, sans-serif; color: #fff6dc;
  background: rgba(40, 24, 16, .85); border: 2px solid #c79a4a; border-radius: 6px; box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.tk-rest-chip b { color: #ffe36a; margin-right: 2px; }
.tk-duel-go:disabled { opacity: .45; cursor: not-allowed; }
.tk-duel-go:disabled b { animation: none; }

/* Overworld place names over their entrances (tk-world.js overworldLabels). */
.town-label { position: absolute; transform: translate(-50%, -100%); padding: 1px 8px 2px; text-align: center; white-space: nowrap; pointer-events: none;
  color: #3a2416; background: rgba(255, 246, 220, .92); border: 2px solid #7a3a22; border-radius: 5px; box-shadow: 0 2px 0 rgba(0, 0, 0, .3); font-family: Georgia, "Songti SC", serif; line-height: 1.2; }
.town-label[hidden] { display: none; }
.town-label b { display: block; font-size: 13px; }
.town-label span { display: block; font: 10px/1.3 system-ui, sans-serif; color: #6a5440; }
.town-label.locked { opacity: .6; filter: grayscale(.6); }
.town-label.goal { border-color: #e6c14a; box-shadow: 0 0 0 2px #8a2a1a, 0 0 12px rgba(230, 193, 74, .8); }

/* Phones and tablets: touching the game moves the party, never the page. A phone held
   upright gets a taller window (tk-world.js gives it a taller view to match). */
.tk-map.tk-town, .tk-map.tk-town canvas { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* quick taps on the board place stones, never zoom the page */
.tk-duel, .tk-duel svg { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tk-duel svg { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 700px) and (orientation: portrait) { .tk-map.tk-town { aspect-ratio: 3 / 4; max-height: 78vh; } }
@media (pointer: coarse) { .town-keys { display: none; } }
/* Full window: the game fills the screen, the page behind stays put */
.tk-menu-row { display: flex; gap: 6px; }
.tk-menu-btn[aria-pressed="true"] { background: rgba(40, 24, 16, .85); }
.tk-map.tk-town.tk-fullwin { position: fixed; inset: 0; z-index: 50; width: auto; height: auto; max-height: none; max-width: none; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.tk-fullwin-on, html.tk-fullwin-on body { overflow: hidden; overscroll-behavior: none; }
.tk-map.tk-town.tk-fullwin .tk-menu { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
/* a narrow game window: the objective goes under the buttons rather than behind them */
/* counsel still to act on, under the goal (tk-world.js activeHint) */
.town-goal-hint { display: block; margin-top: 3px; padding-top: 3px; border-top: 1px solid rgba(199, 154, 74, .45); font-style: italic; opacity: .82; font-size: .9em; }
@media (max-width: 560px) { .tk-map.tk-town .town-goal { top: 46px; right: 10px; max-width: none; } }
/* the travellers' go table (tk-table.js) */
.tk-table-panel { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 16; width: min(92%, 460px); padding: 8px 12px;
  color: #f4ead2; background: rgba(40, 24, 16, .9); border: 2px solid #c79a4a; border-radius: 8px; font-family: Georgia, "Songti SC", serif; line-height: 1.4; }
.tk-table-panel .town-en { font-size: .85em; opacity: .85; margin-top: 2px; }
.tk-table-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tk-duel-go.quiet { background: #5a3a24; }
.tk-table .tk-duel-board.tk-table-board svg { width: min(100%, 62vh); height: auto; }
.tk-duel:not(.tk-duel-full).tk-table .tk-duel-board { height: 92%; aspect-ratio: 1; }
.tk-duel:not(.tk-duel-full).tk-table .tk-duel-board svg { width: 100%; height: 100%; }
.tk-duel-full.tk-table .tk-duel-board { width: min(100%, 520px); }
.tk-duel-full.tk-table .tk-duel-board svg { width: 100%; height: auto; }
.tk-table-player { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 4px; }
.tk-table-player.on { background: rgba(230, 193, 74, .28); }
.tk-table-name { flex: 1; font-weight: bold; }
.tk-table-name small { font-weight: normal; opacity: .75; }
.tk-table-clock { font: 600 .95em/1 ui-monospace, Menlo, monospace; }
.tk-table-stone { width: .9em; height: .9em; border-radius: 50%; flex: none; }
.tk-table-stone.b { background: radial-gradient(circle at 35% 30%, #5a5a5a, #111); }
.tk-table-stone.w { background: radial-gradient(circle at 35% 30%, #fff, #cfcfc7); box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.tk-table svg { touch-action: manipulation; cursor: pointer; }
.tk-table-panel .town-zh { color: #f4ead2; }
.tk-table-panel .town-en { color: #e9dcc0; }

/* painted stills in cutscenes (tk-cutscene.js showStill): under the dialogue, a slow Ken Burns drift */
.tk-still { position: absolute; inset: 0; overflow: hidden; background: #0c0806; opacity: 0; transition: opacity .7s ease; }
.tk-still.on { opacity: 1; }
.tk-still img { width: 100%; height: 100%; object-fit: cover; transform-origin: 50% 50%; animation: 16s ease-out forwards; }
.tk-still.kb-in img { animation-name: tkKbIn; }
.tk-still.kb-out img { animation-name: tkKbOut; }
.tk-still.kb-up img { animation-name: tkKbUp; }
.tk-still.kb-down img { animation-name: tkKbDown; }
.tk-still.kb-pan img { animation-name: tkKbPan; }
@keyframes tkKbIn { from { transform: scale(1); } to { transform: scale(1.14); } }
@keyframes tkKbOut { from { transform: scale(1.14); } to { transform: scale(1); } }
@keyframes tkKbUp { from { transform: scale(1.12) translateY(4%); } to { transform: scale(1.12) translateY(-4%); } }
@keyframes tkKbDown { from { transform: scale(1.12) translateY(-4%); } to { transform: scale(1.12) translateY(4%); } }
@keyframes tkKbPan { from { transform: scale(1.12) translateX(4%); } to { transform: scale(1.12) translateX(-4%); } }
/* a phone held upright (tk-cutscene.js): the picture at up to 1.5 times the screen's width, high on the screen with
   dark above and below, panning from edge to edge and back (--from/--to) */
.tk-still.wide img:not(.tk-still-bg) { position: absolute; left: 0; max-width: none; object-fit: fill; animation: tkKbWide 12s ease-in-out infinite alternate; }
@keyframes tkKbWide { from { transform: translateX(var(--from, 0px)); } to { transform: translateX(var(--to, 0px)); } }
@media (prefers-reduced-motion: reduce) { .tk-still img { animation: none; } .tk-still.wide img:not(.tk-still-bg) { transform: translateX(var(--from, 0px)); } }
/* a problem on a phone turned sideways (or opened that way): board left at full height, words and keys beside it */
@media (orientation: landscape) and (max-height: 560px) {
  .tk-duel-full .tk-duel-stage { flex-direction: row; align-items: center; justify-content: center; height: 100%; min-height: 0; padding: 10px 14px; }
  .tk-duel-full .tk-duel-board { width: auto; height: calc(100vh - 24px); height: calc(100dvh - 24px); max-width: 58vw; }
  .tk-duel-full .tk-duel-board svg { width: auto; height: 100%; max-width: 100%; }   /* keeps a cropped board's shape */
  .tk-duel-full.tk-table .tk-duel-board { aspect-ratio: 1; }
  .tk-duel-full.tk-table .tk-duel-board svg { width: 100%; height: 100%; }
  .tk-duel-full .tk-duel-side { width: auto; flex: 1; min-width: 0; max-height: 100%; overflow-y: auto; }
}
/* thumb-sized menu buttons on a touch screen */
@media (pointer: coarse) { .tk-menu-panel button, .tk-menu-btn { min-height: 40px; } }
.tk-scroll-x { position: sticky; top: 0; float: right; z-index: 1; margin: -6px -6px 6px 8px; padding: 6px 12px; min-height: 36px; font: 600 13px/1.4 system-ui, sans-serif; color: #f4ead2; background: #6b3a24; border: 2px solid #3a2416; border-radius: 6px; cursor: pointer; }

/* feedback from the game menu */
.tk-fb { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tk-fb-text { width: 100%; box-sizing: border-box; resize: vertical; min-height: 54px; padding: 4px 6px; font: 13px/1.4 system-ui, sans-serif; color: #2c1c12; background: #fff6dc; border: 1px solid #7a3a22; border-radius: 4px; }
.tk-fb-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tk-fb-msg { font: 11px/1.3 system-ui, sans-serif; color: #f4ead2; }
@media (pointer: coarse) { .tk-fb-text { font-size: 16px; } }   /* no zoom-on-focus on iPhone */
/* the menu never wider than the screen: long labels (Confirm taps…) wrap instead */
.tk-menu-panel { max-width: min(230px, calc(100vw - 16px)); }
.tk-menu-panel .tk-head-btns > * { max-width: 100%; box-sizing: border-box; white-space: normal; overflow-wrap: anywhere; }

/* ---- painted portraits in the original parchment box (Jade, kits/jade.json "portraits"): the cut-out stands at the
   box's left end, behind it, so the box covers its lower half and the dialogue itself is unchanged ---- */
.town-ui.painted:not(.genshin) .town-portrait { position: absolute; left: max(4px, calc(50% - 380px - 2%)); bottom: 10px; height: 64%; max-width: 34%;
  object-fit: contain; object-position: bottom left; z-index: 1; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .4)); pointer-events: none; }
.town-ui.painted:not(.genshin) .town-portrait.in { animation: tkPortraitIn .35s ease-out; }
.town-ui.painted:not(.genshin) .town-dlg { z-index: 2; }
@media (max-width: 600px) { .town-ui.painted:not(.genshin) .town-portrait { height: 48%; max-width: 40%; } }
/* an upright phone: the box fills the lower third, so the cut-out stands on its top edge (--dlg-h, set by tk-town.js)
   with head and shoulders clear, and the Story tab moves to the box's right end, off the portrait */
@media (max-width: 600px) and (orientation: portrait) {
  .town-ui.painted:not(.genshin) .town-portrait { bottom: calc(10px + var(--dlg-h, 30%) - 22px); height: 30%; max-width: 52%; }
  .town-ui.painted:not(.genshin) .town-dlg.has-portrait .town-tab { left: auto; right: 14px; }
}

/* ---- the Genshin dialogue look (the user's pick): a dark gradient band, gold name, a big cut-out portrait ---- */
.town-ui.genshin .town-portrait { position: absolute; left: 2%; bottom: 0; height: 78%; max-width: 46%; object-fit: contain; object-position: bottom left; z-index: 2; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .45)); pointer-events: none; }
.town-ui.genshin .town-portrait.in { animation: tkPortraitIn .35s ease-out; }
@keyframes tkPortraitIn { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
.town-ui.genshin .town-dlg { left: 0; right: 0; bottom: 0; transform: none; width: 100%; max-width: none; min-height: 0; padding: 18px 8% 22px; z-index: 3;
  justify-content: center; text-align: center; color: #f6f1e6; border: 0; border-radius: 0; box-shadow: none;
  background: linear-gradient(to top, rgba(12, 14, 22, .92) 0%, rgba(12, 14, 22, .78) 55%, rgba(12, 14, 22, 0) 100%); }
.town-ui.genshin .town-dlg.has-portrait { padding-left: max(8%, 30%); text-align: left; justify-content: flex-start; }
.town-ui.genshin .town-who { display: inline-block; color: #f0c76a; font-size: 1.05em; letter-spacing: .06em; margin-bottom: 6px; padding: 0 22px; position: relative; }
.town-ui.genshin .town-who:not(:empty)::before, .town-ui.genshin .town-who:not(:empty)::after { content: ""; position: absolute; top: 50%; width: 16px; height: 1px; background: linear-gradient(90deg, transparent, #f0c76a); }
.town-ui.genshin .town-who::before { left: 0; } .town-ui.genshin .town-who::after { right: 0; transform: scaleX(-1); }
.town-ui.genshin .town-zh { font-size: 1.2em; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.town-ui.genshin .town-en { color: #cfd6e2; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.town-ui.genshin .town-more { color: #f0c76a; right: 4%; bottom: 8px; }
.town-ui.genshin .town-face { background: rgba(255, 255, 255, .08); border: 1px solid rgba(240, 199, 106, .6); border-radius: 50%; }
.town-ui.genshin .town-tab { left: 50%; transform: translateX(-50%); top: 0; background: none; border: 0; box-shadow: none; color: #f0c76a; opacity: .8; font-weight: normal; }
.town-ui.genshin .town-dlg.has-portrait .town-tab { left: 30%; transform: none; }
.town-ui.genshin .town-dlg.chat { background: linear-gradient(to top, rgba(12, 14, 22, .85), rgba(12, 14, 22, 0)); color: #f6f1e6; border: 0; font-size: .95em; }
.town-ui.genshin .town-dlg.chat .town-who { color: #f0c76a; }
.town-ui.genshin .town-dlg.chat .town-en { color: #cfd6e2; }
.town-ui.genshin .town-dlg.chat .town-more { color: #f0c76a; }
.town-ui.genshin .town-dim { background: linear-gradient(to top, rgba(0, 0, 0, .35), transparent 60%); }
@media (max-width: 600px) { .town-ui.genshin .town-portrait { height: 55%; } .town-ui.genshin .town-dlg.has-portrait { padding-left: 34%; } }
.town-ui.genshin .town-dlg.chat, .town-ui.genshin .town-dlg.story { max-width: none; width: 100%; left: 0; right: 0; transform: none; border-radius: 0; }

/* Talk with Claude (tk.js viewTKChat) */
.tk-world-chat { border-style: dashed; }
.tk-chat { max-width: 720px; margin: 12px auto; padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.tk-chat-head { display: flex; flex-direction: column; gap: 2px; }
.tk-chat-head small, .tk-chat-note, .tk-chat-empty { color: var(--muted); font-size: 13px; }
.tk-chat-log { height: min(60vh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.tk-chat-m { max-width: 85%; display: flex; flex-direction: column; gap: 2px; }
.tk-chat-m.me { align-self: flex-end; align-items: flex-end; }
.tk-chat-m.them { align-self: flex-start; }
.tk-chat-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: 7px 10px; border-radius: 10px; font: 14px/1.45 system-ui, sans-serif; }
.tk-chat-m.me .tk-chat-text { background: var(--accent); color: #fff; }
.tk-chat-m.them .tk-chat-text { background: var(--chip); color: var(--ink); }
.tk-chat-m.pending { opacity: .6; }
.tk-chat-m small { color: var(--muted); font-size: 11px; }
.tk-chat-row { display: flex; gap: 6px; align-items: stretch; }
.tk-chat-in { flex: 1; min-width: 0; resize: vertical; padding: 6px 8px; font: 14px/1.4 system-ui, sans-serif; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--ink); }
.tk-chat-send { padding: 0 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.tk-chat-send:disabled { opacity: .5; cursor: default; }

/* the conversation with Claude in the study (tk.js TKTalk): a dialogue box with a line to type in */
.tk-talk { z-index: 6; align-items: stretch; }
.tk-talk-face { width: clamp(64px, 12vw, 120px); height: auto; align-self: flex-end; flex: none; }
.tk-talk-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tk-talk .town-who { display: flex; justify-content: space-between; align-items: center; }
.tk-talk-leave { border: 0; background: none; color: #7a3a22; font-size: 1.1em; cursor: pointer; padding: 0 4px; }
.tk-talk-log { max-height: 22vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.tk-talk-line { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.tk-talk-line.me { color: #6a5440; font-size: .92em; }
.tk-talk-line.pending { opacity: .6; }
.tk-talk-line.thinking { color: #8a2a1a; animation: townBob 1s infinite; }
.tk-talk-row { display: flex; gap: 6px; }
.tk-talk-in { flex: 1; min-width: 0; resize: none; padding: 5px 8px; font: 14px/1.4 system-ui, sans-serif; color: #2c1c12; background: #fff6dc; border: 1px solid #7a3a22; border-radius: 4px; }
.tk-talk-send { padding: 0 12px; border: 0; border-radius: 4px; background: #7a3a22; color: #fff6dc; font-weight: bold; cursor: pointer; }

/* replay from a beat (tk-travel.js) */
.tk-replay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .5); }
.tk-replay-card { max-width: min(420px, calc(100vw - 32px)); padding: 16px 18px; background: #f4ead2; color: #2c1c12; border: 4px solid #7a3a22; border-radius: 8px; font-family: Georgia, "Songti SC", serif; }
.tk-replay-card p { margin: 6px 0 10px; font-size: .9em; }
.tk-replay-sel { width: 100%; font: inherit; padding: 6px; }
.tk-replay-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.tk-test-badge { color: #b4402a; font-weight: bold; }

/* the bag and a sealed pouch's card (tk-feats.js, the Lady Sun book) */
.tk-bag, .tk-pouch { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; background: rgba(20, 14, 8, .45); }
.tk-bag-box, .tk-pouch-card { background: #f6ecd6; color: #2a1d12; border: 2px solid #8a5a2a; border-radius: 10px; padding: 14px 16px; max-width: min(92vw, 460px); box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.tk-bag-box h3 { margin: 0 0 8px; font-size: 17px; }
.tk-bag-box ul { list-style: none; margin: 0 0 10px; padding: 0; }
.tk-bag-box li { padding: 7px 4px; border-top: 1px solid #e0cfa8; cursor: default; }
.tk-bag-box li.sealed { cursor: pointer; }
.tk-bag-box li b { color: #8a2a1a; }
.tk-bag-note { font-size: 13px; color: #5a4632; margin-top: 3px; }
.tk-bag-note.flash { animation: tk-bag-flash .6s; }
@keyframes tk-bag-flash { 0%, 100% { background: transparent; } 40% { background: #f3c98a; } }
.tk-pouch-card { background: #fbf4e2; border-color: #a33a2a; text-align: left; }
.tk-pouch-card .t { font-size: 15px; margin-bottom: 8px; color: #8a2a1a; }
.tk-pouch-card .zh { font-size: 17px; line-height: 1.6; margin: 0 0 6px; }
.tk-pouch-card .en { font-size: 14px; line-height: 1.45; margin: 0 0 10px; color: #4a3a28; }
.tk-pouch-card button, .tk-bag-box button { font: inherit; padding: 4px 14px; border-radius: 6px; border: 1px solid #8a5a2a; background: #fff8e6; cursor: pointer; }
/* "Take me there" in the goal box (apo110): walks you to the goal, place after place; drawn as part of the box (a line under a rule, like the hint), not a button on it */
.town-goal-go { display: block; width: 100%; margin: 3px 0 0; padding: 3px 0 0 1.3em; text-align: left; font: inherit; font-size: .85em; color: #e6c14a;
  background: none; border: none; border-top: 1px solid rgba(199, 154, 74, .45); border-radius: 0; cursor: pointer; }
.town-goal-go::before { content: "➜ "; }
.town-goal-go:hover, .town-goal-go:focus-visible { color: #fff0b8; text-decoration: underline; outline: none; }
.town-goal-news::before { content: "📣 "; }
/* Watch the room (a world's "watch": Red Chamber) shares its row with Take me there, so the goal box stays short on a phone */
.town-goal-watch { display: inline-block; width: auto; padding-right: 1em; }
.town-goal-watch + .town-goal-go { display: inline-block; width: auto; }

/* ---- Misaeng (world 21, tk-modern.js): the record's strip, the audit board, the trade loop ---- */
.tk-strip { position: absolute; right: 10px; top: 44px; transition: top .15s; z-index: 3; pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 4px 2px; background: rgba(20, 22, 26, .78); border: 1px solid rgba(255,255,255,.25); border-radius: 6px; cursor: pointer; font: 600 11px/1.2 system-ui, sans-serif; color: #f3efe6; }
.tk-strip svg { display: block; }
.tk-strip .tk-strip-short { display: none; }
.tk-strip.compact { flex-direction: row; gap: 4px; padding: 6px 8px 6px 6px; min-height: 44px; box-sizing: border-box; }
.tk-strip.compact svg { width: 30px; height: 30px; }
.tk-strip.compact > span:not(.tk-strip-short) { display: none; }
.tk-strip.compact .tk-strip-short { display: inline; }
.tk-record .tk-bag-box { text-align: center; }
.tk-record .tk-bag-box svg { display: block; margin: 0 auto 8px; max-width: 80vw; height: auto; }
.tk-record-sub { font-size: 13px; color: #5a4632; margin: 0 0 10px; }
.tk-trade-chip { position: absolute; right: 10px; top: 152px; transition: top .15s; z-index: 3; max-width: 40%; pointer-events: none; padding: 5px 9px; border-radius: 6px;
  background: rgba(20, 22, 26, .8); color: #f3efe6; font: 12px/1.3 system-ui, sans-serif; }
.tk-trade-chip b { display: block; font-size: 14px; color: #ffd76a; }
.tk-clock { position: absolute; right: 10px; top: 152px; transition: top .15s; z-index: 3; pointer-events: none; padding: 5px 9px; border-radius: 6px;
  background: rgba(20, 22, 26, .8); color: #f3efe6; font: 12px/1.3 system-ui, sans-serif; text-align: right; }
.tk-clock b { display: block; font: 700 18px/1.1 ui-monospace, monospace; color: #ff8a6a; }
.tk-audit .tk-bag-box { max-width: min(94vw, 620px); }
.tk-audit-q { font-weight: 700; margin: 0 0 8px; }
.tk-audit-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tk-audit-card { text-align: left; font: inherit; padding: 8px; border-radius: 8px; border: 1px solid #b8986a; background: #fffaf0; cursor: pointer; }
.tk-audit-card b { display: block; color: #2a3f6a; margin-bottom: 3px; }
.tk-audit-card span { font-size: 12px; color: #5a4632; }
.tk-audit-card.on { outline: 3px solid #d8a020; background: #fff1c8; }
.tk-audit-card.missing { opacity: .45; cursor: default; }
.tk-audit-done { margin: 0 0 8px; padding-left: 20px; font-size: 13px; }
.tk-audit-done li { margin-bottom: 4px; }
.tk-audit-say { min-height: 1.3em; font-style: italic; margin: 0 0 8px; }
.tk-shop li { display: flex; align-items: center; gap: 8px; }
.tk-shop li button { min-height: 40px; min-width: 64px; }
.tk-shop li .n { margin-left: auto; }
.tk-shop-say { font-style: italic; margin: 0 0 8px; }
.tk-shop-cash { font-size: 13px; margin: 0 0 8px; }
.tk-bag-audit { display: block; margin: 0 0 10px; }
.tk-lift li button { width: 100%; min-height: 40px; text-align: left; }
/* an English-only book (tk-modern.js TKEnglish): no Chinese lines or labels */
body.tk-en [lang="zh-CN"], body.tk-en .town-zh, body.tk-en .tk-dlg-zh, body.tk-en .tk-scroll-zh { display: none !important; }

/* a record board as multiple choice (tk-modern.js WorldModern.labels): A-D on the points */
.tk-choice circle { fill: #dcb35c; stroke: none; }   /* the board's own wood: only the grid lines under the letter go */
.tk-choice text { fill: #1a1a1a; font-weight: 400; font-family: Georgia, "Times New Roman", serif; }
/* a move-guessing board answered wrong: the move that was played, ringed (tk.js tkShowRecordMove) */
.tk-record-answer { fill: none; stroke: #c0392b; stroke-width: 3; }
/* stream mode (app.js viewStream): the shared rating, big */
.stream-rating { font-size: 22px; font-weight: 700; margin: 8px 0 4px; }
/* what a rated board is worth (tk.js TKElo.stakesEl): "+8 / −24" before, the change after */
.tk-stakes { font-size: 13px; color: var(--muted, #7a7466); white-space: nowrap; }
.tk-stakes b.up { color: #2e7d4f; } .tk-stakes b.down { color: #b0413e; }
.tk-duel-src .tk-stakes { font-size: inherit; color: inherit; }
.tk-duel-src .tk-stakes b.up { color: #7fd6a0; } .tk-duel-src .tk-stakes b.down { color: #f08a84; }   /* lighter on the board's dark band (Testing: the red was faint) */   /* in a board's source line: its size (Testing: bigger than the line on a phone) */
/* the Play tab: your byoyomi's last 10 seconds, counted on the opponent's last stone (app.js playGame); the
   last-move ring steps aside for the number */
svg.pl-counting .last-move { display: none; }
/* game records (app.js viewGames): a searchable list, a game a row, opening in the Review tab */
.games-head { max-width: 980px; margin: 0 auto 12px; }
.games-head h2 { margin: 0 0 10px; font-size: 20px; }
.games-search { width: 100%; max-width: 420px; padding: 9px 12px; font-size: 15px; border: 1px solid #d8d0bd; border-radius: 8px; background: #fff; }
.games-list { max-width: 980px; margin: 0 auto; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.games-row { display: grid; grid-template-columns: 96px minmax(0, 1.6fr) minmax(52px, max-content) minmax(0, 1.4fr); gap: 12px; padding: 10px 16px;
  border-top: 1px solid #efe9dc; cursor: pointer; font-size: 14px; align-items: baseline; }
.games-row:first-child { border-top: 0; }
.games-row:hover { background: #faf6ec; }
.games-date { color: #7a7466; font-variant-numeric: tabular-nums; }
.games-players b { color: #111; font-weight: 400; } .games-players b.w { color: #888; }
.games-result { font-weight: 600; }
.games-event { color: #7a7466; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .games-row { grid-template-columns: 78px minmax(0, 1fr) max-content; gap: 10px; }
  .games-event { grid-column: 1 / -1; white-space: normal; }
}
/* the Stream's high roller (app.js viewStream): the next problem's stakes ×5 */
.controls button.high-roller { background: #8a5a12; border-color: #8a5a12; color: #fff; }
.controls button.high-roller:hover { background: #6f480e; }

/* ===== The bookshelf (a pilot: app.js viewShelf, #/shelf): a moonlit library ===== */
.shelf-try { display: inline-block; margin: 0 0 14px; padding: 8px 16px; border-radius: 999px; font: 600 14px/1 "Cinzel", Georgia, serif;
  letter-spacing: .06em; color: #f4e2b4; text-decoration: none;
  background: radial-gradient(120% 140% at 30% 20%, #3a2f5c, #160f26 70%); box-shadow: 0 0 0 1px #8c7440, 0 4px 16px rgba(40, 20, 80, .45); }
.shelf-try:hover { box-shadow: 0 0 0 1px #d6b45e, 0 0 22px rgba(214, 180, 94, .45); }

.shelf-room { position: relative; overflow: hidden; isolation: isolate; color: #ead9b0;
  width: 100vw; margin: -24px calc(50% - 50vw) 0; min-height: calc(100vh - 60px); padding: 34px max(22px, calc(50vw - 600px)) 70px;
  background:
    radial-gradient(ellipse 34% 46% at 50% 0%, rgba(150, 170, 255, .16), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(120, 60, 30, .35), transparent 70%),
    linear-gradient(180deg, #0b0a18 0%, #120d22 38%, #1a1020 70%, #120a10 100%);
  font-family: "Cormorant Garamond", Georgia, serif; }
.shelf-room::after { content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none; will-change: transform;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 55%, rgba(0, 0, 0, .55) 100%); }   /* vignette */

/* the arched window on the far wall: a night sky, a crescent moon, two go stones circling like moons */
.shelf-window { position: absolute; z-index: 0; left: 50%; top: 18px; width: min(340px, 46vw); height: 300px; transform: translateX(-50%);
  border-radius: 170px 170px 6px 6px; overflow: hidden;
  background: radial-gradient(ellipse 80% 70% at 50% 30%, #2c3a78 0%, #151d45 45%, #0a0e24 100%);
  box-shadow: inset 0 0 0 6px #2a1d14, inset 0 0 0 9px #6e5432, inset 0 0 40px rgba(0, 0, 0, .7), 0 0 60px rgba(120, 140, 255, .18); }
.shelf-window::before, .shelf-window::after { content: ""; position: absolute; background: #2a1d14; box-shadow: 0 0 0 2px #6e5432; }
.shelf-window::before { left: 50%; top: 0; bottom: 0; width: 6px; transform: translateX(-50%); }   /* the mullion */
.shelf-window::after { left: 0; right: 0; top: 46%; height: 6px; }                                  /* the transom */
.shelf-window .star { position: absolute; width: calc(2px * var(--z)); height: calc(2px * var(--z)); border-radius: 50%; background: #fff;
  box-shadow: 0 0 6px rgba(200, 210, 255, .9); animation: shelf-twinkle 4.5s ease-in-out infinite; }
@keyframes shelf-twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.shelf-moon { position: absolute; right: 22%; top: 16%; width: 54px; height: 54px; border-radius: 50%;
  box-shadow: -12px 6px 0 0 #f3ecd2, -12px 6px 24px 4px rgba(243, 236, 210, .45); }
.shelf-orbit { will-change: transform, opacity; position: absolute; left: 50%; top: 62%; width: 150px; height: 46px; margin-left: -75px; border-radius: 50%;
  border: 1px solid rgba(214, 190, 120, .18); animation: shelf-orbit 22s linear infinite; }
.shelf-orbit .stone { position: absolute; top: -9px; width: 18px; height: 18px; border-radius: 50%; }
.shelf-orbit .stone.b { left: -9px; background: radial-gradient(circle at 35% 30%, #6a6a78, #0b0b10 70%); box-shadow: 0 0 12px rgba(150, 160, 255, .5); }
.shelf-orbit .stone.w { right: -9px; background: radial-gradient(circle at 35% 30%, #fff, #cfcabb 70%); box-shadow: 0 0 14px rgba(255, 245, 210, .7); }
@keyframes shelf-orbit { to { transform: rotate(360deg); } }

/* moonlight falling through, slowly breathing */
.shelf-shafts { position: absolute; z-index: 1; left: 50%; top: 40px; width: 900px; height: 900px; margin-left: -450px; pointer-events: none; }
.shelf-shafts i { will-change: transform, opacity; position: absolute; left: 50%; top: 0; width: 120px; height: 100%; margin-left: -60px; transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(170, 185, 255, .16), rgba(170, 185, 255, .05) 55%, transparent 85%); filter: blur(8px);
  animation: shelf-shaft 9s ease-in-out infinite; }
.shelf-shafts i:nth-child(1) { transform: rotate(14deg); } .shelf-shafts i:nth-child(2) { transform: rotate(-2deg); width: 160px; animation-delay: -3s; }
.shelf-shafts i:nth-child(3) { transform: rotate(-18deg); animation-delay: -6s; }
@keyframes shelf-shaft { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* candles afloat */
.shelf-candles { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.fcandle { will-change: transform, opacity; position: absolute; width: calc(12px * var(--k)); height: calc(46px * var(--k)); border-radius: 2px 2px 3px 3px;
  background: linear-gradient(90deg, #cdbd96, #fbf3dc 45%, #bfae86); box-shadow: 0 0 30px 10px rgba(255, 190, 100, .10);
  animation: shelf-float 7s ease-in-out infinite; }
.fcandle .flame { position: absolute; left: 50%; top: -20px; width: 9px; height: 18px; margin-left: -4.5px; transform-origin: 50% 100%;
  border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 75%, #fffbe6, #ffcc5c 45%, rgba(255, 120, 40, 0) 75%);
  box-shadow: 0 0 18px 6px rgba(255, 196, 100, .55), 0 0 60px 20px rgba(255, 170, 80, .18); animation: shelf-flicker 1.7s ease-in-out infinite; }
@keyframes shelf-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes shelf-flicker { 0%, 100% { transform: scale(1) rotate(-2deg); opacity: .95; } 35% { transform: scale(1.08, .92) rotate(2deg); }
  65% { transform: scale(.94, 1.06) rotate(-1deg); opacity: 1; } }

/* motes: warm dust, now and then a cool arcane spark */
.shelf-motes { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.shelf-motes i { will-change: transform, opacity; position: absolute; bottom: -10px; width: calc(4px * var(--s)); height: calc(4px * var(--s)); border-radius: 50%;
  background: #ffe6a8; box-shadow: 0 0 8px 2px rgba(255, 214, 140, .65); opacity: 0; animation: shelf-mote linear infinite; }
.shelf-motes i.arcane { background: #cfd8ff; box-shadow: 0 0 10px 3px rgba(150, 170, 255, .7); }
@keyframes shelf-mote { 0% { transform: translate(0, 0); opacity: 0; } 12% { opacity: .85; } 50% { transform: translate(24px, -50vh); }
  88% { opacity: .5; } 100% { transform: translate(-14px, -105vh); opacity: 0; } }
.shelf-mist { will-change: transform, opacity; position: absolute; left: -10%; right: -10%; bottom: -20px; height: 180px; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse 50% 60% at 30% 70%, rgba(180, 170, 210, .10), transparent 70%),
              radial-gradient(ellipse 50% 60% at 75% 80%, rgba(180, 170, 210, .09), transparent 70%);
  filter: blur(6px); animation: shelf-mist 26s ease-in-out infinite alternate; }
@keyframes shelf-mist { to { transform: translateX(6%); } }

.shelf-head { position: relative; z-index: 6; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin: 250px 0 26px; padding-bottom: 14px; border-bottom: 1px solid rgba(214, 180, 94, .25); }
.shelf-head h2 { margin: 0; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; font-weight: 400; }
.shelf-head .zh { font: 700 34px/1 "Noto Serif SC", "Songti SC", "STSong", serif; color: #f1d58e; letter-spacing: .12em;
  text-shadow: 0 0 22px rgba(241, 213, 142, .45), 0 2px 0 #3a2410; }
.shelf-head .en { font: 500 22px/1 "Cinzel", Georgia, serif; letter-spacing: .14em; color: #e6cf98; text-shadow: 0 0 14px rgba(230, 207, 152, .3); }
.shelf-back { font: 500 13px/1 "Cinzel", Georgia, serif; letter-spacing: .08em; color: #cdb37a; text-decoration: none; opacity: .8; }
.shelf-back:hover { opacity: 1; color: #f1d58e; }

/* a shelf: an engraved brass plaque, then rows of books on carved wood */
.shelf { position: relative; z-index: 6; margin: 0 0 38px; }
/* a short shelf (the tales, the masters' games): centred, as wide as its books */
.shelf.short { width: fit-content; max-width: 100%; margin-left: auto; margin-right: auto; }
.shelf.short .shelf-row { padding-left: 26px; padding-right: 26px; }
.shelf-plaque { display: inline-flex; align-items: baseline; gap: 10px; margin: 0 0 10px 6px; padding: 5px 16px 6px; border-radius: 3px;
  background: linear-gradient(180deg, #c9a75a, #8d6d2e 55%, #6d521f); box-shadow: inset 0 1px 0 rgba(255, 240, 200, .5), 0 2px 6px rgba(0, 0, 0, .5);
  color: #2a1a08; font: 600 13px/1 "Cinzel", Georgia, serif; letter-spacing: .16em; text-transform: uppercase; text-shadow: 0 1px 0 rgba(255, 236, 190, .45); }
.shelf-plaque .zh { font: 700 15px/1 "Noto Serif SC", "Songti SC", serif; letter-spacing: .1em; text-transform: none; }
/* every row of slots is --row tall with a carved plank under it (the row's own background), so a wrapped shelf gets
   a plank under every row; the back panel is dark wood in shadow */
.shelf-row { --row: 244px; --plank: 18px; display: flex; flex-wrap: wrap; align-items: flex-end; column-gap: 2px; row-gap: var(--plank);
  padding: 0 14px var(--plank); border-radius: 4px;
  background:
    repeating-linear-gradient(180deg, transparent 0 var(--row),
      #c9a75a var(--row), #7a4f2a calc(var(--row) + 2px), #5b3a1e calc(var(--row) + 8px), #3a2412 calc(var(--row) + var(--plank))),
    linear-gradient(90deg, rgba(0, 0, 0, .55), transparent 6%, transparent 94%, rgba(0, 0, 0, .55)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .012) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, #1c120c, #24170e 60%, #1a100a);
  box-shadow: inset 0 0 0 1px rgba(214, 180, 94, .18), inset 0 12px 30px rgba(0, 0, 0, .7), 0 18px 30px rgba(0, 0, 0, .55); }
.slot { height: var(--row); display: flex; align-items: flex-end; }

/* a spine: leather with raised bands, a tooled title, gold leaf that catches the light */
.spine { position: relative; display: flex; flex-direction: column; align-items: center; width: var(--w); height: var(--h); flex: none;
  border-radius: 3px 3px 2px 2px; text-decoration: none; color: #f1e2bf; overflow: hidden; cursor: pointer;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .55) 0%, rgba(255, 255, 255, .14) 22%, rgba(255, 255, 255, .03) 50%, rgba(0, 0, 0, .35) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='80' height='80' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E"),
    var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5), inset 0 0 12px rgba(0, 0, 0, .35), 3px 0 4px rgba(0, 0, 0, .55);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1.1), box-shadow .35s, filter .35s; }
.spine .rib { position: absolute; left: -1px; right: -1px; height: 5px; border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(0, 0, 0, .35)); box-shadow: 0 1px 0 color-mix(in srgb, var(--gilt) 55%, transparent), 0 -1px 0 color-mix(in srgb, var(--gilt) 55%, transparent); }
.spine .r1 { top: 12px; } .spine .r2 { bottom: 34px; } .spine .r3 { bottom: 14px; }
.spine-title { display: flex; flex-direction: column; align-items: center; gap: 7px; margin-top: 26px; height: calc(var(--h) - 76px); overflow: hidden;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .7); }
.spine-title .zh { display: flex; flex-direction: column; align-items: center; flex: none; padding: 5px 3px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gilt) 55%, transparent); background: rgba(0, 0, 0, .18); }
.spine-title .zh b { display: block; font: 700 14px/1.14 "Noto Serif SC", "Songti SC", "STSong", serif;
  background: linear-gradient(180deg, #fff3cf, var(--gilt) 55%, color-mix(in srgb, var(--gilt) 70%, #3a2410)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.spine-title .en { writing-mode: vertical-rl; flex: 1 1 0; min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: italic 500 13px/1 "Cormorant Garamond", Georgia, serif; letter-spacing: .04em; color: color-mix(in srgb, var(--gilt) 60%, #f6ead0); }
.spine-level { position: absolute; bottom: 19px; font: 600 9.5px/1 "Cinzel", Georgia, serif; color: var(--gilt); letter-spacing: .05em; }
.spine-progress { position: absolute; left: 0; bottom: 0; width: 2px; height: calc(var(--done) * 100%);
  background: linear-gradient(0deg, #fff0b8, var(--gilt)); box-shadow: 0 0 8px rgba(255, 224, 150, .9); }
/* gold leaf: a band of light sweeps across when the book is drawn out */
.spine-sheen { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 240, 200, .38) 50%, transparent 65%); background-size: 100% 300%; background-position: 0 120%; }
.spine:hover .spine-sheen, .spine:focus-visible .spine-sheen { opacity: 1; animation: shelf-sheen 1.1s ease-out forwards; }
@keyframes shelf-sheen { from { background-position: 0 120%; } to { background-position: 0 -30%; } }
.spine:hover, .spine:focus-visible { transform: translateY(-16px) scale(1.04); z-index: 7; outline: none; filter: brightness(1.12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5), 0 0 26px 6px color-mix(in srgb, var(--gilt) 45%, transparent), 0 20px 26px rgba(0, 0, 0, .65); }
.spine-ribbon { position: absolute; bottom: -8px; right: 5px; width: 7px; height: 30px; background: linear-gradient(90deg, #7d0f12, #b71c1c, #7d0f12);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%); box-shadow: 0 0 6px rgba(183, 28, 28, .6); }
/* a problem book's star (favourite it there on the shelf): shown on hover and focus, always on a touch screen */
.spine-star { position: absolute; top: 0; left: 50%; transform: translate(-50%, -2px); z-index: 2; padding: 2px 4px; border: 0; background: none;
  font: 15px/1 Georgia, serif; color: #f4dc8e; text-shadow: 0 0 8px rgba(255, 215, 120, .8), 0 1px 1px #000; cursor: pointer; opacity: 0; transition: opacity .2s; }
.spine-star.on { opacity: 1; }
.spine:hover .spine-star, .spine:focus-within .spine-star, .spine-star:focus-visible { opacity: 1; }
@media (pointer: coarse) { .spine-star { opacity: .75; } }
/* the story campaigns: thick tomes with brass corners and a gem set in the spine */
.spine.tome { --w: 62px !important; border-radius: 4px; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--gilt) 70%, transparent),
  inset 0 0 0 5px rgba(0, 0, 0, .3), inset 0 0 14px rgba(0, 0, 0, .4), 4px 0 6px rgba(0, 0, 0, .55); }
.spine.tome::before, .spine.tome::after { content: ""; position: absolute; left: 0; right: 0; height: 14px; pointer-events: none;
  background: linear-gradient(90deg, #8a6a2a, #e6c97a 30%, #a8823a 60%, #6a4e1c); clip-path: polygon(0 0, 100% 0, 100% 100%, 82% 100%, 82% 40%, 18% 40%, 18% 100%, 0 100%); }
.spine.tome::before { top: 0; } .spine.tome::after { bottom: 0; transform: scaleY(-1); }
.spine.tome .spine-title .zh b { font-size: 19px; } .spine.tome .spine-title .en { font-size: 15px; }
.spine .boss { position: absolute; bottom: 44px; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd9d9, #c41e3a 45%, #4d0712); box-shadow: 0 0 0 2px #b58f3e, 0 0 10px rgba(220, 40, 70, .7); }
/* the Stream: an arcane volume, pulsing with a cold light */
/* the Stream: an arcane volume with a cold aura. The aura pulses in opacity on its own layer (the compositor's work,
   no repaint); the spine's own shadow stays still */
.spine.glow { --ink: #1b1640 !important; --gilt: #b9c6ff !important;
  box-shadow: inset 0 0 0 1px rgba(170, 185, 255, .65), 0 0 12px 2px rgba(130, 150, 255, .35); }
.spine.glow .spine-title .en { color: #dfe5ff; }
.slot { position: relative; }
.slot .aura { position: absolute; left: -14px; right: -14px; bottom: -6px; height: calc(var(--row) - 6px); pointer-events: none;
  background: radial-gradient(ellipse 50% 50% at 50% 55%, rgba(140, 160, 255, .55), transparent 70%);
  opacity: .35; will-change: opacity; animation: shelf-arcane 3.6s ease-in-out infinite; }
@keyframes shelf-arcane { 0%, 100% { opacity: .3; } 50% { opacity: .85; } }
/* game records: folios marked with a black and a white stone */
.spine.record::after { content: "●○"; position: absolute; top: 24px; font-size: 9px; letter-spacing: 1px; color: var(--gilt); }
.spine.record .spine-title { margin-top: 38px; }

@media (max-width: 640px) {
  .shelf-room { margin-top: -16px; padding: 20px 12px 50px; }
  .shelf-window { height: 220px; } .shelf-head { margin-top: 190px; } .shelf-head .zh { font-size: 28px; } .shelf-head .en { font-size: 17px; }
  .shelf-row { --row: 232px; flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .spine { scroll-snap-align: start; }
  .fcandle:nth-child(n+5) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .shelf-window .star, .shelf-orbit, .shelf-shafts i, .fcandle, .fcandle .flame, .shelf-mist, .slot .aura, .spine-sheen { animation: none !important; }
  .shelf-motes { display: none; }
  .spine { transition: none; }
}
.byo-voice { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
