:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #4f46e5;
  --correct: #16a34a;
  --incorrect: #dc2626;
  --pending: #cbd5e1;
  --border: #e5e7eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.5;
}

/* ---- Nav ---- */
.topnav {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; font-size: 20px; color: var(--accent); letter-spacing: -0.5px; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  user-select: none;
}
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--accent); color: #fff; }

/* ---- Daily habit bar: streak, daily goal, WPM trend ---- */
.habit-bar {
  width: 100%;
  max-width: 880px;
  margin: 16px 16px 0;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.hb-block { display: flex; align-items: center; gap: 10px; }
.hb-strong { font-size: 15px; font-weight: 700; line-height: 1.2; }
.hb-strong span { font-size: 12px; font-weight: 500; color: var(--muted); }
.hb-sub { font-size: 12px; color: var(--muted); }
.hb-flame { width: 24px; height: 24px; color: var(--pending); flex: none; }
.hb-streak.on .hb-flame { color: #f97316; }
.hb-ring { width: 40px; height: 40px; flex: none; }
.hb-spark { width: 132px; height: 36px; display: block; }
.hb-trend { flex-direction: column; align-items: flex-start; gap: 2px; }
.hb-dots { display: flex; gap: 4px; margin-left: 4px; }
.hb-dot {
  width: 9px; height: 9px; border-radius: 3px;
  background: var(--border); display: block;
}
.hb-dot-on { background: var(--accent); }
.hb-dot-frozen { background: #93c5fd; }
.hb-up { color: var(--correct); }
.hb-down { color: var(--incorrect); }
.hb-goal.done .hb-sub { color: var(--correct); font-weight: 600; }
.hb-freeze {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  color: var(--accent);
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  cursor: pointer;
}
.hb-freeze span { color: var(--muted); }
.hb-freeze:hover { background: #e0e7ff; }
@keyframes hbPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.hb-pop { animation: hbPop .5s ease; }

/* ---- level (XP) + achievements (second-tier retention) ---- */
.hb-level { gap: 8px; }
.hb-lv {
  font-size: 15px; font-weight: 800; line-height: 1; color: #7c3aed;
  background: #f3e8ff; border: 1px solid #e9d5ff; border-radius: 10px;
  padding: 6px 9px; white-space: nowrap;
}
.hb-lv-meta { display: flex; flex-direction: column; gap: 3px; min-width: 116px; }
.hb-xpbar { width: 100%; height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; }
.hb-xpfill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #a855f7, #7c3aed); transition: width .4s ease; }
.hb-badges { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.hb-badge {
  width: 30px; height: 30px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 16px; line-height: 1;
  background: #fff; border: 1px solid var(--border); cursor: default;
}
.hb-badge.locked { filter: grayscale(1); opacity: .4; }
.hb-badge.pop { animation: hbBadge .7s ease; box-shadow: 0 0 0 3px rgba(124,58,237,.35); }
@keyframes hbBadge {
  0% { transform: scale(1); }
  40% { transform: scale(1.35) rotate(-6deg); }
  100% { transform: scale(1); }
}
@media (max-width: 560px) {
  .hb-freeze { margin-left: 0; }
  .hb-spark { width: 110px; }
}

main {
  width: 100%;
  max-width: 880px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin: 24px 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}
.view.hidden, .hidden { display: none; }

/* ---- Controls ---- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}
.control-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.control-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.modes { display: flex; gap: 6px; flex-wrap: wrap; }
.mode-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.mode-btn:hover { border-color: var(--accent); color: var(--accent); }
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.timer { font-size: 22px; font-weight: 700; color: var(--accent); min-width: 52px; text-align: right; }

/* ---- Words / typing ---- */
/* fixed-height typing window: old lines scroll up out of view as you type,
   new lines appear from below (fastfingers.in / monkeytype behaviour) */
.words-window {
  position: relative;
  overflow: hidden;
  height: 138px;              /* 3 lines — JS overrides with the measured height */
  margin-bottom: 8px;
  border-radius: 8px;
  /* fade the top/bottom lines so it reads as a scrolling window */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 14%, #000 86%, transparent 100%);
}
.words {
  font-size: 24px;
  line-height: 1.9;
  letter-spacing: 0.5px;
  user-select: none;
  cursor: text;
  position: relative;      /* anchor for the moving caret */
  white-space: pre-wrap;   /* keep spaces so words wrap correctly */
  will-change: transform;
  transition: transform .16s cubic-bezier(.22,.61,.36,1);
}
.word { color: var(--pending); margin-right: 8px; }
.word.active { color: var(--text); }
.word.done { color: var(--muted); opacity: 0.6; }
.word .correct { color: var(--correct); }
.word .incorrect { color: var(--incorrect); text-decoration: underline; }
/* cursor highlights the character you are on — uses box-shadow so it adds NO width,
   which keeps the text from shifting while you type */
.word .cursor {
  background: #e0e7ff;
  box-shadow: inset 2px 0 0 var(--accent);
  border-radius: 2px;
}
/* characters typed past the end of the word */
.word .extra { color: var(--incorrect); opacity: 0.75; }

/* ---- per-character states (fastfingers.in scheme) ----
   pending  = not typed yet (subtle grey)
   correct  = typed correctly (dark grey)
   incorrect= typed wrong -> RED text on light-red background
   cur      = the character you are currently on           */
.ch.pending   { color: #9ca3af; }
.ch.correct   { color: #374151; }
.ch.incorrect { color: #dc2626; background: #fee2e2; border-radius: 2px; }
.ch.cur       { color: #000; background: #e0e7ff; box-shadow: inset 2px 0 0 var(--accent); border-radius: 2px; }
.ch.extra     { opacity: .8; }

/* smooth moving caret (animates left/top/width like the real site) */
.typing-caret {
  position: absolute;
  pointer-events: none;
  background: rgba(79, 70, 229, 0.15);
  border-left: 2px solid var(--accent);
  transition: left .1s ease-out, top .1s ease-out, width .1s ease-out;
}
.typing-caret.blocked {
  background: rgba(220, 38, 38, 0.25);
  border-left-color: var(--incorrect);
}
.capture-input { position: absolute; opacity: 0; pointer-events: none; left: -9999px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 4px; }

/* ---- Result ---- */
.result { text-align: center; padding: 16px 0; }
.stats { display: flex; justify-content: center; gap: 32px; flex-wrap: wrap; margin: 16px 0; }
.stat { display: flex; flex-direction: column; }
.stat .num { font-size: 40px; font-weight: 800; color: var(--accent); }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.best { color: var(--muted); font-size: 13px; margin-top: 8px; }
.restart-btn {
  margin-top: 12px; background: var(--accent); color: #fff; border: none;
  padding: 11px 26px; font-size: 15px; border-radius: 10px; cursor: pointer;
}
.restart-btn:hover { filter: brightness(1.08); }
.restart-btn.small { padding: 6px 14px; font-size: 13px; margin-top: 0; }
.lesson-actions { display: flex; gap: 12px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.lesson-actions .restart-btn { flex: 1 1 0; min-width: 140px; max-width: 220px; margin-top: 0; }
.go-actions { display: flex; gap: 12px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.go-actions .restart-btn { flex: 1 1 140px; min-width: 140px; max-width: 220px; width: 100%; margin-top: 0; }
.lb-submit .restart-btn { width: 220px; max-width: 100%; min-width: 140px; margin-top: 0; }

/* ---- Lessons / cards ---- */
.view-title { font-size: 22px; margin-bottom: 4px; }
.view-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.diff-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
/* hide the difficulty selector during active play (see showGameArea/hideGameArea) */
.diff-row.hidden { display: none; }
.diff-note { font-size: 12px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: #fff;
}
.card h3 { font-size: 17px; margin-bottom: 6px; }
.card p { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.lesson-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lesson-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.lesson-item:hover { border-color: var(--accent); }
.lesson-item.done { background: #ecfdf5; border-color: #6ee7b7; }
.lesson-item .tick { color: var(--correct); font-weight: 700; }
.lesson-back { margin-bottom: 14px; background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; }
.lesson-instruction { background: var(--bg); border-radius: 10px; padding: 14px; margin: 12px 0; font-size: 14px; }
.lesson-keys { font-weight: 700; color: var(--accent); }
.lesson-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.part-badge {
  background: #eef2ff; color: var(--accent); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; font-weight: 700;
}
.unit-block { margin-top: 20px; }
.unit-title { font-size: 15px; font-weight: 800; }
.unit-sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.progress-line { color: var(--muted); font-size: 12px; margin-top: 6px; }
.bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--correct); transition: width .3s ease; }

/* finger-placement keyboard */
.kb-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 14px 0 8px; }
.kb { display: flex; flex-direction: column; gap: 6px; align-items: center; background: var(--bg); border-radius: 12px; padding: 14px 10px; }
.kb-row { display: flex; gap: 5px; justify-content: center; width: 100%; }
.key {
  flex: 1 1 0;
  min-width: 0; height: 34px; padding: 0 4px;
  display: grid; place-items: center;
  border: 1.5px solid var(--border); border-radius: 7px;
  background: #fff; color: #cbd5e1; font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden;
}
.key.wide { flex: 5.5 1 0; max-width: 320px; }
.key.backspace { flex: 1.6 1 0; font-size: 11px; text-transform: uppercase; }
.key.tab { flex: 1.4 1 0; text-transform: uppercase; }
.key.backslash { flex: 1.3 1 0; }
.key.caps { flex: 1.6 1 0; text-transform: uppercase; }
.key.enter { flex: 1.7 1 0; text-transform: uppercase; }
.key.shift { flex: 2.0 1 0; text-transform: uppercase; }
.key.rev { border-color: var(--accent); color: var(--accent); background: #fff; }
.key.new { box-shadow: 0 3px 10px rgba(0,0,0,.16); }
.kb-space { margin-top: 2px; }
.kb-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.key.sample { flex: 0 0 auto; width: 22px; min-width: 22px; height: 22px; border-radius: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: flex; flex-direction: column; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 7px 12px; background: #fff; font-size: 12px;
}
/* ---- hands finger-placement diagram ---- */
.hands { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin-top: 14px; }
.hand { width: 158px; height: 173px; overflow: visible; }
.hf { opacity: .32; }
.hf.on { opacity: 1; animation: hfPulse 1.4s ease-in-out infinite; }
.hf.soft { opacity: .85; }
.palm { fill: #f6c9ad; stroke: #d9a184; stroke-width: 1.5; }
.hlabel { font-size: 10px; font-weight: 800; letter-spacing: 3px; fill: #94a3b8; }
@keyframes hfPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.chip b { font-size: 15px; letter-spacing: 2px; }
.chip span { color: var(--muted); }

/* ---- Games ---- */
#game-area { position: relative; }
.game-hud { display: flex; gap: 20px; align-items: center; margin-bottom: 12px; font-size: 15px; flex-wrap: wrap; }
.game-hud b { color: var(--accent); }
.falling-field {
  position: relative; height: 320px; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; background: linear-gradient(180deg,#eef2ff,#fff); margin-bottom: 12px;
}
.falling-field.shake { animation: shake .3s ease; }
@keyframes shake { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
.falling-word {
  position: absolute; font-size: 20px; font-weight: 600; padding: 4px 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; white-space: nowrap;
  color: var(--muted);
}
.falling-word.target {
  border-color: var(--accent); color: var(--accent);
  background: #eef2ff; box-shadow: 0 2px 10px rgba(79,70,229,.18);
}
.falling-word.pop { animation: pop .22s ease-out forwards; }
@keyframes pop { to { transform: scale(1.4); opacity: 0; } }
.falling-word.miss { animation: miss .25s ease-out forwards; }
@keyframes miss { to { transform: translateY(24px) scale(.9); opacity: 0; } }
.jump-track {
  position: relative; height: 74px; border: 1px solid var(--border); border-radius: 12px;
  background: repeating-linear-gradient(90deg,#eef2ff,#eef2ff 40px,#e0e7ff 40px,#e0e7ff 80px);
  margin-bottom: 12px; overflow: hidden;
}
.jump-runner { position: absolute; left: 0; bottom: 6px; font-size: 34px; transition: left .25s ease; }
.jump-runner.hop { animation: hop .3s ease-out; }
@keyframes hop { 50% { transform: translateY(-20px); } }
.jump-chaser { position: absolute; left: 0; bottom: 4px; font-size: 30px; transition: left .1s linear; }
.game-words { min-height: 70px; font-size: 28px; }
.game-words .upcoming {
  display: block; font-size: 15px; color: var(--pending); margin-top: 12px;
  line-height: 1.6; letter-spacing: .4px;
}
/* game-over overlay */
.game-over {
  position: absolute; inset: 0; z-index: 5; border-radius: 12px;
  background: rgba(255,255,255,.95);
  display: flex; align-items: center; justify-content: center;
}
.game-over-card { text-align: center; padding: 18px; }
.game-over-card h3 { font-size: 24px; margin-bottom: 4px; }
.game-over-card .stat .num { font-size: 34px; }
/* rules that set `display` MUST NOT out-rank .hidden (equal specificity, later in file
   wins), otherwise the overlay / card grid can never be hidden */
.cards.hidden, .game-over.hidden { display: none; }

/* ---- Leaderboard ---- */
.lb-tabs { display: flex; gap: 8px; margin: 16px 0 10px; }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
.lb-table th { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.lb-table tr.you td { background: #eef2ff; font-weight: 700; }
.lb-note { color: var(--muted); font-size: 12px; margin-top: 12px; }
.lb-table.hide-country th:nth-child(3), .lb-table.hide-country td:nth-child(3) { display: none; }
.lb-name { font-weight: 600; }
.lb-name .flag { margin-right: 6px; }
.lb-country-head { font-size: 14px; font-weight: 700; color: var(--accent); margin: 4px 0 8px; }
.lb-country-wrap { margin: 0 0 10px; }
.lb-filter-wrap { margin: 0 0 10px; }
.flag { font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }

/* ---- Account / auth ---- */
.account-area { display: flex; align-items: center; gap: 8px; }
.account-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s ease;
}
.account-btn:hover { border-color: var(--accent); color: var(--accent); }
.account-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.account-btn.primary:hover { filter: brightness(1.08); color: #fff; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 5px 10px; background: var(--bg); border-radius: 999px; }

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.auth-card {
  position: relative; width: 340px; max-width: 92vw; background: #fff; border-radius: 16px;
  padding: 24px; box-shadow: 0 18px 50px rgba(0,0,0,.22); z-index: 1;
}
.modal-x { position: absolute; top: 12px; right: 14px; border: none; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 9px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.auth-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.modal.hidden, .auth-form.hidden { display: none; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.auth-form input, .country-select {
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 14px; color: var(--text);
  background: #fff; font-family: inherit;
}
.auth-form input:focus, .country-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #e0e7ff; }
.auth-err { color: var(--incorrect); font-size: 12px; min-height: 14px; }

/* Google sign-in button */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px;
  background: #fff; color: #3c4043; font-size: 14px; font-weight: 600; text-decoration: none;
  cursor: pointer; transition: background .15s, box-shadow .15s;
}
.google-btn:hover { background: #f8f9fa; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.g-icon { flex: 0 0 auto; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; color: var(--muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* leaderboard submit controls */
.lb-submit { margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lb-saved { color: var(--correct); font-weight: 700; font-size: 14px; }
.guest-submit { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.gs-input { border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; font-size: 14px; font-family: inherit; }
.gs-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #e0e7ff; }
.gs-err { color: var(--incorrect); font-size: 12px; min-height: 14px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px;
  z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: opacity .25s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; }

footer { color: var(--muted); font-size: 12px; text-align: center; margin: 8px 0 28px; padding: 0 16px; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.site-stats { margin-left: 6px; color: var(--muted); }

/* ===== Cookie / consent banner ===== */
.cookie-banner {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(20px);
  width: min(720px, calc(100% - 24px)); background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 12px 32px rgba(15,23,42,.18); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; z-index: 55;
  opacity: 0; transition: opacity .3s ease, transform .3s ease;
}
.cookie-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cb-text { flex: 1 1 320px; font-size: 13px; color: var(--text); line-height: 1.45; }
.cb-text a { color: var(--accent); }
.cb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cb-btn { border: none; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-family: inherit; }
.cb-btn:hover { filter: brightness(1.06); }
.cb-btn.ghost { background: #eef2ff; color: var(--accent); }

/* ===== Delete-account modal ===== */
.delete-card { max-width: 420px; text-align: left; padding: 22px 24px; }
.delete-card h3 { margin-bottom: 10px; font-size: 18px; }
.delete-warn { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.delete-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.account-btn { border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 600;
  font-size: 13px; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-family: inherit; }
.account-btn:hover { background: var(--bg); }
.account-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.account-btn.danger { background: #fff; color: var(--incorrect); border-color: #fca5a5; }
.account-btn.danger:hover { background: #fef2f2; }
.delete-actions .account-btn.danger { flex: 1 1 auto; }
.delete-actions .account-btn:not(.danger) { flex: 1 1 auto; }

/* ===== Legal / privacy page ===== */
.legal-page { width: min(760px, calc(100% - 32px)); background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 30px; margin: 18px 0 36px; box-shadow: 0 8px 28px rgba(15,23,42,.06); }
.legal-page h1 { font-size: 26px; margin-bottom: 4px; }
.legal-updated { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.legal-page h2 { font-size: 18px; margin: 22px 0 8px; }
.legal-page p, .legal-page li { font-size: 14px; color: var(--text); }
.legal-page ul { padding-left: 20px; margin: 6px 0; }
.legal-page li { margin: 4px 0; }
.legal-page code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.legal-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.legal-table th, .legal-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.legal-table th { background: var(--bg); }
.legal-foot { margin-top: 18px; }
.legal-foot a { color: var(--accent); text-decoration: none; }

@media (max-width: 560px) {
  .words { font-size: 20px; }
  .stat .num { font-size: 32px; }
  .cookie-banner { flex-direction: column; align-items: stretch; }
  .cb-actions { justify-content: stretch; }
  .cb-btn { flex: 1 1 auto; }
}

/* ============ Typing of the Dead — Plants vs Zombies style lawn ============ */
.zombie-field {
  position: relative; width: 33%; height: 640px; overflow: hidden; border-radius: 14px; margin: 4px auto 12px;
  background: linear-gradient(180deg,#8ed36f,#5fa54d);
  box-shadow: inset 0 0 0 4px #47853a, inset 0 0 40px rgba(0,0,0,.12);
}
.z-col { position: absolute; top: 0; bottom: 0; border-left: 1px solid rgba(255,255,255,.20); }
.z-col.alt { background: rgba(255,255,255,.10); }
.z-plant {
  position: absolute; bottom: 10px; font-size: 30px; line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.28));
}
.z-plant.eaten { animation: plantEaten .42s; }
@keyframes plantEaten {
  0% { transform: scale(1); }
  35% { transform: scale(.78) rotate(-14deg); }
  100% { transform: scale(1); }
}
.zombie {
  position: absolute; left: 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  padding: 5px 6px 4px; border-radius: 12px; white-space: normal; max-width: var(--col-w, 110px);
  background: rgba(248,250,252,.97); color: #14532d;
  font-weight: 800; font-size: 15px; border: 2px solid var(--tint, #94a3b8);
  box-shadow: 0 4px 8px rgba(0,0,0,.24); transition: box-shadow .12s, border-color .12s;
  transform: translateX(-50%);
}
.z-word { letter-spacing: .2px; text-align: center; line-height: 1.1; }
/* cartoon zombie sprite (inline SVG) — body, arms and legs are animated separately */
.z-fig { position: relative; display: inline-block; width: 34px; height: 48px; flex: none; }
.z-body {
  position: absolute; inset: 0; display: block;
  animation: zbob .52s ease-in-out infinite;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.30));
}
.zsprite { width: 100%; height: 100%; display: block; overflow: visible; }
.zsprite .z-leg, .zsprite .z-arm { transform-box: fill-box; }
.zsprite .z-leg { transform-origin: 50% 0%; }
.zsprite .z-leg.l { animation: zlegA .52s ease-in-out infinite; }
.zsprite .z-leg.r { animation: zlegB .52s ease-in-out infinite; }
.zsprite .z-arm { transform-origin: 100% 50%; }
.zsprite .z-arm.a { animation: zarmA 1.04s ease-in-out infinite; }
.zsprite .z-arm.b { animation: zarmB 1.04s ease-in-out infinite; }
.zsprite .z-head { transform-box: fill-box; transform-origin: 50% 100%; animation: zhead .52s ease-in-out infinite; }
@keyframes zbob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
@keyframes zhead { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes zlegA { 0%,100% { transform: rotate(14deg); } 50% { transform: rotate(-14deg); } }
@keyframes zlegB { 0%,100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }
@keyframes zarmA { 0%,100% { transform: rotate(-7deg); } 50% { transform: rotate(5deg); } }
@keyframes zarmB { 0%,100% { transform: rotate(6deg); } 50% { transform: rotate(-6deg); } }
.z-word { letter-spacing: .2px; }
.zombie.z-hover .z-body { animation: zHover 1.7s ease-in-out infinite; }
@keyframes zHover { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.zombie.target { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.45), 0 4px 8px rgba(0,0,0,.24); }
.zombie.zpop { animation: zpop .42s ease forwards; }
.zombie.zmiss { animation: zmiss .26s ease forwards; }
/* the whole sprite topples when it goes down */
@keyframes zpop {
  0% { opacity: 1; }
  25% { opacity: 1; filter: brightness(1.7); }
  100% { transform: translateX(-50%) translateY(16px) rotate(75deg); opacity: 0; }
}
@keyframes zmiss { to { transform: translateX(calc(-50% - 26px)); opacity: 0; } }
.z-pea { position: absolute; font-size: 15px; transition: top .22s linear; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.z-float {
  position: absolute; font-size: 13px; font-weight: 900; color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.5); pointer-events: none;
  animation: zfloat .72s ease forwards;
}
@keyframes zfloat { 0% { opacity: 0; transform: translateY(8px); } 22% { opacity: 1; } 100% { opacity: 0; transform: translateY(-28px); } }
.zombie-field.hidden, .boss-field.hidden, .z-legend.hidden { display: none; }

/* "wanted poster" strip above the lawn: shows each zombie + the word it needs */
.z-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 0 0 12px; padding: 8px 10px;
  max-height: 148px; overflow-y: auto;
  background: linear-gradient(180deg,#f8fafc,#eef2f7);
  border: 1px solid var(--border); border-radius: 12px;
}
.z-legend-title {
  width: 100%; font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.z-legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 4px; border-radius: 999px;
  background: #fff; border: 2px solid var(--tint, #94a3b8);
  box-shadow: 0 1px 3px rgba(0,0,0,.10); font-size: 13px;
}
.z-legend-item.locked { opacity: .38; filter: grayscale(1); }
.z-fig.small { width: 26px; height: 38px; }
.z-legend-word { font-weight: 900; color: #14532d; }
.z-legend-pts { font-size: 11px; font-weight: 800; color: var(--muted); }
.shake { animation: shake .3s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ============ Boss Battle — polish ============ */
.boss-field { position: relative; padding: 10px 12px; background: linear-gradient(180deg,#f8fafc,#eef2ff); border: 1px solid var(--border); border-radius: 14px; }
.boss-sprite { font-size: 64px; line-height: 1; filter: drop-shadow(0 5px 8px rgba(0,0,0,.28)); animation: bossIdle 1.8s ease-in-out infinite; }
.boss-sprite.hit { animation: bossHit .26s; }
@keyframes bossIdle { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-9px) rotate(3deg); } }
@keyframes bossHit { 0% { filter: brightness(2.6) drop-shadow(0 0 12px #ef4444); transform: scale(1.12); } 100% { filter: none; transform: scale(1); } }
.boss-field.attacking { box-shadow: inset 0 0 0 3px #ef4444, 0 0 22px rgba(239,68,68,.45); }
.boss-field.attacking .boss-attack { animation: bossPulse .6s ease-in-out infinite; }
@keyframes bossPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.boss-float {
  position: absolute; right: 16px; top: 8px; font-size: 18px; font-weight: 900; color: #ef4444;
  text-shadow: 0 2px 4px rgba(0,0,0,.35); pointer-events: none; animation: bossFloat .76s ease forwards;
}
@keyframes bossFloat { 0% { opacity: 0; transform: translateY(10px) scale(.9); } 25% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-30px); } }
.boss-hp { height: 18px; }
.boss-hp-fill { background: linear-gradient(90deg,#dc2626,#f59e0b,#facc15); }

/* ============ Falling Words / Keyboard Jump — polish ============ */
.falling-field { background: linear-gradient(180deg,#f5f7ff,#e6ecff); border-radius: 14px; }
.falling-word { background: #fff; border: 2px solid #dbe3f5; border-radius: 10px; padding: 6px 11px; font-weight: 800; box-shadow: 0 4px 8px rgba(15,23,42,.14); }
.falling-word.target { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.32), 0 4px 8px rgba(15,23,42,.14); }
.jump-track { border-radius: 14px; background: linear-gradient(90deg,#fef3c7,#fde68a); }
.jump-chaser, .jump-runner { font-size: 34px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.25)); }

/* ============ Boss Battle ============ */
.boss-field { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 12px; }
.boss-enemy { display: flex; align-items: center; gap: 14px; font-size: 44px; }
.boss-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#boss-name { font-size: 14px; font-weight: 700; color: var(--text); }
.boss-hp { height: 16px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.boss-hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg,#ef4444,#f59e0b); transition: width .2s ease; }
.boss-bars { display: flex; align-items: center; gap: 10px; }
.boss-charge-label { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.boss-charge-track { flex: 1; height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.boss-charge { height: 100%; width: 0%; background: #6366f1; transition: width .1s linear; }
.boss-charge.danger { background: #ef4444; }
.boss-attack { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 10px 14px; border-radius: 10px; font-weight: 700; font-size: 15px; text-align: center; }
.boss-attack b { color: #ef4444; }
