/* ═══ THE GUILDMASTER — SNES menu aesthetic ═══════════════════════════════════
   Design language: early-90s JRPG menu system (FF/DQ style).
   Rules: hard edges (no radius except the classic slight window rounding),
   flat colors from a small palette, double-bordered "windows", segmented
   bars, blinking ▶ selection cursor, bevel buttons. */

/* ─── Palette & fonts ────────────────────────────────────────────────────────── */
:root {
  --bg:          #000010;
  --window-top:  #2a347e;
  --window-bot:  #141c54;
  --window-dark: #0a0e2e;   /* header/nav/inset fills */
  --border-lite: #e8e8e8;   /* the white window frame */
  --text:        #f0f0f0;
  --text-dim:    #9aa2d0;
  --text-hi:     #ffffff;
  --gold:        #f8d020;
  --gold-dim:    #b09010;
  --hp:          #e84040;
  --hp-bg:       #380810;
  --xp:          #3cbcfc;
  --xp-bg:       #041838;
  --streak:      #f87838;
  --success:     #58d854;
  --success-bg:  #0a2c0a;
  --danger:      #f83800;
  --font-pixel:  'Press Start 2P', monospace;
  --font-body:   'VT323', monospace;
}

/* ─── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.35;
  min-height: 100vh;
  -webkit-font-smoothing: none;
}

/* CRT scanlines — subtle, sits above everything, never intercepts input */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.14) 0 1px, transparent 1px 3px);
}

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

input, textarea, select {
  font-family: var(--font-body);
  font-size: 18px;
  background: #000;
  border: 2px solid var(--border-lite);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 0;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }

/* ─── The window — every panel is one of these ──────────────────────────────── */
.window, .panel {
  background: linear-gradient(180deg, var(--window-top) 0%, var(--window-bot) 100%);
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 16px;
}
.window-dark {
  background: var(--window-dark);
}
.panel-title, .window-title {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 14px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000;
}

/* ─── Blinking selection cursor ─────────────────────────────────────────────── */
@keyframes cursor-blink { 50% { opacity: 0; } }
.cursor-target { position: relative; }
.cursor-target::before {
  content: '▶';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 14px;
  opacity: 0;
  text-shadow: 1px 1px 0 #000;
}
.cursor-target:hover::before,
.cursor-target:focus-within::before {
  opacity: 1;
  animation: cursor-blink 0.8s steps(1) infinite;
}
.cursor-target:hover { background-color: rgba(248, 208, 32, 0.08); }

/* ─── Segmented stat bars ───────────────────────────────────────────────────── */
.stat-bar {
  height: 14px;
  border: 2px solid #000;
  position: relative;
  overflow: hidden;
  border-radius: 0;
}
.stat-bar::after {          /* the segment notches */
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(0,0,0,0.45) 7px 9px);
  pointer-events: none;
}
.stat-bar.hp-bar { background: var(--hp-bg); }
.stat-bar.xp-bar { background: var(--xp-bg); }
.stat-bar-fill {
  height: 100%;
  border-radius: 0;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.35);
  transition: width 0.5s steps(10);
}
.stat-bar.hp-bar .stat-bar-fill { background: var(--hp); }
.stat-bar.xp-bar .stat-bar-fill { background: var(--xp); }

.stat-bar-wrap { margin-bottom: 10px; }
.stat-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.stat-bar-label strong { color: var(--text); }

/* white flash when a bar takes a hit */
@keyframes bar-hit-flash { 0%, 40% { filter: brightness(3) saturate(0); } 100% { filter: none; } }
.bar-hit .stat-bar-fill, .bar-hit.bs-fill, .bar-hit .bs-fill { animation: bar-hit-flash 0.45s steps(2); }

/* ─── Bevel buttons ─────────────────────────────────────────────────────────── */
.btn {
  border: 2px solid #000;
  border-radius: 0;
  padding: 8px 18px;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: #3048a8;
  color: #fff;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.45), inset 3px 3px 0 rgba(255,255,255,0.3);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
}
.btn:active {
  box-shadow: inset 3px 3px 0 rgba(0,0,0,0.45);
  transform: translate(1px, 1px);
}
.btn-primary   { background: var(--gold); color: #000; text-shadow: none; }
.btn-secondary { background: #3048a8; }
.btn-danger    { background: var(--danger); }
.btn-success   { background: var(--success); color: #000; text-shadow: none; }
.btn-sm        { padding: 4px 10px; font-size: 16px; }
.btn:disabled  { opacity: 0.4; cursor: not-allowed; }

/* ─── Tags ──────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 2px solid;
  border-radius: 0;
  font-size: 15px;
  background: #000;
}
.tag-gold    { color: var(--gold);   border-color: var(--gold-dim); }
.tag-streak  { color: var(--streak); border-color: var(--streak); }
.tag-success { color: var(--success); border-color: var(--success); }
.tag-muted   { color: var(--text-dim); border-color: var(--text-dim); }

/* ─── Loading ───────────────────────────────────────────────────────────────── */
#loading-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100vh; gap: 20px;
}
.loading-title {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
  animation: pulse 2s infinite;
}
.loading-sub { color: var(--text-dim); font-size: 18px; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* ─── Login / access screens ────────────────────────────────────────────────── */
#login-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-title {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 10px;
  text-align: center;
}
.login-sub { color: var(--text-dim); font-size: 18px; margin-bottom: 28px; text-align: center; }
.player-cards { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; max-width: 620px; }
.player-card-select {
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 18px 26px 18px 34px;
  cursor: pointer;
  min-width: 210px;
  text-align: center;
}
.player-card-select .pc-name {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 2px 2px 0 #000;
}
.player-card-select .pc-level { color: var(--text-dim); font-size: 16px; margin-bottom: 12px; }
.mini-bar {
  height: 8px;
  border: 2px solid #000;
  background: var(--hp-bg);
  overflow: hidden;
  margin-bottom: 4px;
  position: relative;
}
.mini-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(0,0,0,0.45) 5px 6px);
}
.mini-bar-fill { height: 100%; }
.mini-bar.hp .mini-bar-fill { background: var(--hp); }
.mini-bar.xp { background: var(--xp-bg); }
.mini-bar.xp .mini-bar-fill { background: var(--xp); }

/* ─── App shell / header ────────────────────────────────────────────────────── */
#app-shell { display: flex; flex-direction: column; min-height: 100vh; }

#header {
  background: var(--window-dark);
  border-bottom: 3px solid var(--border-lite);
  box-shadow: 0 2px 0 #000;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  flex-shrink: 0;
}
.header-title {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--gold);
  white-space: nowrap;
  text-shadow: 2px 2px 0 #000;
}
.header-spacer { flex: 1; }
.header-player { font-size: 17px; color: var(--text-dim); }
.header-player strong { color: var(--gold); }
.btn-logout, .btn-sound {
  background: #000;
  border: 2px solid var(--text-dim);
  color: var(--text-dim);
  padding: 3px 10px;
  font-size: 16px;
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }
.btn-sound:hover  { color: var(--gold); border-color: var(--gold); }

/* ─── Content ───────────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  padding: 18px 14px 100px;   /* bottom padding clears the fixed nav */
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Bottom nav — 4 fixed command tabs ─────────────────────────────────────── */
#bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--window-dark);
  border-top: 3px solid var(--border-lite);
  box-shadow: 0 -2px 0 #000;
  display: flex;
  z-index: 50;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
}
.bnav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 6px;
}
.bnav-btn .bnav-icon  { font-size: 20px; line-height: 1; }
.bnav-btn .bnav-label { font-family: var(--font-pixel); font-size: 8px; letter-spacing: 1px; }
.bnav-btn.active { color: var(--gold); }
.bnav-btn.active .bnav-label::before { content: '▶ '; animation: cursor-blink 0.8s steps(1) infinite; }

/* ─── Today screen ──────────────────────────────────────────────────────────── */
.today-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}
.th-avatar {
  width: 56px; height: 56px;
  background: #000;
  border: 2px solid var(--border-lite);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.th-info { flex: 1; min-width: 0; }
.th-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.th-name { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.th-lvl  { font-size: 17px; color: var(--text); }
.th-streak { font-size: 17px; color: var(--streak); margin-left: auto; }
.th-bars { display: flex; flex-direction: column; gap: 5px; }
.th-bar  { display: flex; flex-direction: column; gap: 2px; }
.th-bar span { font-size: 15px; color: var(--text-dim); }
.th-bar .stat-bar { height: 10px; }

.today-list-head {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin: 0 4px 8px;
  text-shadow: 1px 1px 0 #000;
}
.today-list { display: flex; flex-direction: column; gap: 8px; }
.today-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 10px 12px 10px 26px;
}
/* Logged today — clearly done (green edge + tint) but NOT dimmed, since it
   stays re-loggable. */
.today-row.done { border-color: var(--success); background: linear-gradient(180deg, #17361b, #0e2413); }
.done-tag { color: var(--success); }
/* The repeat "+ LOG" button is de-emphasized vs a first-time gold LOG so the eye
   goes to un-logged habits first, but it's still clearly tappable. */
.btn-log-quick.again {
  background: #000;
  color: var(--gold);
  border: 2px solid var(--gold-dim);
  box-shadow: none;
}
.today-emoji { font-size: 22px; flex-shrink: 0; }

/* ─── Sprite icons (Higgsfield 16-bit set) — sized per context ──────────────── */
.spr { display: inline-block; vertical-align: middle; }
.today-emoji  .spr-cat { width: 34px; height: 34px; display: block; }
.habit-row-emoji .spr-cat { width: 30px; height: 30px; display: block; }
.stat-bar-label .spr-cat { width: 22px; height: 22px; vertical-align: -5px; }
.bnav-icon .spr-nav { width: 30px; height: 30px; display: block; }

/* Inline UI icons (streak, freeze, assist, badge, level) — sit next to numbers */
.spr-ic { width: 1.25em; height: 1.25em; vertical-align: -0.28em; }
.cmd-icon .spr-ic  { width: 26px; height: 26px; vertical-align: middle; }
.panel-title .spr-ic { width: 14px; height: 14px; vertical-align: -2px; }
/* Character portraits fill their avatar/dialogue frame */
.spr-portrait { width: 100%; height: 100%; object-fit: cover; display: block; }
.today-name { flex: 1; font-size: 20px; color: var(--text-hi); min-width: 0; }
.today-meta { display: block; font-size: 14px; color: var(--text-dim); }

.btn-log-quick {
  background: var(--gold);
  color: #000;
  border: 2px solid #000;
  padding: 8px 18px;
  font-size: 17px;
  font-family: var(--font-pixel);
  font-size: 10px;
  min-width: 64px;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.35), inset 3px 3px 0 rgba(255,255,255,0.45);
}
.btn-log-quick:active { box-shadow: inset 3px 3px 0 rgba(0,0,0,0.35); transform: translate(1px,1px); }
.btn-log-quick:disabled { opacity: 0.35; cursor: not-allowed; }

/* Today boss banner — a compact art card (was a thin 40px-thumbnail strip).
   Shows the battle scene edge-to-edge with the name + HP bar overlaid, so the
   boss is actually visible without pushing the habit list off-screen. */
.boss-strip {
  position: relative;
  margin-top: 16px;
  height: 108px;
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  overflow: hidden;
  cursor: pointer;
  background: #000;
}
.bs-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;        /* bias up toward the boss in the scene */
  image-rendering: pixelated;
}
.bs-scrim {                            /* keeps overlaid text legible over any art */
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,16,0.55) 0%, rgba(0,0,16,0) 34%, rgba(0,0,16,0.88) 100%);
}
.bs-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 12px;
}
.bs-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.bs-label {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000;
  white-space: nowrap;
}
.bs-name {
  font-size: 18px;
  color: var(--text-hi);
  text-shadow: 1px 1px 0 #000, 0 0 6px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bs-bottom { display: flex; align-items: center; gap: 8px; }
.bs-bar {
  flex: 1;
  height: 13px;
  border: 2px solid #000;
  background: var(--hp-bg);
  overflow: hidden;
  position: relative;
}
.bs-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(0,0,0,0.45) 7px 9px);
  pointer-events: none;
}
.bs-fill {
  height: 100%;
  background: var(--hp);
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.35);
  transition: width 0.6s steps(8);
}
.bs-hp {
  font-size: 15px;
  color: var(--text-hi);
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}
.bs-defeated {
  color: var(--success);
  font-family: var(--font-pixel);
  font-size: 10px;
  text-shadow: 2px 2px 0 #000;
}
.bs-noart {                            /* fallback when a boss has no art */
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
}
.bs-noart .bs-scrim { display: none; }

/* ─── Toast (result window) ─────────────────────────────────────────────────── */
#toast-stack {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 520px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 12px 14px;
  animation: window-in 0.15s steps(3);
  pointer-events: auto;
}
@keyframes window-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
.toast-err { display: flex; align-items: center; gap: 10px; }
.toast-row { display: flex; align-items: flex-start; gap: 10px; }
.toast-main { flex: 1; font-size: 18px; color: var(--text-hi); }
.toast-x {
  background: none; border: none; color: var(--text-dim);
  font-size: 18px; line-height: 1; padding: 2px 6px; flex-shrink: 0;
}
.toast-x:hover { color: var(--danger); }
.toast-events { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.toast-chip {
  font-size: 15px;
  background: #000;
  border: 2px solid var(--gold-dim);
  color: var(--gold);
  padding: 1px 7px;
}
.toast-actions { display: flex; gap: 8px; margin-top: 10px; }
.toast-btn {
  background: #000;
  border: 2px solid var(--text-dim);
  color: var(--text);
  padding: 5px 12px;
  font-size: 16px;
  text-transform: uppercase;
}
.toast-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ─── Guildmaster dialogue box ──────────────────────────────────────────────── */
#dialogue {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 640px;
  z-index: 65;
}
#dialogue:empty { display: none; }
.dlg-window {
  display: flex;
  gap: 12px;
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 14px;
  cursor: pointer;
  animation: window-in 0.15s steps(3);
}
.dlg-portrait {
  width: 56px; height: 56px;
  background: #000;
  border: 2px solid var(--border-lite);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  flex-shrink: 0;
}
.dlg-body { flex: 1; min-width: 0; }
.dlg-name {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--gold);
  margin-bottom: 6px;
  text-shadow: 2px 2px 0 #000;
}
.dlg-text {
  font-size: 20px;
  line-height: 1.3;
  color: var(--text-hi);
  min-height: 52px;
  white-space: pre-wrap;
  position: relative;
}
.dlg-sizer { visibility: hidden; }        /* reserves the full-quote height up front */
.dlg-typed { position: absolute; inset: 0; }
.dlg-caret {
  text-align: right;
  color: var(--gold);
  font-size: 16px;
  height: 16px;
  line-height: 1;
}
.dlg-caret.on { animation: cursor-blink 0.7s steps(1) infinite; }

/* ─── Floating damage / XP numbers & level-up banner ────────────────────────── */
.dmg-float {
  position: fixed;
  z-index: 250;
  font-family: var(--font-pixel);
  font-size: 15px;
  pointer-events: none;
  text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
  animation: dmg-rise 2s steps(14) forwards;
  white-space: nowrap;
}
.dmg-float.big { font-size: 24px; }    /* boss damage — the headline number */
.dmg-float.dmg   { color: var(--hp); }
.dmg-float.xp    { color: var(--xp); }
.dmg-float.gold  { color: var(--gold); }
.dmg-float.green { color: var(--success); }
/* pop in oversized, settle, hold readable, then drift up and fade */
@keyframes dmg-rise {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.4); }
  8%   { opacity: 1; transform: translate(-50%, -4px) scale(1.35); }
  18%  { transform: translate(-50%, -8px) scale(1); }
  70%  { opacity: 1; transform: translate(-50%, -20px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -64px) scale(1); }
}

/* impact shake for the element that took the hit */
.hit-shake { animation: hit-shake 0.4s steps(2); }
@keyframes hit-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

#levelup-banner {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 260;
  font-family: var(--font-pixel);
  font-size: 22px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000, 0 0 24px var(--gold-dim);
  pointer-events: none;
  animation: banner-flash 2.2s steps(6) forwards;
  white-space: nowrap;
}
@keyframes banner-flash {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.6); }
  15%  { opacity: 1; transform: translateX(-50%) scale(1.15); }
  25%  { transform: translateX(-50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ─── Battle screen ─────────────────────────────────────────────────────────── */
.bt-scene {
  text-align: center;
  padding: 22px 16px;
  margin-bottom: 14px;
  position: relative;
}
/* The boss art is a full 16:9 battle scene (name banner included in the art) —
   bleed it to the window frame like a JRPG battle screen. */
.bt-backdrop {
  display: block;
  width: calc(100% + 32px);          /* counter .bt-scene's 16px side padding */
  margin: -22px -16px 14px;          /* counter .bt-scene's 22px top padding  */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  max-height: 400px;
  image-rendering: pixelated;
  border-radius: 3px 3px 0 0;        /* hug the window's inner corner radius  */
  border-bottom: 3px solid var(--border-lite);
  background: #000;
}
.bt-sprite-fallback { font-size: 56px; margin-bottom: 10px; }
.bt-name {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--text-hi);
  margin-bottom: 6px;
  text-shadow: 2px 2px 0 #000;
}
.bt-flavor { font-size: 16px; color: var(--text-dim); font-style: italic; margin-bottom: 12px; }
.bt-hp-label { font-size: 17px; margin-bottom: 4px; }
.bt-hp-label .hp-val { color: var(--hp); font-weight: bold; }
.bt-hp-bar {
  height: 16px;
  border: 2px solid #000;
  background: var(--hp-bg);
  overflow: hidden;
  position: relative;
  max-width: 420px;
  margin: 0 auto 8px;
}
.bt-hp-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 8px, rgba(0,0,0,0.45) 8px 10px);
  pointer-events: none;
}
.bt-hp-fill {
  height: 100%;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.35);
  transition: width 0.6s steps(8);
}
.bt-week { font-size: 15px; color: var(--text-dim); }
.bt-defeated {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--success);
  border: 2px solid var(--success);
  background: #000;
  padding: 6px 10px;
  display: inline-block;
  margin-top: 6px;
}
.bt-cooldown {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--gold);
  border: 2px solid var(--gold-dim);
  background: #000;
  padding: 6px 10px;
  display: inline-block;
  margin-top: 8px;
}

/* FF-style party status rows */
.ps-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 8px 24px;
  border-bottom: 2px solid rgba(0,0,0,0.4);
  font-size: 19px;
}
.ps-row:last-child { border-bottom: none; }
.ps-name { width: 130px; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-name small { color: var(--text-dim); font-size: 14px; }
.ps-bars { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 100px; }
.ps-bars .stat-bar { height: 9px; }
.ps-meta { font-size: 15px; color: var(--text-dim); white-space: nowrap; }

/* command / item rows */
.cmd-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px 10px 26px;
  border-bottom: 2px solid rgba(0,0,0,0.4);
}
.cmd-row:last-child { border-bottom: none; }
.cmd-icon { font-size: 24px; flex-shrink: 0; }
.cmd-body { flex: 1; }
.cmd-name { font-size: 19px; color: var(--text-hi); }
.cmd-desc { font-size: 15px; color: var(--text-dim); }

/* ─── Leaderboard ───────────────────────────────────────────────────────────── */
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th {
  text-align: left;
  padding: 8px 10px;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  border-bottom: 2px solid #000;
  font-weight: normal;
  white-space: nowrap;
  letter-spacing: 1px;
}
.leaderboard-table td {
  padding: 10px;
  border-bottom: 2px solid rgba(0,0,0,0.4);
  font-size: 18px;
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr.me td { background: rgba(248,208,32,0.07); }
.rank-num { font-family: var(--font-pixel); font-size: 10px; color: var(--text-dim); }
.rank-num.top1 { color: var(--gold); }
.rank-num.top2 { color: #b8bce0; }
.rank-num.top3 { color: #b87c44; }
.lb-name { font-weight: bold; color: var(--text-hi); }
.lb-level { color: var(--gold); font-family: var(--font-pixel); font-size: 11px; }
.lb-streak { color: var(--streak); }
.lb-hp-bar-wrap { width: 80px; }
.lb-hp-num { font-size: 14px; color: var(--text-dim); }

/* ─── Conquests ─────────────────────────────────────────────────────────────── */
.conquest-section-title {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--gold);
  margin: 22px 0 12px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000;
}
.conquest-section-title:first-child { margin-top: 0; }
.conquest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.conquest-card {
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 14px;
  text-align: center;
}
.conquest-card { padding: 0 0 12px; overflow: hidden; }
.conquest-name, .conquest-tier, .conquest-meta { padding-left: 10px; padding-right: 10px; }
.conquest-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  image-rendering: pixelated;
  margin: 0 0 8px;
  display: block;
  border-bottom: 3px solid var(--border-lite);
  border-radius: 3px 3px 0 0;
}
.conquest-icon { padding-top: 12px; }
.conquest-icon { font-size: 36px; margin-bottom: 8px; }
.conquest-name { font-size: 16px; color: var(--text); margin-bottom: 2px; }
.conquest-meta { font-size: 14px; color: var(--text-dim); }
.conquest-tier { font-size: 14px; color: var(--gold-dim); }
.conquest-empty { color: var(--text-dim); font-size: 17px; padding: 16px 0; }

/* ─── Hero screen / habit management ────────────────────────────────────────── */
.player-panel-inner { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.player-avatar {
  width: 72px; height: 72px;
  background: #000;
  border: 2px solid var(--border-lite);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  flex-shrink: 0;
}
.player-info { flex: 1; min-width: 200px; }
.player-name {
  font-family: var(--font-pixel);
  font-size: 13px;
  color: var(--gold);
  margin-bottom: 4px;
  text-shadow: 2px 2px 0 #000;
}
.player-level { font-size: 17px; color: var(--text-dim); margin-bottom: 10px; }
.player-level strong { color: var(--text); }
.player-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.add-habit-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.add-habit-form .field { display: flex; flex-direction: column; gap: 3px; }
.add-habit-form label { font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.add-habit-form input, .add-habit-form select { min-width: 160px; }

.habit-list { display: flex; flex-direction: column; gap: 8px; }
.habit-row {
  background: var(--window-dark);
  border: 2px solid #000;
  padding: 10px 12px 10px 26px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.habit-row.paused { opacity: 0.55; }
.habit-row-emoji { font-size: 20px; flex-shrink: 0; }
.habit-row-info { flex: 1; min-width: 160px; }
.habit-row-name { font-size: 19px; color: var(--text-hi); }
.habit-row-meta { font-size: 14px; color: var(--text-dim); }
.habit-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.inline-edit {
  background: #000;
  border: 2px solid var(--border-lite);
  padding: 12px 14px;
  margin-bottom: 4px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,16,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: linear-gradient(180deg, var(--window-top), var(--window-bot));
  border: 3px solid var(--border-lite);
  border-radius: 6px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000;
  padding: 24px;
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: window-in 0.15s steps(3);
}
.result-title {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 16px;
  text-align: center;
  text-shadow: 2px 2px 0 #000;
}
.note-sheet textarea { width: 100%; resize: vertical; min-height: 90px; }

/* ─── Misc ──────────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; color: var(--text-dim); padding: 36px 20px; font-size: 18px; }
.empty-state big { display: block; font-size: 32px; margin-bottom: 10px; }
.divider { border: none; border-top: 2px solid #000; margin: 18px 0; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.col { flex: 1; min-width: 240px; }
.spin { animation: spin 1s steps(8) infinite; display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
