/* ================================================================
   BREAD CLICKER — style.css
   Sections:
     1.  Base custom properties (default / novice theme)
     2.  Theme overrides  (8 levels)
     3.  Reset & base
     4.  Header + level badge
     5.  Layout
     6.  Clicker panel
     7.  Loaf rain animation
     8.  Floating "+N" numbers
     9.  Save controls
    10.  Tab bar
    11.  Upgrade shop cards
    12.  Roadmap / preview
    13.  Theme unlock banner
    14.  Modal
    15.  Responsive
   ================================================================ */


/* ── 1. BASE CUSTOM PROPERTIES (theme: novice) ── */
:root {
  /* --- Palette tokens (overridden per theme) --- */
  --bg:             #fdf6ec;
  --bg-alt:         #f5e9d0;
  --surface:        #ffffff;
  --border:         #ecdbb5;
  --accent:         #b5651d;
  --accent-light:   #f0a85a;
  --accent-dark:    #7c3f0e;
  --header-from:    #7c3f0e;
  --header-to:      #5a2c09;
  --text-main:      #3b1f0a;
  --text-muted:     #8a6a4a;
  --text-header:    #f5e9d0;
  --score-color:    #d4a96a;
  --level-bar:      #d4a96a;
  --card-flash:     #fef3e2;
  --card-accent:    #d4a96a;

  /* --- Fixed tokens (never change) --- */
  --danger:         #c0392b;
  --success:        #27ae60;
  --white:          #ffffff;

  /* --- Shape --- */
  --radius:         14px;
  --radius-lg:      22px;
  --radius-pill:    100px;
  --shadow-sm:      0 2px 8px  rgba(90,50,10,.10);
  --shadow-md:      0 4px 20px rgba(90,50,10,.14);
  --shadow-lg:      0 8px 36px rgba(90,50,10,.18);
  --transition:     0.2s ease;

  /* --- Fonts --- */
  --font-display:   'Playfair Display', Georgia, serif;
  --font-body:      'Lato', 'Helvetica Neue', sans-serif;
}


/* ════════════════════════════════════════════════════════════
   2. THEME OVERRIDES
   Applied via <html data-theme="X">.
   Each theme fully re-tokens the colour palette.
   ════════════════════════════════════════════════════════════ */

/* ── Lv 1 novice — warm cream (default, no override needed) ── */

/* ── Lv 2 apprentice — golden sunrise ── */
[data-theme="apprentice"] {
  --bg:             #fffbee;
  --bg-alt:         #fef3c7;
  --surface:        #fffdf5;
  --border:         #fcd34d;
  --accent:         #d97706;
  --accent-light:   #fbbf24;
  --accent-dark:    #92400e;
  --header-from:    #b45309;
  --header-to:      #78350f;
  --text-main:      #1c1007;
  --text-muted:     #92400e;
  --text-header:    #fef3c7;
  --score-color:    #fcd34d;
  --level-bar:      #fbbf24;
  --card-flash:     #fef9c3;
  --card-accent:    #fcd34d;
  --shadow-sm:      0 2px 8px  rgba(180,83,9,.12);
  --shadow-md:      0 4px 20px rgba(180,83,9,.18);
  --shadow-lg:      0 8px 36px rgba(180,83,9,.22);
}

/* ── Lv 3 journeyman — toasty amber ── */
[data-theme="journeyman"] {
  --bg:             #fff7ed;
  --bg-alt:         #ffedd5;
  --surface:        #fffaf5;
  --border:         #fed7aa;
  --accent:         #ea580c;
  --accent-light:   #fb923c;
  --accent-dark:    #9a3412;
  --header-from:    #c2410c;
  --header-to:      #7c2d12;
  --text-main:      #1a0a03;
  --text-muted:     #9a3412;
  --text-header:    #ffedd5;
  --score-color:    #fdba74;
  --level-bar:      #fb923c;
  --card-flash:     #fff7ed;
  --card-accent:    #fdba74;
  --shadow-sm:      0 2px 8px  rgba(194,65,12,.12);
  --shadow-md:      0 4px 20px rgba(194,65,12,.18);
  --shadow-lg:      0 8px 36px rgba(194,65,12,.22);
}

/* ── Lv 4 artisan — rich mahogany ── */
[data-theme="artisan"] {
  --bg:             #fdf4ec;
  --bg-alt:         #f9e8d8;
  --surface:        #fef9f5;
  --border:         #d6a07a;
  --accent:         #a0522d;
  --accent-light:   #c0743d;
  --accent-dark:    #5c2d0e;
  --header-from:    #7b3310;
  --header-to:      #4a1e08;
  --text-main:      #2a1208;
  --text-muted:     #7b4422;
  --text-header:    #f9e8d8;
  --score-color:    #c9956a;
  --level-bar:      #c0743d;
  --card-flash:     #fdf0e6;
  --card-accent:    #d6a07a;
  --shadow-sm:      0 2px 8px  rgba(123,51,16,.12);
  --shadow-md:      0 4px 20px rgba(123,51,16,.20);
  --shadow-lg:      0 8px 36px rgba(123,51,16,.26);
}

/* ── Lv 5 master — midnight bakery (dark) ── */
[data-theme="master"] {
  --bg:             #1a100a;
  --bg-alt:         #231509;
  --surface:        #2c1c10;
  --border:         #4a2c18;
  --accent:         #e08a3c;
  --accent-light:   #f5a957;
  --accent-dark:    #b56520;
  --header-from:    #0f0804;
  --header-to:      #1e1008;
  --text-main:      #f5dfc5;
  --text-muted:     #a07050;
  --text-header:    #e0b87a;
  --score-color:    #e08a3c;
  --level-bar:      #e08a3c;
  --card-flash:     #3a2210;
  --card-accent:    #e08a3c;
  --shadow-sm:      0 2px 8px  rgba(0,0,0,.4);
  --shadow-md:      0 4px 20px rgba(0,0,0,.5);
  --shadow-lg:      0 8px 40px rgba(0,0,0,.6);
}

/* ── Lv 6 grandmaster — deep violet royale ── */
[data-theme="grandmaster"] {
  --bg:             #13091f;
  --bg-alt:         #1c0f2e;
  --surface:        #231240;
  --border:         #4a2870;
  --accent:         #c084fc;
  --accent-light:   #d8a4ff;
  --accent-dark:    #7c3aed;
  --header-from:    #3b0764;
  --header-to:      #1e0438;
  --text-main:      #ede9fe;
  --text-muted:     #a78bca;
  --text-header:    #e9d5ff;
  --score-color:    #c084fc;
  --level-bar:      #a855f7;
  --card-flash:     #2e1058;
  --card-accent:    #c084fc;
  --shadow-sm:      0 2px 8px  rgba(124,58,237,.2);
  --shadow-md:      0 4px 20px rgba(124,58,237,.3);
  --shadow-lg:      0 8px 40px rgba(124,58,237,.4);
}

/* ── Lv 7 cosmic — deep space teal ── */
[data-theme="cosmic"] {
  --bg:             #020d12;
  --bg-alt:         #041820;
  --surface:        #062030;
  --border:         #0e4d60;
  --accent:         #06b6d4;
  --accent-light:   #22d3ee;
  --accent-dark:    #0369a1;
  --header-from:    #0c4a6e;
  --header-to:      #082f47;
  --text-main:      #cffafe;
  --text-muted:     #4bbfd8;
  --text-header:    #a5f3fc;
  --score-color:    #22d3ee;
  --level-bar:      #06b6d4;
  --card-flash:     #0a3344;
  --card-accent:    #22d3ee;
  --shadow-sm:      0 2px 8px  rgba(6,182,212,.2);
  --shadow-md:      0 4px 20px rgba(6,182,212,.3);
  --shadow-lg:      0 8px 40px rgba(6,182,212,.4);
}

/* ── Lv 8 bread god — radiant gold / celestial ── */
[data-theme="breadgod"] {
  --bg:             #0a0800;
  --bg-alt:         #150f00;
  --surface:        #1e1600;
  --border:         #4a3800;
  --accent:         #ffd700;
  --accent-light:   #ffe44d;
  --accent-dark:    #b8860b;
  --header-from:    #3d2e00;
  --header-to:      #1a1200;
  --text-main:      #fffacd;
  --text-muted:     #c8a800;
  --text-header:    #ffd700;
  --score-color:    #ffd700;
  --level-bar:      #ffd700;
  --card-flash:     #2a2000;
  --card-accent:    #ffd700;
  --shadow-sm:      0 2px 8px  rgba(255,215,0,.15);
  --shadow-md:      0 4px 20px rgba(255,215,0,.25);
  --shadow-lg:      0 8px 40px rgba(255,215,0,.35);
}


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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.8s ease, color 0.8s ease;
  animation: fadein 0.4s ease both;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

button { font-family: var(--font-body); cursor: pointer; border: none; }


/* ── 4. HEADER + LEVEL BADGE ── */
.header {
  background: var(--header-from);
  background-image: linear-gradient(135deg, var(--header-from) 0%, var(--header-to) 100%);
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.8s ease, background-image 0.8s ease;
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-header);
  letter-spacing: 0.5px;
  flex-shrink: 0;
  transition: color 0.8s;
}

/* Level badge */
.level-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 10px;
  transition: background 0.3s;
}

.level-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.level-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 110px;
}

.level-name {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--text-header);
  white-space: nowrap;
  transition: color 0.8s;
}

.level-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}

.level-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--level-bar);
  border-radius: 4px;
  transition: width 0.6s ease, background 0.8s;
}

.level-number {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--score-color);
  white-space: nowrap;
  transition: color 0.8s;
}

/* Score */
.score-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
}

.score-number {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--score-color);
  line-height: 1;
  min-width: 80px;
  text-align: right;
  transition: color 0.8s;
}

.score-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
}

.rate-block {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.rate-block span {
  color: var(--score-color);
  font-weight: 700;
  transition: color 0.8s;
}


/* ── 5. LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 1000px;
  margin: 28px auto;
  padding: 0 20px 60px;
}


/* ── 6. CLICKER PANEL ── */
.clicker-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  position: relative;
}

.bread-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 1;
}

.bread-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--bg-alt);
  border: 4px solid var(--border);
  box-shadow: var(--shadow-lg), inset 0 2px 8px rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: visible;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background 0.8s,
    border-color 0.8s;
}

.bread-btn:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg), 0 0 0 8px rgba(var(--accent), 0.1), inset 0 2px 8px rgba(255,255,255,0.2);
  transform: scale(1.04);
}

.bread-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.bread-btn:active { transform: scale(0.93); }

.bread-btn.pressing {
  animation: bread-press 0.15s ease;
}

@keyframes bread-press {
  0%   { transform: scale(1);    }
  40%  { transform: scale(0.88); }
  100% { transform: scale(1);    }
}

.bread-icon {
  font-size: 90px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  display: block;
  transition: transform var(--transition);
}

.bread-btn:hover .bread-icon { transform: rotate(-5deg) scale(1.05); }

.click-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 1.2em;
  transition: color 0.8s;
}


/* ── 7. LOAF RAIN ── */
/*
   A fixed-height container that sits above the bread button.
   JS spawns loaf emoji elements inside it at a rate proportional to BPS.
   They animate upward and fade out.
*/
.loaf-rain {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 200px;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.loaf-drop {
  position: absolute;
  bottom: 0;
  font-size: 1.6rem;
  line-height: 1;
  pointer-events: none;
  animation: loaf-rise var(--rise-dur, 2s) ease-out forwards;
  opacity: 0;
}

@keyframes loaf-rise {
  0%   { opacity: 0;    transform: translateY(0)     scale(0.6) rotate(0deg);   }
  15%  { opacity: 0.9;  transform: translateY(-20px) scale(1.0) rotate(5deg);   }
  80%  { opacity: 0.7;  transform: translateY(var(--rise-height, -160px)) scale(0.9) rotate(-8deg); }
  100% { opacity: 0;    transform: translateY(var(--rise-height, -180px)) scale(0.7) rotate(-12deg); }
}


/* ── 8. FLOATING "+N" CLICK NUMBERS ── */
.floats-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}

.float-num {
  position: absolute;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(255,255,255,0.6);
  pointer-events: none;
  animation: float-up 0.85s ease-out forwards;
  white-space: nowrap;
  transition: color 0.8s;
}

@keyframes float-up {
  0%   { opacity: 1;   transform: translateY(0)     scale(1);    }
  50%  { opacity: 1;   transform: translateY(-44px)  scale(1.15); }
  100% { opacity: 0;   transform: translateY(-90px)  scale(0.9);  }
}


/* ── 9. SAVE CONTROLS ── */
.save-controls {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition),
    color 0.8s;
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-secondary:active { transform: scale(0.96); }

.btn-danger {
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 700;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.btn-danger:hover {
  background: var(--danger);
  color: var(--white);
  transform: translateY(-1px);
}

.btn-danger:active { transform: scale(0.96); }

.save-status {
  font-size: 0.75rem;
  color: var(--success);
  font-style: italic;
  min-height: 1.1em;
  text-align: center;
}


/* ── 10. TAB BAR ── */
.upgrades-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.tab-bar {
  display: flex;
  gap: 0;
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  flex-shrink: 0;
  transition: background 0.8s, border-color 0.8s;
}

.tab-btn {
  flex: 1;
  padding: 11px 10px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition);
  letter-spacing: 0.3px;
}

.tab-btn:hover:not(.active) {
  background: rgba(0,0,0,0.05);
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.tab-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 16px;
  max-height: 560px;
  overflow-y: auto;
  transition: background 0.8s, border-color 0.8s;
}

/* Custom scrollbar */
.tab-panel::-webkit-scrollbar { width: 5px; }
.tab-panel::-webkit-scrollbar-track { background: var(--bg-alt); border-radius: 3px; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tab-panel:not(.active) { display: none; }


/* ── 11. UPGRADE SHOP CARDS ── */
.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-card {
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 3px 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition),
    opacity var(--transition),
    background 0.8s;
}

/* Coloured left accent bar */
.upgrade-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--card-accent);
  border-radius: var(--radius) 0 0 var(--radius);
  transition: background var(--transition);
}

.upgrade-card:hover:not(.upgrade-card--locked) {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.upgrade-card:hover:not(.upgrade-card--locked)::before {
  background: var(--accent);
}

.upgrade-card--locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.upgrade-card--locked:hover { transform: none; }

.upgrade-card--purchased {
  animation: card-flash 0.35s ease;
}

@keyframes card-flash {
  0%   { background: var(--card-flash); }
  100% { background: var(--bg-alt); }
}

.upgrade-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  grid-column: 1; grid-row: 1;
  align-self: center;
  transition: color 0.8s;
}

.upgrade-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
  grid-column: 1; grid-row: 2;
  transition: color 0.8s;
}

.upgrade-meta {
  grid-column: 2; grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-width: 70px;
}

.upgrade-cost {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  transition: color 0.8s;
}

.upgrade-owned {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.8s;
}

.upgrade-owned strong {
  color: var(--text-main);
  font-weight: 700;
}


/* ── 12. ROADMAP / PREVIEW TAB ── */
.preview-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Tier section heading */
.preview-tier-heading {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  transition: color 0.8s, border-color 0.8s;
}

/* Individual roadmap row */
.preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg-alt);
  position: relative;
  overflow: hidden;
  transition: background 0.8s, border-color 0.8s;
}

/* Status stripe on left edge */
.preview-row::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--border);
  transition: background 0.3s;
}

.preview-row--owned::before   { background: var(--success); }
.preview-row--available::before { background: var(--accent); }
.preview-row--locked::before  { background: var(--border); }

.preview-row--owned {
  opacity: 0.7;
}

.preview-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  filter: none;
  transition: filter 0.3s;
}

.preview-row--locked .preview-icon { filter: grayscale(1) opacity(0.45); }

.preview-body {
  flex: 1;
  min-width: 0;
}

.preview-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.8s;
}

.preview-row--locked .preview-name { color: var(--text-muted); }

.preview-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
  transition: color 0.8s;
}

/* Right-side status badge */
.preview-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.preview-badge--owned {
  background: rgba(39,174,96,0.15);
  color: var(--success);
  border: 1px solid rgba(39,174,96,0.3);
}

.preview-badge--available {
  background: rgba(var(--accent), 0.1);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.preview-badge--locked {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}


/* ── 13. THEME UNLOCK BANNER ── */
.theme-banner {
  position: fixed;
  top: -90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--header-from);
  background-image: linear-gradient(135deg, var(--header-from), var(--header-to));
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 14px 24px;
  min-width: 280px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  transition: top 0.4s cubic-bezier(0.34,1.56,0.64,1), background 0s;
  pointer-events: none;
}

.theme-banner.show {
  top: 80px;
}

.theme-banner-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.theme-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theme-banner-text strong {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-header);
  display: block;
  transition: color 0;
}

.theme-banner-text span {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.65);
}


/* ── 14. MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.2s ease, background 0.8s;
}

.modal-overlay.visible .modal { transform: scale(1); }

.modal h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text-main);
  margin-bottom: 10px;
}

.modal p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions { display: flex; gap: 12px; justify-content: center; }



/* ── 16. CHEAT TERMINAL ── */

/* Full-screen dim overlay */
.cheat-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cheat-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* The terminal window */
.cheat-terminal {
  width: 100%;
  max-width: 520px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255,255,255,0.05);
  font-family: 'Courier New', 'Lucida Console', monospace;
  overflow: hidden;
  transform: scale(0.92) translateY(-10px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cheat-overlay.visible .cheat-terminal {
  transform: scale(1) translateY(0);
}

/* Title bar */
.cheat-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #161b22;
  padding: 10px 14px;
  border-bottom: 1px solid #30363d;
  user-select: none;
}

.cheat-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot-red    { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green  { background: #27c93f; }

.cheat-titlebar-name {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  color: #8b949e;
  letter-spacing: 0.5px;
}

.cheat-x {
  background: none;
  border: none;
  color: #8b949e;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.cheat-x:hover {
  color: #f85149;
  background: rgba(248, 81, 73, 0.1);
}

/* Log area */
.cheat-log {
  padding: 14px 16px 8px;
  min-height: 110px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cheat-log::-webkit-scrollbar { width: 4px; }
.cheat-log::-webkit-scrollbar-track { background: #0d1117; }
.cheat-log::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }

.cline {
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.cline-sys   { color: #8b949e; }
.cline-input { color: #58a6ff; }
.cline-ok    { color: #3fb950; }
.cline-err   { color: #f85149; }
.cline-warn  { color: #d29922; }

/* Input row */
.cheat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 14px;
  border-top: 1px solid #21262d;
}

.cheat-prompt {
  font-size: 0.78rem;
  color: #3fb950;
  font-family: 'Courier New', monospace;
  flex-shrink: 0;
  user-select: none;
}

.cheat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e6edf3;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.82rem;
  caret-color: #58a6ff;
}

.cheat-input::placeholder { color: #484f58; }


/* ── 17. CHEAT MENU ── */

.cheat-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 590;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cheat-menu-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.cheat-menu {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  font-family: 'Courier New', monospace;
  transform: scale(0.93);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cheat-menu::-webkit-scrollbar { width: 4px; }
.cheat-menu::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }

.cheat-menu-overlay.visible .cheat-menu {
  transform: scale(1);
}

.cheat-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  position: sticky;
  top: 0;
}

.cheat-menu-title {
  font-size: 0.95rem;
  color: #e6edf3;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex: 1;
  font-family: 'Courier New', monospace;
}

.cheat-menu-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #3fb950;
  border: 1px solid #3fb950;
  border-radius: 4px;
  padding: 2px 7px;
  background: rgba(63, 185, 80, 0.1);
}

.cheat-menu-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cheat-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8b949e;
  margin-top: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid #21262d;
  padding-bottom: 4px;
}

.cheat-group-label:first-child { margin-top: 0; }

.cheat-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

/* Cheat action button */
.cbtn {
  padding: 9px 10px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #58a6ff;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cbtn:hover {
  background: #1f2937;
  border-color: #58a6ff;
  transform: translateY(-1px);
}

.cbtn:active { transform: scale(0.96); }

.cbtn-danger {
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.3);
}

.cbtn-danger:hover {
  background: rgba(248, 81, 73, 0.1);
  border-color: #f85149;
}

.cheat-menu-status {
  font-size: 0.72rem;
  color: #3fb950;
  font-family: 'Courier New', monospace;
  padding: 8px 16px 14px;
  min-height: 2em;
  text-align: center;
}


/* ── 15. RESPONSIVE ── */
@media (max-width: 680px) {
  .layout {
    grid-template-columns: 1fr;
    margin-top: 16px;
    gap: 16px;
    padding: 0 12px 40px;
  }

  .level-badge { display: none; } /* hide on very small screens */

  .tab-panel { max-height: 400px; }
}

@media (max-width: 420px) {
  .score-number { font-size: 1.6rem; }
  .bread-btn    { width: 150px; height: 150px; }
  .bread-icon   { font-size: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
