:root {
  --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --ok: #16a34a; --bad: #dc2626; --bg: #ffffff; --soft: #f8fafc;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
header.site, footer.site {
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between;
  padding: .9rem 1.25rem; border-bottom: 1px solid var(--line);
}
footer.site { border-top: 1px solid var(--line); border-bottom: 0; margin-top: 3rem; color: var(--muted); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
nav a, footer a { color: var(--accent); text-decoration: none; margin-right: .75rem; }
nav a:hover, footer a:hover { text-decoration: underline; }
main { max-width: 880px; margin: 0 auto; padding: 1.5rem 1.25rem; }
h1 { font-size: 1.9rem; line-height: 1.25; margin: .5rem 0 .75rem; }
h2 { font-size: 1.3rem; margin-top: 2.2rem; }
h3 { font-size: 1.08rem; margin-bottom: .4rem; }
.lede { font-size: 1.08rem; color: #374151; }
.fineprint { color: var(--muted); font-size: .88rem; }
code { background: var(--soft); padding: .1rem .35rem; border-radius: 4px; font-size: .92em; }
.badge {
  display: inline-block; background: var(--soft); border: 1px solid var(--line); border-radius: 999px;
  padding: .15rem .7rem; font-size: .86rem; color: #374151; margin: 0 .3rem .3rem 0;
}
.checks li { margin: .5rem 0; }
.steps { padding-left: 1.2rem; }
.steps li { margin: .5rem 0; }

/* game cards on the hub */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.gcard { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; background: var(--bg); }
.gcard p { margin: .3rem 0 0; color: #374151; font-size: .95rem; }
.gcard .who { color: var(--muted); font-size: .88rem; }
.gcard a { text-decoration: none; color: var(--accent); font-weight: 600; }

/* shared game shell */
.game {
  border: 2px solid var(--accent); border-radius: 14px; background: var(--soft);
  padding: 1.2rem 1.2rem 1.4rem; margin: 1.4rem 0;
}
.game-top { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; justify-content: space-between; }
.game-stat { font-weight: 600; }
.bar { height: 6px; background: var(--line); border-radius: 999px; margin: .7rem 0 1rem; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: .55rem 1.1rem; font-size: 1rem; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.big { font-size: 1.6rem; padding: .55rem 1.6rem; }
.btn.small { padding: .3rem .65rem; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: default; }
.controls { display: flex; flex-wrap: wrap; gap: .6rem 1.1rem; align-items: center; margin: .6rem 0 1rem; font-size: .95rem; }
.controls label { display: inline-flex; gap: .35rem; align-items: center; }
.fb { margin: .9rem 0 .3rem; padding: .65rem .9rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.fb[hidden] { display: none; }
.result-score { font-size: 1.6rem; font-weight: 700; margin: .4rem 0; }

/* listen & choose */
.speakline { display: flex; align-items: center; gap: 1rem; margin: .6rem 0 1rem; }
#lq-word { font-size: 2.6rem; line-height: 1; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.opt {
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: .8rem .6rem;
  font-size: 1.05rem; cursor: pointer; text-align: center; min-height: 64px;
}
.opt:hover { border-color: var(--accent); }
.opt .opt-han { display: block; font-size: 1.6rem; font-weight: 600; }
.opt .opt-en { display: block; color: var(--muted); font-size: .86rem; margin-top: .25rem; }
.opt.right { border-color: var(--ok); background: #f0fdf4; }
.opt.wrong { border-color: var(--bad); background: #fef2f2; }

/* matching game */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.card {
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: .7rem .5rem;
  min-height: 92px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; justify-content: center; gap: .25rem;
}
.card:hover { border-color: var(--accent); }
.card.sel { border-color: var(--accent); background: #eef2ff; box-shadow: 0 0 0 2px var(--accent) inset; }
.card.matched { border-color: var(--ok); background: #f0fdf4; cursor: default; opacity: .85; }
.card.wrong { border-color: var(--bad); background: #fef2f2; animation: shake .4s; }
.card .card-han { font-size: 2.1rem; font-weight: 600; line-height: 1.1; }
.card .card-pin { font-size: 1.15rem; font-weight: 600; }
.card .card-en { font-size: .92rem; color: #374151; }
.card .card-sub { display: block; font-size: .75rem; color: var(--muted); border-top: 1px dashed var(--line); margin-top: .3rem; padding-top: .25rem; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); }
}

/* word list table */
table.wordlist { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .95rem; }
table.wordlist th, table.wordlist td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; }
table.wordlist th { background: var(--soft); }
table.wordlist td:first-child { font-size: 1.15rem; white-space: nowrap; }
table.wordlist td:nth-child(2) { white-space: nowrap; color: #374151; }

@media (max-width: 560px) {
  h1 { font-size: 1.5rem; }
  .mgrid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); }
  .opts { grid-template-columns: repeat(2, 1fr); }
  .card .card-han { font-size: 1.7rem; }
}
