:root{
  --bg:#f4f5f7;
  --panel:#ffffff;
  --line:#e1e5eb;
  --ink:#1c2530;
  --muted:#697280;
  --accent:#ea580c;
  --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; }
.brand h1 #dlabel{
  font-size:13px; color:var(--muted); font-family:"SF Mono","Menlo",monospace;
  font-variant-numeric:tabular-nums; font-weight:400; margin-left:6px;
}
.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; }

.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;
}
.question{
  margin:0;
  color:var(--ink);
  font-family:"PingFang TC","Noto Sans TC",serif;
  text-align:center;
  display:flex; flex-direction:column; gap:0; align-items:center; justify-content:center;
}
.q-text{
  font-size:16px;
  line-height:1.5;
  font-weight:600;
  display:block;
}
.q-info{
  background:none; border:none; color:var(--accent);
  font-size:13px; padding:0 4px; cursor:help; line-height:1;
  flex-shrink:0;
}
.q-info:hover{ text-decoration:underline; }
.q-def{
  margin-top:8px; font-size:12px; color:var(--ink);
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  line-height:1.4; text-align:center;
  display:block;
}

/* ---------- 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;
}
.roundDots i.on{ background:#c3c9d2; border-color:#b3bac4; }
.roundDots i.now{ background:var(--accent); border-color:var(--accent); }

/* ---------- county-card arena ---------- */
.arena{
  width:100%;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:stretch;
  gap:8px;
  -webkit-user-select:none; user-select:none;
  -webkit-tap-highlight-color:transparent;
}
.ccard{
  position:relative;
  min-height:150px;
  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;
}
.ccard:hover{ border-color:var(--accent); background:#fff; }
.ccard.lit{ border-color:var(--accent); background:rgba(234,88,12,.07); }
.cname{
  font-family:"PingFang TC","Noto Sans TC",serif;
  font-size:24px; font-weight:600; line-height:1.3; text-align:center;
  overflow-wrap:anywhere; min-width:0; max-width:100%;
}
.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:#4c4c4f; 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 a{
  color:var(--accent); text-decoration:none; border-bottom:1px solid #d3d8e0;
}
.footer-note a:hover{
  border-bottom-color:var(--accent);
}
.footer-note .ver{
  color:#4c4c4f;
  font-variant-numeric:tabular-nums;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
}

.archive-banner{
  width:100%;
  background:rgba(234,88,12,.08);
  border:1px solid rgba(234,88,12,.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;
}
.report .rp-stack{ display:flex; flex-direction:column; gap:8px; margin-top:14px; }
.report .rp-stack button{ width:100%; }

/* 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:grid;
  grid-template-columns:20px 1fr auto auto;
  align-items:baseline; gap:6px;
  border-bottom:1px dashed var(--line);
  padding:4px 0;
}
.rp-rounds .rr:last-child{ border-bottom:none; }
.rp-rounds .rr .no{
  font-family:"SF Mono","Menlo",monospace; font-size:11px;
  color:#b3bac4;
  font-variant-numeric:tabular-nums;
}
.rp-rounds .rr .ind{
  font-family:"PingFang TC","Noto Sans TC",sans-serif; font-size:12px;
  color:var(--muted);
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.rp-rounds .rr .pair{ min-width:0; }
.rp-rounds .rr .pair i{ color:var(--muted); font-style:normal; margin:0 4px; font-size:11.5px; }
.rp-rounds .rr .mk{ font-size:12px; }
@media (max-width:380px){
  .rp-rounds .rr{
    grid-template-columns:20px 1fr auto;
  }
  .rp-rounds .rr .ind{ display:none; }
}

/* ---------- review 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;
}
#revList{ max-height:56vh; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.rev-row{
  display:grid;
  grid-template-columns:20px minmax(0,1fr);
  column-gap:6px; row-gap:5px;
  align-items:start;
  padding:9px 2px;
  border-bottom:1px dashed var(--line);
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  font-size:14px;
}
.rev-row:last-child{ border-bottom:none; }
.rev-row .no{
  font-family:"SF Mono","Menlo",monospace; font-size:11px;
  color:#b3bac4;
  font-variant-numeric:tabular-nums;
  padding-top:2px;
}
.rev-q{
  grid-column:2;
  font-size:12.5px; color:var(--muted); margin-bottom:2px;
  display:flex; gap:6px; align-items:center; flex-wrap:wrap;
  position:relative;
}
.rev-ind{
  display:flex; gap:4px; align-items:center;
}
.rev-word{
  font-family:"PingFang TC","Noto Sans TC",sans-serif;
  font-size:12px; color:var(--accent); font-weight:600;
}
.rev-info{
  background:none; border:none; color:var(--accent);
  font-size:16px; padding:0; cursor:help; line-height:1;
  position:relative; flex-shrink:0;
}
.rev-info:hover{ opacity:.7; }
.rev-def-popup{
  position:fixed;
  font-size:11px; color:var(--ink);
  background:var(--panel); padding:10px 12px; border-radius:6px;
  border:1px solid var(--line); box-shadow:0 4px 12px rgba(20,30,45,.15);
  line-height:1.4; word-break:break-word; z-index:70;
  white-space:normal;
}
.rev-def-mobile{
  grid-column:2; font-size:11px; color:var(--ink);
  background:rgba(234,88,12,.08); padding:8px 10px; border-radius:4px;
  margin-top:4px; border:1px solid rgba(234,88,12,.2);
  line-height:1.4; word-break:break-word;
}
.rev-def{
  grid-column:2; font-size:11px; color:var(--ink);
  background:rgba(234,88,12,.08); padding:6px 8px; border-radius:4px;
  margin-top:2px; border:1px solid rgba(234,88,12,.2);
  line-height:1.4; word-break:break-word;
}
.rev-pair{
  grid-column:2;
  display:flex; flex-wrap:wrap; align-items:center;
  gap:4px 6px; min-width:0;
}
.rev-vs{ color:var(--muted); font-size:11.5px; flex-shrink:0; }
.rev-c{
  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;
}
.rev-c .nm{ min-width:0; overflow-wrap:anywhere; line-height:1.35; }
.rev-c em{
  font-style:normal; color:var(--muted);
  font-family:"SF Mono","Menlo",monospace; font-size:11.5px;
  font-variant-numeric:tabular-nums;
}
/* The tinted county is always the correct answer; the colour says whether the
   player got that round right. */
.rev-c.ok{ font-weight:600; }
.rev-c.ok.hit{ background:rgba(24,138,84,.12); border-color:var(--good); color:#12603b; }
.rev-c.ok.hit em{ color:#3f8a63; }
.rev-c.ok.miss{ background:rgba(200,64,47,.1); border-color:var(--bad); color:#8f2c20; }
.rev-c.ok.miss em{ color:#b06a5f; }

/* ---------- 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-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-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; }
  .cname{ font-size:28px; }
  .ccard{ min-height:180px; }
  .question{ font-size:18px; }
}
@media (max-width:359px){
  .cname{ font-size:20px; }
  .ccard{ min-height:140px; }
  .rp-rounds{ font-size:12.5px; }
  .rev-row{ font-size:13px; }
  .question{ font-size:14.5px; }
}
