:root {
  --bg: #0f1226;
  --bg-2: #161a36;
  --card: #1d2247;
  --card-2: #252a5a;
  --text: #f2f3ff;
  --muted: #9aa0c7;
  --accent: #ffcb3a;
  --accent-2: #ff7a59;
  --good: #4ade80;
  --bad: #ef4444;
  --warn: #f59e0b;
  --primary: #7c5cff;
  --primary-2: #5e3eff;
  --border: #2b315e;

  /* finger colors */
  --f-lp: #ff6b6b;     /* left pinky */
  --f-lr: #ffa94d;     /* left ring */
  --f-lm: #ffd43b;     /* left middle */
  --f-li: #51cf66;     /* left index */
  --f-ri: #4dabf7;     /* right index */
  --f-rm: #b197fc;     /* right middle */
  --f-rr: #f783ac;     /* right ring */
  --f-rp: #cbd5e1;     /* right pinky */
  --f-thumb: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 20% 0%, #1f2756 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

button { font-family: inherit; }

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(6px);
}
.brand { display: flex; gap: 6px; align-items: center; font-weight: 700; font-size: 20px; }
.brand-link {
  display: flex; gap: 12px; align-items: center;
  background: transparent; border: 0; padding: 4px 8px;
  color: inherit; font: inherit; cursor: pointer;
  border-radius: 10px;
  transition: background .15s ease;
}
.brand-link:hover { background: rgba(124,92,255,0.12); }
.brand-link:active { transform: translateY(1px); }
.brand .logo { font-size: 26px; filter: drop-shadow(0 2px 6px rgba(124,92,255,.6)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.brand-title { font-weight: 700; font-size: 20px; }
.brand-domain { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.3px; }
.brand-link:hover .brand-domain { color: var(--accent); }
.help-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  margin-left: 4px;
}
.help-btn:hover { background: var(--card-2); }
.profile { display: flex; gap: 14px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.profile .label { color: var(--muted); }
.profile .username { font-weight: 700; color: var(--accent); }
.rank-pill, .pts-pill {
  background: var(--card);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 14px;
  color: inherit;
  font-family: inherit;
}
.rank-pill.clickable { cursor: pointer; }
.rank-pill.clickable:hover { background: var(--card-2); border-color: var(--primary); }
.pts-pill b { color: var(--accent); }
.rank-pill b { color: var(--good); }

.settings {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  flex-wrap: wrap;
}
.settings .seg { display: flex; align-items: center; gap: 8px; }
.settings .seg.right { margin-left: auto; }
.settings label { color: var(--muted); font-size: 13px; }

.btn-group { display: inline-flex; background: var(--card); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.btn-group button {
  background: transparent; color: var(--text); border: 0;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.btn-group button.active { background: var(--primary); color: white; }

.btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: var(--card-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: transparent; color: white; }
.btn.primary:hover { background: var(--primary-2); }
.btn.warn { background: #43243a; border-color: #6b2e51; color: #ffb4d3; }
.btn.warn:hover { background: #58294a; }
.btn.ghost { background: transparent; }

main { padding: 12px 24px 80px; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  margin-top: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

h2 { margin: 0 0 6px; }

/* Modal/dialog title — visually equivalent to an h2, but a <p> so search
   engines see a clean H1 → H2 → H3 hierarchy in the SEO content below
   (modals are interactive UI, not document structure). */
.modal-title {
  display: block;
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 6px;
}
.modal-card.big .modal-title { text-align: center; margin-top: 0; }
.intro-card .modal-title { margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }

/* LEVEL GRID */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.level-tile {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
}
.level-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.35); border-color: var(--primary); }
.level-tile.locked { opacity: 0.45; cursor: not-allowed; }
.level-tile.locked:hover { transform: none; box-shadow: none; border-color: var(--border); }
.level-tile .lvl-num { color: var(--muted); font-size: 12px; }
.level-tile .lvl-name { font-weight: 700; margin: 4px 0; }
.level-tile .lvl-keys {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 2px;
}
.level-tile .stars { margin-top: 8px; font-size: 14px; letter-spacing: 2px; color: var(--accent); }
.level-tile .stars .off { color: #3a3f6e; }
.level-tile.completed::after {
  content: "✓";
  position: absolute;
  top: 8px; right: 10px;
  color: var(--good);
  font-weight: 800;
}

.rank-bar { margin-top: 18px; }
.rank-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.rank-label b { color: var(--accent); }
.rank-track {
  height: 12px; background: var(--card-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border);
}
.rank-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .4s ease;
}
.rank-numbers { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: right; }

/* LEVEL VIEW */
.level-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.level-title { flex: 1; }
.lt-main { font-weight: 800; font-size: 20px; }
.lt-keys {
  font-family: ui-monospace, monospace;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 3px;
  margin-top: 2px;
}
.stars-best { color: var(--accent); letter-spacing: 2px; }
.stars-best .off { color: #3a3f6e; }

.phase-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.phase-tab {
  background: var(--card-2);
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
}
.phase-tab.active { opacity: 1; border-color: var(--primary); color: var(--accent); }
.phase-tab.done::after { content: " ✓"; color: var(--good); }

.phase-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.phase-hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.typing-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  min-height: 110px;
}
.typing-text {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 22px;
  line-height: 1.7;
  letter-spacing: 1px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.typing-text .char { padding: 2px 1px; border-radius: 3px; }
.typing-text .char.done { color: var(--good); }
.typing-text .char.err { color: var(--bad); background: rgba(239,68,68,0.18); }
.typing-text .char.cur { background: var(--accent); color: #1a1320; animation: blink 1s infinite; }
.typing-text .char.space {
  display: inline-block;
  min-width: 0.6em;
  border-bottom: 2px dotted rgba(255,255,255,0.22);
  margin: 0 1px;
}
.typing-text .char.space.done { border-bottom-color: var(--good); }
.typing-text .char.space.err { background: rgba(239,68,68,0.35); border-bottom-color: var(--bad); }
.typing-text .char.space.cur { background: var(--accent); border-bottom-color: var(--accent); }

@keyframes blink { 50% { opacity: 0.5; } }

.metrics {
  margin-top: 12px;
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  flex-wrap: wrap;
}
.metrics b { color: var(--text); }

/* GAME AREA */
.game-area { text-align: center; padding: 16px 0; }
.game-stats { display: flex; gap: 18px; justify-content: center; color: var(--muted); margin-bottom: 16px; flex-wrap: wrap; }
.game-stats b { color: var(--text); }
.big-letter {
  font-family: ui-monospace, monospace;
  font-size: 110px;
  font-weight: 800;
  height: 180px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--card-2), var(--bg-2));
  border-radius: 18px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  user-select: none;
  transition: transform .08s ease;
}
.big-letter.hit { animation: pop .25s ease; color: var(--good); }
.big-letter.miss { animation: shake .25s ease; color: var(--bad); }
@keyframes pop { 0% { transform: scale(.95);} 50% { transform: scale(1.08);} 100% { transform: scale(1);} }
@keyframes shake { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-8px);} 75%{transform:translateX(8px);} }

/* KEYBOARD */
.kb-wrap { margin-top: 18px; }
.kb {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
}
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, monospace;
  font-weight: 700;
  font-size: 14px;
  position: relative;
  color: var(--text);
}
.key.wide { width: 70px; font-size: 11px; color: var(--muted); }
.key.xwide { width: 92px; font-size: 11px; color: var(--muted); }
.key.space { width: 280px; font-size: 11px; color: var(--muted); }
.key.target { background: var(--accent); color: #1a1320; box-shadow: 0 0 0 3px rgba(255,203,58,0.35); }
.key.pressed { transform: translateY(2px); border-bottom-width: 1px; }
.key.wrong { background: var(--bad); color: white; }
.key .nub {
  position: absolute;
  bottom: 6px;
  width: 14px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  opacity: 0.8;
}

/* finger colors as background tint stripe at top */
.key::before {
  content: "";
  position: absolute;
  top: 3px; left: 6px; right: 6px;
  height: 3px;
  border-radius: 2px;
  background: transparent;
}
.key.f-lp::before { background: var(--f-lp); }
.key.f-lr::before { background: var(--f-lr); }
.key.f-lm::before { background: var(--f-lm); }
.key.f-li::before { background: var(--f-li); }
.key.f-ri::before { background: var(--f-ri); }
.key.f-rm::before { background: var(--f-rm); }
.key.f-rr::before { background: var(--f-rr); }
.key.f-rp::before { background: var(--f-rp); }
.key.f-thumb::before { background: var(--f-thumb); }

.finger-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center;
  font-size: 12px; color: var(--muted);
  margin-top: 10px;
}
.finger-legend .swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px; margin-right: 6px; vertical-align: middle;
}

/* RESULTS MODAL */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 7, 22, 0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 30px 60px rgba(0,0,0,0.6);
  text-align: center;
  box-sizing: border-box;
}
.modal-card::-webkit-scrollbar { width: 10px; }
.modal-card::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.modal-card::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.modal-card::-webkit-scrollbar-track { background: transparent; }
.modal-card input[type=text] {
  width: 100%;
  font-size: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  margin: 10px 0;
}
.modal-card input[type=text]:focus { border-color: var(--primary); }
.big-stars { font-size: 44px; letter-spacing: 6px; color: var(--accent); margin: 8px 0 14px; }
.big-stars .off { color: #3a3f6e; }
.res-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  margin: 10px 0;
}
.res-grid > div {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted);
}
.res-grid b { color: var(--text); font-size: 20px; }
.res-msg { color: var(--accent); font-weight: 600; margin: 10px 0 16px; min-height: 22px; }
.res-actions { display: flex; gap: 10px; justify-content: center; }

.user-list {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px;
  max-height: 140px; overflow-y: auto;
}
.user-list .chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.user-list .chip:hover { border-color: var(--primary); }
.user-list .chip.active { background: var(--primary); border-color: transparent; color: white; }

footer {
  text-align: center;
  color: var(--muted);
  padding: 20px;
  font-size: 12px;
}

/* SEO long-form description section (renders below the app, above footer).
   Friendly typographic style, easy to read for kids and adults alike. */
.seo-description {
  max-width: 880px;
  margin: 48px auto 24px;
  padding: 0 24px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}
.seo-description h2 {
  margin: 36px 0 10px;
  font-size: 22px;
  color: var(--accent);
}
.seo-description h2:first-child { margin-top: 0; }
.seo-description h3 {
  margin: 22px 0 8px;
  font-size: 17px;
  color: var(--text);
}
.seo-description p, .seo-description ul, .seo-description ol, .seo-description dl {
  margin: 8px 0 14px;
}
.seo-description ul, .seo-description ol {
  padding-left: 22px;
}
.seo-description li { margin: 4px 0; }
.seo-description a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.seo-description a:hover { border-bottom-style: solid; }
.seo-description table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  overflow: hidden;
  font-size: 14px;
}
.seo-description th {
  background: rgba(255,203,58,0.12);
  color: var(--accent);
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
}
.seo-description td {
  padding: 7px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.seo-description tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.seo-description code {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  color: var(--accent);
}
.seo-description dl dt { margin-top: 12px; }
.seo-description dl dd { margin: 4px 0 8px 16px; color: var(--muted); }
.seo-description h1 {
  margin: 0 0 18px;
  font-size: 26px;
  line-height: 1.25;
  color: var(--text);
}

/* Visible breadcrumb above the H1. Matches BreadcrumbList JSON-LD. */
.seo-description .breadcrumb {
  margin: 0 0 16px;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}
.seo-description .breadcrumb a {
  color: var(--muted);
  border-bottom: none;
  transition: color 0.15s;
}
.seo-description .breadcrumb a:hover { color: var(--accent); }
.seo-description .breadcrumb-sep { color: var(--border); margin: 0 4px; }

/* Inline images (OG screenshot + keyboard layout illustration) in body */
.seo-description .seo-image {
  margin: 18px 0;
  text-align: center;
}
.seo-description .seo-image img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

@media (max-width: 640px) {
  .seo-description { padding: 0 14px; font-size: 14px; }
  .seo-description h1 { font-size: 22px; }
  .seo-description h2 { font-size: 19px; }
  .seo-description table { font-size: 13px; }
}

#confettiCanvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 300;
}

/* ====== MAIN NAV ======
   Used both in the main app header (typing tutor pages) AND blog pages
   so the navigation is consistent across the entire site. */
.main-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.main-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.main-nav a:hover,
.main-nav a.active {
  color: var(--accent);
  background: rgba(255,203,58,0.08);
}
.main-nav a.cta {
  color: var(--accent);
  border: 1px solid var(--accent);
}
.main-nav a.cta:hover {
  background: var(--accent);
  color: #0f1226;
}

/* ====== BLOG PAGES ======
   Document-style layout for /blog/ and /blog/<slug>/.
   Uses the same .topbar + .main-nav + <footer> as main app. */

/* Blog post (article page) */
.blog-post {
  max-width: 760px;
  margin: 32px auto 64px;
  padding: 0 24px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
}
.blog-post .breadcrumb {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--muted);
}
.blog-post .breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.blog-post .breadcrumb a:hover { color: var(--accent); }
.blog-post .breadcrumb-sep { color: var(--border); margin: 0 4px; }

.blog-hero {
  margin: 0 0 24px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  background: #1a1d3a;
}
.blog-hero img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
}
.blog-post-header h1 {
  margin: 0 0 12px;
  font-size: 36px;
  line-height: 1.2;
  color: var(--text);
}
.blog-post-header .blog-meta {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 32px;
}

.blog-content h2 {
  margin: 48px 0 14px;
  font-size: 26px;
  color: var(--accent);
  line-height: 1.3;
}
.blog-content h3 {
  margin: 32px 0 10px;
  font-size: 20px;
  color: var(--text);
}
.blog-content p {
  margin: 0 0 18px;
}
.blog-content ul,
.blog-content ol {
  margin: 0 0 18px;
  padding-left: 28px;
}
.blog-content li {
  margin: 8px 0;
}
.blog-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.blog-content a:hover { border-bottom-style: solid; }
.blog-content strong { color: var(--text); }
.blog-content em { color: var(--muted); }
.blog-content code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent);
}
.blog-content pre {
  background: rgba(0,0,0,0.3);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--border);
}
.blog-content pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 14px;
}
.blog-content blockquote {
  margin: 18px 0;
  padding: 12px 20px;
  border-left: 3px solid var(--accent);
  background: rgba(255,203,58,0.04);
  color: var(--muted);
  font-style: italic;
}
.blog-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  overflow: hidden;
  font-size: 15px;
}
.blog-content th {
  background: rgba(255,203,58,0.12);
  color: var(--accent);
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
}
.blog-content td {
  padding: 9px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.blog-content tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.blog-content hr {
  margin: 40px 0;
  border: none;
  border-top: 1px solid var(--border);
}
.blog-content .seo-image {
  margin: 24px 0;
  text-align: center;
}
.blog-content .seo-image img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* Blog index (list of all posts) */
.blog-index {
  max-width: 1100px;
  margin: 32px auto 64px;
  padding: 0 24px;
}
.blog-index .breadcrumb {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}
.blog-index .breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.blog-index .breadcrumb a:hover { color: var(--accent); }
.blog-index .breadcrumb-sep { color: var(--border); margin: 0 4px; }

.blog-index-header {
  margin: 16px 0 40px;
}
.blog-index-header h1 {
  margin: 0 0 12px;
  font-size: 36px;
  color: var(--text);
}
.blog-index-header p {
  color: var(--muted);
  max-width: 700px;
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.blog-category {
  margin: 48px 0;
}
.blog-category h2 {
  margin: 0 0 20px;
  font-size: 24px;
  color: var(--accent);
}
.blog-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
}
.blog-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.blog-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.blog-card-image {
  width: 100%;
  aspect-ratio: 1200 / 630;
  overflow: hidden;
  background: #1a1d3a;
  border-bottom: 1px solid var(--border);
}
.blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.blog-card:hover .blog-card-image img {
  transform: scale(1.03);
}
.blog-card-body {
  padding: 18px 20px 20px;
}
.blog-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
  color: var(--text);
}
.blog-card p {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.blog-card-meta {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

.footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }

@media (max-width: 640px) {
  .blog-post { font-size: 16px; padding: 0 16px; margin: 16px auto 48px; }
  .blog-post-header h1 { font-size: 28px; }
  .blog-content h2 { font-size: 22px; margin-top: 36px; }
  .blog-content h3 { font-size: 17px; }
  .blog-index { padding: 0 16px; }
  .blog-index-header h1 { font-size: 28px; }
  .blog-card-grid { grid-template-columns: 1fr; }
}

/* DROPDOWNS */
.dropdown { position: relative; }
.dropdown-toggle {
  display: inline-flex; gap: 8px; align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  min-width: 130px;
}
.dropdown-toggle:hover { background: var(--card-2); border-color: var(--primary); }
.dd-flag { font-size: 16px; }
.dd-label { flex: 1; text-align: left; }
.dd-caret { color: var(--muted); font-size: 10px; transition: transform .15s; }
.dropdown.open .dd-caret { transform: rotate(180deg); }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0; margin-top: 4px;
  min-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  z-index: 100;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: flex; gap: 8px; align-items: center;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  font-family: inherit;
}
.dropdown-item:hover { background: var(--card-2); }
.dropdown-item.active { background: var(--primary); color: white; }
.dropdown-item .dd-flag { width: 20px; text-align: center; }

/* SPACE HINT */
.space-hint {
  display: inline-flex; gap: 8px; align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  animation: pulse 1.6s infinite;
}
.space-hint.center { display: flex; justify-content: center; margin-top: 14px; }

/* Phase continue panel (between phases / after game) */
.phase-continue {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-top: 18px;
}
.space-hint kbd {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 4px 10px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}
@keyframes pulse { 50% { opacity: 0.6; } }

/* HELP MODAL */
.modal-card.big { max-width: 600px; text-align: left; }
.modal-card.big h2 { text-align: center; margin-top: 0; }
.modal-card.big h3 { margin-top: 16px; margin-bottom: 8px; color: var(--accent); font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; }
.help-body { color: var(--text); font-size: 14px; line-height: 1.6; }
.help-body p { margin: 8px 0; }
.help-body ul { padding-left: 22px; margin: 8px 0; }
.help-body li { margin: 4px 0; }
.help-body strong { color: var(--accent); }
.help-body kbd {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--accent);
}

/* RANK TABLE */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 16px;
  font-size: 13px;
}
.rank-table th, .rank-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.rank-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-2);
}
.rank-table tr.current { background: rgba(124,92,255,0.15); }
.rank-table tr.current td { color: var(--accent); font-weight: 700; }
.rank-table td.pts { text-align: right; font-family: ui-monospace, monospace; }

.footer-domain { color: var(--accent); margin-left: 6px; }

/* DEV unlock badge */
.unlock-badge {
  position: fixed; bottom: 14px; right: 14px;
  background: var(--accent); color: #1a1320;
  padding: 6px 8px 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
  z-index: 400;
  display: flex; gap: 8px; align-items: center;
  box-shadow: 0 8px 20px rgba(255,203,58,0.35);
}
.unlock-close {
  background: rgba(0,0,0,0.25); border: 0;
  width: 20px; height: 20px; border-radius: 50%;
  color: inherit; cursor: pointer; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.unlock-close:hover { background: rgba(0,0,0,0.45); color: #fff; }

/* LEVEL INTRO MODAL */
.intro-card { max-width: 860px; padding: 22px; text-align: center; }
.intro-card h2 { margin: 0 0 4px; }
.intro-card p.muted { margin-bottom: 14px; }
.intro-kb-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 8px 0 14px;
  padding: 6px;
  box-sizing: border-box;
  /* overflow visible so arrow arcs can rise above the keyboard;
     JS sizes the wrap to the scaled keyboard so the visible kb stays in the modal */
}
.intro-kb-wrap .kb {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
}
.intro-kb-wrap .key {
  width: 30px; height: 34px; font-size: 11px;
}
.intro-kb-wrap .key.wide  { width: 42px; font-size: 9px; }
.intro-kb-wrap .key.xwide { width: 54px; font-size: 9px; }
.intro-kb-wrap .key.space { width: 140px; font-size: 9px; }

@media (max-width: 760px) {
  .intro-card { padding: 14px; }
  .intro-kb-wrap .kb { padding: 6px; }
  .intro-kb-wrap .key { width: 24px; height: 28px; font-size: 9px; }
  .intro-kb-wrap .key.wide  { width: 32px; }
  .intro-kb-wrap .key.xwide { width: 42px; }
  .intro-kb-wrap .key.space { width: 100px; }
}
@media (max-width: 500px) {
  .intro-kb-wrap .key { width: 20px; height: 24px; font-size: 8px; }
  .intro-kb-wrap .key.wide  { width: 26px; }
  .intro-kb-wrap .key.xwide { width: 34px; }
  .intro-kb-wrap .key.space { width: 75px; }
}
.intro-kb-wrap .key.home-mark {
  border-color: var(--good);
  box-shadow: 0 0 0 2px var(--good), 0 0 12px rgba(74,222,128,0.3);
  color: var(--good);
  z-index: 1;
}
.intro-kb-wrap .key.new-mark {
  background: var(--accent);
  color: #1a1320;
  z-index: 2;
  animation: pulseKey 1.3s ease-in-out infinite;
  border-color: var(--accent);
}
@keyframes pulseKey {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,203,58,0.7); }
  50%      { transform: scale(1.12); box-shadow: 0 0 18px 8px rgba(255,203,58,0.3); }
}
/* Sequential dead-key pulse: step-1 pulses during 0-50% of the 2.6s cycle,
   step-2 during 50-100% (achieved with a negative animation-delay). */
.intro-kb-wrap .key.new-mark.step-1,
.intro-kb-wrap .key.new-mark.step-2 {
  animation: pulseSeq 2.6s ease-in-out infinite;
}
.intro-kb-wrap .key.new-mark.step-2 {
  animation-delay: -1.3s;
}
@keyframes pulseSeq {
  0%, 50%, 100% {
    transform: scale(1);
    background: var(--card-2);
    color: var(--text);
    box-shadow: 0 0 0 0 rgba(255,203,58,0);
    border-color: var(--border);
  }
  25% {
    transform: scale(1.12);
    background: var(--accent);
    color: #1a1320;
    box-shadow: 0 0 18px 8px rgba(255,203,58,0.3);
    border-color: var(--accent);
  }
}

/* arrow SVG overlay */
.intro-kb-wrap svg.arrows {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.intro-kb-wrap svg.arrows path {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: arrowDraw 0.9s ease forwards;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
}
.intro-kb-wrap svg.arrows polygon {
  opacity: 0;
  animation: arrowFadeIn 0.4s ease forwards;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
}
@keyframes arrowDraw { to { stroke-dashoffset: 0; } }
@keyframes arrowFadeIn { to { opacity: 1; } }

/* "finger" dot that travels from home to new key */
.intro-kb-wrap .finger-dot {
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 12px 4px rgba(255,255,255,0.4);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}

.intro-finger-info {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  margin: 12px 0 18px;
}
.intro-finger-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
  min-width: 200px;
  text-align: left;
}
.ifi-key {
  width: 48px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-weight: 800;
  font-size: 18px;
  color: #1a1320;
  background: var(--accent);
  flex-shrink: 0;
}

/* Dead-key sequence card: [dead] + [vowel] = [result] equation */
.intro-finger-item.dead-key {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
}
.ifi-sequence {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.ifi-sequence .ifi-key.small {
  width: 36px; height: 36px; font-size: 15px;
}
.ifi-sequence .ifi-key.result {
  width: 46px; height: 40px; font-size: 22px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(255,203,58,0.45);
}
.ifi-op {
  color: var(--muted);
  font-weight: 800;
  font-size: 18px;
  padding: 0 2px;
}

/* Textless SPACE-bar icon — used wherever the SPACE key is shown as an
   icon (intro finger card, big-letter target in game, etc.). Inherits
   currentColor so it adapts to the container's text colour. */
.space-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 26px;
  min-height: 14px;
}
.space-icon::after {
  content: "";
  display: block;
  width: 78%;
  height: 22%;
  min-width: 22px;
  min-height: 4px;
  background: currentColor;
  border-radius: 999px;
  opacity: 0.92;
}
/* When the icon lives inside the big game-letter area, give it a more
   prominent bar so it reads as the SPACE bar at that scale. */
.big-letter .space-icon::after {
  width: 50%;
  height: 14%;
  min-height: 16px;
  border-radius: 14px;
  box-shadow: 0 0 24px rgba(255,255,255,0.15);
}
.ifi-text { flex: 1; }
.ifi-finger { font-weight: 600; font-size: 13px; }
.ifi-dir { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ifi-dir .arrow { font-size: 16px; vertical-align: middle; color: var(--accent); }
.ifi-dir .home-key {
  display: inline-block; padding: 1px 6px; margin: 0 2px;
  font-family: ui-monospace, monospace; font-weight: 700;
  background: rgba(74,222,128,0.15); color: var(--good);
  border-radius: 4px;
}

@media (max-width: 720px) {
  .key { width: 32px; height: 38px; font-size: 12px; }
  .key.wide { width: 52px; }
  .key.xwide { width: 64px; }
  .key.space { width: 180px; }
  .typing-text { font-size: 18px; }
  .big-letter { font-size: 80px; height: 140px; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .settings { padding: 10px 14px; }
  main { padding: 8px 14px 80px; }
  .res-grid { grid-template-columns: 1fr; }
  .dropdown-toggle { min-width: 110px; padding: 6px 10px; font-size: 12px; }
  .brand-domain { display: none; }
}
