/* Word Challenge - styles. Mobile first, high contrast, keyboard friendly. */

:root {
  --teal: #b8440a;
  --teal-dark: #983a08;
  --teal-soft: #fdeee3;
  --amber: #f2a93b;
  --amber-soft: #fff3dc;
  --ink: #17303a;
  --muted: #4d6169;
  --bg: #f5f8f7;
  --card: #ffffff;
  --line: #d3dedd;
  --good: #17693a;
  --good-soft: #e3f4ea;
  --bad: #a3271f;
  --bad-soft: #fbe9e7;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(120, 50, 10, 0.10);
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding-top: 1.25rem; padding-bottom: 2.5rem; outline: none; }

.wrap { width: 100%; max-width: 52rem; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 0 0 0.6rem; }
p { margin: 0 0 1rem; }
a { color: var(--teal); text-underline-offset: 3px; }
a:hover { color: var(--teal-dark); }

:focus-visible { outline: 3px solid #1a73e8; outline-offset: 3px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 0.5rem; top: -4rem; background: #fff; color: var(--ink);
  padding: 0.6rem 1rem; border-radius: 8px; z-index: 100; border: 2px solid var(--teal);
}
.skip-link:focus { top: 0.5rem; }

[hidden] { display: none !important; }

/* ---------- header / footer ---------- */
.site-header { background: linear-gradient(135deg, var(--banner-a), var(--banner-b)); color: #fff; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.7rem; padding-bottom: 0.7rem; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.3rem; display: inline-flex; align-items: center; gap: 0.5rem; }
.brand:hover { color: #fff; }
.brand-seal { width: 2rem; height: 2rem; display: block; border-radius: 3px; }
.brand-name { font-family: "Anton", Impact, "Arial Narrow Bold", sans-serif; font-weight: 400; font-size: 1.55rem; line-height: 1.3; letter-spacing: 0.02em; }
.brand-mark { display: inline-grid; place-items: center; width: 2rem; height: 2rem; background: var(--amber); color: var(--ink); border-radius: 8px; font-weight: 800; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.1rem; }
.main-nav a, .main-nav .link-button { color: #fff; font-size: 1rem; text-decoration: none; padding: 0.45rem 0.1rem; }
.main-nav a:hover, .main-nav .link-button:hover { text-decoration: underline; color: #fff; }
.site-header :focus-visible { outline-color: #fff; }
.inline-form { display: inline; margin: 0; }

.site-footer { border-top: 1px solid var(--line); padding: 1rem 0; color: var(--muted); font-size: 0.95rem; }
.site-footer p { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer;
  min-height: 48px; padding: 0.65rem 1.3rem; border-radius: 12px; border: 2px solid transparent; line-height: 1.3;
}
.btn-large { font-size: 1.2rem; padding: 0.8rem 1.8rem; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-secondary { background: var(--teal-soft); color: var(--teal-dark); border-color: var(--teal); }
.btn-secondary:hover { background: #f9dcc7; color: var(--teal-dark); }
.btn-outline { background: #fff; color: var(--ink); border-color: #93a6ab; font-weight: 500; }
.btn-outline:hover:not(:disabled) { border-color: var(--teal); background: var(--teal-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.link-button { background: none; border: 0; font: inherit; color: var(--teal); text-decoration: underline; cursor: pointer; padding: 0.4rem 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.25rem 0; }

/* ---------- cards / notices ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.cards.three { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 2rem; }
.cards.three .card { margin: 0; }

.notice { padding: 0.8rem 1rem; border-radius: 10px; border: 1px solid; margin: 0 0 1rem; }
.notice-success { background: var(--good-soft); border-color: #86c7a0; color: #0f4d2b; }
.notice-error { background: var(--bad-soft); border-color: #e0a19b; color: #7d1d17; }

.hero { padding: 1.5rem 0 0.5rem; }
.hero h1 { font-size: 2.2rem; }
.lead { font-size: 1.25rem; color: var(--muted); }

.welcome h1 { margin-bottom: 0.2rem; }
.points-big { font-size: 2rem; font-weight: 800; color: var(--teal-dark); margin: 0.2rem 0 1rem; }
.points-big span { color: var(--amber); }
.resume { background: var(--amber-soft); border-color: var(--amber); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin: 1rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 0.5rem; text-align: center; }
.stat-num { display: block; font-size: 1.8rem; font-weight: 800; color: var(--teal-dark); line-height: 1.1; }
.stat-label { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 0.25rem; }

.coming-soon { margin-top: 2rem; color: var(--muted); }
.coming-soon h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.05em; }
.pill-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill-list li { background: #e8eeed; border-radius: 999px; padding: 0.3rem 0.9rem; font-size: 0.95rem; }

/* ---------- forms ---------- */
.form-card { max-width: 30rem; margin: 1rem auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.form-card h1 { font-size: 1.7rem; margin-top: 0; }
label { display: block; font-weight: 600; margin: 1rem 0 0.3rem; }
input[type="text"], input[type="password"], input[type="email"] {
  width: 100%; font: inherit; padding: 0.7rem 0.8rem; border: 2px solid #93a6ab; border-radius: 10px; background: #fff; color: var(--ink); min-height: 48px;
}
input:focus { border-color: var(--teal); }
.help { font-size: 0.92rem; color: var(--muted); margin: 0.3rem 0 0; }
.form-card .btn { margin-top: 1.4rem; width: 100%; }
.form-alt { text-align: center; margin: 1.2rem 0 0; }

/* ---------- level choice ---------- */
.level-grid { display: grid; gap: 0.9rem; grid-template-columns: 1fr 1fr; margin: 1.2rem 0; }
.level-btn {
  font: inherit; cursor: pointer; text-align: center; padding: 1.1rem 0.6rem; border-radius: var(--radius); border: 2px solid var(--teal);
  background: #fff; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 0.2rem; min-height: 120px; justify-content: center;
}
.level-btn:hover:not(:disabled) { background: var(--teal-soft); }
.level-btn:disabled { opacity: 0.6; cursor: wait; }
.level-num { font-size: 2.4rem; font-weight: 800; color: var(--teal-dark); line-height: 1; }
.level-name { font-size: 1rem; color: var(--muted); }
.level-mixed { grid-column: 1 / -1; border-color: var(--amber); background: var(--amber-soft); min-height: 90px; }
.level-mixed:hover:not(:disabled) { background: #ffe9bd; }

.how-to { margin-top: 1rem; }
.how-to summary { cursor: pointer; font-weight: 600; color: var(--teal-dark); padding: 0.4rem 0; }
.how-to ul { margin: 0.4rem 0 0; padding-left: 1.3rem; }

/* ---------- game ---------- */
.game-top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-bottom: 0.6rem; }
.game-stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0.5rem; text-align: center; }
.game-stat-label { display: block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.game-stat-value { display: block; font-size: 1.9rem; font-weight: 800; color: var(--teal-dark); font-variant-numeric: tabular-nums; line-height: 1.2; }
.timer-low { color: var(--bad); }

.timer-bar { height: 8px; background: #dbe5e4; border-radius: 99px; overflow: hidden; margin-bottom: 1rem; }
.timer-fill { height: 100%; width: 100%; background: var(--teal); transition: width 0.25s linear; }

.game-card { text-align: center; padding: 1.4rem 1rem; }
.prompt { color: var(--muted); margin-bottom: 0.8rem; }
.audio-row { margin-bottom: 1rem; }

.pattern { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; min-height: 3rem; margin: 0 0 1rem; }
.tile {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.6rem; border-bottom: 4px solid var(--teal);
  background: var(--teal-soft); border-radius: 6px 6px 0 0; font-weight: 800; font-size: 1.4rem; color: var(--ink);
}
.tile-gap { margin-right: 1.1rem; }
.tile-revealed { background: var(--amber-soft); border-bottom-color: var(--amber); }

#answer-form { display: flex; flex-direction: column; gap: 0.7rem; max-width: 26rem; margin: 0 auto; }
.answer-input { text-align: center; font-size: 1.6rem !important; letter-spacing: 0.06em; }
#answer-form .btn { margin: 0; }

.message { min-height: 1.6rem; margin: 0.9rem 0 0.2rem; font-weight: 600; }
.message-error { color: var(--bad); }
.stake { color: var(--muted); font-size: 0.98rem; margin-bottom: 1rem; }

.helper-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.helper-row .btn { flex: 1 1 10rem; }

.end-row { text-align: center; margin: 0.5rem 0 0; }
.end-row .link-button { color: var(--muted); font-size: 0.95rem; }

.feedback-title { font-size: 1.6rem; font-weight: 800; margin: 0 0 0.4rem; }
.feedback-title.is-correct { color: var(--good); }
.feedback-title.is-passed { color: var(--muted); }
.feedback-word { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.04em; margin: 0 0 0.3rem; word-break: break-word; }
.feedback-def { color: var(--muted); font-size: 1.1rem; margin-bottom: 0.8rem; }
.feedback-points { font-size: 1.4rem; font-weight: 700; color: var(--teal-dark); }

/* ---------- results ---------- */
.results-head { text-align: center; margin-bottom: 0.5rem; }
.word-list { list-style: none; padding: 0; margin: 0; }
.word-list li { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.word-list li:first-child { border-top: 0; }
.word-list .word { display: block; font-size: 1.3rem; }
.word-list .def { color: var(--muted); }
.results-table { width: 100%; border-collapse: collapse; }
.results-table th, .results-table td { text-align: left; padding: 0.55rem 0.4rem; border-top: 1px solid var(--line); }
.results-table thead th { border-top: 0; color: var(--muted); font-size: 0.9rem; }
.results-table tbody th { font-weight: 600; }

/* ---------- wider screens ---------- */
@media (min-width: 40rem) {
  h1 { font-size: 2.2rem; }
  .hero h1 { font-size: 2.8rem; }
  .cards.three { grid-template-columns: repeat(3, 1fr); }
  .level-grid { grid-template-columns: repeat(4, 1fr); }
  .level-mixed { grid-column: 1 / -1; }
  .tile { width: 2.5rem; height: 3rem; font-size: 1.6rem; }
  .game-card { padding: 2rem; }
  #answer-form { flex-direction: row; }
  #answer-form .answer-input { flex: 1; }
  #answer-form .btn { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Users who ask for more contrast */
@media (prefers-contrast: more) {
  :root { --muted: #2e444c; --line: #6b8288; }
}


/* ---------- welcome banner (Alpha Speller) ---------- */
@font-face {
  font-family: "Anton";
  src: url("../fonts/anton-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
:root {
  /* Banner colours (dark orange): change these two to recolour the banner and the Join button. */
  --banner-a: #b8440a;
  --banner-b: #c24e0c;
}

.banner {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "seal title"
    "seal rule"
    "tag  tag";
  column-gap: clamp(0.9rem, 3.2vw, 2.4rem);
  align-items: center;
  padding: clamp(1.1rem, 3.5vw, 2.2rem) clamp(1.1rem, 4vw, 2.6rem);
  border-radius: 18px;
  color: #fff;
  background:
    radial-gradient(circle at 94% 8%, rgba(255, 255, 255, 0.28) 0, rgba(255, 255, 255, 0) 26%),
    radial-gradient(circle at 6% 108%, rgba(255, 255, 255, 0.18) 0, rgba(255, 255, 255, 0) 30%),
    linear-gradient(135deg, var(--banner-a), var(--banner-b));
  box-shadow: 0 4px 14px rgba(184, 68, 10, 0.3);
}
.banner-seal {
  grid-area: seal;
  width: clamp(76px, 15vw, 150px);
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.banner h1.banner-title {
  grid-area: title;
  align-self: end;
  margin: 0;
  font-family: "Anton", Impact, "Arial Narrow Bold", sans-serif;
  font-weight: 400;
  font-size: clamp(2.3rem, 9.5vw, 5rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
}
.banner-rule {
  grid-area: rule;
  align-self: start;
  width: 100%;
  height: 2px;
  margin: 0.6rem 0 0;
  border: 0;
  background: rgba(255, 255, 255, 0.9);
}
.banner-tagline {
  grid-area: tag;
  text-align: center;
  margin: clamp(0.8rem, 2.5vw, 1.4rem) 0 0;
  font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  font-size: clamp(0.75rem, 3.9vw, 2.1rem);   /* small enough that the whole line always fits on one row */
  line-height: 1.3;
  white-space: nowrap;
}

/* ---------- welcome page: no top bar, orange Join button ---------- */
body.landing main { padding-top: clamp(1rem, 3vw, 2rem); }
body.landing .btn-primary { background: var(--banner-a); color: #fff; }
body.landing .btn-primary:hover { background: #983a08; color: #fff; }


/* =====================================================================
   Game screen (letter-by-letter typing)
   ===================================================================== */
body.page-play { transition: background-color 0.9s ease; }

.game-top { grid-template-columns: repeat(4, 1fr); gap: 0.45rem; }
.game-stat { padding: 0.4rem 0.2rem; }
.game-stat-label { font-size: 0.7rem; }
.game-stat-value { font-size: 1.5rem; }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.badge { display: inline-block; padding: 0.15rem 0.8rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  background: var(--teal-soft); color: var(--teal-dark); border: 1px solid #efc7ae; }
.restart-btn { font-size: 0.9rem; color: var(--muted); text-decoration: none; padding: 0.3rem 0.5rem; border-radius: 8px; }
.restart-btn:hover { background: var(--teal-soft); color: var(--teal-dark); }

.audio-row { margin: 0.4rem 0 0.2rem; }
.audio-btn {
  width: 5.2rem; height: 5.2rem; border-radius: 50%; border: 0; cursor: pointer; color: #fff; font-size: 2.2rem; line-height: 1;
  background: linear-gradient(135deg, var(--banner-a), #e8892b);
  box-shadow: 0 4px 14px rgba(184, 68, 10, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.audio-btn:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 6px 18px rgba(184, 68, 10, 0.45); }
.audio-btn:active:not(:disabled) { transform: scale(0.97); }
.audio-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.audio-caption { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }

.pattern { gap: 0.4rem; min-height: 3.6rem; margin: 0 0 0.4rem; padding: 0.2rem 0; cursor: text; }
.tile {
  position: relative; width: 2.2rem; height: 3rem; font-size: 1.5rem; font-weight: 800; text-transform: uppercase; color: var(--ink);
  border-bottom: 4px solid var(--teal); background: var(--teal-soft); border-radius: 8px 8px 0 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tile-pending { color: var(--muted); }
.tile-ok { color: #000; border-bottom-color: #000; background: #f1f1f1; }
.tile-bad { color: #d11a1a; border-bottom-color: #d11a1a; background: var(--bad-soft); }
.tile-shake { animation: tile-shake 0.35s ease-in-out; }
@keyframes tile-shake {
  0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.tile-revealed { font-style: italic; color: #7a4a00; background: var(--amber-soft); border-bottom-color: var(--amber); }
.tile-badge::after { content: attr(data-hint); position: absolute; top: 2px; right: 4px; font-size: 0.65rem; font-style: italic; color: #7a4a00; text-decoration: none; }
.tile-active { border-bottom-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(184, 68, 10, 0.22); }
.pattern.is-focused .tile-active::before {
  content: ""; position: absolute; left: 50%; top: 18%; height: 64%; width: 2px; margin-left: -1px;
  background: var(--teal-dark); animation: caret-blink 0.9s infinite;
}
.pattern.is-focused .tile-revealed.tile-active::before { left: 14%; }
@keyframes caret-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.1; } }

/* The box that receives the keys: invisible, but it is a real input so phones show their keyboard. */
input.type-capture {
  position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important;
  margin: -1px !important; border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; outline: none !important;
  font-size: 16px; background: transparent;
}
.type-hint { color: var(--muted); font-size: 0.9rem; margin: 0.3rem 0 0; }
.type-hint-off { color: var(--teal-dark); font-weight: 700; }

.message { min-height: 1.6rem; margin: 0.6rem 0 0.1rem; }
.stake { margin-bottom: 0.3rem; }
.last-result { min-height: 1.5rem; margin: 0 0 0.8rem; font-weight: 600; color: var(--muted); }
.last-good { color: var(--good); }
.last-passed { color: var(--muted); }

.helper-row .btn { flex: 1 1 9.5rem; }

.sentences { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 0.9rem; text-align: left; }
.sentences-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font: inherit; font-weight: 600; cursor: pointer;
  padding: 0.7rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-align: left;
}
.sentences-toggle:hover { background: var(--teal-soft); }
.sentences-body { margin-top: 0.6rem; }
.sentences-body p { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.9rem; margin: 0 0 0.5rem; }

.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(30, 20, 10, 0.55); }
.modal-box { background: #fff; border-radius: 16px; padding: 1.4rem; max-width: 26rem; width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); }
.modal-box h2 { margin-top: 0; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; }

@media (min-width: 40rem) {
  .game-stat-label { font-size: 0.8rem; }
  .game-stat-value { font-size: 1.9rem; }
  .tile { width: 3rem; height: 4rem; font-size: 2rem; }
  .tile-gap { margin-right: 1.3rem; }
  .pattern { gap: 0.5rem; }
}
@media (max-width: 24rem) {
  .game-stat-value { font-size: 1.25rem; }
  .tile { width: 1.9rem; height: 2.6rem; font-size: 1.3rem; }
  .pattern { gap: 0.3rem; }
}
.site-footer .copyright { margin-top: 0.35rem; font-size: 0.85rem; }

/* ---------- end of game: "Super Charge Your Score!" ---------- */
#results-view[hidden], .drill-offer[hidden] { display: none; }
.drill-offer { text-align: center; padding: 3rem 0 2rem; animation: offer-in 0.5s ease both; }
.drill-title { font-family: "Anton", Impact, "Arial Narrow Bold", sans-serif; font-weight: 400; font-size: clamp(2.2rem, 7vw, 3.6rem); color: var(--teal-dark); margin: 0 0 0.5rem; letter-spacing: 0.02em; }
.drill-sub { font-size: clamp(1.2rem, 4vw, 1.7rem); font-weight: 700; color: var(--ink); margin: 0 0 2rem; }
.drill-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
@keyframes offer-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- flip-clock score board (points for the word being played) ---------- */
.card-top { align-items: flex-start; }
.flip {
  --s: 5rem; --flip-bg: #a63f0b;
  flex: none;
  position: relative; width: var(--s); height: var(--s); perspective: 700px;
  border-radius: 12px; box-shadow: 0 4px 10px rgba(120, 45, 5, 0.3);
  font-family: "Anton", Impact, "Arial Narrow Bold", sans-serif;
}
.flip.is-zero { --flip-bg: #7d1b10; }
.flip-half { position: absolute; left: 0; width: 100%; height: 50%; overflow: hidden; background: var(--flip-bg); color: #fff; }
.flip-top, .flip-front { top: 0; border-radius: 12px 12px 0 0; }
.flip-bottom, .flip-back { top: 50%; border-radius: 0 0 12px 12px; }
.flip-half .d { position: absolute; left: 0; width: 100%; height: var(--s); line-height: var(--s); text-align: center; font-size: calc(var(--s) * 0.82); font-weight: 400; }
.flip-top .d, .flip-front .d { top: 0; }
.flip-bottom .d, .flip-back .d { top: calc(var(--s) * -0.5); }
.flip::after {            /* the thin line across the middle of a flip clock */
  content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 1px); height: 2px; background: rgba(0, 0, 0, 0.35); z-index: 5;
}
.flip-leaf { visibility: hidden; z-index: 4; backface-visibility: hidden; }
.flip-front { transform-origin: 50% 100%; }
.flip-back { transform-origin: 50% 0; }
.flip.is-flipping .flip-leaf { visibility: visible; }
.flip.is-flipping .flip-front { animation: flip-front 0.52s ease-in both; }
.flip.is-flipping .flip-back { animation: flip-back 0.52s ease-out both; }
@keyframes flip-front {
  0% { transform: rotateX(0deg); filter: brightness(1); }
  50% { transform: rotateX(-90deg); filter: brightness(0.7); }
  50.1%, 100% { transform: rotateX(-90deg); visibility: hidden; }
}
@keyframes flip-back {
  0%, 49.9% { transform: rotateX(90deg); visibility: hidden; }
  50% { transform: rotateX(90deg); visibility: visible; filter: brightness(0.7); }
  100% { transform: rotateX(0deg); visibility: visible; filter: brightness(1); }
}
.flip.is-done { animation: flip-pop 0.6s ease-out; }
@keyframes flip-pop { 0% { transform: scale(1); } 35% { transform: scale(1.14); } 100% { transform: scale(1); } }
@media (max-width: 560px) { .flip { --s: 4rem; } }
@media (prefers-reduced-motion: reduce) {
  .flip.is-flipping .flip-front, .flip.is-flipping .flip-back, .flip.is-done { animation: none; }
}

/* ---------- flip-clock timer (top right of the game card), black ---------- */
.card-top { justify-content: space-between; }
.clock { display: flex; align-items: flex-start; gap: 0.25rem; flex: none; }
.flip.flip-clock { --s: 4.4rem; --flip-bg: #111; width: calc(var(--s) * 0.7); }
.clock-colon { font-family: "Anton", Impact, "Arial Narrow Bold", sans-serif; font-size: 2.6rem; line-height: 4.2rem; color: #111; padding: 0 0.05rem; }
.clock.clock-low .flip-clock .d { color: #ff6b5b; }
.flip-clock .d { font-size: calc(var(--s) * 0.8); }
@media (max-width: 560px) {
  .flip.flip-clock { --s: 3.4rem; }
  .clock { gap: 0.15rem; }
  .clock-colon { font-size: 2rem; line-height: 3.2rem; }
}

/* ---------- the correct word flashes twice when a word is finished ---------- */
.tile-flash { animation: tile-flash 1.2s ease-in-out both; }
@keyframes tile-flash {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.08; }
}
@media (prefers-reduced-motion: reduce) { .tile-flash { animation: none; } }

/* ---------- bigger top bar ---------- */
.header-inner { padding-top: 1.25rem; padding-bottom: 1.25rem; gap: 0.75rem 2rem; }
.brand-seal { width: 3.4rem; height: 3.4rem; border-radius: 5px; }
.brand { gap: 0.8rem; }
.brand-name { font-size: 2.4rem; line-height: 1.2; }
.main-nav { gap: 0.25rem 1.6rem; }
.main-nav a, .main-nav .link-button { font-size: 1.2rem; }
@media (max-width: 560px) {
  .header-inner { padding-top: 0.9rem; padding-bottom: 0.9rem; }
  .brand-seal { width: 2.8rem; height: 2.8rem; }
  .brand-name { font-size: 1.9rem; }
  .main-nav a, .main-nav .link-button { font-size: 1.05rem; }
}

/* ---------- end of game: Your Total Final Score ---------- */
.final-view { text-align: center; padding: 2rem 0 1rem; }
.final-title {
  font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-weight: 400;
  font-size: clamp(2.4rem, 9vw, 4.6rem); color: #a63f0b; letter-spacing: 0.02em; margin: 0 0 2rem;
}
.final-board { display: flex; justify-content: center; gap: 0.45rem; flex-wrap: wrap; }
.final-fallback { font-family: Impact, "Anton", sans-serif; font-size: 5rem; color: #a63f0b; }
.flip.flip-final { --s: 7rem; width: calc(var(--s) * 0.72); }
.flip-final .d { font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-size: calc(var(--s) * 0.82); }
.flip.flip-fast.is-flipping .flip-front { animation-duration: 0.15s; }
.flip.flip-fast.is-flipping .flip-back { animation-duration: 0.15s; }
.final-board.is-done { animation: flip-pop 0.6s ease-out; }
.final-actions { margin: 2.5rem 0 1rem; }
@media (max-width: 560px) { .flip.flip-final { --s: 4.6rem; } .final-board { gap: 0.3rem; } }

/* ---------- Alpha Drill: Ghost Type ---------- */
.drill-panel { text-align: center; padding: 2rem 0 1rem; }
.drill-panel[hidden], #view-drill[hidden] { display: none; }
.drill-heading { font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-weight: 400; font-size: clamp(2.2rem, 7vw, 3.6rem); color: #a63f0b; letter-spacing: 0.02em; margin: 0 0 1rem; }
.drill-steps { display: inline-block; text-align: left; margin: 0.5rem 0 1rem; padding-left: 1.4rem; }
.drill-steps li { margin: 0.35rem 0; }
.drill-status { text-align: center; font-weight: 700; color: var(--ink); margin: 0 0 0.75rem; }
.drill-points { font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-size: clamp(2rem, 6vw, 3rem); color: #a63f0b; margin: 0.5rem 0 1rem; }
.tile-ghost { color: #bdbdbd; background: #f6f6f6; border-bottom-color: #d6d6d6; }

/* ---------- Alpha Drill: Word Harvest ---------- */
.page-harvest .wrap { max-width: 62rem; }
.hv-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.hv-board, .hv-clock { display: flex; gap: 0.25rem; flex: none; }
.hv-board .flip { --s: 4.4rem; width: calc(var(--s) * 0.7); }
.hv-board .flip .d { font-size: calc(var(--s) * 0.8); }
.hv-center { flex: 1; text-align: center; min-width: 0; }
.hv-wordrow { display: flex; align-items: center; justify-content: center; gap: 0.75rem; flex-wrap: wrap; }
.hv-word { margin: 0; font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-weight: 400; color: #a63f0b; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.1; overflow-wrap: anywhere; }
.hv-audio { width: 3.2rem; height: 3.2rem; font-size: 1.4rem; }
.hv-chances { list-style: none; display: flex; justify-content: center; gap: 0.6rem; margin: 0.6rem 0 0; padding: 0; }
.hv-chance { width: 2.3rem; height: 2.3rem; border-radius: 50%; background: #1f5fbf; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; transition: opacity 0.3s, background 0.3s; }
.hv-chance.is-used { background: #b9c4d3; color: #b9c4d3; opacity: 0.7; }
.hv-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hv-col { min-width: 0; }
.hv-label { margin: 0 0 0.5rem; font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 1rem; line-height: 1.3; }
.hv-label-syn { color: #a63f0b; }
.hv-label-ant { color: #14316b; }
.hv-bank { border: 3px solid #17303a; border-radius: 18px; padding: 0.4rem 0.6rem 0.6rem; min-height: 6.2rem; background: #fff; margin-bottom: 0.8rem; }
.hv-bank-label { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hv-bank-words { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; margin-top: 0.25rem; }
.hv-bank-word { font-weight: 700; font-size: 1.05rem; }
.hv-col-syn .hv-bank-word { color: #a63f0b; }
.hv-col-ant .hv-bank-word { color: #14316b; }
.hv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem; padding: 0.35rem; border-radius: 14px; }
.hv-grid-syn { background: #a63f0b; }
.hv-grid-ant { background: #14316b; }
.hv-tile { min-height: 3.4rem; border: 0; border-radius: 8px; padding: 0.2rem; font: inherit; font-size: clamp(0.62rem, 1.9vw, 0.95rem); font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; cursor: pointer; background: rgba(255,255,255,0.12); color: #fff; }
.hv-tile:disabled { cursor: default; }
/* no hover effect on the tiles: only a click is a selection, so hovering must not look like one */
.hv-grid-syn .hv-tile.is-preview { background: #fff; color: #a63f0b; }
.hv-grid-ant .hv-tile.is-preview { background: #fff; color: #14316b; }
.hv-grid-syn .hv-tile.is-found, .hv-grid-syn .hv-tile.is-found:disabled { background: #fff; color: #a63f0b; }
.hv-grid-ant .hv-tile.is-found, .hv-grid-ant .hv-tile.is-found:disabled { background: #fff; color: #14316b; }
.hv-tile.is-found { box-shadow: inset 0 0 0 3px currentColor; }
.hv-tile.is-missed { background: #ffe39a !important; color: #17303a !important; }
.hv-tile.is-shake { animation: hv-shake 0.4s; }
.hv-flash { animation: hv-flash 1s steps(1, end); }
.hv-cta { text-align: center; margin: 1rem 0 0; min-height: 3.4rem; }
.hv-cta-text { display: inline-block; background: #1f5fbf; color: #fff; font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-size: 1.6rem; padding: 0.4rem 1.6rem; border-radius: 12px; }
.hv-cta-flash { animation: hv-cta 1.8s steps(1, end); }
@keyframes hv-flash { 0%, 33%, 66% { opacity: 1; } 16%, 50%, 83% { opacity: 0.1; } 100% { opacity: 1; } }
@keyframes hv-cta { 0%, 33.3%, 66.6% { opacity: 1; } 16.6%, 50%, 83.3% { opacity: 0.1; } 100% { opacity: 1; } }
@keyframes hv-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@media (max-width: 40rem) {
  .hv-board .flip, .hv-clock .flip.flip-clock { --s: 3rem; }
  .hv-columns { gap: 0.5rem; }
  .hv-label { font-size: 0.8rem; }
  .hv-tile { min-height: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) { .hv-flash, .hv-cta-flash, .hv-tile.is-shake { animation: none; } }

/* Friend and Foe - chances row with the GO button */
.hv-chancerow { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 0.6rem; flex-wrap: wrap; }
.hv-chancerow .hv-chances { margin: 0; }
.hv-go { border: 0; border-radius: 12px; padding: 0.35rem 1.5rem; font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-size: 1.6rem; letter-spacing: 0.05em; line-height: 1.2; color: #fff; background: #17693a; cursor: pointer; box-shadow: 0 4px 10px rgba(23, 105, 58, 0.35); }
.hv-go:disabled { background: #9db3a6; box-shadow: none; cursor: default; }
.hv-go.is-ready { animation: hv-go-pulse 1.1s ease-in-out infinite; }
.hv-go:not(:disabled):hover { background: #12532e; }
@keyframes hv-go-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(23, 105, 58, 0.55); } 50% { box-shadow: 0 0 0 10px rgba(23, 105, 58, 0); } }
.hv-cta-text { font-size: 1.25rem; max-width: 100%; }
@media (prefers-reduced-motion: reduce) { .hv-go.is-ready { animation: none; } }

/* One look for the title of every game: dark orange */
.game-title, .drill-heading, .drill-title, .final-title, .results-head h1 {
  font-family: Impact, "Anton", "Arial Narrow Bold", sans-serif; font-weight: 400; color: #a63f0b; letter-spacing: 0.02em;
}
.game-title { font-size: clamp(2.2rem, 7vw, 3.6rem); margin: 0 0 0.75rem; line-height: 1.1; }
.results-head h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1.1; }
.results-head .actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }
.hv-choice { text-align: center; }
.hv-choice-text { font-size: 1.4rem; margin: 1rem 0 1.5rem; }
.hv-choice .actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Alpha Drill: Word String ---------- */
.ws-title { margin: 0; font-size: clamp(2rem, 6vw, 3rem); line-height: 1.1; }
.ws-progress { margin: 0.25rem 0 0; color: var(--muted); font-weight: 700; }
.ws-box { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; flex: none; }
.ws-cap { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.ws-panel { border: 3px solid #17303a; border-radius: 18px; background: #fff; padding: 0.7rem 1rem 1rem; margin-bottom: 1rem; }
.ws-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ws-instruction { margin: 0; font-weight: 700; font-size: 1.15rem; color: #17303a; }
.ws-label { margin: 0.5rem 0 0.35rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.ws-bank { display: flex; flex-wrap: wrap; gap: 0.5rem 0.6rem; min-height: 4.4rem; }
.ws-word { background: #eef3fb; border: 2px solid #1f5fbf; color: #14316b; font-weight: 700; font-size: 1.1rem; line-height: 1.3; border-radius: 10px; padding: 0.15rem 0.7rem; animation: ws-pop 0.35s both; }
@keyframes ws-pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.ws-typing { position: relative; border: 2px solid #b6c1cc; border-radius: 12px; background: #fff; min-height: 10.5rem; }
.ws-typing.is-wrong { border-color: #c0392b; animation: hv-shake 0.4s; }
.ws-typing.is-right { border-color: #17693a; box-shadow: 0 0 0 3px rgba(23, 105, 58, 0.25); }
.ws-ghost, .ws-input { box-sizing: border-box; width: 100%; margin: 0; padding: 0.8rem 4.2rem 0.8rem 1rem; font: 400 1.3rem/1.7 Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; word-spacing: 0; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.ws-ghost { position: absolute; inset: 0; color: #bdbdbd; pointer-events: none; overflow: hidden; }
.ws-g { visibility: hidden; }
.ws-g.on { visibility: visible; }
.ws-input { position: relative; display: block; min-height: 10.5rem; background: transparent; border: 0; outline: 0; resize: none; color: #17303a; border-radius: 12px; }
.ws-caret { position: absolute; left: 1rem; top: 1rem; width: 2px; height: 1.5rem; background: #17303a; animation: ws-blink 1s steps(1) infinite; display: none; pointer-events: none; }
.ws-typing.is-idle .ws-caret, .ws-typing.is-empty:not(:focus-within) .ws-caret { display: block; }
@keyframes ws-blink { 50% { opacity: 0; } }
.ws-check { position: absolute; right: 0.6rem; bottom: 0.6rem; width: 3rem; height: 3rem; border-radius: 50%; border: 0; background: #17693a; color: #fff; font-size: 1.7rem; line-height: 1; cursor: pointer; box-shadow: 0 3px 8px rgba(23, 105, 58, 0.35); }
.ws-check:disabled { background: #9db3a6; box-shadow: none; cursor: default; }
.ws-check:not(:disabled):hover { background: #12532e; }
@media (max-width: 40rem) {
  .ws-ghost, .ws-input { font-size: 1.1rem; }
  .ws-word { font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) { .ws-word, .ws-caret, .ws-typing.is-wrong { animation: none; } }

/* Alpha Drill hub */
.hub-list { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; margin: 1.5rem 0; }
.hub-list .btn { min-width: min(18rem, 100%); text-align: center; }

/* background music button */
.music-toggle { position: fixed; left: 0.8rem; bottom: 0.8rem; z-index: 50; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 2px solid #17303a; background: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); opacity: 0.85; }
.music-toggle:hover { opacity: 1; }

/* ---------- Bilingual information panels (English / Chinese tabs) ---------- */
.lang-panel { margin: 1rem 0; text-align: left; }
.lang-tabs { display: flex; gap: 0.3rem; margin: 0 0 -2px 0.9rem; position: relative; z-index: 1; }
.lang-tab { font: 600 0.95rem/1 Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; padding: 0.55rem 1.2rem; border: 2px solid #17303a; border-bottom: 0; border-radius: 10px 10px 0 0; background: #e6ebee; color: #4d6169; cursor: pointer; }
.lang-tab[aria-selected="true"] { background: #fff; color: #17303a; padding-bottom: calc(0.55rem + 2px); }
.lang-tab:not([aria-selected="true"]):hover { background: #f1f4f6; }
.lang-body { border: 2px solid #17303a; border-radius: 0 14px 14px 14px; background: #fff; padding: 1rem 1.3rem 1.1rem; }
.lang-body[hidden] { display: none; }
.lang-en { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 300; }
.lang-zh { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 300; }
.lang-body strong { font-weight: 600; }
.lang-body > :first-child { margin-top: 0; }
.lang-body > :last-child { margin-bottom: 0; }
.lang-body .lead { margin-top: 0; }
.lang-body .drill-steps, .lang-body ul { margin: 0.6rem 0; padding-left: 1.3rem; }
.lang-body h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }

/* ---------- speaker.png as the audio icon ---------- */
.speaker-img { display: block; width: 56%; height: auto; margin: 0 auto; pointer-events: none; }
.music-toggle img { display: block; width: 1.5rem; height: 1.5rem; margin: auto; pointer-events: none; }
.music-toggle.is-off img { opacity: 0.35; }
.music-toggle.is-off::after { content: ""; position: absolute; left: 20%; right: 20%; top: 50%; height: 2px; background: #a63f0b; transform: rotate(-45deg); pointer-events: none; }

/* ---------- Ghost Type: the two definition panels ---------- */
.def-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; text-align: left; }
.def-panel { background: #fff; border: 2px solid #17303a; border-radius: 14px; padding: 0.7rem 1rem 0.9rem; }
.def-label { margin: 0 0 0.35rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.def-text { margin: 0; font-size: 1.15rem; line-height: 1.5; color: #17303a; }
.def-en .def-text { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 300; }
.def-zh .def-text { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 300; font-size: 1.25rem; }
@media (max-width: 640px) { .def-panels { grid-template-columns: 1fr; } }

/* Word String level 2: the paragraph has a title */
.ws-title { margin: 0 0 0.3rem; font: 700 1.25rem/1.4 Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; text-align: center; color: #17303a; }

/* ---------- Alpha Drill Typing Areas: handwriting (now Helvetica) ---------- */
#ws-typing .ws-sentence, #ws-typing .ws-ghost, #ws-typing .ws-input,
#ws-typing .ws-blank { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 400; }
#ws-typing .ws-sentence, #ws-typing .ws-ghost, #ws-typing .ws-input { font-size: 1.6rem; }
#ws-typing .ws-blank { font-size: 1.45rem; }
#ws-typing .ws-title { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 400; font-size: 1.9rem; }
@media (max-width: 560px) { #ws-typing .ws-sentence, #ws-typing .ws-ghost, #ws-typing .ws-input { font-size: 1.3rem; } #ws-typing .ws-blank { font-size: 1.15rem; } }

/* ---------- speaker.png is a finished orange round icon: it fills the button itself ---------- */
.audio-btn { background: none; padding: 0; overflow: hidden; }
.audio-btn .speaker-img { width: 100%; height: 100%; margin: 0; object-fit: contain; }
.music-toggle { background: none; border: 0; padding: 0; box-shadow: none; overflow: visible; }
.music-toggle img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); }
.music-toggle.is-off img { opacity: 0.4; filter: grayscale(1); }
.music-toggle.is-off::after { left: 14%; right: 14%; height: 3px; background: #17303a; }
/* the icon file has a black square behind the orange circle: crop it away so only the round icon shows */
.audio-btn, .music-toggle { overflow: hidden; border-radius: 50%; }
.audio-btn .speaker-img, .music-toggle img { object-fit: contain; transform: none; }
.music-toggle img { filter: none; }
.music-toggle.is-off img { filter: grayscale(1); }

/* ---------- welcome page: three cheerful pastel panels ---------- */
.cards.three .card-listen  { background: #dff1fd; border-color: #a9d8f3; }
.cards.three .card-spell   { background: #fff3c4; border-color: #f2d97a; }
.cards.three .card-improve { background: #dcf6e4; border-color: #9fdcb4; }
.cards.three .card h2 { position: relative; padding-bottom: 0.45rem; }
.cards.three .card h2::after { content: ""; position: absolute; left: 0; bottom: 0; width: 2.6rem; height: 4px; border-radius: 3px; }
.cards.three .card-listen h2::after  { background: #3aa0dc; }
.cards.three .card-spell h2::after   { background: #eab61c; }
.cards.three .card-improve h2::after { background: #35b062; }

/* ---------- welcome page: English / 中文 tabs inside each pastel panel ---------- */
.cards.three .card-lang { margin: 0; }
.cards.three .card-lang .lang-tabs { margin: 0 0 0.8rem; gap: 0.35rem; z-index: auto; }
.cards.three .card-lang .lang-tab {
  font: 600 0.85rem/1 Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 0.4rem 0.95rem; border: 1.5px solid rgba(23, 48, 58, 0.35); border-radius: 999px;
  background: rgba(255, 255, 255, 0.55); color: #4d6169;
}
.cards.three .card-lang .lang-tab[aria-selected="true"] { background: #fff; color: #17303a; border-color: #17303a; padding-bottom: 0.4rem; }
.cards.three .card-lang .lang-tab:not([aria-selected="true"]):hover { background: rgba(255, 255, 255, 0.85); }
.cards.three .card-lang .lang-body { border: 0; border-radius: 0; background: none; padding: 0; }
.cards.three .card-lang .lang-en { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 400; }
.cards.three .card-lang .lang-zh { font-weight: 400; line-height: 1.7; }
.cards.three .card-lang .lang-body[hidden] { display: none; }

/* ---------- open-eye icon in front of "Example sentences" ---------- */
.sent-label { display: inline-flex; align-items: center; gap: 0.55rem; }
.eye-icon { flex: none; display: block; width: 1.5rem; height: 1.5rem; color: #17303a; }

/* ---------- Word String: GO flashes once the Word Bank is on screen; no cursor while the grey words play ---------- */
.hv-go.is-flashing { animation: ws-go-flash 0.9s ease-in-out infinite; }
@keyframes ws-go-flash { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(23, 105, 58, 0.6); } 50% { opacity: 0.25; box-shadow: 0 0 0 10px rgba(23, 105, 58, 0); } }
@media (prefers-reduced-motion: reduce) { .hv-go.is-flashing { animation: none; } }
.ws-typing.no-caret .ws-caret { display: none !important; }

/* ---------- information panels: two colours - orange for the "how does it work" panels, light green for the definitions ---------- */
.lang-body { background: #ffd9a8; }
.lang-tab[aria-selected="true"] { background: #ffd9a8; }
.lang-tab:not([aria-selected="true"]):hover { background: #ffecd2; }
.def-panel.def-en, .def-panel.def-zh { background: #d6f5d9; }
.lang-body .lead { color: #17303a; }

/* ---------- information panels, part 2: Word String (Word Bank orange, Typing Area light green), Friend and Foe word bank, sentences ---------- */
.ws-panel { background: #ffd9a8; }
.ws-panel + .ws-panel { background: #d6f5d9; }
.ws-label, .ws-cap { color: #17303a; }
.hv-bank { background: #ffd9a8; }
.sentences-body p { background: #d6f5d9; }

/* ---------- information panels: classic tab-panel design (tabs on top-left, grey tabs, orange highlight on the chosen one); every panel has its own colour ---------- */
.lang-panel { --tone: #ffd9a8; --tone-line: #e9a85a; margin: 1rem 0; }
.lang-panel.tone-peach  { --tone: #ffd9a8; --tone-line: #e9a85a; }
.lang-panel.tone-mint   { --tone: #d6f5d9; --tone-line: #7cc98a; }
.lang-panel.tone-sky    { --tone: #d4e9fb; --tone-line: #7fb6e6; }
.lang-panel.tone-lilac  { --tone: #e6dcf8; --tone-line: #aa92de; }
.lang-panel.tone-butter { --tone: #fff1b3; --tone-line: #e2c24a; }
.lang-panel.tone-rose   { --tone: #fcd9e6; --tone-line: #e68fb1; }
.lang-tabs { gap: 3px; margin: 0 0 -1px 0.8rem; }
.lang-tab {
  font: 500 1rem/1 Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 0.5rem 0.85rem; color: #555; border: 1px solid #b9b5af; border-bottom: 0; border-radius: 7px 7px 0 0;
  background: linear-gradient(#f2f0ed, #dedad5);
}
.lang-tab:not([aria-selected="true"]):hover { background: linear-gradient(#fbfaf8, #e8e5e0); }
.lang-tab[aria-selected="true"] {
  background: var(--tone); color: #17303a; padding-bottom: calc(0.5rem + 1px);
  box-shadow: inset 0 0 0 2px var(--tone-line); border-color: var(--tone-line);
}
.lang-body { background: var(--tone); border: 1px solid #b9b5af; border-radius: 7px; padding: 1.1rem 1.4rem 1.2rem; }
.lang-body .lead { color: #17303a; }
/* definitions (Ghost Type): one tabbed panel */
.def-panels { display: block; max-width: 44rem; margin: 1rem auto 0; }
.def-panels .lang-panel { margin: 0; }
.def-en, .def-zh { background: none; }
/* welcome page: the three cards become plain frames around the coloured tab panels */
.cards.three .card-listen, .cards.three .card-spell, .cards.three .card-improve { background: #fff; border-color: #e1ddd6; }
.cards.three .card-lang .lang-tabs { margin: 0 0 -1px 0.8rem; gap: 3px; }
.cards.three .card-lang .lang-tab {
  font: 500 0.95rem/1 Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 0.5rem 0.8rem; color: #555; border: 1px solid #b9b5af; border-bottom: 0; border-radius: 7px 7px 0 0;
  background: linear-gradient(#f2f0ed, #dedad5);
}
.cards.three .card-lang .lang-tab[aria-selected="true"] { background: var(--tone); color: #17303a; border-color: var(--tone-line); padding-bottom: calc(0.5rem + 1px); }
.cards.three .card-lang .lang-tab:not([aria-selected="true"]):hover { background: linear-gradient(#fbfaf8, #e8e5e0); }
.cards.three .card-lang .lang-body { border: 1px solid #b9b5af; border-radius: 7px; background: var(--tone); padding: 0.9rem 1.1rem 1rem; }
/* in-play panels, each its own colour */
.ws-panel { background: #ffd9a8; border-width: 1px; border-color: #b9b5af; border-radius: 7px; }
.ws-panel + .ws-panel { background: #d6f5d9; }
.hv-bank { background: #d4e9fb; border-width: 1px; border-color: #b9b5af; border-radius: 7px; }

/* ---------- one colour per language: English = orange, 中文 = light green (tabs and panel body, on every panel) ---------- */
.lang-panel .lang-tab[data-lang="en"] { background: #ffe6c7; border-color: #e9a85a; }
.lang-panel .lang-tab[data-lang="zh"] { background: #e6f8e8; border-color: #7cc98a; }
.lang-panel .lang-tab[data-lang="en"]:not([aria-selected="true"]):hover { background: #fff0dc; }
.lang-panel .lang-tab[data-lang="zh"]:not([aria-selected="true"]):hover { background: #f1fbf2; }
.lang-panel .lang-tab[data-lang="en"][aria-selected="true"] { background: #ffd9a8; box-shadow: inset 0 0 0 2px #e9a85a; }
.lang-panel .lang-tab[data-lang="zh"][aria-selected="true"] { background: #d6f5d9; box-shadow: inset 0 0 0 2px #7cc98a; }
.lang-panel .lang-body.lang-en, .cards.three .card-lang .lang-body.lang-en { background: #ffd9a8; border-color: #e9a85a; }
.lang-panel .lang-body.lang-zh, .cards.three .card-lang .lang-body.lang-zh { background: #d6f5d9; border-color: #7cc98a; }
.cards.three .card-lang .lang-tab[data-lang="en"] { background: #ffe6c7; border-color: #e9a85a; }
.cards.three .card-lang .lang-tab[data-lang="zh"] { background: #e6f8e8; border-color: #7cc98a; }
.cards.three .card-lang .lang-tab[data-lang="en"][aria-selected="true"] { background: #ffd9a8; }
.cards.three .card-lang .lang-tab[data-lang="zh"][aria-selected="true"] { background: #d6f5d9; }

/* ---------- music: speaker button + volume bar ---------- */
.music-control { position: fixed; left: 0.8rem; bottom: 0.8rem; z-index: 50; display: flex; align-items: center; gap: 0.6rem; }
.music-control .music-toggle { position: relative; left: auto; bottom: auto; flex: none; }
.music-volume { -webkit-appearance: none; appearance: none; width: 7rem; height: 0.5rem; border-radius: 999px; background: #ffd9a8; border: 1px solid #c98a3c; outline-offset: 4px; cursor: pointer; margin: 0; }
.music-volume::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #b8440a; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.music-volume::-moz-range-thumb { width: 0.9rem; height: 0.9rem; border-radius: 50%; background: #b8440a; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.music-volume::-moz-range-track { background: transparent; }

/* ---------- Alpha Drill Typing Areas: Helvetica, 20% smaller ---------- */
#ws-typing, #ws-typing * { font-family: Helvetica, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif !important; font-weight: 400; }
#ws-typing .ws-sentence, #ws-typing .ws-ghost, #ws-typing .ws-input { font-size: 1.28rem; }
#ws-typing .ws-blank { font-size: 1.16rem; }
#ws-typing .ws-title { font-size: 1.52rem; }
@media (max-width: 560px) { #ws-typing .ws-sentence, #ws-typing .ws-ghost, #ws-typing .ws-input { font-size: 1.04rem; } #ws-typing .ws-blank { font-size: 0.92rem; } }

/* ---------- Word String level 1: the Typing Area is as tall as its text (JS sets min-height from the sentence) ---------- */
.ws-typing:not(.ws-l2) { min-height: 5rem; }
.ws-typing:not(.ws-l2) .ws-input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
.ws-typing:not(.ws-l2) .ws-caret { top: 0.9rem; height: 1.2rem; }
.ws-typing:not(.ws-l2) .ws-check { width: 2.6rem; height: 2.6rem; font-size: 1.5rem; }

/* ---------- mobile friendly ---------- */
html { -webkit-text-size-adjust: 100%; }
img, svg, video { max-width: 100%; }
.btn, .lang-tab, .hv-go, .ws-check, .audio-btn { touch-action: manipulation; }
@media (max-width: 700px) {
  /* Friend and Foe: synonyms on top, antonyms below */
  .hv-columns { grid-template-columns: 1fr; gap: 1rem; }
  .hv-label { font-size: 0.95rem; }
  .hv-tile { min-height: 3rem; font-size: clamp(0.7rem, 3.4vw, 0.95rem); }
  .hv-bank { min-height: 4.2rem; }
  .hv-chancerow { gap: 0.6rem; }
  .ws-head { gap: 0.6rem; }
  .ws-instruction { font-size: 1rem; }
  .ws-panel { padding: 0.6rem 0.7rem 0.8rem; }
  .ws-word { font-size: 1rem; }
  .drill-panel { padding: 1rem 0 0.5rem; }
  .drill-steps { padding-left: 1.1rem; }
  .lang-body { padding: 0.8rem 0.9rem 0.9rem; }
  .lang-tab { padding: 0.55rem 0.8rem; }
  .btn-large { width: 100%; max-width: 22rem; }
  .actions, .drill-buttons, .final-actions { flex-direction: column; align-items: center; }
  .cards.three { grid-template-columns: 1fr; }
  .music-control { left: 0.5rem; bottom: 0.5rem; }
  .music-volume { width: 5.5rem; }
  main { padding-bottom: 4.5rem; }
}
@media (max-width: 400px) {
  .container, main { padding-left: 0.75rem; padding-right: 0.75rem; }
  .site-header .nav, .site-header nav { flex-wrap: wrap; }
}
.ws-bank { align-content: flex-start; }

/* ---------- Ghost Type: same fonts and letter boxes as the spelling game (no special font) ---------- */


.flip.two-digit:not(.flip-clock) .d { font-size: calc(var(--s) * 0.58); letter-spacing: -0.04em; }

/* ---------- Alpha Drill: Fit Fix (word partners) ---------- */
.ff-modes { border: 2px solid var(--line); border-radius: var(--radius); background: #fff; margin: 1.2rem auto; padding: 0.8rem 1rem 1rem; max-width: 40rem; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem; }
.ff-modes legend { font-weight: 700; padding: 0 0.5rem; color: var(--ink); }
.ff-mode { display: flex; align-items: center; gap: 0.6rem; min-height: 3.2rem; padding: 0.4rem 0.9rem; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; text-align: left; }
.ff-mode input { width: 1.3rem; height: 1.3rem; accent-color: var(--teal); flex: none; }
.ff-mode span { display: flex; flex-direction: column; line-height: 1.25; }
.ff-mode small { color: var(--muted); font-size: 0.95rem; }
.ff-mode:hover { border-color: var(--amber); }
.ff-mode:focus-within { outline: 3px solid var(--teal-dark); outline-offset: 2px; }
.ff-best { font-weight: 700; color: var(--teal-dark); }
kbd { font: inherit; font-weight: 700; padding: 0 0.4rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #fff; }

.ff { max-width: 46rem; margin: 0 auto; padding: 0.5rem 0 2rem; }
.ff[hidden] { display: none; }
.ff-top { display: grid; grid-template-columns: 6rem 1fr 6rem; gap: 0.6rem; align-items: start; margin-bottom: 0.8rem; }
.ff-stat { background: #fff; border: 2px solid var(--line); border-radius: 12px; text-align: center; padding: 0.3rem 0.2rem 0.4rem; }
.ff-stat-label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ff-stat-num { display: block; font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--teal-dark); font-variant-numeric: tabular-nums; }
.ff-center { text-align: center; }
.ff-title { margin: 0; font-size: clamp(1.8rem, 6vw, 2.6rem); }
.ff-progress { margin: 0.1rem 0 0.3rem; font-weight: 700; color: var(--ink); }
.ff-dots { list-style: none; display: flex; justify-content: center; gap: 0.35rem; margin: 0; padding: 0; flex-wrap: wrap; }
.ff-dot { width: 0.85rem; height: 0.85rem; border-radius: 50%; border: 2px solid #8a9a9f; background: #fff; }
.ff-dot.is-good { background: var(--good); border-color: var(--good); }
.ff-dot.is-ok { background: var(--amber); border-color: #b9770e; }
.ff-dot.is-miss { background: var(--bad); border-color: var(--bad); }
.ff-dot.is-now { box-shadow: 0 0 0 3px rgba(184, 68, 10, 0.35); border-color: var(--teal-dark); }

.ff-card { background: #fff; border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 1.1rem clamp(0.9rem, 3vw, 1.6rem) 1.3rem; }
.ff-kind { display: flex; justify-content: space-between; align-items: center; margin: 0 0 0.4rem; }
.ff-chip { display: inline-block; padding: 0.15rem 0.9rem; border-radius: 999px; font-weight: 800; letter-spacing: 0.03em; background: var(--teal-dark); color: #fff; }
.ff-card.ff-k-snap .ff-chip { background: #1f5f6b; }
.ff-card.ff-k-fix .ff-chip { background: #8a2b1f; }
.ff-sound { min-width: 2.75rem; min-height: 2.75rem; font-size: 1.4rem; border: 2px solid var(--line); border-radius: 50%; background: #fff; cursor: pointer; }
.ff-sound[aria-pressed="false"] { opacity: 0.7; }
.ff-task { font-size: 1.2rem; margin: 0.2rem 0 0.8rem; color: var(--ink); }
.ff-task:focus { outline: none; }
.ff-task:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 3px; }

.ff-sentence { font-size: clamp(1.4rem, 4.6vw, 1.9rem); line-height: 2.1; text-align: center; margin: 0.4rem 0 1.1rem; font-weight: 600; }
.ff-slot { display: inline-block; min-height: 1.5em; vertical-align: middle; min-width: 4.6rem; padding: 0 0.6rem; margin: 0 0.15rem; border-radius: 10px; border: 3px dashed #c98a3c; background: var(--amber-soft); line-height: 1.5; vertical-align: baseline; }
.ff-q { color: #8a5a10; font-weight: 800; }
.ff-slot.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.ff-wrongword { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 3px; font-weight: 800; }
.ff-slot.is-snapped { border: 3px solid var(--good); background: var(--good-soft); animation: ff-snap 0.5s ease-out; }
.ff-slot.is-shown { border: 3px solid #1f5f6b; background: #e3f0f2; }
.ff-fitword { color: #0f4d2a; font-weight: 800; }
.ff-slot.is-shown .ff-fitword { color: #123f49; }

.ff-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; margin: 0.4rem 0 0.9rem; }
.ff-options[hidden], .ff-snap[hidden], .ff-sentence[hidden] { display: none; }
.ff-piece { position: relative; display: flex; align-items: center; gap: 0.7rem; min-height: 3.6rem; padding: 0.6rem 2rem 0.6rem 0.8rem; border: 2px solid rgba(23, 48, 58, 0.45); border-radius: 14px; font: inherit; font-size: 1.35rem; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.ff-piece::after { content: ""; position: absolute; right: -0.65rem; top: 50%; width: 1.1rem; height: 1.1rem; margin-top: -0.55rem; border-radius: 50%; background: inherit; border: 2px solid rgba(23, 48, 58, 0.45); border-left: none; clip-path: inset(-2px -2px -2px 50%); }
.ff-p0 { background: #ffe1c2; } .ff-p1 { background: #d6f0f3; } .ff-p2 { background: #e5def7; } .ff-p3 { background: #dff3d2; }
.ff-piece:hover:not([aria-disabled="true"]) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(120, 50, 10, 0.2); }
.ff-piece:focus-visible, .ff-tile:focus-visible, .ff-mode input:focus-visible, .ff-sound:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 3px; }
.ff-key { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; flex: none; border-radius: 6px; background: #fff; border: 2px solid rgba(23, 48, 58, 0.55); font-size: 0.95rem; font-weight: 800; }
.ff-mark { position: absolute; right: 0.55rem; font-size: 1.5rem; font-weight: 800; }
.ff-piece.is-wrong { background: var(--bad-soft); border-color: var(--bad); color: #6b1a14; text-decoration: line-through; opacity: 0.85; cursor: default; }
.ff-piece.is-wrong .ff-mark { color: var(--bad); text-decoration: none; }
.ff-piece.is-right, .ff-piece.is-reveal { background: var(--good-soft); border-color: var(--good); color: #0f4d2a; }
.ff-piece.is-right .ff-mark, .ff-piece.is-reveal .ff-mark { color: var(--good); }
.ff-piece.is-locked:not(.is-right):not(.is-reveal):not(.is-wrong) { opacity: 0.55; cursor: default; }
.ff-piece[aria-disabled="true"] { cursor: default; }

.ff-snap { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; margin: 0.4rem 0 0.8rem; }
.ff-col { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.ff-tile { position: relative; width: 100%; display: flex; align-items: center; gap: 0.6rem; min-height: 3.4rem; padding: 0.5rem 0.7rem; border: 2px solid rgba(23, 48, 58, 0.45); border-radius: 14px; font: inherit; font-size: 1.2rem; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left; background: #fff0dc; transition: transform 0.12s ease; }
.ff-tr { background: #dcf1f4; }
.ff-tl::after, .ff-tr::before { content: ""; position: absolute; top: 50%; width: 1rem; height: 1rem; margin-top: -0.5rem; border-radius: 50%; background: inherit; border: 2px solid rgba(23, 48, 58, 0.45); }
.ff-tl::after { right: -0.6rem; clip-path: inset(-2px -2px -2px 50%); border-left: none; }
.ff-tr::before { left: -0.6rem; clip-path: inset(-2px 50% -2px -2px); border-right: none; }
.ff-tile.is-picked { border-color: var(--teal-dark); box-shadow: 0 0 0 4px rgba(184, 68, 10, 0.3); transform: translateY(-2px); }
.ff-tile.is-picked .ff-word { text-decoration: underline; text-underline-offset: 4px; }
.ff-tile.is-matched { background: var(--good-soft); border-color: var(--good); color: #0f4d2a; cursor: default; animation: ff-snap 0.5s ease-out; }
.ff-tile.is-nope { background: var(--bad-soft); border-color: var(--bad); }
.ff-tile.is-shake { animation: ff-shake 0.4s ease-in-out; }
.ff-tick { margin-left: auto; font-size: 1.3rem; font-weight: 800; color: var(--good); }
.ff-snapped { list-style: none; margin: 0.3rem 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.ff-pair { padding: 0.35rem 0.7rem; border-radius: 10px; background: var(--good-soft); color: #0f4d2a; font-size: 1.05rem; animation: ff-snap 0.5s ease-out; }
.ff-snapped:empty { display: none; }

.ff-feedback { border-radius: 14px; padding: 0.8rem 1rem; margin: 0.8rem 0 0.4rem; border-left: 8px solid var(--line); background: #f3f5f5; color: var(--ink); }
.ff-feedback[hidden] { display: none; }
.ff-feedback.is-good { background: var(--good-soft); border-color: var(--good); }
.ff-feedback.is-ok { background: var(--amber-soft); border-color: #b9770e; }
.ff-feedback.is-bad { background: var(--bad-soft); border-color: var(--bad); }
.ff-fb-title { font-weight: 800; font-size: 1.2rem; margin: 0 0 0.2rem; }
.ff-fb-phrase { font-size: 1.15rem; margin: 0.1rem 0; }
.ff-fb-tip { margin: 0.2rem 0 0; font-size: 1rem; }
.ff-fb-tip:empty, .ff-fb-phrase:empty { display: none; }
.ff-actions { text-align: center; margin: 0.8rem 0 0; }

.ff-done { max-width: 40rem; margin: 0 auto; }
.ff-stars { font-size: clamp(3rem, 14vw, 5rem); line-height: 1; margin: 0.2rem 0; letter-spacing: 0.1em; color: #b9770e; }
.ff-s3 { animation: ff-pop 0.8s ease-out; }
.ff-final-label { font-weight: 700; color: var(--muted); margin-right: 0.4rem; }
.ff-fix-h { margin: 1rem 0 0.2rem; font-size: 1.4rem; color: var(--teal-dark); }
.ff-fix-lead { margin: 0 0 0.5rem; color: var(--muted); }
.ff-fixlist { list-style: none; margin: 0 auto 1rem; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 0.45rem; }
.ff-fixitem { background: #fff; border: 2px solid var(--line); border-left: 8px solid var(--amber); border-radius: 10px; padding: 0.45rem 0.8rem; font-size: 1.1rem; }
.ff-fixnot { color: var(--muted); font-size: 0.95rem; }

@keyframes ff-snap { 0% { transform: scale(0.8); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes ff-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes ff-pop { 0% { transform: scale(0.5); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }

@media (max-width: 560px) {
  .ff-top { grid-template-columns: 4.6rem 1fr 4.6rem; gap: 0.4rem; }
  .ff-stat-num { font-size: 1.5rem; }
  .ff-options { gap: 0.9rem 0.9rem; }
  .ff-piece { font-size: 1.15rem; padding-right: 1.6rem; }
  .ff-tile { font-size: 1.02rem; padding: 0.45rem 0.5rem; }
  .ff-key { width: 1.5rem; height: 1.5rem; }
  .ff-snap { gap: 0.9rem; }
}
@media (max-width: 360px) { .ff-options { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  .ff-slot.is-snapped, .ff-tile.is-matched, .ff-pair, .ff-s3, .ff-tile.is-shake { animation: none; }
  .ff-piece, .ff-tile { transition: none; }
}
.ff-done h1:focus { outline: none; }
#ff-app .actions { text-align: center; }
@media (max-width: 420px) { .ff-dots { gap: 0.22rem; } .ff-dot { width: 0.7rem; height: 0.7rem; } }

/* ---------- Alpha Drill menu: the table of components ---------- */
.hub-table { width: 100%; max-width: 46rem; margin: 1.2rem auto; border-collapse: separate; border-spacing: 0; background: #fff; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; text-align: left; }
.hub-table th, .hub-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.hub-table thead th { background: var(--teal-dark); color: #fff; font-size: 0.95rem; letter-spacing: 0.03em; text-transform: uppercase; }
.hub-table tbody tr:last-child th, .hub-table tbody tr:last-child td { border-bottom: none; }
.hub-table tbody tr:nth-child(even) { background: var(--teal-soft); }
.hub-table tbody th { font-weight: 400; white-space: nowrap; }
.hub-table .btn { min-width: 10.5rem; text-align: center; }
.hub-table .btn-disabled { display: inline-block; padding: 0.6rem 1.2rem; border-radius: 10px; background: #e4e7e7; color: #4d6169; font-weight: 700; cursor: not-allowed; }
.hub-table td:last-child { font-weight: 700; color: var(--teal-dark); }
@media (max-width: 640px) {
  .hub-table thead { position: absolute; left: -9999px; }
  .hub-table, .hub-table tbody, .hub-table tr, .hub-table th, .hub-table td { display: block; width: 100%; }
  .hub-table tbody tr { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
  .hub-table th, .hub-table td { border-bottom: none; padding: 0.3rem 1rem; }
  .hub-table .btn { width: 100%; }
}

/* ================= Alpha Rank ================= */
.rank-page { max-width: 54rem; margin: 0 auto; }
.rank-page .game-title { text-align: center; }
.rank-lead { text-align: center; margin-top: 0; }

.rank-you { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem 1.3rem; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 1.1rem clamp(0.9rem, 3vw, 1.6rem); margin: 1rem 0 1.4rem; }
.rank-you-badge { width: 4.6rem; height: 4.6rem; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 30% 25%, #ffd98a, var(--amber) 55%, #c9811a); border: 3px solid #fff; box-shadow: 0 0 0 3px var(--teal-dark), var(--shadow); }
.rank-level { font-size: 2rem; font-weight: 900; color: #5a2503; line-height: 1; }
.rank-you-title { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.rank-tier-name { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.7rem; border-radius: 999px; background: var(--teal-dark); color: #fff; font-size: 1rem; vertical-align: middle; }
.rank-you-pts { margin: 0.25rem 0 0.45rem; font-weight: 700; color: var(--teal-dark); }
.rank-bar { display: block; width: 100%; height: 0.9rem; border: 0; border-radius: 999px; overflow: hidden; background: #efe3d8; -webkit-appearance: none; appearance: none; }
.rank-bar::-webkit-progress-bar { background: #efe3d8; border-radius: 999px; }
.rank-bar::-webkit-progress-value { background: linear-gradient(90deg, var(--amber), var(--teal)); border-radius: 999px; }
.rank-bar::-moz-progress-bar { background: linear-gradient(90deg, var(--amber), var(--teal)); border-radius: 999px; }
.rank-you-next { margin: 0.4rem 0 0; font-size: 0.95rem; color: var(--muted); }
.rank-you-place { text-align: center; min-width: 9rem; padding-left: 1.2rem; border-left: 2px dashed var(--line); }
.rank-place-num { margin: 0; font-size: 2.6rem; font-weight: 900; line-height: 1; color: var(--teal-dark); }
.rank-place-none { color: var(--muted); }
.rank-place-of { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--muted); }
.rank-place-gap { margin: 0.4rem 0 0; font-size: 0.95rem; }

.rank-tabs { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.4rem 0 0; }
.rank-tab { display: inline-block; min-height: 2.75rem; padding: 0.55rem 1.3rem; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); font-weight: 700; text-decoration: none; }
.rank-tab:hover { border-color: var(--teal); }
.rank-tab.is-on { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.rank-caption { text-align: center; color: var(--muted); margin: 0.6rem 0 1.2rem; }
.rank-reset { white-space: nowrap; }

.rank-empty { text-align: center; background: #fff; border: 2px dashed var(--line); border-radius: 16px; padding: 1.6rem 1rem; margin-bottom: 1.4rem; }
.rank-empty-big { font-size: 1.3rem; font-weight: 800; margin: 0 0 0.3rem; }

/* podium: 2nd | 1st | 3rd, the winner standing tallest */
.rank-podium { list-style: none; padding: 0; margin: 0 0 1.2rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; align-items: end; }
.rank-pod { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.9rem 0.5rem; border-radius: 16px 16px 8px 8px; text-align: center; border: 2px solid rgba(0, 0, 0, 0.12); box-shadow: var(--shadow); color: #2a1604; min-width: 0; }
.rank-pod[data-place="1"] { order: 2; padding-top: 1.6rem; padding-bottom: 1.6rem; }
.rank-pod[data-place="2"] { order: 1; }
.rank-pod[data-place="3"] { order: 3; }
.rank-pod-gold { background: linear-gradient(180deg, #ffe49a, #f6c64f); }
.rank-pod-silver { background: linear-gradient(180deg, #f1f3f5, #cfd6db); }
.rank-pod-bronze { background: linear-gradient(180deg, #f6d3b3, #dba06b); }
.rank-pod.is-you { outline: 3px solid var(--teal-dark); outline-offset: 2px; }
.rank-pod-place { font-weight: 900; font-size: 1.5rem; line-height: 1; }
.rank-pod-name { font-weight: 800; font-size: 1.1rem; max-width: 100%; overflow-wrap: anywhere; }
.rank-pod-tier { font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; opacity: 0.85; }
.rank-pod-pts { font-weight: 900; font-size: 1.5rem; }
.rank-pod-pts small { font-size: 0.8rem; font-weight: 700; }
.rank-you-tag { display: inline-block; padding: 0 0.5rem; margin-left: 0.25rem; border-radius: 999px; background: var(--teal-dark); color: #fff; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; }

.rank-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; text-align: left; margin-bottom: 1.4rem; }
.rank-table th, .rank-table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rank-table thead th { background: var(--teal-dark); color: #fff; font-size: 0.9rem; letter-spacing: 0.03em; text-transform: uppercase; }
.rank-table tbody th { font-weight: 800; color: var(--teal-dark); white-space: nowrap; }
.rank-table tbody tr:last-child th, .rank-table tbody tr:last-child td { border-bottom: none; }
.rank-table tbody tr:nth-child(even) { background: var(--teal-soft); }
.rank-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-table .rank-name { font-weight: 700; overflow-wrap: anywhere; }
.rank-table tr.is-you { background: var(--amber-soft); box-shadow: inset 4px 0 0 var(--teal-dark); }
.rank-table tr.rank-gap td { text-align: center; color: var(--muted); letter-spacing: 0.4em; padding: 0.2rem; background: #fff; }

.rank-ladder { margin: 1.6rem 0; }
.rank-ladder h2 { text-align: center; margin: 0 0 0.8rem; }
.rank-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.6rem; }
.rank-step { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "lvl name" "lvl pts"; gap: 0 0.6rem; align-items: center; padding: 0.55rem 0.7rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.rank-step-lvl { grid-area: lvl; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: #e8eeed; font-weight: 800; }
.rank-step-name { grid-area: name; font-weight: 800; }
.rank-step-zh { display: block; white-space: nowrap; font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.rank-step-pts { grid-area: pts; font-size: 0.85rem; color: var(--muted); }
.rank-step.is-done { background: var(--good-soft); border-color: #a9d8bb; }
.rank-step.is-done .rank-step-lvl { background: var(--good); color: #fff; }
.rank-step.is-now { background: var(--amber-soft); border-color: var(--teal-dark); box-shadow: 0 0 0 2px var(--teal-dark); }
.rank-step.is-now .rank-step-lvl { background: var(--teal-dark); color: #fff; }

@media (max-width: 640px) {
  .rank-you { grid-template-columns: auto 1fr; }
  .rank-you-place { grid-column: 1 / -1; border-left: 0; border-top: 2px dashed var(--line); padding: 0.8rem 0 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0.2rem 0.8rem; }
  .rank-place-num { font-size: 2.2rem; }
  .rank-podium { gap: 0.4rem; }
  .rank-pod { padding: 0.7rem 0.3rem; }
  .rank-pod-name { font-size: 0.95rem; }
  .rank-pod-pts { font-size: 1.15rem; }
  .rank-table thead { position: absolute; left: -9999px; }
  .rank-table, .rank-table tbody, .rank-table tr, .rank-table th, .rank-table td { display: block; }
  .rank-table tr { padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); }
  .rank-table tbody tr:last-child { border-bottom: none; }
  .rank-table th, .rank-table td { border: 0 !important; padding: 0.15rem 0; }
  .rank-table td::before, .rank-table tbody th::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 400; font-size: 0.85rem; }
  .rank-table .num { text-align: left; }
  .rank-table tr.rank-gap { padding: 0; }
  .rank-table tr.rank-gap td::before { content: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .rank-tab { transition: background 0.15s, border-color 0.15s; }
}

/* the bot trap on the registration form: out of sight for people, still a normal box for programs */
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ================= accounts with e-mail ================= */
.form-wide { max-width: 38rem; }
.notice-info { background: #e8f1fb; border-color: #9cc0e6; color: #12395f; }
select { width: 100%; font: inherit; padding: 0.7rem 0.8rem; min-height: 48px; border: 2px solid #93a6ab; border-radius: 10px; background: #fff; color: var(--ink); }
select:focus { border-color: var(--teal); }
.reg-steps { margin: 0.3rem 0 0.6rem; padding-left: 1.3rem; }
.reg-steps li { margin: 0.25rem 0; }
.reg-birth { border: 0; padding: 0; margin: 0.8rem 0 0.4rem; }
.reg-birth legend { font-weight: 700; padding: 0; }
.reg-birth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.reg-birth-row label { font-weight: 400; font-size: 0.9rem; }
.consent-line { display: flex; gap: 0.6rem; align-items: flex-start; margin: 1.2rem 0 0; }
.consent-line input[type="checkbox"] { width: 1.4rem; height: 1.4rem; margin-top: 0.15rem; flex: 0 0 auto; accent-color: var(--teal-dark); }
.consent-line label.inline { display: inline; font-weight: 400; margin: 0; }
.legal-links { margin: 0.3rem 0 0; font-size: 0.9rem; }
.legal-links a { color: inherit; }
.legal-page { max-width: 46rem; margin: 1rem auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem clamp(1rem, 3vw, 2rem); box-shadow: var(--shadow); }
.legal-page h1 { margin-top: 0; }
.legal-page h2 { margin: 1.6rem 0 0.4rem; font-size: 1.2rem; }
.legal-page .legal-updated { color: var(--muted); font-size: 0.9rem; }
.mail-box { background: var(--teal-soft); border: 2px dashed var(--teal); border-radius: 12px; padding: 0.8rem 1rem; text-align: center; font-weight: 700; word-break: break-all; }
.consent-card ul { padding-left: 1.2rem; }
.consent-card .actions { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.consent-card .actions .btn { margin-top: 0.5rem; width: auto; }
.btn-danger-link { background: none; border: 0; color: var(--bad); text-decoration: underline; cursor: pointer; font-size: 1rem; padding: 0.5rem; }

/* ---- Players ("Who's playing?") and membership ---- */
.player-cards { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.player-card { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.35rem; box-shadow: var(--shadow); }
.player-card.is-current { border-color: var(--teal); background: var(--teal-soft); }
.player-name { font-size: 1.3rem; font-weight: 800; word-break: break-word; }
.player-meta { color: var(--muted); font-size: 0.95rem; }
.player-now { font-weight: 700; color: var(--teal-dark); }
.player-card form { margin-top: 0.3rem; }
.player-card .btn { width: 100%; }
.remove-form { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.6rem; }
.member-line { margin: 0.8rem 0; }

/* Body text is Helvetica; titles, scores and timers keep Impact/Anton */
button, input, select, textarea, optgroup { font-family: inherit; }
kbd, code, pre, samp { font-family: inherit; }

/* ===================== Alpha Duel ===================== */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
.duel-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.duel-table th, .duel-table td { padding: 0.55rem 0.7rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.duel-table th { font-size: 0.85rem; color: var(--muted); background: var(--teal-soft); }
.duel-table .num { text-align: right; }
.duel-table tr.is-me { background: var(--amber-soft); }
.duel-cell { width: 1%; }
.duel-btn { padding: 0.35rem 1.1rem; font-weight: 700; }
.duel-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.duel-you { color: var(--muted); font-weight: 700; }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.25rem; }
.dot-on { background: #2e9e57; box-shadow: 0 0 0 3px rgba(46, 158, 87, 0.2); }
.dot-off { background: #c6ccce; }

/* challenge pop-up, waiting notice, notes */
.duel-invite { position: fixed; z-index: 300; left: 50%; top: 18%; transform: translateX(-50%); width: min(92vw, 27rem); background: #fff; border: 3px solid var(--teal); border-radius: 16px; padding: 1.2rem 1.4rem; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4); }
.duel-invite h2 { margin: 0 0 0.5rem; color: var(--teal); }
.duel-invite-text { font-size: 1.15rem; margin: 0.3rem 0; }
.duel-invite-note { font-size: 0.92rem; color: var(--muted); margin: 0.3rem 0; }
.duel-invite-secs { font-weight: 700; margin: 0.4rem 0 0.8rem; }
.duel-wait, .duel-note { position: fixed; z-index: 250; left: 50%; bottom: 1.2rem; transform: translateX(-50%); max-width: 92vw; background: #fff; border: 2px solid var(--teal); border-radius: 12px; padding: 0.7rem 1rem; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3); display: flex; gap: 0.8rem; align-items: center; }

/* the small window while a duel is on (lower left) */
.duel-mini { position: fixed; z-index: 240; left: 0.8rem; bottom: 0.8rem; width: 15rem; background: rgba(255, 255, 255, 0.96); border: 2px solid var(--teal); border-radius: 12px; padding: 0.6rem 0.8rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); font-size: 0.95rem; }
.duel-mini-title { font-weight: 700; color: var(--teal); margin-bottom: 0.2rem; }
.duel-mini-scores { display: flex; justify-content: space-between; gap: 0.5rem; }
.duel-mini-scores b { font-size: 1.15rem; }
.duel-mini-bar { height: 0.55rem; margin: 0.45rem 0 0.2rem; background: var(--line); border-radius: 6px; overflow: hidden; }
.duel-mini-bar span { display: block; height: 100%; width: 0; background: var(--teal); }
.duel-mini-time { font-size: 0.85rem; color: var(--muted); }
.duel-mini-link { display: block; margin-top: 0.3rem; font-size: 0.85rem; }

/* the duel page: countdown and result */
.duel-page { text-align: center; }
.duel-stage { padding: 1rem 0 2rem; }
.duel-vs { font-size: 1.6rem; font-weight: 700; }
.duel-vs em { color: var(--teal); font-style: normal; margin: 0 0.5rem; }
.duel-big-text { font-size: 1.5rem; margin: 1rem 0 0; }
.duel-count { font-size: 7rem; font-weight: 800; color: var(--teal); line-height: 1.1; min-height: 8rem; }
.duel-headline { font-size: clamp(2rem, 6vw, 3rem); margin: 0.5rem 0 1rem; color: var(--teal); }
.duel-cards { display: flex; gap: 1rem; justify-content: center; align-items: stretch; flex-wrap: wrap; }
.duel-card { position: relative; flex: 1 1 14rem; max-width: 20rem; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 1.4rem 1rem 1rem; box-shadow: var(--shadow); }
.duel-card.is-winner { border-color: var(--amber); background: var(--amber-soft); }
.duel-card h2 { margin: 0 0 0.3rem; font-size: 1.3rem; overflow-wrap: anywhere; }
.duel-crown { position: absolute; top: -0.8rem; left: 50%; transform: translateX(-50%); background: var(--amber); color: #3b2300; font-weight: 800; font-size: 0.8rem; letter-spacing: 0.1em; padding: 0.15rem 0.8rem; border-radius: 999px; }
.duel-score { font-size: 4rem; font-weight: 800; color: var(--teal); line-height: 1.1; }
.duel-score-label { color: var(--muted); margin-bottom: 0.6rem; }
.duel-line { display: flex; justify-content: space-between; margin: 0.2rem 0; }
.duel-line.bonus b { color: var(--good); }
.duel-versus { align-self: center; font-size: 1.4rem; font-weight: 800; color: var(--muted); }
.duel-sub { color: var(--muted); margin: 1rem 0 0.3rem; }
.duel-thanks { font-size: 1.4rem; font-weight: 700; color: var(--teal); margin: 1rem 0; }
@media (max-width: 40rem) { .duel-mini { width: 11.5rem; font-size: 0.85rem; } .duel-count { font-size: 5rem; } }
