/* ==========================================================================
 * QuestTodo — Dark Fantasy Neon Theme
 * ========================================================================== */

:root {
  --bg:        #0d0d14;
  --bg-2:      #14141f;
  --panel:     #1a1a28;
  --panel-2:   #22223400;
  --border:    #2a2a3d;
  --text:      #e8e8f0;
  --muted:     #8a8aa3;
  --cyan:      #00e5ff;
  --magenta:   #ff2e97;
  --gold:      #ffd447;
  --green:     #3ddc84;
  --orange:    #ff9f1c;
  --purple:    #b06bff;
  --radius:    16px;
  --glow-cyan: 0 0 12px rgba(0, 229, 255, .55);
  --glow-mag:  0 0 12px rgba(255, 46, 151, .55);
  --glow-gold: 0 0 14px rgba(255, 212, 71, .6);
}

/* Theme: Cyber (freischaltbar) */
body.theme-cyber   { --cyan: #14f195; --magenta: #7b2fff; --gold: #00e5ff; }
body.theme-inferno { --cyan: #ff9f1c; --magenta: #ff2e2e; --gold: #ffd447; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 46, 151, .10), transparent 60%),
    radial-gradient(1000px 500px at -10% 10%, rgba(0, 229, 255, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
/* Horizontale Safety ohne vertikales Scrollen zu brechen (clip statt hidden). */
html { overflow-x: clip; max-width: 100%; }

.hidden { display: none !important; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: rgba(13, 13, 20, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: 'Orbitron', sans-serif; }
.brand-mark { font-size: 22px; filter: drop-shadow(var(--glow-gold)); }
.brand-name { font-weight: 900; letter-spacing: .5px; font-size: 18px; }
.brand-name span { color: var(--cyan); text-shadow: var(--glow-cyan); }

.hud { display: flex; align-items: center; gap: 10px; }
.hud-item {
  display: flex; align-items: center; gap: 5px;
  font-weight: 700; font-size: 14px;
  padding: 5px 9px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border);
}
.hud-icon { font-size: 15px; }
.hud-xpbar {
  width: 90px; height: 8px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--border); overflow: hidden;
}
.hud-xpbar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  box-shadow: var(--glow-cyan); transition: width .5s cubic-bezier(.2,.9,.3,1);
}
.icon-btn {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); width: 36px; height: 36px; border-radius: 10px;
  font-size: 16px; cursor: pointer; transition: transform .15s, border-color .15s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--cyan); }

/* ===== Content ===== */
.content { max-width: 900px; margin: 0 auto; padding: 16px; padding-bottom: 130px; }

.section-head {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 4px 12px;
}
.section-head h2 {
  font-family: 'Orbitron', sans-serif; font-size: 15px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}
.section-head .count {
  font-size: 12px; font-weight: 700; color: var(--cyan);
  background: var(--panel); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 20px;
}
.done-head h2 { color: #5a5a72; }
.btn-undo {
  margin-left: auto; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--gold); color: var(--gold);
  font-weight: 700; font-size: 12px; transition: transform .15s, box-shadow .15s;
}
.btn-undo:hover { transform: translateY(-1px); box-shadow: var(--glow-gold); }

/* ===== Hero card ===== */
.hero-card {
  display: flex; align-items: center; gap: 16px;
  padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.hero-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(400px 120px at 100% 0%, rgba(0,229,255,.12), transparent 70%);
  pointer-events: none;
}
.hero-avatar {
  font-size: 42px; width: 68px; height: 68px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--cyan);
  box-shadow: var(--glow-cyan);
}
.hero-info { flex: 1; min-width: 0; }
.hero-level { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 20px; margin-bottom: 8px; }
.hero-level span { color: var(--gold); text-shadow: var(--glow-gold); }
.hero-xp-wrap {
  position: relative; height: 22px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border); overflow: hidden;
}
.hero-xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  box-shadow: 0 0 16px rgba(0,229,255,.5);
  transition: width .6s cubic-bezier(.2,.9,.3,1);
}
.hero-xp-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px #000;
}

/* ===== Stat grid ===== */
.stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px;
}
.stat-card {
  padding: 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  text-align: center;
}
.stat-value { font-family: 'Orbitron', sans-serif; font-size: 26px; font-weight: 900; color: var(--cyan); }
.stat-card.streak .stat-value { color: var(--orange); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== Boss card ===== */
.boss-card {
  margin-top: 18px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, #241426, var(--bg-2));
  border: 1px solid var(--magenta);
  box-shadow: inset 0 0 40px rgba(255,46,151,.08);
  position: relative; overflow: hidden;
}
.boss-card.hit { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}
.boss-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.boss-emoji { font-size: 40px; filter: drop-shadow(var(--glow-mag)); }
.boss-name { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 18px; color: var(--magenta); }
.boss-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.boss-hp-wrap {
  position: relative; height: 20px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border); overflow: hidden;
}
.boss-hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--magenta), #ff6b6b);
  box-shadow: 0 0 14px rgba(255,46,151,.5);
  transition: width .5s cubic-bezier(.2,.9,.3,1);
}
.boss-hp-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px #000;
}
.boss-expiry { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: right; }

/* ===== Add form ===== */
.add-form {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 6px;
}
.add-form input[type=text] {
  width: 100%; padding: 12px 14px; font-size: 15px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); outline: none; transition: border-color .15s;
}
.add-form input[type=text]:focus { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.add-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-row select, .add-row input[type=date] {
  flex: 1 1 auto; min-width: 120px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; outline: none;
}
.add-row input[type=date] { color-scheme: dark; }

/* ===== Buttons ===== */
.btn-primary {
  padding: 11px 18px; border: none; border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: 14px; color: #0a0a12;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  box-shadow: var(--glow-cyan); transition: transform .15s, filter .15s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  padding: 11px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); font-weight: 600; cursor: pointer;
  transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--cyan); }
.btn-danger {
  width: 100%; margin-top: 14px; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--magenta); color: var(--magenta);
  font-weight: 700; font-size: 13px; transition: background .15s;
}
.btn-danger:hover { background: rgba(255,46,151,.12); }
#btn-prestige { margin-bottom: 4px; }

/* ===== Todo list ===== */
.todo-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--prio, var(--cyan));
  transition: transform .15s, opacity .3s, background .15s;
}
.todo-item:hover { transform: translateX(2px); background: var(--bg-2); }
.todo-item.completing { animation: pop .4s; }
@keyframes pop {
  0% { transform: scale(1); } 40% { transform: scale(1.03); background: rgba(61,220,132,.12); }
  100% { transform: scale(1); }
}
.check {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent; cursor: pointer;
  display: grid; place-items: center; font-size: 16px; color: transparent;
  transition: all .2s;
}
.check:hover { border-color: var(--green); box-shadow: 0 0 10px rgba(61,220,132,.4); }
.todo-item.done .check {
  border-color: var(--green); background: var(--green); color: #0a0a12;
}
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-size: 15px; font-weight: 500; word-break: break-word; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; gap: 8px; margin-top: 3px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.todo-badge { padding: 1px 7px; border-radius: 20px; background: var(--bg); border: 1px solid var(--border); font-weight: 600; }
.todo-badge.due-overdue { color: var(--magenta); border-color: var(--magenta); }
.todo-badge.due-today { color: var(--gold); border-color: var(--gold); }
.todo-del {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 18px; padding: 4px 6px; border-radius: 8px; transition: color .15s, background .15s;
}
.todo-del:hover { color: var(--magenta); background: rgba(255,46,151,.1); }
.done-list .todo-item { opacity: .6; }

.empty-hint { color: var(--muted); font-size: 13px; text-align: center; padding: 18px; }

/* ===== Routinen ===== */
#routine-groups { display: flex; flex-direction: column; gap: 10px; }
.routine-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.routine-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.routine-frac { color: var(--cyan); font-family: 'Orbitron', sans-serif; font-size: 13px; }
.routine-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.routine-check {
  width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--muted);
  background: transparent; color: #0a0a12; cursor: pointer; font-weight: 900; font-size: 14px; transition: all .15s;
}
.routine-row.done .routine-check { background: var(--green); border-color: var(--green); }
.routine-label { flex: 1; font-size: 14px; }
.routine-row.done .routine-label { text-decoration: line-through; color: var(--muted); }
.routine-row.excused .routine-label { color: var(--muted); font-style: italic; }
.routine-exc {
  flex: none; padding: 4px 9px; border-radius: 8px; font-size: 11px; font-weight: 600; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
}
.routine-exc.active { border-color: var(--gold); color: var(--gold); }
.routine-edit-group { margin-bottom: 12px; }
.routine-edit-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.routine-edit-row .edit-input { margin-bottom: 0; }

/* ===== Kalender ===== */
.modal-wide { max-width: 460px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font-size: 16px; }
.cal-nav { padding: 6px 14px; font-size: 18px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; position: relative; padding: 2px;
}
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.today { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.cal-num { font-size: 12px; font-weight: 600; }
.cal-dots { display: flex; gap: 2px; height: 6px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; font-size: 11px; color: var(--muted); justify-content: center; }
.cal-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 3px; }
#cal-day-detail { text-align: left; max-height: 30vh; overflow-y: auto; }

/* ===== Charts ===== */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart-card { padding: 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.chart-title { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.chart-card canvas { width: 100%; height: 120px; display: block; }
@media (max-width: 560px) { .charts { grid-template-columns: 1fr; } }

/* ===== Sort / mini buttons ===== */
.sort-select {
  margin-left: auto; padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); outline: none; cursor: pointer;
}
.btn-mini {
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer;
  background: var(--panel); color: var(--cyan); border: 1px solid var(--cyan);
}
.btn-mini:hover { box-shadow: var(--glow-cyan); }

/* ===== Todo actions (edit/delete) ===== */
.todo-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.todo-edit {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 4px 6px; border-radius: 8px; transition: background .15s;
}
.todo-edit:hover { background: rgba(0,229,255,.1); }

/* ===== Edit / Archive ===== */
.edit-input {
  width: 100%; padding: 10px 12px; margin-bottom: 4px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; outline: none; font-size: 14px;
}
.edit-input:focus { border-color: var(--cyan); }
.archive-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; text-align: left; }
.archive-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); font-size: 13px;
}
.archive-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Badges ===== */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge {
  padding: 18px 12px; border-radius: var(--radius); text-align: center;
  background: var(--panel); border: 1px solid var(--border);
  transition: transform .15s;
}
.badge.unlocked { border-color: var(--gold); box-shadow: var(--glow-gold); }
.badge.unlocked:hover { transform: translateY(-3px); }
.badge.locked { opacity: .4; filter: grayscale(1); }
.badge-emoji { font-size: 34px; }
.badge-name { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 13px; margin-top: 8px; }
.badge-desc { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ===== Dungeon panel ===== */
.energy-card {
  padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel), var(--bg-2));
  border: 1px solid var(--cyan);
}
.energy-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.energy-head span:last-child { color: var(--cyan); font-family: 'Orbitron', sans-serif; }
.energy-bar { height: 14px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.energy-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #14f195, var(--cyan)); box-shadow: var(--glow-cyan); transition: width .4s; }
.energy-card .field-hint { margin: 8px 0 0; }

.ic { width: 15px; height: 15px; vertical-align: -2px; display: inline-block; image-rendering: auto; }
.zone-img { width: 40px; height: 40px; flex: none; image-rendering: auto; }
.w-img { width: 22px; height: 22px; }
.shop-img { width: 34px; height: 34px; }
.zone-map { display: flex; flex-direction: column; gap: 10px; }
.zone-card {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border-radius: 14px; background: var(--panel); border: 1px solid var(--border);
}
.zone-card.locked { opacity: .5; }
.zone-emoji { font-size: 34px; flex: none; }
.zone-info { flex: 1; min-width: 0; }
.zone-name { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 15px; }
.zone-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.zone-play {
  padding: 10px 16px; border-radius: 10px; border: none; cursor: pointer; font-weight: 700; font-size: 13px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta)); color: #0a0a12; box-shadow: var(--glow-cyan);
}
.zone-play:disabled { background: var(--bg); color: var(--muted); box-shadow: none; cursor: not-allowed; }

.loadout { display: flex; flex-wrap: wrap; gap: 8px; }
.weapon-chip {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px;
  background: var(--panel); border: 2px solid var(--border); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px;
}
.weapon-chip.active { box-shadow: 0 0 10px currentColor; }
.w-emoji { font-size: 18px; }
.stat-summary { width: 100%; font-size: 12px; color: var(--muted); padding: 6px 2px; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shop-item {
  padding: 14px; border-radius: 14px; text-align: center;
  background: var(--panel); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.shop-emoji { font-size: 30px; }
.shop-name { font-weight: 700; font-size: 14px; }
.shop-stat { font-size: 11px; color: var(--muted); min-height: 26px; }
.shop-buy {
  margin-top: 6px; padding: 8px 14px; border-radius: 8px; border: none; cursor: pointer;
  font-weight: 700; font-size: 13px; background: var(--gold); color: #0a0a12;
}
.shop-buy:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; border: 1px solid var(--border); }

/* ===== Battle overlay ===== */
.battle-overlay { position: fixed; inset: 0; z-index: 100; background: #0d0d14; touch-action: none; }
.phaser-parent { position: absolute; inset: 0; touch-action: none; }
.phaser-parent canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.battle-flee {
  position: absolute; bottom: 44px; left: 18px; z-index: 101;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--magenta);
  background: rgba(13,13,20,.7); color: var(--magenta); font-weight: 700; cursor: pointer;
}
.battle-melee {
  position: absolute; right: 22px; bottom: 40px; z-index: 101;
  width: 68px; height: 68px; border-radius: 50%; font-size: 30px;
  border: 2px solid var(--gold); background: rgba(255,212,71,.15); color: #fff;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none;
  box-shadow: var(--glow-gold);
}
.battle-melee:active { background: rgba(255,212,71,.4); }
.battle-dash {
  position: absolute; right: 100px; bottom: 46px; z-index: 101;
  width: 56px; height: 56px; border-radius: 50%; font-size: 26px;
  border: 2px solid var(--cyan); background: rgba(0,229,255,.15); color: #fff;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none;
  box-shadow: var(--glow-cyan); display: grid; place-items: center;
}
.battle-dash:active { background: rgba(0,229,255,.4); }
.battle-result {
  position: absolute; inset: 0; z-index: 102; display: grid; place-items: center;
  background: rgba(5,5,10,.85); backdrop-filter: blur(6px); text-align: center; padding: 20px;
}
.battle-result h2 { font-family: 'Orbitron', sans-serif; font-size: 26px; margin: 10px 0; }
.battle-result p { color: var(--muted); white-space: pre-line; margin-bottom: 18px; }
.result-emoji { font-size: 70px; animation: burst .6s; }

/* ===== Tabbar ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(13,13,20,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 1; padding: 6px; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 11px; font-weight: 600; transition: color .15s;
}
.tab-btn span { font-size: 20px; transition: transform .15s; }
.tab-btn.active { color: var(--cyan); }
.tab-btn.active span { transform: translateY(-2px); filter: drop-shadow(var(--glow-cyan)); }

/* ===== Modals ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 20px;
  background: rgba(5,5,10,.8); backdrop-filter: blur(6px);
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 400px; padding: 26px;
  max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(135deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: 20px; text-align: center;
  animation: rise .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes rise { from { transform: translateY(20px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { font-family: 'Orbitron', sans-serif; margin-bottom: 14px; }
.modal p { color: var(--muted); font-size: 14px; margin: 10px 0; }
.modal.levelup { border-color: var(--gold); box-shadow: var(--glow-gold); }
.modal.boss-win { border-color: var(--magenta); box-shadow: var(--glow-mag); }
.levelup-burst, .boss-win-emoji { font-size: 56px; animation: burst .6s; }
@keyframes burst {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.levelup-num {
  font-family: 'Orbitron', sans-serif; font-size: 60px; font-weight: 900;
  color: var(--gold); text-shadow: var(--glow-gold); margin: 6px 0;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* Settings fields */
.field-label { display: block; text-align: left; font-weight: 700; font-size: 13px; margin: 14px 0 6px; }
.field-hint { text-align: left; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.field-hint code { color: var(--cyan); }
.code-row { display: flex; gap: 8px; }
.code-row input {
  flex: 1; padding: 10px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
}
.code-row input:focus { border-color: var(--cyan); }
.sync-status { font-size: 12px; margin-top: 8px; text-align: left; color: var(--muted); }
.theme-row { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-swatch {
  width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border); position: relative;
}
.theme-swatch.active { border-color: var(--gold); box-shadow: var(--glow-gold); }
.theme-swatch.locked::after { content: '🔒'; position: absolute; inset: 0; display: grid; place-items: center; }

/* ===== FX layer (floating numbers / crit) ===== */
.fx-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.fx-float {
  position: absolute; font-family: 'Orbitron', sans-serif; font-weight: 900;
  font-size: 22px; color: var(--cyan); text-shadow: 0 0 10px currentColor, 0 2px 4px #000;
  animation: floatUp 1.1s ease-out forwards;
}
.fx-float.crit { font-size: 30px; color: var(--gold); }
.fx-float.mega { font-size: 38px; color: var(--magenta); }
@keyframes floatUp {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  20% { transform: translateY(-14px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-90px) scale(1); opacity: 0; }
}
.fx-confetti {
  position: absolute; width: 9px; height: 9px; border-radius: 2px;
  animation: confetti 1.6s ease-in forwards;
}
@keyframes confetti {
  0% { transform: translateY(-10px) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ===== Desktop ===== */
@media (min-width: 720px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .tabbar {
    top: 0; bottom: auto; max-width: 900px; margin: 0 auto; left: 0; right: 0;
    justify-content: center; gap: 8px; border-top: none;
    background: transparent; backdrop-filter: none; position: static;
    padding: 8px 16px 0;
  }
  body { padding-bottom: 20px; }
  .tab-btn { flex: none; flex-direction: row; padding: 8px 18px; border-radius: 10px; }
  .tab-btn.active { background: var(--panel); border: 1px solid var(--border); }
}

/* ===== Kleine Handys: Header kompakt, kein Overflow ===== */
@media (max-width: 430px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .hud { gap: 6px; }
  .hud-xpbar { display: none; }        /* Dashboard hat große XP-Bar */
  .hud-item { padding: 4px 7px; font-size: 13px; }
  .brand-name { font-size: 16px; }
  .content { padding: 14px 12px 130px; }
  .hero-card { padding: 14px; gap: 12px; }
  .hero-avatar { width: 58px; height: 58px; font-size: 34px; }
}
@media (max-width: 360px) {
  .brand-name { font-size: 15px; }
  .hud-item { padding: 3px 6px; font-size: 12px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
