:root{
  --bg:#f4f5f7;
  --panel:#ffffff;
  --line:#e1e5eb;
  --ink:#1c2530;
  --muted:#697280;
  --accent:#0f766e;
  --good:#188a54;
  --bad:#c8402f;
}
*{box-sizing:border-box; hyphens:none; -webkit-hyphens:none;}
html,body{margin:0;height:100%;}
body{
  background:
    radial-gradient(1200px 600px at 15% -10%, #ffffff 0%, transparent 60%),
    radial-gradient(1000px 500px at 100% 10%, #eef0f4 0%, transparent 55%),
    var(--bg);
  color:var(--ink);
  font-family:"Iowan Old Style","Georgia",serif;
  display:flex;
  flex-direction:column;
  min-height:100vh;
  -webkit-text-size-adjust:100%;
}

/* ---------- header ---------- */
.topbar{
  padding:18px 20px 10px;
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  border-bottom:1px solid var(--line);
}
.brand{ display:flex; flex-direction:column; gap:4px; }
.brand h1{
  margin:0;
  font-size:24px;
  font-weight:600;
  letter-spacing:.01em;
  font-family:"PingFang TC","Noto Sans TC",serif;
}
.brand h1 a{ color:inherit; text-decoration:none; }
.switcher{
  font-size:11.5px;
  letter-spacing:.06em;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  color:var(--muted);
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.switcher a{ color:var(--accent); text-decoration:none; border-bottom:1px solid #d3d8e0; }
.switcher a:hover{ border-bottom-color:var(--accent); }
.stats{
  font-family:"SF Mono","Menlo",monospace;
  font-size:12.5px;
  color:var(--muted);
  display:flex;
  gap:14px;
  align-items:baseline;
  font-variant-numeric:tabular-nums;
}
.stats b{ color:var(--ink); font-size:19px; font-family:inherit; }
.stats .pct{ color:var(--accent); }

.progressWrap{ height:3px; background:var(--line); position:relative; overflow:hidden; }
.progressBar{ height:100%; width:0%; background:var(--accent); transition:width .35s ease; }

/* ---------- main ---------- */
.wrap{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:16px 14px 20px;
  gap:12px;
  width:100%;
  max-width:560px;
  margin:0 auto;
}
.tagline{
  margin:0;
  font-size:12.5px;
  line-height:1.5;
  color:var(--muted);
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  text-align:center;
}

/* ---------- round dots ---------- */
.roundDots{ display:flex; gap:6px; justify-content:center; }
.roundDots i{
  width:8px; height:8px; border-radius:50%;
  background:var(--line); border:1px solid #d7dce3;
  /* Deliberately neutral: a filled dot means "answered", NOT "correct". */
}
.roundDots i.on{ background:#c3c9d2; border-color:#b3bac4; }
.roundDots i.now{ background:var(--accent); border-color:var(--accent); }

/* ---------- swipe arena ---------- */
.arena{
  width:100%;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:stretch;
  gap:8px;
  touch-action:none;              /* the page must not scroll mid-swipe */
  -webkit-user-select:none; user-select:none;
  -webkit-tap-highlight-color:transparent;
  will-change:transform;
}
.arena.settling{ transition:transform .22s ease, opacity .22s ease; }
.arena.gone{ opacity:0; }
.pcard{
  position:relative;
  min-height:190px;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:8px; padding:16px 10px;
  background:#fbfbfc;
  border:1px solid #cfd5dd;
  border-radius:8px;
  cursor:pointer;
  transition:background .15s, border-color .15s;
}
.pcard:hover{ border-color:var(--accent); background:#fff; }
.pcard.lit{ border-color:var(--accent); background:rgba(15,118,110,.07); }
.pname{
  font-family:"PingFang TC","Noto Sans TC",serif;
  font-size:26px; font-weight:600; line-height:1.2; text-align:center;
  overflow-wrap:anywhere; min-width:0; max-width:100%;
}
/* Set by render() from the name's length. */
.pname.long{ font-size:20px; line-height:1.25; }
.pname.xlong{ font-size:16px; line-height:1.3; letter-spacing:0; }
.pocc{
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  font-size:12px; color:var(--muted); letter-spacing:.06em;
}
.pcard .hintArrow{
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  font-size:11px; color:#aeb5bf; letter-spacing:.08em;
  position:absolute; bottom:10px;
}
.vs{
  display:flex; align-items:center; justify-content:center;
  font-family:"SF Mono","Menlo",monospace;
  font-size:12px; letter-spacing:.14em; color:#aeb5bf;
  width:26px;
}

/* ---------- choices ---------- */
.choices{ display:flex; gap:8px; width:100%; max-width:300px; }
.choices button{ flex:1; }

/* ---------- buttons ---------- */
button{
  background:#eef0f3;
  color:var(--ink);
  border:1px solid #cfd5dd;
  padding:11px 14px;
  border-radius:8px;
  font-size:13px;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  cursor:pointer;
}
button:hover{ border-color:var(--accent); }
button.primary{ background:var(--accent); color:#fffdf8; border-color:var(--accent); font-weight:600; }
button.primary:hover{ filter:brightness(1.1); }
button:disabled{ opacity:.5; cursor:default; }

.footer-note{
  font-size:11px; color:#9098a3; line-height:1.6;
  margin:auto 0 0; padding-top:14px;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  text-align:center;
  max-width:420px;
}
.footer-note .ver{
  color:#b3bac4;
  font-variant-numeric:tabular-nums;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
}

.archive-banner{
  width:100%;
  background:rgba(15,118,110,.08);
  border:1px solid rgba(15,118,110,.25);
  border-radius:8px;
  padding:8px 12px;
  font-size:12.5px; line-height:1.5;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  color:var(--ink);
  text-align:center;
}
.archive-banner a{ color:var(--accent); }

/* ---------- result card ---------- */
.overlay{
  position:fixed; inset:0; z-index:60;
  background:rgba(20,30,45,.55);
  display:none; align-items:flex-start; justify-content:center;
  padding:20px; overflow-y:auto;
}
.overlay.show{ display:flex; }
.report{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:0 18px 50px rgba(20,30,45,.28);
  width:100%; max-width:380px;
  padding:24px 22px 18px;
  text-align:center;
  margin:auto;
}
.report h2{
  margin:0;
  font-size:20px; font-weight:600;
  font-family:"PingFang TC","Noto Sans TC",serif;
}
.report .rp-rank{
  margin:14px 0 2px;
  font-size:28px; font-weight:700; color:var(--accent);
  font-family:"PingFang TC","Noto Sans TC",serif;
  letter-spacing:.04em;
}
.report .rp-quip{
  font-size:13px; color:var(--muted); line-height:1.55;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  margin:6px 0 0;
}
.report .rp-score{
  margin:14px 0 2px;
  font-size:40px; font-weight:600; color:var(--ink);
  font-family:"SF Mono","Menlo",monospace; font-variant-numeric:tabular-nums;
}
/* The emoji block is share-text only — the card shows the ten recap rows
   instead — but keep the rule so a screenshot-friendly variant is one line away. */
.report .rp-emoji{
  font-size:26px; line-height:1.35; letter-spacing:.12em;
  margin:12px 0 4px;
}
.report .rp-stack{ display:flex; flex-direction:column; gap:8px; margin-top:14px; }
.report .rp-stack button{ width:100%; }
.report .rp-tomorrow{
  font-size:12px; color:var(--muted); margin:14px 0 0;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
}

/* per-round recap lines — the shareable part, so keep it tight and legible */
.rp-rounds{
  margin:14px 0 2px;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  font-size:13.5px; line-height:1.85;
  text-align:left;
}
.rp-rounds .rr{
  display:flex; align-items:baseline; gap:6px;
  border-bottom:1px dashed var(--line);
  padding:2px 0;
}
.rp-rounds .rr:last-child{ border-bottom:none; }
.rp-rounds .rr .no{
  font-family:"SF Mono","Menlo",monospace; font-size:11px;
  color:#b3bac4; width:20px; flex-shrink:0;
  font-variant-numeric:tabular-nums;
}
.rp-rounds .rr .pair{ flex:1; min-width:0; }
.rp-rounds .rr .pair b{ font-weight:600; }
.rp-rounds .rr .pair i{ color:var(--muted); font-style:normal; margin:0 4px; font-size:11.5px; }
.rp-rounds .rr .mk{ flex-shrink:0; font-size:12px; }

/* ---------- solution panel ---------- */
.tab-hint{
  font-size:12.5px; color:var(--muted); margin:0 0 10px;
  font-family:"PingFang TC","Noto Sans TC",sans-serif; line-height:1.5;
}
#solList{ max-height:56vh; overflow-y:auto; -webkit-overflow-scrolling:touch; }
/* Grid, not flex, so the number column can't be squeezed and the pair always
   gets a definite width (minmax(0,1fr)) to wrap inside. */
.sol-row{
  display:grid;
  grid-template-columns:20px minmax(0,1fr);
  column-gap:6px; row-gap:3px;
  align-items:center;
  padding:7px 2px;
  border-bottom:1px dashed var(--line);
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  font-size:14px;
}
.sol-row:last-child{ border-bottom:none; }
.sol-row .no{
  font-family:"SF Mono","Menlo",monospace; font-size:11px;
  color:#b3bac4;
  font-variant-numeric:tabular-nums;
}
.sol-pair{
  display:flex; flex-wrap:wrap; align-items:center;
  gap:4px 6px; min-width:0;
}
.sol-vs{ color:var(--muted); font-size:11.5px; flex-shrink:0; }
/* flex-shrink:0 is the fix for the one-character-per-line names: a shrinkable
   flex item collapses to min-content, which for CJK is a single glyph. Capped at
   the row width so an over-long name wraps into full lines inside its own chip
   instead of overflowing the panel. */
.sol-p{
  display:inline-flex; align-items:baseline; flex-wrap:wrap; gap:5px;
  flex-shrink:0; max-width:100%;
  padding:3px 7px; border-radius:6px;
  border:1px solid transparent;
}
.sol-p .nm{ min-width:0; overflow-wrap:anywhere; line-height:1.35; }
.sol-p em{
  font-style:normal; color:var(--muted);
  font-family:"SF Mono","Menlo",monospace; font-size:11.5px;
  font-variant-numeric:tabular-nums;
}
/* The tinted person is always the older one; the colour says whether the player
   got that round right. */
.sol-p.old{ font-weight:600; }
.sol-p.old.ok{ background:rgba(24,138,84,.12); border-color:var(--good); color:#12603b; }
.sol-p.old.ok em{ color:#3f8a63; }
.sol-p.old.no{ background:rgba(200,64,47,.1); border-color:var(--bad); color:#8f2c20; }
.sol-p.old.no em{ color:#b06a5f; }
.sol-tie{
  grid-column:2;
  font-size:11.5px; color:var(--muted);
}

/* ---------- archive list (玩以前的題目) ---------- */
.archive-link{
  font-size:12.5px; color:var(--accent); text-decoration:none;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  border-bottom:1px solid #d3d8e0; padding-bottom:1px;
}
.archive-link:hover{ border-bottom-color:var(--accent); }
#arList{ max-height:56vh; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.plist{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left;
  background:none; border:none; border-bottom:1px dashed var(--line);
  border-radius:0; padding:11px 2px;
}
.plist:last-child{ border-bottom:none; }
.plist:hover:not(:disabled){ background:#f4f5f7; }
.plist:disabled{ opacity:1; cursor:default; }
.pl-no{
  font-family:"SF Mono","Menlo",monospace; font-size:12px;
  color:var(--accent); flex-shrink:0;
  font-variant-numeric:tabular-nums;
}
.pl-mid{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.pl-date{ font-size:13.5px; }
.pl-status{
  font-family:"SF Mono","Menlo",monospace; font-size:12px;
  color:var(--muted); flex-shrink:0;
  font-variant-numeric:tabular-nums;
}
.pl-status.done{ color:var(--good); }

/* ---------- wide panel (other games) ---------- */
.overlay.wide{ padding:12px; }
.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:0 18px 50px rgba(20,30,45,.28);
  width:100%; max-width:520px;
  padding:18px 16px 16px;
  margin:auto;
}
.panel-hd{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; margin-bottom:12px;
}
.panel-hd h2{
  margin:0; font-size:17px; font-weight:600;
  font-family:"PingFang TC","Noto Sans TC",serif;
}
.panel-hd .x{ padding:6px 10px; font-size:15px; line-height:1; }
.other-h3{
  margin:18px 0 8px; font-size:11px; text-transform:uppercase;
  letter-spacing:.12em; color:var(--muted); font-weight:500; font-family:sans-serif;
}
.other-games{ display:flex; gap:8px; flex-wrap:wrap; }
.gamecard{
  flex:1; min-width:96px; text-align:center;
  padding:11px 10px; border:1px solid #cfd5dd; border-radius:8px;
  font-size:13px; color:var(--ink); text-decoration:none;
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
}
.gamecard:hover{ border-color:var(--accent); color:var(--accent); }

@media (min-width:600px){
  .brand h1{ font-size:26px; }
  .pname{ font-size:30px; }
  .pname.long{ font-size:23px; }
  .pname.xlong{ font-size:18px; }
  .pcard{ min-height:220px; }
}
@media (max-width:359px){
  .pname{ font-size:22px; }
  .pname.long{ font-size:18px; }
  .pname.xlong{ font-size:15px; }
  .pcard{ min-height:170px; }
  .rp-rounds{ font-size:12.5px; }
  .sol-row{ font-size:13px; }
}
