/* =============================================================
   TypZoo — Master Stylesheet
   Stage 1: Layout, Asset Placeholders & Visual Foundation
   ============================================================= */

/* ── 1. RESET & BASE ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Nunito', system-ui, sans-serif;
  background: #111;
  color: white;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

button:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 3px;
}


/* ── 2. SCREEN SYSTEM ──────────────────────────────────────── */
/*
   Screens are full-viewport layers.
   Only one main screen (start / game) is visible at a time.
   Overlay screens (levelup, gameover, win) float ABOVE screen-game.
*/
.screen {
  position: fixed;
  inset: 0;
  display: none;            /* hidden by default */
  flex-direction: column;
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* Overlay screens: semi-transparent, centred content */
.overlay-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
}

.overlay-screen.hidden {
  display: none;
}


/* ── 3. START SCREEN ───────────────────────────────────────── */
#screen-start {
  background:
    radial-gradient(ellipse at 20% 80%, rgba(212, 168, 67, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.2) 0%, transparent 60%),
    linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f2027 100%);
  align-items: center;
  justify-content: flex-start;  /* was center — now start so overflow can scroll */
  overflow-y: auto;
}

.start-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  max-width: 700px;
  width: 100%;
  margin: auto 0;  /* auto top+bottom margins re-centre content when it fits */
}

.start-title-block {
  text-align: center;
  animation: floatBob 3s ease-in-out infinite;
}

.start-logo {
  font-size: 5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.start-title {
  font-size: clamp(3.5rem, 10vw, 6.5rem);
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 40%, #fde68a 70%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: -0.04em;
  filter: drop-shadow(0 2px 24px rgba(251, 191, 36, 0.35));
}

.start-sub {
  font-size: 1.15rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 0.5rem;
}

/* How-to card */
.how-to-card {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 1.25rem;
  padding: 1.25rem 1.5rem;
  width: 100%;
  backdrop-filter: blur(8px);
}

.how-to-heading {
  font-size: 1.1rem;
  font-weight: 900;
  color: #fbbf24;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.how-to-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.how-to-list li {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.how-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ── Profile Selector ───────────────────────────────────── */
.profile-section {
  width: 100%;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 1.25rem;
  padding: 1rem 1.25rem 1.1rem;
}

.profile-section-hd { margin-bottom: 0.75rem; }

.profile-heading {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
}

.profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: flex-start;
}

/* Profile card chip */
.profile-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 110px;
  padding: 0.5rem 0.8rem 0.5rem 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}
.profile-chip:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.24);
}
.profile-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.45);
}
.profile-chip.active {
  background: rgba(251, 191, 36, 0.10);
  border-color: rgba(251, 191, 36, 0.52);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.15);
}

.profile-chip-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.profile-chip-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.90);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.profile-chip.active .profile-chip-name { color: #fbbf24; }

.profile-chip-stats {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.40);
}
.profile-chip.active .profile-chip-stats { color: rgba(251, 191, 36, 0.60); }

/* Delete (×) — only visible on chip hover */
.profile-chip-delete {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  background: rgba(30, 30, 50, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.12s ease, color 0.12s ease;
}
.profile-chip:hover .profile-chip-delete { opacity: 1; }
.profile-chip-delete:hover {
  background: rgba(220, 38, 38, 0.85);
  border-color: rgba(220, 38, 38, 0.6);
  color: white;
}

/* "+ Add" button — styled like a dashed chip */
.profile-chip-add {
  min-width: 72px;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.35);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-chip-add:hover {
  border-color: rgba(255, 255, 255, 0.38);
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.04);
}

/* New-profile form */
.new-profile-form {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.new-profile-form.hidden { display: none !important; }

.new-profile-form input {
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}
.new-profile-form input::placeholder {
  color: rgba(255, 255, 255, 0.28);
  font-weight: 400;
}
.new-profile-form input:focus { border-color: rgba(251, 191, 36, 0.55); }

.new-profile-btns {
  display: flex;
  gap: 0.5rem;
}

.profile-error {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #f87171;
}
.profile-error.hidden { display: none; }

/* Disabled Start button — no active profile selected */
#btn-start:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  pointer-events: none;
}

/* Share (↗) — only visible on chip hover, top-left corner */
.profile-chip-share {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 18px;
  height: 18px;
  background: rgba(30, 30, 50, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.12s ease, color 0.12s ease;
}
.profile-chip:hover .profile-chip-share { opacity: 1; }
.profile-chip-share:hover {
  background: rgba(16, 185, 129, 0.85);
  border-color: rgba(16, 185, 129, 0.6);
  color: white;
}

/* Progress code panel */
.code-panel {
  margin-top: 0.8rem;
  padding: 0.9rem 1rem;
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.code-panel.hidden { display: none; }

.code-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.code-panel-title {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(52, 211, 153, 0.85);
}

.code-panel-for {
  font-size: 0.75rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The code itself — monospace, yellow, click-to-select-all */
.code-display {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #fbbf24;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 7px;
  padding: 0.55rem 0.75rem;
  text-align: center;
  user-select: all;
  -webkit-user-select: all;
  cursor: text;
  word-break: break-all;
}

.code-hint {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.32);
  text-align: center;
}

.code-actions {
  display: flex;
  gap: 0.45rem;
}

.btn-copy-code {
  flex: 1;
  padding: 0.45rem 0.75rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.38);
  border-radius: 7px;
  color: #6ee7b7;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-copy-code:hover {
  background: rgba(16, 185, 129, 0.3);
  color: white;
}

.btn-close-code {
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.35);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-close-code:hover {
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.65);
}

/* Restore-into-existing section inside the code panel */
.code-restore-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.code-restore-label {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
}

.code-restore-input-row {
  display: flex;
  gap: 0.4rem;
}

.code-restore-input-row input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  color: white;
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s ease;
}
.code-restore-input-row input::placeholder {
  color: rgba(255, 255, 255, 0.2);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.code-restore-input-row input:focus {
  border-color: rgba(251, 191, 36, 0.5);
}

.btn-restore-existing {
  padding: 0.45rem 0.75rem;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 7px;
  color: #fbbf24;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-restore-existing:hover {
  background: rgba(251, 191, 36, 0.25);
  color: white;
}

.restore-existing-error {
  font-size: 0.72rem;
  font-weight: 700;
  color: #f87171;
}
.restore-existing-error.hidden { display: none; }

/* Restore code row inside new-profile form */
.restore-code-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.restore-code-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
}

#restore-code-input {
  font-family: 'Courier New', 'Consolas', monospace !important;
  font-size: 0.95rem !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Theme chips */
.theme-chips {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.theme-chip {
  padding: 0.35rem 0.9rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 800;
  border: 2px solid;
}

.chip-savanna { background: rgba(212,168,67,0.15); border-color: rgba(212,168,67,0.5); color: #fde68a; }
.chip-forest  { background: rgba(90,138,60,0.15);  border-color: rgba(90,138,60,0.5);  color: #86efac; }
.chip-ocean   { background: rgba(43,108,176,0.15); border-color: rgba(43,108,176,0.5); color: #93c5fd; }
.chip-apex    { background: rgba(197,48,48,0.15);  border-color: rgba(197,48,48,0.5);  color: #fca5a5; }

/* Save data strip — shown alongside the Continue button when a save exists */
.save-display {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  padding: 0.45rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
}
.save-display.hidden { display: none; }
#btn-continue.hidden { display: none; }
.save-item strong    { color: #fbbf24; font-weight: 900; }

/* ── Ko-fi donation button ───────────────────────────────── */
.kofi-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  background: rgba(74, 222, 128, 0.10);
  border: 1px solid rgba(74, 222, 128, 0.30);
  border-radius: 50px;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  user-select: none;
}
.kofi-btn:hover {
  background: rgba(74, 222, 128, 0.22);
  border-color: rgba(74, 222, 128, 0.60);
  color: rgba(255, 255, 255, 0.90);
}
.kofi-cup {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Level progress grid ─────────────────────────────────── */
#level-progress-grid          { width: 100%; }
#level-progress-grid.hidden   { display: none; }

.progress-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 1.25rem;
  padding: 1rem 1.25rem;
  backdrop-filter: blur(8px);
}

.prog-heading {
  font-size: 0.65rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.1rem;
}

.prog-theme-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.prog-theme-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.prog-theme-emoji { font-size: 0.9rem; }

.prog-theme-name {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.prog-theme-frac {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.32);
}
.prog-theme-frac.all-done { color: #4ade80; }

.prog-dots {
  display: flex;
  gap: 0.35rem;
}

.prog-dot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 3px;
  border-radius: 8px;
  border: 2px solid;
  min-width: 0;
  cursor: default;
  transition: opacity 0.2s ease;
}

/* done: border + background injected as inline styles using theme accentHex */
.prog-dot.done {
  /* CSS fallback if inline style absent */
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.08);
}
.prog-dot.current {
  border-color: rgba(251, 191, 36, 0.6);
  background: rgba(251, 191, 36, 0.10);
  animation: currentGlow 2s ease-in-out infinite;
}
.prog-dot.locked {
  border-color: rgba(255, 255, 255, 0.08);
  background: transparent;
  opacity: 0.38;
}

.prog-dot-num {
  font-size: 0.78rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}
.prog-dot.locked .prog-dot-num { color: rgba(255, 255, 255, 0.4); }

.prog-dot-sub {
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.55);
}
.prog-dot.done    .prog-dot-sub { color: rgba(255, 255, 255, 0.75); }
.prog-dot.current .prog-dot-sub { color: #fbbf24; font-size: 0.72rem; }
.prog-dot.locked  .prog-dot-sub { color: rgba(255, 255, 255, 0.2); }

/* ── Clickable dots (done + current) ──────────────────────── */
.prog-dot.clickable {
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease,
              box-shadow 0.15s ease, filter 0.15s ease;
}
.prog-dot.clickable:hover,
.prog-dot.clickable:focus-visible {
  transform: scale(1.14);
  filter: brightness(1.3);
  outline: none;
}
.prog-dot.clickable:hover {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}
.prog-dot.clickable:focus-visible {
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.65);
}

@keyframes currentGlow {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.22); }
}


/* ── 4. GAME SCREEN LAYOUT ──────────────────────────────── */
/*
   #screen-game is a full-viewport backdrop (gutters on wide screens).
   #game-canvas is the fixed-width column centred inside it.
*/
#screen-game {
  display: none; /* overridden by .active */
}

#screen-game.active {
  /* Horizontal centering — game-canvas sits in the middle */
  display: flex;
  flex-direction: row;
  align-items: center;        /* game-canvas vertically centred (not stretched full height) */
  justify-content: center;    /* game-canvas centred horizontally */
  background: #0b0b14;        /* dark gutter visible on wide monitors */
}

#game-canvas {
  position: relative;         /* stacking context for absolute menu panel */
  width: 100%;
  max-width: 1280px;          /* ← edit this to change the game width */
  height: 100%;               /* fill the screen… */
  max-height: 600px;          /* …but cap at this height */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;              /* lets flex children shrink correctly */
  overflow: hidden;           /* clip anything that strays outside (and hides closed menu) */
}

/* Screen shake — targets the canvas, not the gutter wrapper */
#game-canvas.screen-shake {
  animation: screenShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}


/* ── 5. HUD BAR ─────────────────────────────────────────── */
#hud {
  height: 60px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: 1rem;
  z-index: 50;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

.hud-label {
  font-size: 0.58rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-value {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.hud-yellow { color: #fbbf24; }
.hud-green  { color: #4ade80; font-size: 0.95rem; white-space: nowrap; }
.hud-blue   { color: #60a5fa; }
.hud-purple { color: #c084fc; }

/* Shared style for small icon buttons in the HUD (hamburger + mute) */
.btn-hud-icon {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  color: white;
  opacity: 0.65;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.btn-hud-icon:hover { opacity: 1; background: rgba(255, 255, 255, 0.10); }

/* Brand wordmark in HUD — sits right of the hamburger button */
.hud-brand {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #fde68a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  margin-right: 0.25rem;  /* small gap before the LEVEL cell */
}

/* Mute toggle button — right edge of HUD */
.btn-mute {
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  color: white;
  opacity: 0.6;
  flex-shrink: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.btn-mute:hover  { opacity: 1; background: rgba(255, 255, 255, 0.10); }
.btn-mute.muted  { opacity: 0.3; }

/* Central countdown timer */
.hud-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.timer-wrap {
  position: relative;
  width: 260px;
  height: 26px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  border-radius: 11px;
  transition: width 0.45s linear, background-color 0.5s ease;
}

.timer-bar.warn   { background: linear-gradient(90deg, #f59e0b, #fde68a); }
.timer-bar.danger { background: linear-gradient(90deg, #ef4444, #fca5a5); animation: timerPulse 0.5s ease-in-out infinite; }

.timer-txt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}


/* ── 5b. GAME MENU PANEL ────────────────────────────────── */

/* Backdrop — covers rest of canvas while menu is open */
#game-menu-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
}
#game-menu-backdrop.open { display: block; }

/* Slide-in panel — hidden left of canvas by overflow:hidden on #game-canvas */
#game-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 300px;
  height: 100%;
  background: rgba(10, 10, 22, 0.98);
  border-right: 2px solid rgba(255, 255, 255, 0.10);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#game-menu.open { transform: translateX(0); }

/* ── Header row ── */
.game-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  flex-shrink: 0;
}
.game-menu-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.05em;
}
#btn-menu-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
#btn-menu-close:hover { color: white; background: rgba(255, 255, 255, 0.10); }

/* ── Home button ── */
.game-menu-actions {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
#btn-menu-home {
  width: 100%;
  padding: 0.55rem 0.9rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}
#btn-menu-home:hover { background: rgba(255, 255, 255, 0.13); }

/* ── "Levels" section label ── */
.game-menu-levels-label {
  padding: 0.65rem 0.9rem 0.25rem;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.30);
  flex-shrink: 0;
}

/* ── Scrollable level list ── */
#game-menu-levels {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 0.5rem;
}
#game-menu-levels::-webkit-scrollbar       { width: 4px; }
#game-menu-levels::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ── Theme block inside level list ── */
.menu-theme-block { padding: 0.3rem 0 0.2rem; }
.menu-theme-block + .menu-theme-block { border-top: 1px solid rgba(255,255,255,0.06); }

.menu-theme-name {
  padding: 0.25rem 0.9rem 0.15rem;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
}
.menu-theme-block.locked .menu-theme-name { opacity: 0.5; }

/* ── Individual level row ── */
.menu-level-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.38rem 0.9rem;
  transition: background 0.1s ease;
}
.menu-level-row.clickable {
  cursor: pointer;
}
.menu-level-row.clickable:hover    { background: rgba(255, 255, 255, 0.07); }
.menu-level-row.clickable:focus-visible {
  outline: none;
  background: rgba(251, 191, 36, 0.10);
}
.menu-level-row.locked { opacity: 0.28; }

/* Level number badge */
.menu-level-num {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.09);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}
.menu-level-row.done    .menu-level-num { background: rgba(74, 222, 128, 0.18); color: #4ade80; }
.menu-level-row.current .menu-level-num { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }

/* Focus description */
.menu-level-focus {
  flex: 1;
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-level-row.current .menu-level-focus { color: #fbbf24; font-weight: 700; }
.menu-level-row.locked  .menu-level-focus { color: rgba(255, 255, 255, 0.3); }

/* WPM / state badge */
.menu-level-badge {
  font-size: 0.63rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
}
.menu-level-row.done    .menu-level-badge { color: #4ade80; }
.menu-level-row.current .menu-level-badge { color: #fbbf24; }


/* ── 6. GAME VIEWPORT ───────────────────────────────────── */
#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0; /* important for flex child overflow */
}

/* Background layers — z-indices create depth */
.bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#bg-sky {
  /* Default savanna sky; overridden per-theme by JS */
  background: linear-gradient(180deg,
    #5ba3d9 0%,
    #87ceeb 45%,
    #d4e8b0 75%,
    #e8d5a0 100%
  );
  z-index: 0;
}

#bg-hills {
  bottom: 0;
  top: auto;
  height: 42%;
  background: linear-gradient(180deg, rgba(120,180,80,0.6) 0%, transparent 100%);
  z-index: 1;
}

#bg-ground {
  bottom: 0;
  top: auto;
  height: 120px; /* MUST match CONFIG.GROUND_H */
  background: linear-gradient(180deg, #8B7D2A 0%, #5C4A0A 100%);
  z-index: 2;
}

#bg-ground::before {
  /* Grass strip — only in the walk-path zone (left: 96px onward).
     The keeper platform area (0–96px) stays plain earth. */
  content: '';
  position: absolute;
  top: -10px;
  left: 96px;   /* matches keeperEdge = KEEPER_LEFT(32) + KEEPER_WIDTH(64) */
  right: 0;
  height: 18px;
  background: linear-gradient(180deg, #5a9e30, #3d7320);
  border-radius: 2px 2px 0 0;
}

/* ── Walk path: the corridor animals travel ────────────────── */
/* Extends exactly from the left boundary to the right edge,
   sits flush on the ground surface.                           */
#walk-path {
  position: absolute;
  left: 96px;    /* keeperEdge — first pixel animals can occupy  */
  right: 0;
  bottom: 120px; /* top of ground surface                        */
  height: 60px;  /* covers the animal walking band               */
  background: linear-gradient(180deg,
    transparent                   0%,
    rgba(80, 160, 40, 0.06)       60%,
    rgba(80, 160, 40, 0.14)      100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  z-index: 3;
  pointer-events: none;
}

/* ── Keeper platform: raised earth stage on the left ──────── */
#keeper-platform {
  position: absolute;
  left: 0;
  width: 96px;   /* keeper zone width                            */
  bottom: 0;
  height: 128px; /* slightly taller than ground to look raised   */
  background: linear-gradient(180deg,
    #7a5c1a 0%,
    #5c3e0a 50%,
    #3e2800 100%
  );
  border-right: 2px solid rgba(0,0,0,0.4);
  z-index: 3;
  pointer-events: none;
}

/* Decorative deco layer (populated by JS with theme sprites) */
#deco-layer {
  z-index: 3;
  pointer-events: none;
}

/* ── 7. ANIMAL LAYER & CARDS ────────────────────────────── */
#animal-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

/* Feed burst particles — emoji confetti radiating outward on a successful feed */
.burst-particle {
  position: absolute;
  font-size: 1.15rem;
  pointer-events: none;
  z-index: 45;
  animation: burstOut 0.65s ease-out forwards;
}

/* Individual animal card (injected by JS) */
.animal-card {
  position: absolute;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  will-change: transform; /* GPU layer for smooth X translation */
}

/* Speech bubble containing the target word */
.animal-bubble {
  background: white;
  border-radius: 10px;
  padding: 3px 10px 4px;
  margin-bottom: 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.28);
  border: 3px solid rgba(0, 0, 0, 0.07);
  position: relative;
}

/* Bubble tail */
.animal-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid white;
}

.animal-word {
  font-size: 1.25rem;
  font-weight: 900;
  color: #1e1b4b;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Character-level highlight states (applied in Stage 2) */
.char-done    { color: #16a34a; }  /* already typed correctly */
.char-active  { color: #1e40af; text-decoration: underline; text-underline-offset: 3px; }
.char-pending { color: #6b7280; }

/* Active target: bubble gets a blue glow */
.animal-card.is-active .animal-bubble {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.35), 0 3px 10px rgba(0,0,0,0.28);
}

/* Error feedback: bubble shakes red when player types a wrong character */
.animal-bubble.bubble-error {
  border-color: #ef4444 !important;
  animation: bubbleErrorFlash 0.35s ease-out forwards;
}

/* Danger state: animal close to zookeeper */
.animal-card.is-danger .animal-emoji {
  animation: dangerShake 0.35s ease-in-out infinite;
}

.animal-card.is-danger .animal-bubble {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.4), 0 3px 10px rgba(0,0,0,0.28);
}

/* Fed state: animal exits happily */
.animal-card.is-fed {
  animation: animalFed 0.75s cubic-bezier(0.34,1.56,0.64,1) forwards;
  pointer-events: none;
}

/* Animal emoji & walking animation */
.animal-emoji {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.3));
  /* --emoji-flip is set per card in JS: -1 flips to face left, 1 leaves as-is */
  transform: scaleX(var(--emoji-flip, -1));
}

.animal-emoji.walking {
  animation: animalWalk 0.55s ease-in-out infinite;
}


/* ── 8. PATH FENCE, ZOOKEEPER ──────────────────────────── */

/* Left path boundary — a wooden fence post that marks exactly where
   animals stop and the keeper's platform begins.
   Position: left edge of first animal pixel = keeperEdge (96px).    */
#path-fence {
  position: absolute;
  left: 92px;     /* visually centred on the 96px boundary             */
  bottom: 112px;  /* embedded a few px into the ground for stability   */
  width: 10px;
  height: 90px;   /* post height above ground                           */
  background: linear-gradient(90deg, #5c3a0a, #9a6820, #7a5215, #5c3a0a);
  border-radius: 3px 3px 2px 2px;
  box-shadow: 2px 0 6px rgba(0,0,0,0.5), inset 1px 0 2px rgba(255,255,255,0.1);
  z-index: 11;    /* above keeper (10) so it reads as a hard boundary   */
  pointer-events: none;
}

/* Rounded post cap */
#path-fence::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -3px;
  right: -3px;
  height: 10px;
  background: linear-gradient(180deg, #b88030, #7a5215);
  border-radius: 5px 5px 2px 2px;
  box-shadow: 0 -1px 4px rgba(0,0,0,0.4);
}

/* Faint warning glow that reaches upward — helps the eye read the boundary */
#path-fence::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 260px;
  background: linear-gradient(180deg,
    transparent                   0%,
    rgba(255, 200, 60, 0.12)    50%,
    rgba(255, 180, 30, 0.35)   100%
  );
  pointer-events: none;
}

#zookeeper {
  position: absolute;
  left: 10px;    /* centred in the 96px keeper platform */
  right: auto;
  bottom: 128px; /* sits on top of the raised platform  */
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#keeper-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.15s ease;
}

#keeper-emoji {
  font-size: 3.4rem;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.3));
  transition: transform 0.2s ease;
}

#keeper-bucket {
  font-size: 1.8rem;
  line-height: 1;
  transition: transform 0.3s ease, opacity 0.3s ease;
  margin-top: -4px;
}

#keeper-label {
  font-size: 0.7rem;
  font-weight: 900;
  color: rgba(255,255,255,0.65);
  background: rgba(0,0,0,0.35);
  padding: 2px 8px;
  border-radius: 8px;
}

/* Keeper panic state — applied via JS */
#keeper-char.panicking #keeper-emoji {
  animation: keeperPanic 0.18s ease-in-out infinite;
}

#keeper-char.panicking #keeper-bucket {
  transform: rotate(100deg) translate(16px, 8px);
  opacity: 0.5;
}

/* Keeper celebration — brief jump on every successful animal feed */
#keeper-char.celebrating {
  animation: keeperCelebrate 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}


/* ── 9. ACCURACY BADGE ──────────────────────────────────── */
#acc-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  border-radius: 10px;
  padding: 5px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 30;
}

.acc-label {
  font-size: 0.55rem;
  font-weight: 900;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.acc-value {
  font-size: 1.1rem;
  font-weight: 900;
  color: #4ade80;
}

.acc-value.warn   { color: #fbbf24; }
.acc-value.danger { color: #ef4444; }


/* ── 9b. STREAK BADGE ───────────────────────────────────── */
/* Shown near top-left of the viewport during a run of consecutive feeds. */
#streak-badge {
  position: absolute;
  top: 10px;
  left: 110px;  /* clear of the fence post at ~96px */
  background: rgba(0, 0, 0, 0.60);
  border: 2px solid rgba(251, 191, 36, 0.50);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 1rem;
  font-weight: 900;
  color: #fbbf24;
  z-index: 30;
  white-space: nowrap;
  pointer-events: none;
  animation: streakPulse 1.2s ease-in-out infinite;
}

#streak-badge.hidden { display: none; }

/* Fire-red variant for streaks of 10+ */
#streak-badge.streak-hot {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.55);
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}


/* ── 10. LEVEL BANNER ───────────────────────────────────── */
.level-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 1.5rem;
  padding: 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  z-index: 100;
  backdrop-filter: blur(12px);
  animation: bannerPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.level-banner.hidden { display: none; }

#banner-level {
  font-size: 2.5rem;
  font-weight: 900;
  color: #fbbf24;
}

#banner-theme {
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
}

#banner-focus {
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
}


/* ── 11. PANIC OVERLAY ──────────────────────────────────── */
#panic-overlay {
  position: absolute;
  inset: 0;
  background: rgba(220, 38, 38, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
  animation: panicFlash 0.4s ease-in-out infinite;
}

#panic-overlay.hidden { display: none; }

.panic-title {
  font-size: 2.6rem;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.panic-sub {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  margin-top: 0.4rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#panic-bar-wrap {
  margin-top: 1rem;
  width: 180px;
  height: 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 5px;
  overflow: hidden;
}

#panic-bar {
  height: 100%;
  background: #ef4444;
  border-radius: 5px;
  transition: width 0.1s linear;
}


/* ── 12. INPUT ZONE ─────────────────────────────────────── */
#input-zone {
  min-height: 88px;    /* grows slightly when #next-key-hint is visible */
  flex-shrink: 0;
  background: rgba(0,0,0,0.88);
  border-top: 2px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 2rem;
  position: relative;
  z-index: 50;
}

#typed-display {
  font-size: 1.7rem;
  font-weight: 900;
  color: white;          /* neutral base; spans provide per-char colour */
  letter-spacing: 0.06em;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
}

/* Per-character colour states rendered by renderTypedDisplay() */
#typed-text .t-ok  { color: #4ade80; }
#typed-text .t-bad {
  color: #ef4444;
  text-decoration: underline wavy #ef4444;
  text-underline-offset: 3px;
}
#typed-text .t-dim { color: rgba(239, 68, 68, 0.45); }

#typed-cursor {
  color: #4ade80;
  animation: cursorBlink 0.75s ease-in-out infinite;
  margin-left: 1px;
}

#target-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  min-height: 1rem;
}

/* Hidden real input — covers the whole footer for easy focus-click */
#game-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: default;
  caret-color: transparent;
  font-size: 1rem; /* prevents iOS zoom */
  background: transparent;
  border: none;
  outline: none;
  z-index: 1;
}

#focus-nudge {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* ── 12b. CAPS LOCK WARNING ──────────────────────────────── */
/* Absolutely-positioned inside #input-zone so it doesn't push content down */
#caps-warn {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(245, 158, 11, 0.12);
  border: 1.5px solid rgba(245, 158, 11, 0.55);
  border-radius: 6px;
  padding: 2px 14px;
  font-size: 0.68rem;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
  animation: warnPulse 1.6s ease-in-out infinite;
}

#caps-warn.hidden { display: none; }

/* ── 12c. NEXT-KEY HINT ──────────────────────────────────── */
/* Shows the player which special key (Shift / Space) to press next.
   Only appears at levels 11+ or when a space character is required. */
#next-key-hint {
  font-size: 0.8rem;
  font-weight: 900;
  min-height: 1.1rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

#next-key-hint.hidden { display: none; }

/* Key-type colour variants */
#next-key-hint.hint-shift { color: #a78bfa; }  /* purple — Shift for capitals */
#next-key-hint.hint-space { color: #67e8f9; }  /* cyan  — Spacebar */
#next-key-hint.hint-punct { color: #fbbf24; }  /* amber — punctuation */

/* Visible-space dot inside animal bubbles and the typed display */
.char-space, .t-space { opacity: 0.6; letter-spacing: 0.15em; }


/* ── 13. OVERLAY CARDS (level-up / game-over / win) ─────── */
.overlay-card {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 2rem;
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  max-width: 540px;
  width: 90%;
  backdrop-filter: blur(20px);
  animation: cardRise 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.overlay-icon {
  font-size: 4.5rem;
  line-height: 1;
}

.anim-bounce { animation: floatBob 1.8s ease-in-out infinite; }

.overlay-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: white;
  text-align: center;
  line-height: 1.15;
}

.overlay-sub {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-align: center;
}

.stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-box {
  background: rgba(255,255,255,0.07);
  border-radius: 1rem;
  padding: 0.8rem 1.2rem;
  text-align: center;
  min-width: 88px;
}

.stat-val {
  font-size: 1.9rem;
  font-weight: 900;
  color: #fbbf24;
}

.stat-lbl {
  font-size: 0.65rem;
  font-weight: 800;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 3px;
}

.unlock-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 1rem;
  padding: 0.7rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.unlock-badge.hidden { display: none; }
.unlock-badge strong { font-size: 1.1rem; font-weight: 900; }

/* Personal best WPM indicator on the level-up overlay */
#lu-pb {
  font-size: 0.9rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}
#lu-pb.hidden { display: none; }
#lu-pb.new-pb { color: #fbbf24; font-size: 1rem; animation: floatBob 1s ease-in-out 2; }

.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}


/* ── 14. BUTTONS ────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-weight: 900;
  border-radius: 1rem;
  padding: 0.65rem 1.6rem;
  font-size: 1rem;
  box-shadow: 0 5px 18px rgba(245,158,11,0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:hover  { transform: translateY(-2px) scale(1.02); box-shadow: 0 8px 24px rgba(245,158,11,0.5); }
.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  font-weight: 800;
  border-radius: 1rem;
  padding: 0.65rem 1.6rem;
  font-size: 1rem;
  border: 2px solid rgba(255,255,255,0.25);
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-secondary:hover  { background: rgba(255,255,255,0.2); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(0); }

.btn-large {
  font-size: 1.3rem;
  padding: 0.85rem 2.2rem;
  border-radius: 1.25rem;
}


/* ── 15. FLOATING SCORE POP ─────────────────────────────── */
.score-pop {
  position: absolute;
  font-size: 1.4rem;
  font-weight: 900;
  color: #4ade80;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
  pointer-events: none;
  animation: scorePop 0.9s ease-out forwards;
  z-index: 40;
  white-space: nowrap;
}

.score-pop.penalty { color: #ef4444; }


/* ── 15·5. COPYRIGHT BAR ────────────────────────────────── */
#copyright-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.22);
  padding: 0.35rem 1rem;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
}

/* Give the start screen enough bottom padding so the Ko-fi button
   never sits behind the copyright bar */
.start-inner {
  padding-bottom: 2.5rem;
}


/* ── 16. ANIMATIONS ─────────────────────────────────────── */
@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes animalWalk {
  /* var(--emoji-flip) keeps the per-animal flip alive inside the animation */
  0%, 100% { transform: scaleX(var(--emoji-flip, -1)) rotate(-2deg) translateY(0); }
  50%       { transform: scaleX(var(--emoji-flip, -1)) rotate(2deg) translateY(-3px); }
}

@keyframes animalFed {
  0%   { transform: scale(1) translateY(0);   opacity: 1; }
  25%  { transform: scale(1.3) translateY(-18px); opacity: 1; }
  70%  { transform: scale(1.1) translateY(-10px) rotate(12deg); opacity: 0.7; }
  100% { transform: scale(0.4) translateY(-70px) rotate(20deg); opacity: 0; }
}

@keyframes dangerShake {
  /* var(--emoji-flip) keeps the per-animal flip alive inside the animation */
  0%, 100% { transform: scaleX(var(--emoji-flip, -1)) rotate(0deg); }
  25%       { transform: scaleX(var(--emoji-flip, -1)) rotate(-4deg); }
  75%       { transform: scaleX(var(--emoji-flip, -1)) rotate(4deg); }
}

@keyframes keeperPanic {
  0%, 100% { transform: rotate(-6deg); }
  50%       { transform: rotate(6deg); }
}

@keyframes panicFlash {
  0%, 100% { background-color: rgba(220,38,38,0.12); }
  50%       { background-color: rgba(220,38,38,0.28); }
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

@keyframes scorePop {
  0%   { transform: translateY(0) scale(1);    opacity: 1; }
  60%  { transform: translateY(-45px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.9); opacity: 0; }
}

@keyframes bannerPop {
  0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

@keyframes cardRise {
  0%   { transform: translateY(30px) scale(0.95); opacity: 0; }
  100% { transform: translateY(0)    scale(1);    opacity: 1; }
}

@keyframes streakPulse {
  0%, 100% { transform: scale(1);    }
  50%       { transform: scale(1.05); }
}

@keyframes warnPulse {
  0%, 100% { opacity: 1;    }
  50%       { opacity: 0.55; }
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-7px); }
  30%       { transform: translateX(7px); }
  45%       { transform: translateX(-5px); }
  60%       { transform: translateX(5px); }
  75%       { transform: translateX(-2px); }
  90%       { transform: translateX(2px); }
}

@keyframes burstOut {
  0%   { transform: translate(0, 0) scale(1.1); opacity: 1; }
  100% { transform: translate(var(--dx, 0px), var(--dy, -50px)) scale(0.4); opacity: 0; }
}

@keyframes keeperCelebrate {
  0%   { transform: translateY(0) rotate(0deg); }
  25%  { transform: translateY(-14px) rotate(-8deg); }
  55%  { transform: translateY(-18px) rotate(8deg); }
  75%  { transform: translateY(-8px) rotate(-3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* ── START SCREEN NAV BAR ───────────────────────────────────
   Sticky bar at the top of the start screen; holds the TypZoo
   brand wordmark and the hamburger that opens the game menu.
─────────────────────────────────────────────────────────── */
.start-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* TypZoo wordmark link in the nav */
.start-nav-brand {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #fde68a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.start-nav-brand:hover { filter: brightness(1.15); }


/* ── GAMES SIDE MENU (start screen) ────────────────────────
   Slides in from the left; fixed so it overlays regardless of
   scroll position inside #screen-start.
─────────────────────────────────────────────────────────── */
#start-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 299;
}
#start-menu-backdrop.open { display: block; }

#start-game-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: rgba(10, 10, 22, 0.98);
  border-right: 2px solid rgba(255, 255, 255, 0.10);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow-y: auto;
}
#start-game-menu.open { transform: translateX(0); }

.start-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  flex-shrink: 0;
}

.start-menu-title {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#btn-start-menu-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
#btn-start-menu-close:hover { color: white; background: rgba(255, 255, 255, 0.10); }

.start-menu-section-label {
  padding: 0.65rem 0.9rem 0.25rem;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.30);
  flex-shrink: 0;
}

/* Individual game link / active indicator */
.start-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  color: white;
  cursor: pointer;
  transition: background 0.12s ease;
}
.start-menu-item:hover { background: rgba(255, 255, 255, 0.07); }

.start-menu-item--active {
  background: rgba(251, 191, 36, 0.07);
  cursor: default;
  pointer-events: none;
}
.start-menu-item--active:hover { background: rgba(251, 191, 36, 0.07); }

.start-menu-item-icon {
  font-size: 1.55rem;
  line-height: 1;
  flex-shrink: 0;
  width: 30px;
  text-align: center;
}

.start-menu-item-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.start-menu-item-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
}
.start-menu-item--active .start-menu-item-name { color: #fbbf24; }

.start-menu-item-desc {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.38);
}
.start-menu-item--active .start-menu-item-desc { color: rgba(251, 191, 36, 0.55); }


/* ── END START SCREEN NAV/MENU ──────────────────────────── */

/* Bubble shakes red on a wrong keypress, then snaps back to white */
@keyframes bubbleErrorFlash {
  0%   { background: white;                     transform: translateX(0);   }
  15%  { background: rgba(239, 68, 68, 0.22);   transform: translateX(-6px); }
  40%  { background: rgba(239, 68, 68, 0.18);   transform: translateX( 6px); }
  65%  { background: rgba(239, 68, 68, 0.08);   transform: translateX(-3px); }
  82%  { background: rgba(239, 68, 68, 0.03);   transform: translateX( 2px); }
  100% { background: white;                     transform: translateX(0);   }
}
