/* Scholar's Odyssey v0.3 — modern manuscript
   Design language: soft, layered, deliberate motion. Parchment palette kept
   but rendered with elevation, glass, gradients, and a modern sans for UI. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fraunces:wght@500;700;900&display=swap');

:root {
  --ink:        #2a1e0e;
  --ink-2:      #4a3820;
  --ink-3:      #6c5423;
  --ink-mute:   #8b7237;
  --paper:      #f7efd8;
  --paper-2:    #ede0be;
  --paper-3:    #f9f3e0;
  --paper-hi:   #fff9e2;
  --gold:       #a8792b;
  --gold-2:     #d4a041;
  --wine:       #7d2626;
  --wine-2:     #a83232;
  --arch:       #b07b2b;
  --arts:       #a3232a;
  --textile:    #2f5aa8;
  --dance:      #2e6f34;
  --active:     #e8b940;
  --stopred:    #a52020;
  --shadow-sm:  0 1px 2px rgba(60, 40, 15, .10);
  --shadow-md:  0 3px 8px rgba(60, 40, 15, .12), 0 1px 2px rgba(60,40,15,.08);
  --shadow-lg:  0 8px 24px rgba(60, 40, 15, .18), 0 2px 6px rgba(60,40,15,.10);
  --glass-bg:   rgba(255, 249, 226, .78);
  --glass-brd:  rgba(184, 158, 95, .55);
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --font-ui:    'Inter', -apple-system, "Segoe UI", sans-serif;
  --font-serif: 'Fraunces', 'Georgia', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1200px 500px at 15% 0%, #f9edc8 0%, transparent 55%),
    radial-gradient(900px 500px at 85% 100%, #e6d9b0 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 20px;
  background: linear-gradient(180deg, rgba(255, 246, 214, .85), rgba(235, 218, 168, .85));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--glass-brd);
  box-shadow: var(--shadow-sm);
  position: relative; z-index: 5;
}
.brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 19px; letter-spacing: -0.4px;
  background: linear-gradient(90deg, var(--wine) 0%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand .ver {
  font-family: var(--font-ui); font-size: 10px; font-weight: 500;
  color: var(--ink-mute); margin-left: 6px;
  background: none; -webkit-text-fill-color: var(--ink-mute);
}
.brand .sub { font-size: 11px; color: var(--ink-3); font-style: italic; margin-top: 0; }

.controls { display: flex; gap: 8px; align-items: center; }
.controls label {
  font-size: 12px; color: var(--ink-3); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.controls select, .controls input {
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: inherit; font-size: 12px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.controls select:focus, .controls input:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(168, 121, 43, .18);
}
.controls input { width: 5em; }

/* ---------- Buttons ---------- */
button {
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s, background .15s, border-color .15s;
  box-shadow: var(--shadow-sm);
}
button:hover:not(:disabled) {
  background: var(--paper-3);
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
button:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-sm); }
button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

button.primary {
  background: linear-gradient(135deg, var(--wine) 0%, var(--wine-2) 100%);
  color: var(--paper-hi);
  border: 1px solid rgba(76, 20, 20, .8);
  font-weight: 600;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.15);
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #942f2f 0%, #b23b3b 100%);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.2);
}
button.secondary { background: var(--paper-2); }

/* ---------- Turn banner ---------- */
#turnBanner {
  padding: 6px 20px;
  background: linear-gradient(180deg, rgba(235, 218, 168, .95), rgba(224, 200, 145, .95));
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--glass-brd);
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-2);
  display: flex; align-items: center;
  transition: background .3s;
}
#turnBanner.your-turn {
  background: linear-gradient(90deg,
    rgba(232, 185, 64, .35) 0%,
    rgba(255, 239, 168, .95) 30%,
    rgba(232, 185, 64, .55) 70%,
    rgba(232, 185, 64, .35) 100%);
  color: var(--wine);
  font-weight: 600;
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
#turnBanner .alarm {
  color: var(--wine);
  font-weight: 700; margin-left: 12px;
  padding: 2px 10px; background: rgba(193, 39, 45, .1);
  border-radius: 20px; font-size: 12px;
  border: 1px solid rgba(193, 39, 45, .3);
}

/* ---------- Progress bar ---------- */
#progressBar {
  display: flex; gap: 6px; align-items: center;
  padding: 5px 20px;
  background: rgba(247, 239, 216, .5);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--glass-brd);
  font-size: 11px; flex-wrap: wrap;
}
.pg-item {
  display: flex; gap: 4px; align-items: center;
  padding: 2px 8px;
  background: var(--paper-hi);
  border-radius: 20px;
  border: 1px solid var(--glass-brd);
  box-shadow: var(--shadow-sm);
}
.pg-label { color: var(--ink-3); font-weight: 500; font-size: 10.5px; }
.pg-val { font-weight: 700; color: var(--wine); font-variant-numeric: tabular-nums; }
.pg-label.alarm { color: var(--wine); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }

/* ---------- Layout ---------- */
main {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 340px;
  gap: 10px;
  padding: 8px 14px;
  height: calc(100vh - 108px);
  overflow: hidden;
}

/* Common panel style */
#leftPanel, #rightPanel {
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}
#leftPanel::-webkit-scrollbar,
#rightPanel::-webkit-scrollbar { width: 6px; }
#leftPanel::-webkit-scrollbar-thumb,
#rightPanel::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

/* Left panel is a single glass card */
#leftPanel {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  font-size: 11px;
}

/* ---------- Board ---------- */
#boardWrap {
  background:
    linear-gradient(140deg, rgba(255, 249, 226, .6), rgba(237, 224, 190, .6)),
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(184, 158, 95, .05) 6px 7px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 0 45px rgba(120, 80, 20, .12);
  position: relative;
  overflow: hidden;
  display: flex; align-items: stretch; justify-content: center;
}
#board { width: 100%; height: 100%; display: block; min-height: 0; }

#legend {
  position: absolute; bottom: 8px; right: 8px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 6px 10px; font-size: 10px;
  line-height: 1.45;
  pointer-events: none;
  max-width: 200px;
  box-shadow: var(--shadow-md);
}
.lg-row { display: flex; align-items: center; gap: 5px; }
.lg-title {
  font-size: 9px; font-weight: 700; color: var(--wine);
  text-transform: uppercase; letter-spacing: .8px;
  margin-top: 4px;
}
.lg-title:first-child { margin-top: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1.5px solid var(--ink); box-shadow: var(--shadow-sm); }
.dot.arch    { background: var(--arch); }
.dot.arts    { background: var(--arts); }
.dot.textile { background: var(--textile); }
.dot.dance   { background: var(--dance); }
.dot.avail   { background: var(--arch); }
.dot.collected { background: #d9c99a; border-style: dashed; }
.ring { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--gold); display: inline-block; }
.line.solid  { width: 20px; height: 0; border-top: 2px solid var(--ink-3); display: inline-block; border-radius: 1px; }
.line.dashed { width: 20px; height: 0; border-top: 2px dashed var(--wine); display: inline-block; }

/* ---------- SVG classes ---------- */
.country { fill: #f5e9c7; stroke: #8b7237; stroke-width: 1.2; stroke-linejoin: round; }
.country.india { fill: #f7efd8; stroke: #6c5423; stroke-width: 1.8; filter: drop-shadow(0 2px 4px rgba(60,40,15,.15)); }
.country.neighbour { fill: #e6d9b0; opacity: .78; }

.zone { opacity: .28; stroke: #8b7237; stroke-width: 1; stroke-dasharray: 4 3; }
.zone-label {
  fill: #8b6a24; font-family: var(--font-serif); font-weight: 900;
  font-size: 20px; letter-spacing: 3px;
  text-anchor: middle; opacity: .55; pointer-events: none;
  paint-order: stroke; stroke: #f7efd8; stroke-width: 4;
}

.edge { stroke-linecap: round; }
.edge.same-zone  { stroke: #5c4a1e; stroke-width: 2.6; opacity: .95; }
.edge.cross-zone { stroke: #7d2626; stroke-width: 2.4; stroke-dasharray: 8 5; opacity: .9; }
.edge-halo { stroke: #f7efd8; stroke-width: 5.5; stroke-linecap: round; opacity: .9; }

.pin { transition: r .15s ease; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.pin.hover { r: 26; }
.pin.collected { opacity: .55; }
.pin-hit { fill: transparent; }
.pin-glyph {
  text-anchor: middle; font-size: 20px; pointer-events: none; user-select: none;
  fill: #fff9e2; paint-order: stroke; stroke: #1a1305; stroke-width: 1;
}
.pin-glyph.collected { fill: #6c5423; stroke: #f7efd8; stroke-width: 2; font-size: 18px; font-weight: 700; }
.card-badge {
  text-anchor: middle; font-size: 16px; pointer-events: none; user-select: none;
  paint-order: stroke; stroke: #fff9e2; stroke-width: 2;
}
.airport-ring { fill: none; stroke: var(--gold); stroke-width: 4; opacity: .95; }
.airport-badge {
  text-anchor: middle; font-size: 20px; fill: var(--gold); font-weight: 700;
  paint-order: stroke; stroke: #fff9e2; stroke-width: 3;
}

.city-label {
  text-anchor: middle; font-size: 15px; fill: var(--ink);
  font-family: var(--font-ui); font-weight: 700;
  pointer-events: none; user-select: none;
  paint-order: stroke; stroke: #f7efd8; stroke-width: 4;
}
.city-label.collected { fill: #6c5423; font-weight: 400; font-style: italic; }

/* ---------- Pawns ---------- */
.pawn-g { pointer-events: none; }
.pawn-label {
  fill: #fff; font-size: 11px; font-weight: 700;
  font-family: var(--font-ui); text-anchor: middle;
  paint-order: stroke; stroke: rgba(26,19,5,.5); stroke-width: 1.2;
}
.pawn-label.human { font-size: 10px; letter-spacing: .5px; }
.pawn-stem { stroke: #1a1305; stroke-width: 2; }
.pawn-halo {
  fill: none; stroke: var(--active); stroke-width: 5;
  animation: halo 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(232, 185, 64, .6));
}
@keyframes halo {
  0%, 100% { r: 32; opacity: .95; }
  50%      { r: 42; opacity: .35; }
}
.pawn-g.human .pawn-stem { stroke-width: 3; stroke: var(--wine); }

.hl-ring {
  fill: none; stroke: #2b7a2b; stroke-width: 5;
  animation: legalPulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(43, 122, 43, .5));
}
@keyframes legalPulse {
  0%, 100% { r: 32; opacity: .95; }
  50%      { r: 40; opacity: .55; }
}

/* City hover tooltip */
#cityTooltip {
  position: absolute; pointer-events: none;
  background: rgba(255, 249, 226, .96);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 10px 12px; font-size: 12px; line-height: 1.55;
  box-shadow: var(--shadow-lg);
  max-width: 280px; z-index: 20;
  animation: tipIn .15s ease-out;
}
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tip-head { font-family: var(--font-serif); font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.tip-meta { font-size: 11px; color: var(--ink-3); font-style: italic; margin-bottom: 4px; }
.tip-tag { display: inline-block; background: var(--gold); color: #fff9e2; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.tip-row { font-size: 12px; margin-top: 3px; }

/* ---------- Panel headers ---------- */
.phead {
  font-family: var(--font-serif);
  font-size: 12px; font-weight: 700; color: var(--wine);
  border-bottom: 1px solid var(--glass-brd);
  padding-bottom: 3px; margin-bottom: 5px;
  display: flex; align-items: center; gap: 4px;
}
.cite { font-family: var(--font-ui); font-size: 9.5px; color: var(--ink-mute); font-weight: 400; margin-left: 4px; }

/* ---------- Player cards ---------- */
#players { display: flex; flex-direction: column; gap: 5px; }
.player {
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 6px 8px; font-size: 11.5px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
.player.active {
  border-color: var(--active);
  background: linear-gradient(135deg, rgba(255,242,198,.9), rgba(255,239,168,.9));
  box-shadow: var(--shadow-md), 0 0 0 2px rgba(232, 185, 64, .25);
  transform: translateX(-2px);
}
.player.human .whoami { font-weight: 700; color: var(--wine); }
.player .pname { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  color: #fff; text-align: center;
  font-size: 13px; font-weight: 700;
  border: 2px solid #1a1305;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.chip-shield  { border-radius: 8px 8px 14px 14px / 8px 8px 22px 22px; }
.chip-diamond { transform: rotate(45deg); border-radius: 4px; width: 18px; height: 18px; }
.chip-diamond > * { transform: rotate(-45deg); display: inline-block; }
.chip-hex     { clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%); border: none; box-shadow: inset 0 0 0 2px #1a1305, var(--shadow-md); }
.chip-star    { clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); border: none; }

.player .whoami { flex: 0 0 auto; font-weight: 600; }
.player .loc {
  font-size: 10.5px; color: var(--ink-3); margin-left: auto;
  background: rgba(255, 249, 226, .55);
  padding: 1px 7px; border-radius: 20px;
  border: 1px solid rgba(184, 158, 95, .3);
}
.player .stats {
  display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap;
}
.player .stats span {
  padding: 1px 7px;
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  border-radius: 20px;
  font-size: 10.5px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.player .books { margin-top: 4px; display: flex; gap: 3px; flex-wrap: wrap; }
.book {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 6px; font-size: 9.5px; font-weight: 700;
  background: var(--ink-3); color: var(--paper-hi);
  border-radius: 3px;
  box-shadow: var(--shadow-sm);
}
.book.featured { box-shadow: 0 0 0 2px var(--gold), var(--shadow-sm); }

.opphand { margin-top: 4px; display: flex; gap: 3px; flex-wrap: wrap; }
.opphand .empty { font-size: 10px; color: var(--ink-mute); font-style: italic; }
.mini-card {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; font-size: 10px; font-weight: 500;
  background: var(--paper-hi);
  border: 1.5px solid; border-radius: 3px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.mini-card.peer { background: #f4e6b8; }

.persona-tag {
  display: inline-block; padding: 2px 7px; font-size: 10px;
  background: linear-gradient(135deg, var(--paper-2), var(--paper-hi));
  border: 1px solid var(--glass-brd); border-radius: 20px;
  color: var(--ink-3); cursor: help;
  font-weight: 500;
}

/* ---------- Actions panel ---------- */
#actions {
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}
#actions .ghead {
  font-size: 10px; color: var(--wine); font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 1px;
  text-align: center;
}
.act {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; margin-bottom: 4px;
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  position: relative;
  transition: transform .1s ease, box-shadow .15s, background .15s;
  box-shadow: var(--shadow-sm);
}
.act:hover:not(:disabled) {
  background: linear-gradient(135deg, #fff9e2, #ffefa8);
  transform: translateX(2px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.act .a-title { font-weight: 700; font-size: 12px; color: var(--ink); }
.act .a-sub   { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; font-weight: 400; line-height: 1.3; }
.act .a-why {
  font-size: 9.5px; color: var(--stopred); margin-top: 3px;
  font-style: italic; font-weight: 500;
}
.act:disabled { opacity: .55; }

/* ---------- Expedition panel ---------- */
#expedPanel {
  background: linear-gradient(135deg, rgba(255, 242, 198, .95), rgba(255, 239, 168, .95));
  backdrop-filter: blur(6px);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-md);
  animation: slideIn .25s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
#expedStatus { font-size: 12px; margin-bottom: 8px; }
.hopcount { font-size: 11px; color: var(--wine); font-weight: 600; margin-top: 4px; }
.airport-tag {
  background: var(--gold); color: #fff9e2;
  padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
}
.tickets {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  margin-bottom: 8px;
}
.ticket {
  font-size: 11px; font-weight: 600; padding: 6px 4px;
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  text-align: center;
  display: flex; flex-direction: column; gap: 1px;
  transition: all .15s ease;
}
.ticket:hover:not(:disabled) {
  background: linear-gradient(135deg, #fff9e2, #ffefa8);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.ticket .cost { color: var(--wine); font-weight: 700; }
.ticket .tcount { font-size: 10px; color: var(--ink-3); font-weight: 500; }
#expedHint { font-size: 11px; color: var(--ink-3); font-style: italic; margin: 6px 0; }
#expedPanel .row { display: flex; gap: 6px; }

/* ---------- Hand ---------- */
#handPanel {
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}
#hand { display: flex; gap: 4px; flex-wrap: wrap; }
.hand-empty { color: var(--ink-mute); font-style: italic; font-size: 11px; }
.card {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 6px; min-width: 66px;
  background: linear-gradient(180deg, var(--paper-hi) 0%, var(--paper-2) 100%);
  border: 2px solid var(--ink); border-radius: var(--radius-sm);
  font-size: 10.5px; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.card:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: var(--shadow-md);
}
.card.sel {
  outline: 3px solid var(--active);
  background: linear-gradient(180deg, #fff2c6 0%, #ffefa8 100%);
  transform: translateY(-2px);
}
.card.peer::after {
  content: "★"; position: absolute; top: -6px; right: -4px;
  background: var(--wine); color: #fff9e2;
  font-size: 10px; padding: 2px 5px; border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.card .c-glyph { font-size: 16px; line-height: 1; }
.card .c-name  { font-weight: 700; text-align: center; margin-top: 2px; font-size: 10.5px; }
.card .c-zone  { font-size: 9px; color: var(--ink-mute); font-weight: 500; }

/* ---------- Log ---------- */
#log {
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}
#logHead { cursor: pointer; user-select: none; }
#logToggle { display: inline-block; width: 12px; }
#log ol {
  margin: 0; padding-left: 18px; font-size: 10.5px;
  max-height: 110px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--gold) transparent;
}
#log li { color: var(--ink-3); margin-bottom: 2px; line-height: 1.35; }

/* ---------- Reference chart ---------- */
#refHead { cursor: pointer; user-select: none; }
#refBody { font-size: 11px; }
.ref-title {
  font-family: var(--font-serif);
  font-size: 10px; font-weight: 700; color: var(--wine);
  text-transform: uppercase; letter-spacing: .8px;
  margin: 8px 0 3px; padding-bottom: 2px;
  border-bottom: 1px dotted var(--glass-brd);
}
.ref-title:first-child { margin-top: 0; }
.ref-sub { font-size: 10px; color: var(--ink-3); font-style: italic; margin-bottom: 3px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.ref-table td, .ref-table th {
  padding: 2px 4px; text-align: left; vertical-align: top;
}
.ref-table th {
  background: var(--paper-2);
  font-weight: 600; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--ink-3);
}
.ref-table.pub-table td:nth-child(2),
.ref-table.pub-table td:nth-child(3),
.ref-table.pub-table td:nth-child(4) {
  text-align: center; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ref-table td:first-child { font-weight: 600; }
.ref-note {
  font-size: 10px; color: var(--ink-3);
  font-style: italic; margin-top: 3px; line-height: 1.4;
  padding-left: 4px; border-left: 2px solid var(--glass-brd);
}
.fp { font-size: 10.5px; padding: 1px 0; }
.fp-glyph { font-size: 12px; margin-right: 3px; }
.fp-sep { color: var(--ink-mute); margin: 0 3px; }

/* ---------- Scoring panel ---------- */
#scoring {
  background: linear-gradient(135deg, rgba(255, 242, 198, .95), rgba(255, 239, 168, .95));
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-lg);
}
#scoring table { width: 100%; border-collapse: collapse; font-size: 12px; }
#scoring th, #scoring td {
  padding: 5px 6px; border-bottom: 1px solid var(--glass-brd); text-align: left;
}
#scoring th { background: var(--paper-2); font-weight: 700; }
#scoring .row {
  display: flex; gap: 8px; margin-top: 10px;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 10, 5, .55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn .2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal[hidden] { display: none; }
#expedPanel[hidden], #scoring[hidden] { display: none; }
.modal-card {
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  min-width: 360px; max-width: 540px;
  box-shadow: var(--shadow-lg);
  max-height: 85vh; overflow-y: auto;
  animation: cardIn .25s cubic-bezier(.2,.9,.3,1.4);
}
@keyframes cardIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
.modal-card h3 {
  margin: 0 0 14px;
  font-family: var(--font-serif); font-weight: 700; color: var(--wine);
  font-size: 20px;
}
.mopt {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; margin-bottom: 6px;
  border: 1px solid var(--glass-brd); background: var(--paper-hi);
  border-radius: var(--radius-sm); font-size: 13px;
  transition: all .12s ease;
}
.mopt:hover:not(:disabled) {
  background: linear-gradient(135deg, #fff9e2, #ffefa8);
  transform: translateX(3px);
  border-color: var(--gold);
}
.mopt-glyph { font-size: 16px; margin-right: 6px; }
.mopt-tag { color: var(--ink-3); font-size: 11px; }
.peer-msg p { margin: 8px 0; font-size: 13px; line-height: 1.55; }
.peer-card {
  padding: 10px; background: var(--paper-hi);
  border: 1px solid var(--glass-brd); border-radius: var(--radius-sm);
  margin: 8px 0; box-shadow: var(--shadow-sm);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.rules { font-family: var(--font-ui); font-size: 12px; line-height: 1.6; }
.rules p { margin: 6px 0; }

#modalCancel { display: none; }

/* ---------- Persona picker ---------- */
.persona-help {
  font-size: 12.5px; color: var(--ink-3); font-style: italic;
  margin-bottom: 12px; line-height: 1.5;
  padding: 8px 10px; background: var(--paper-3);
  border-left: 3px solid var(--gold); border-radius: 3px;
}
.ppick {
  background: linear-gradient(135deg, var(--paper-hi), var(--paper-3));
  border: 1px solid var(--glass-brd); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.pph { font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ppick-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  align-items: end;
}
.ppick-row label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10.5px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px;
}
.ppick-row select {
  background: var(--paper-hi);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  padding: 6px 8px; font-family: inherit; font-size: 12px;
  color: var(--ink); font-weight: 500;
  cursor: pointer;
  text-transform: none; letter-spacing: normal;
}
.ppick-row select:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(168, 121, 43, .18);
}
.ppick-desc {
  font-size: 11px; color: var(--ink-3); font-style: italic;
  margin-top: 6px; padding-left: 4px; border-left: 2px solid var(--glass-brd);
}

/* ---------- Final scoring buttons ---------- */
#scoring .row button { flex: 1; }
