/* =========================================================================
 * Fright Estate – Stylesheet (grafikfrei: nur CSS, Text, Emoji, Unicode-Balken)
 * ========================================================================= */

:root {
  --bg:        #0d0b14;
  --bg2:       #15121f;
  --panel:     #1c1830;
  --panel2:    #241f3a;
  --ink:       #e7e2f5;
  --muted:     #9a93b8;
  --accent:    #b07cff;
  --accent2:   #6ce0c0;
  --gold:      #ffd57a;
  --good:      #6ce08a;
  --warn:      #ffcf6b;
  --danger:    #ff6b88;
  --bored:     #7c8aa8;
  --line:      #332b4a;
  --radius:    12px;
  --shadow:    0 6px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1b1530 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

.mono { font-family: "Cascadia Code", "Consolas", ui-monospace, monospace; letter-spacing: -1px; }
.hidden { display: none !important; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.bored { color: var(--bored); }
.muted { color: var(--muted); }

h1, h2 { margin: 0; font-weight: 700; }

/* ---------------- Screens ---------------- */
.screen { max-width: 1060px; margin: 0 auto; padding: 18px; }

/* ---------------- Auth ---------------- */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-box {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow); text-align: center;
}
.logo { font-size: 30px; letter-spacing: .5px; }
.tagline { color: var(--muted); margin: 6px 0 20px; font-size: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 9px; background: var(--panel2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--accent); color: #1a1030; border-color: var(--accent); font-weight: 700; }
form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
form label small { color: var(--muted); opacity: .7; }
form input {
  padding: 10px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); font-size: 15px;
}
form input:focus { outline: none; border-color: var(--accent); }
.primary {
  padding: 11px; background: linear-gradient(180deg, var(--accent), #8a52e0);
  color: #fff; border: none; border-radius: 8px; cursor: pointer;
  font-size: 15px; font-weight: 700; margin-top: 4px;
}
.primary:hover { filter: brightness(1.08); }
.error { color: var(--danger); font-size: 13px; margin: 12px 0 0; }
.hint { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px;
}
.brand { font-weight: 700; font-size: 17px; }
.spacer { flex: 1; }
.save-status { color: var(--muted); font-size: 12px; }
.user { font-size: 13px; color: var(--muted); }

.mini {
  padding: 6px 10px; background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer; font-size: 13px;
}
.mini:hover { border-color: var(--accent); }
.mini.danger { color: var(--danger); }

/* ---------------- Stats ---------------- */
.stats {
  display: grid; grid-template-columns: repeat(12, 1fr);
  gap: 8px; margin-bottom: 8px;
}
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
}
.stat:nth-child(-n+4) {
  grid-column: span 3;
}
.stat:nth-child(n+5) {
  grid-column: span 4;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-val { font-size: 20px; font-weight: 700; color: var(--gold); }
.stat-sub { font-size: 11px; color: var(--muted); }
.bar-wrap { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.bar-wrap .stat-val { font-size: 15px; }

/* ---------------- Buffs ---------------- */
.buffs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.buff {
  background: rgba(176,124,255,.16); border: 1px solid var(--accent);
  color: var(--ink); padding: 5px 10px; border-radius: 20px; font-size: 12px;
}

/* ---------------- Board ---------------- */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.col { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.panel h2 { font-size: 14px; color: var(--accent2); margin-bottom: 10px; }

.list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.empty { color: var(--muted); font-size: 13px; font-style: italic; margin: 6px 0; }

.row {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px;
}
.row .ic { font-size: 18px; }
.row .nm { font-weight: 600; }
.row .nm small { color: var(--muted); font-weight: 400; font-size: 12px; }
.row .meta { color: var(--muted); font-size: 11px; margin-left: auto; }
.row.ghost .meta { margin-left: auto; }
.row.ghost button { margin-left: 8px; }
.row .fear { margin-left: auto; font-size: 14px; }

/* ---------------- Cards (Shops) ---------------- */
.cards { display: flex; flex-wrap: wrap; gap: 8px; }
.card {
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 9px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 3px; min-width: 104px; flex: 1 1 104px;
  transition: border-color .12s, transform .06s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card:active { transform: translateY(0); }
.card.wide { flex-basis: 100%; flex-direction: row; align-items: center; gap: 10px; }
.card.cant { opacity: .5; }
.card.owned { opacity: .65; border-color: var(--accent2); cursor: default; }
.card-ic { font-size: 20px; }
.card-nm { font-weight: 700; font-size: 13px; }
.card-meta { font-size: 11px; color: var(--muted); }
.card-cost { font-size: 13px; font-weight: 700; color: var(--gold); }
.card.wide .card-cost { margin-left: auto; white-space: nowrap; }
.card-body { display: flex; flex-direction: column; gap: 2px; }
.card-desc { font-size: 11px; color: var(--muted); }

/* ---------------- Log ---------------- */
.logpanel { margin-top: 14px; }
.log { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; font-size: 13px; }
.log-line { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.log-n { color: var(--muted); font-size: 11px; margin-right: 6px; font-family: ui-monospace, monospace; }

/* ---------------- Overlay / Toast ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(8,6,14,.86);
  display: flex; align-items: center; justify-content: center; z-index: 30;
}
.overlay-box {
  background: var(--panel); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 32px; text-align: center; max-width: 460px;
}
.overlay-box h1 { color: var(--danger); margin-bottom: 12px; }
.overlay-box p { color: var(--muted); margin-bottom: 20px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--accent);
  color: var(--ink); padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 40; font-size: 14px;
}
.toast.error { border-color: var(--danger); }

/* ---------------- Scrollbars ---------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat.wide { grid-column: span 2; }
  .controls { flex-direction: row; grid-column: span 2; }
  .board { grid-template-columns: 1fr; }
  .ribbon { flex-wrap: wrap; }
}

/* ---------------- Tag/Nacht-Tönung des Hintergrunds ---------------- */
body[data-phase="day"]   { background: radial-gradient(1200px 600px at 50% -10%, #241b3a 0%, var(--bg) 60%); }
body[data-phase="night"] { background: radial-gradient(1200px 600px at 50% -10%, #140f28 0%, #08060f 60%); }
body[data-phase="blood"] { background: radial-gradient(1200px 600px at 50% -10%, #3a1018 0%, #0c0608 60%); }
body { transition: background .8s ease; }

/* ---------------- Statusleiste (Ribbon) ---------------- */
.ribbon {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 12px; margin-bottom: 8px;
}
.phase-badge { font-weight: 700; padding: 5px 12px; border-radius: 20px; font-size: 14px; }
.phase-badge.p-day   { background: rgba(255,213,122,.16); color: var(--gold); border: 1px solid var(--gold); }
.phase-badge.p-night { background: rgba(176,124,255,.16); color: var(--accent); border: 1px solid var(--accent); }
.phase-badge.p-blood { background: rgba(255,107,136,.18); color: var(--danger); border: 1px solid var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.ribbon-day { color: var(--muted); font-size: 14px; }
.ribbon-day b { color: var(--ink); }
.ribbon-progress { margin-left: auto; font-size: 17px; letter-spacing: 2px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; border: 1px solid var(--line); background: var(--panel2); }
.badge.blood { color: var(--danger); border-color: var(--danger); }
.badge.legacy { color: var(--accent2); border-color: var(--accent2); }

.stat-val.small { font-size: 14px; }

/* ---------------- Geister-Level / Aufrüsten ---------------- */
.lvl { font-size: 10px; background: var(--accent); color: #1a1030; padding: 1px 5px; border-radius: 6px; font-weight: 700; vertical-align: middle; }
.mini.up { color: var(--accent2); border-color: var(--accent2); white-space: nowrap; }
.mini.up.cant { opacity: .4; }
.row.ghost .meta { margin-left: 6px; font-size: 11px; }
.row.ghost button { margin-left: 6px; }

/* ---------------- VIP-Gast ---------------- */
.row.visitor.vip { border-color: var(--gold); background: linear-gradient(90deg, rgba(255,213,122,.12), var(--panel2)); }
.row.visitor.vip .nm { color: var(--gold); }
.row.visitor .mood { margin-left: auto; font-size: 12px; white-space: nowrap; }
.row.visitor .fear { margin-left: 8px; }

/* ---------------- Prestige-Karte ---------------- */
.card.prestige { border-color: var(--accent2); }
.card.prestige .card-cost { color: var(--accent2); }

/* ---------------- Achievements-Modal ---------------- */
.wide-box { max-width: 560px; width: 100%; text-align: left; }
.achv-list { display: flex; flex-direction: column; gap: 7px; max-height: 50vh; overflow-y: auto; margin: 14px 0; }
.achv { display: flex; align-items: center; gap: 11px; padding: 8px 11px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; }
.achv.got { border-color: var(--gold); }
.achv.locked { opacity: .5; }
.achv-ic { font-size: 20px; }
.achv-body { display: flex; flex-direction: column; }
.achv-body small { color: var(--muted); font-size: 12px; }
.achv-stat { margin-left: auto; color: var(--good); font-weight: 700; }

/* ---------------- Tutorial ---------------- */
.overlay-box p { line-height: 1.5; }
.tut-dots { display: flex; gap: 7px; justify-content: center; margin: 18px 0; }
.tut-dots .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.tut-dots .dot.on { background: var(--accent); }
.tut-nav { display: flex; align-items: center; gap: 8px; }
.tut-nav .spacer { flex: 1; }
.tut-nav .primary { padding: 9px 18px; }

/* ---------------- Zimmer-Panel ---------------- */
.room { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; }
.room.collapsed { opacity: .6; border-color: var(--danger); }
.room-head { display: flex; align-items: center; gap: 8px; }
.room-head b { font-size: 13px; }
.room-head small { color: var(--muted); }
.room-ic { font-size: 16px; }
.room-cond { margin-left: auto; font-size: 12px; white-space: nowrap; }
.room-head .mini { margin-left: 4px; padding: 3px 7px; }
.room-body { display: flex; gap: 12px; margin-top: 5px; font-size: 12px; flex-wrap: wrap; }
.room-occ { font-weight: 600; }
.room-ghosts { color: var(--muted); }

/* ---------------- Geister-Raum-Zuweisung ---------------- */
.row.ghost { flex-wrap: wrap; }
.assign {
  flex-basis: 100%;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.assign-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.assign-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rbtn { background: var(--bg2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; cursor: pointer; font-size: 11px; min-width: 22px; }
.rbtn:hover { border-color: var(--accent); }
.rbtn.on { background: var(--accent); color: #1a1030; border-color: var(--accent); font-weight: 700; }

/* ---------------- Saison / Wettervorhersage ---------------- */
.badge.next { color: var(--muted); }
.badge.season { color: var(--muted); }
.badge.season.special { color: var(--accent2); border-color: var(--accent2); }

/* ---------------- Synergien ---------------- */
.syn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.syn { background: rgba(108,224,192,.14); border: 1px solid var(--accent2); color: var(--accent2); padding: 3px 9px; border-radius: 20px; font-size: 11px; }

/* ---------------- Aufträge / Quests ---------------- */
.quest { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; }
.quest-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.quest-reward { margin-left: auto; color: var(--gold); font-size: 12px; white-space: nowrap; }
.quest-desc { color: var(--muted); font-size: 12px; margin: 2px 0 4px; }
.quest-prog { font-size: 12px; }

/* ---------------- Statistik-Modal ---------------- */
.stat-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.stat-line .stat-k { flex: 0 0 150px; font-size: 13px; color: var(--muted); }
.stat-line .spark { font-size: 16px; letter-spacing: 1px; flex: 1; }
.stat-line .stat-v { font-weight: 700; color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 16px; text-align: center; }
.stat-grid > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 6px; font-size: 12px; color: var(--muted); }
.stat-grid b { color: var(--ink); font-size: 16px; }

/* ---------------- Geister-Fähigkeiten & Forschung ---------------- */
.mini.ability-btn {
  transition: all 0.15s ease;
}
.mini.ability-btn.ready {
  border-color: var(--accent2);
  background: rgba(108, 224, 192, 0.12);
  font-weight: 700;
}
.mini.ability-btn.ready:hover {
  background: rgba(108, 224, 192, 0.28);
  box-shadow: 0 0 8px rgba(108, 224, 192, 0.45);
}
.mini.ability-btn.cant {
  opacity: 0.4;
  cursor: not-allowed;
}
.card.research {
  flex-basis: calc(50% - 4px);
  min-width: 180px;
}
.card.research.owned {
  border-color: var(--good);
  background: rgba(108, 224, 138, 0.1);
  cursor: default;
  transform: none;
}
.card.research.locked {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* =========================================================================
   RESPONSIVE & MOBILE OPTIMIZATIONS (20 Improvements)
   ========================================================================= */

/* Fluid Typography */
body {
  font-size: clamp(13px, 2.5vw, 15px) !important;
}
.stat-val {
  font-size: clamp(16px, 4vw, 20px) !important;
}

/* Default bottom nav hidden on desktop */
.mobile-only-nav {
  display: none;
}

/* Visitor mood outline indicators */
.row.visitor .ic {
  border-radius: 50%;
  padding: 2px;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}
.row.visitor.bored .ic {
  border-color: var(--bored) !important;
  background: rgba(124, 138, 168, 0.15);
}
.row.visitor.good .ic {
  border-color: var(--good) !important;
  background: rgba(108, 224, 138, 0.15);
}
.row.visitor.danger .ic {
  border-color: var(--danger) !important;
  background: rgba(255, 107, 136, 0.15);
}

@media (max-width: 860px) {
  /* OLED Black backgrounds during night/bloodmoon */
  body[data-phase="night"] {
    background: #000000 !important;
  }
  body[data-phase="blood"] {
    background: radial-gradient(1200px 600px at 50% -10%, #220005 0%, #000000 60%) !important;
  }

  /* Body padding for fixed nav at bottom */
  body {
    padding-bottom: 74px !important;
  }

  /* Bottom tab navigation styling */
  .mobile-only-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-top: 1px solid var(--line);
    z-index: 1000;
    height: 58px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    justify-content: space-around;
  }

  .mobile-only-nav .nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 6px 0;
    transition: all 0.15s ease;
    outline: none;
    height: 100%;
  }

  .mobile-only-nav .nav-tab.active {
    color: var(--accent);
    background: rgba(176, 124, 255, 0.08);
  }

  .mobile-only-nav .nav-tab .tab-label {
    font-size: 9px;
    margin-top: 2px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
  }

  /* Tabbing Visibility Engine: hide all panels under tabbing */
  #game-screen[data-active-tab] .panel {
    display: none !important;
  }

  /* Show only panels matching the active tab */
  #game-screen[data-active-tab="zimmer"] .panel-zimmer,
  #game-screen[data-active-tab="zimmer"] .panel-building {
    display: block !important;
  }

  #game-screen[data-active-tab="geister"] .panel-ghosts,
  #game-screen[data-active-tab="geister"] .panel-summon {
    display: block !important;
  }

  #game-screen[data-active-tab="gaeste"] .panel-visitors,
  #game-screen[data-active-tab="gaeste"] .panel-quests {
    display: block !important;
  }

  #game-screen[data-active-tab="laden"] .panel-staff,
  #game-screen[data-active-tab="laden"] .panel-artifacts,
  #game-screen[data-active-tab="laden"] .panel-prestige {
    display: block !important;
  }

  #game-screen[data-active-tab="log"] .panel-log {
    display: block !important;
  }

  /* Horizontal Karussell Scrolling only for Summon Cards */
  #summon-list.cards {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    gap: 8px;
    scrollbar-width: none; /* Firefox */
  }
  #summon-list.cards::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  #summon-list .card {
    flex: 0 0 140px !important;
    scroll-snap-align: start;
  }

  /* Bottom Sheet Modals on Mobile */
  .overlay {
    align-items: flex-end !important;
  }
  .overlay-box {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    border-bottom: none !important;
    margin-bottom: 0 !important;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(100%);
    animation: slideUp 0.28s cubic-bezier(0.1, 0.76, 0.55, 0.94) forwards;
  }
  .overlay-box.wide-box {
    max-width: 100% !important;
  }
  @keyframes slideUp {
    to { transform: translateY(0); }
  }

  /* Touch Target sizes (Fitts's Law) */
  button, .mini, .rbtn {
    min-height: 42px;
    min-width: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px !important;
  }
  .rbtn {
    min-width: 34px;
    min-height: 34px;
  }
  .dec-buy-btn {
    min-width: 32px;
    min-height: 32px;
    font-size: 12px !important;
  }

  /* Enforce horizontal boundaries on mobile viewport */
  html, body, #game-screen {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  /* Touch layout compact paddings and shrink enforcement */
  .board, .col, .panel, .list, .row {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .row {
    padding: 10px 12px !important;
    width: 100% !important;
  }
  .row.ghost .meta {
    margin-left: auto;
    flex-basis: 100%;
    margin-top: 6px;
    text-align: right;
  }
  .assign {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }
  .assign-buttons {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
  }

  /* Exorzist sticky banner */
  #exorcist-alert {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    margin-bottom: 0 !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
  }

  /* Compact upper area & stats grid on mobile */
  .topbar {
    padding: 6px 10px !important;
    margin-bottom: 6px !important;
    gap: 8px !important;
  }
  .user, .save-status {
    display: none !important; /* Hide non-critical header items on mobile */
  }
  .ribbon {
    padding: 4px 10px !important;
    margin-bottom: 6px !important;
    gap: 6px !important;
    font-size: 12px !important;
  }
  .phase-badge {
    padding: 3px 8px !important;
    font-size: 11px !important;
  }
  .badge {
    padding: 2px 6px !important;
    font-size: 11px !important;
  }
  .ribbon-progress {
    font-size: 13px !important;
  }
  .stats {
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 6px !important;
  }
  .stat {
    padding: 6px 8px !important;
    border-radius: 8px !important;
    gap: 1px !important;
  }
  .stat-val {
    font-size: 15px !important;
  }
  .bar-wrap {
    font-size: 11px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
  }
  .bar-wrap .mono {
    font-size: 10px !important;
    letter-spacing: -1.5px !important;
  }

  /* Details Modal Mobile Stack */
  .detail-box {
    padding: 16px !important;
    max-height: 90vh !important;
  }
  .detail-layout {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: center !important;
  }
  .detail-visual {
    flex: 0 0 180px !important;
    width: 140px !important;
    height: 180px !important;
  }
  .detail-info {
    text-align: center !important;
    width: 100% !important;
  }
  .detail-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    text-align: left !important;
  }
}

@media (max-width: 480px) {
  .stat-line .spark {
    display: none !important; /* Hide sparklines on tiny screens */
  }
  .card-desc {
    display: none !important; /* Hide details on small lists */
  }
  .card.research .card-desc {
    display: block !important; /* Keep details for research modal */
  }
}

/* Battery-low animation damper */
.battery-low *, .battery-low .phase-badge.p-blood {
  animation: none !important;
  transition: none !important;
}

/* ---------------- Avatars & detail modals ---------------- */
.avatar-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.row .ic.avatar-ic {
  font-size: 0; /* hides fallback text if any */
}

/* Detail modal styles */
.detail-box {
  max-width: 580px !important;
  text-align: left !important;
  padding: 24px !important;
  border-color: var(--accent) !important;
}
.detail-layout {
  display: flex;
  gap: 20px;
}
.detail-visual {
  flex: 0 0 180px;
  height: 280px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.detail-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detail-info h1 {
  font-size: 22px;
  color: var(--accent2);
  margin: 0;
}
.detail-info p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.detail-stat {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.detail-stat b {
  color: var(--gold);
  font-size: 14px;
}
.detail-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  margin-top: 8px;
}

