/* ==========================================================================
   MANITHAN VAANAM — NPC DOSSIER STYLESHEET
   Shared across every NPC page. Colors/fonts are pulled directly from
   manithanvaanam.neocities.org's own stylesheet so every dossier page
   matches the encyclopedia. Structure/features are modeled on the
   Teobaldo-style OC dossier template (sidebar + tabbed Main/Media/
   Relationships articles).

   Link this file the same way on every NPC page:
     <link rel="stylesheet" href="./dossier.css">
   Then use the small <style> block at the top of each NPC's HTML file
   to override --npc-accent with that character's signature color.
   ========================================================================== */

:root {
  /* --- Core Manithan Vaanam palette (from the encyclopedia's own CSS) --- */
  --bg-parchment: #d9c79b;
  --pane-bg: rgba(217, 199, 155, 0.88);
  --ink: #241d1a;
  --purple: #2c1738;
  --cream: #f8e7b5;
  --gold: #d29a3a;
  --gold-bright: #e3b14f;
  --card-fill: #f2e7c6;
  --card-fill-bright: #fff8e6;
  --teal: #0f5f68;
  --crimson: #7a2f2a;
  --visited: #684e79;

  /* badge hues, straight from the encyclopedia's category key */
  --hue-manithan: #a24936;
  --hue-kingdom: #0f5f68;
  --hue-location: #7a4c22;
  --hue-geography: #3a5f73;
  --hue-jaadhi: #684e79;
  --hue-creature: #597b3f;
  --hue-item: #d29a3a;
  --hue-threat: #4a1e1b;
  --hue-kadavul: #2c1738;
  --hue-concept: #f2e7c6;

  /* dark mode */
  --dark-bg: #140d1a;
  --dark-pane: rgba(44, 23, 56, 0.85);
  --dark-card: #23122e;

  /* per-NPC signature accent — override this per character, same idea as
     Teobaldo's --accentcolor override comment */
  --npc-accent: var(--gold);
  --npc-accent-bright: var(--gold-bright);

  --font-body: "Georgia", Times, serif;
  --sidebar-w: 270px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin : 0 ;
    min-height : 100 vh ;
    font-family : var(--font-body) ;
    font-size : 15 px ;
    line-height : 1.55 ;
    color : var(--ink) ;
    background-color : var(--bg-parchment) ;
    
    /* 1. Pull the local image from the HTML variable */
    background-image : var(--page-bg) ; 
    
    /* 2. Web 1.0 Tiling Behavior */
    background-size : auto ;
    background-repeat : repeat ;
    background-position : top left ;
    background-attachment : scroll ; /* Change to 'fixed' if you want the grid to stay still while text moves */
    
    transition : background-color .2 s ease , color .2 s ease ;
}

body.dark-mode {
  background-image: url('/background-night.png');
  background-color: var(--dark-bg);
  color: var(--cream);
}

a { color: var(--teal); text-decoration: none; border-bottom: 1px dashed rgba(15, 95, 104, 0.45); }
a:visited { color: var(--visited); border-bottom-color: rgba(104, 78, 121, 0.45); }
a:hover { color: var(--crimson); border-bottom: 1px solid var(--crimson); cursor: pointer; }
body.dark-mode a { color: var(--gold-bright); border-bottom-color: rgba(227, 177, 79, 0.45); }
body.dark-mode a:visited { color: #b08bbd; }
body.dark-mode a:hover { color: var(--card-fill-bright); border-bottom-color: var(--card-fill-bright); }

hr { border: 0; border-top: 1px solid rgba(93, 52, 31, 0.45); margin: 1.1rem 0; clear: both; }
ul { list-style-type: square; padding-left: 20px; }

/* ==========================================================================
   LAYOUT — sidebar + main
   ========================================================================== */

#container {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ---- Sidebar (the "dossier") ---- */

#dossier {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background-color: var(--purple);
  color: var(--cream);
  border-right: 4px double var(--gold);
  padding: 18px 16px 40px;
  text-align: center;
  transition: margin-left .3s ease;
  z-index: 50;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) var(--purple);
}

#container.sidebar-collapsed #dossier { margin-left: calc(-1 * var(--sidebar-w)); }

#dossier::-webkit-scrollbar { width: 8px; }
#dossier::-webkit-scrollbar-thumb { background: var(--gold); }
#dossier::-webkit-scrollbar-track { background: var(--purple); }

#dossier h1, #dossier h2, #dossier h3, #dossier h4 {
  font-variant: small-caps;
  letter-spacing: 1.5px;
  font-weight: normal;
  margin: 0.5em 0;
}

#dossier h1.npc-name {
  font-size: 26px;
  letter-spacing: 2px;
  color: var(--cream);
  margin: 8px 0 2px;
}

#dossier .npc-name-tamil {
  display: block;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--npc-accent-bright, var(--gold-bright));
  font-variant: normal;
  margin-bottom: 10px;
}

#dossier h2.nav-link,
#dossier h2.nav-cat {
  font-size: 16px;
  cursor: pointer;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(248, 231, 181, 0.15);
  transition: color .15s ease, background-color .15s ease;
}

#dossier h2.nav-link:hover,
#dossier h2.nav-cat:hover { color: var(--gold-bright); background-color: rgba(248, 231, 181, 0.06); }

#dossier h2.nav-cat.active {
  color: var(--purple);
  background-color: var(--gold-bright);
  border-radius: 3px;
}

.npc-icon-frame {
  width: 96px; height: 96px;
  margin: 4px auto 10px;
  border-radius: 50%;
  border: 3px double var(--gold);
  background-color: var(--card-fill);
  background-image: var(--charicon, none);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.35);
}

.player-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 12px auto 0;
  padding: 8px 16px;
  width: fit-content;
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.4); /* Matches gold sidebar accents */
  border-radius: 6px;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.4);
}

.badge-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gold, #d4af37);
  opacity: 0.9;
}

.badge-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f0f0f0;
  letter-spacing: 0.5px;
}

#dossier hr { border-top-color: rgba(248,231,181,0.25); }

#dossier .charts-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 7px 10px;
  background-color: var(--card-fill);
  color: var(--ink);
  border: 1px solid var(--purple);
  font-family: var(--font-body);
  font-variant: small-caps;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 3px;
}
#dossier .charts-btn:hover { background-color: var(--card-fill-bright); }

/* ---- Sidebar collapse toggle ---- */

#buttons {
  position: fixed;
  top: 16px;
  left: calc(var(--sidebar-w) - 18px);
  z-index: 60;
  transition: left .3s ease;
}
#container.sidebar-collapsed #buttons { left: 6px; }

#sidebarToggle {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background-color: var(--purple);
  color: var(--cream);
  font-size: 15px;
  cursor: pointer;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.3);
  transition: transform .3s ease;
}
#container.sidebar-collapsed #sidebarToggle { transform: rotate(180deg); }

/* ---- Main content ---- */

main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 30px 4vw 60px;
  transition: margin-left .3s ease;
  min-width: 0;
}
#container.sidebar-collapsed main { margin-left: 0; }

.content-pane {
  max-width: 900px;
  margin: 0 auto;
  background-color: var(--pane-bg);
  backdrop-filter: blur(10px) saturate(80%);
  -webkit-backdrop-filter: blur(10px) saturate(80%);
  padding: 30px clamp(16px, 4vw, 44px);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(44, 23, 56, 0.15);
}
body.dark-mode .content-pane {
  background-color: var(--dark-pane);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.dossier-tab { display: none; }
.dossier-tab.active { display: block; }

main h1 { font-variant: small-caps; letter-spacing: 1px; color: var(--purple); margin-top: 1.4em; }
body.dark-mode main h1 { color: var(--gold-bright); }
main h1:first-child { margin-top: 0; }

.npc-banner { text-align: center; margin-bottom: 6px; }
.npc-banner h1.npc-name-main {
  font-size: 30px;
  letter-spacing: 2px;
  margin: 0;
  border-bottom: 3px double var(--purple);
  display: inline-block;
  padding-bottom: 6px;
}
body.dark-mode .npc-banner h1.npc-name-main { border-bottom-color: var(--gold-bright); }
.npc-banner .npc-name-tamil-main {
  display: block;
  font-size: 14px;
  letter-spacing: 1px;
  font-variant: normal;
  color: var(--crimson);
  margin-top: 4px;
}
body.dark-mode .npc-banner .npc-name-tamil-main { color: var(--gold-bright); }

.back-to-top-link { display: inline-block; margin: 18px 0 6px; font-variant: small-caps; letter-spacing: 1px; font-size: 13px; }

/* ==========================================================================
   PARCHMENT CARD — the one signature surface reused everywhere
   ========================================================================== */

.parchment-card {
  background-color: var(--card-fill);
  border: 3px double var(--purple);
  box-shadow: 5px 5px 0px var(--purple);
  padding: 14px 18px;
}
body.dark-mode .parchment-card {
  background-color: var(--dark-card);
  border-color: var(--gold-bright);
  box-shadow: 5px 5px 0px var(--gold-bright);
}

/* ==========================================================================
   IMAGE TABS (outfit switcher)
   ========================================================================== */

.imgtabs { display: flex; gap: 4px; margin-bottom: 0; flex-wrap: wrap; }
.imgtab {
  padding: 6px 14px;
  background-color: rgba(44,23,56,0.08);
  border: 1px solid var(--purple);
  border-bottom: none;
  font-family: var(--font-body);
  font-variant: small-caps;
  letter-spacing: 1px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.imgtab.active { background-color: var(--card-fill); font-weight: bold; }
body.dark-mode .imgtab { color: var(--cream); border-color: var(--gold-bright); background-color: rgba(255,255,255,0.05);}
body.dark-mode .imgtab.active { background-color: var(--dark-card); }

.tab-panels {
  border: 3px double var(--purple);
  background-color: var(--card-fill);
  padding: 10px;
  text-align: center;
  min-height: 120px;
}
body.dark-mode .tab-panels { border-color: var(--gold-bright); background-color: var(--dark-card); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel img { max-width: 100%; height: auto; }
.tab-panel .art-placeholder {
  padding: 60px 10px;
  font-variant: small-caps;
  letter-spacing: 1px;
  color: rgba(36,29,26,0.5);
  border: 1px dashed rgba(36,29,26,0.35);
}
body.dark-mode .tab-panel .art-placeholder { color: rgba(248,231,181,0.45); border-color: rgba(248,231,181,0.3); }

/* ==========================================================================
   INFOBOX / INFOTABLE
   ========================================================================== */

.infobox { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 20px; }
.infobox .imgtab-col { flex: 1 1 260px; }
.infobox .infotable-col { flex: 1 1 340px; }

table.infotable {
  width: 100%;
  border-collapse: collapse;
  border: 3px double var(--purple);
  background-color: var(--card-fill);
}
body.dark-mode table.infotable { border-color: var(--gold-bright); background-color: var(--dark-card); }

table.infotable th, table.infotable td {
  border: 1px solid rgba(44,23,56,0.25);
  padding: 5px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13.5px;
}
body.dark-mode table.infotable th, body.dark-mode table.infotable td { border-color: rgba(227,177,79,0.25); }

table.infotable th#centertext,
table.infotable th.section-header {
  text-align: center;
  background-color: var(--purple);
  color: var(--cream);
}
table.infotable th#centertext h2, table.infotable th.section-header h2 {
  margin: 4px 0;
  font-size: 15px;
  font-variant: small-caps;
  letter-spacing: 2px;
  font-weight: normal;
}
body.dark-mode table.infotable th#centertext,
body.dark-mode table.infotable th.section-header { background-color: var(--dark-bg); color: var(--gold-bright); }

table.infotable tr > th:not(#centertext):not(.section-header) {
  width: 38%;
  font-variant: small-caps;
  letter-spacing: 1px;
  font-weight: bold;
  background-color: rgba(44,23,56,0.06);
}
body.dark-mode table.infotable tr > th:not(#centertext):not(.section-header) { background-color: rgba(227,177,79,0.08); }

/* ==========================================================================
   QUOTEBOX
   ========================================================================== */

.quotebox {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
}
.quotebox .charicon {
  flex: 0 0 56px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background-color: var(--purple);
  background-image: var(--charicon, none);
  background-size: cover;
  background-position: center;
  border: 2px solid var(--gold);
}
.quotebox .textbox {
  flex: 1;
  border-left: 3px solid var(--npc-accent);
  padding: 6px 14px;
  font-style: italic;
}
.quotebox .textbox p { margin: 0; text-indent: 0; }

/* ==========================================================================
   BASIC INFO portrait
   ========================================================================== */

.basicinfo-img {
  float: right;
  max-width: 45%;
  margin: 0 0 15px 25px;
  border: 3px double var(--purple);
  background-color: var(--card-fill);
  padding: 8px;
  box-shadow: 5px 5px 0px var(--purple);
}
body.dark-mode .basicinfo-img { background-color: var(--dark-card); border-color: var(--gold-bright); box-shadow: 5px 5px 0px var(--gold-bright); }
.basicinfo-img img { display: block; max-width: 100%; }

/* ==========================================================================
   EVENBOX (two-column: Assets/Flaws, Likes/Dislikes, Habits/Fears)
   ========================================================================== */

.evenbox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 20px 0;
}
.evenbox > div { padding: 12px 16px; }
.evenbox h1 { margin: 0 0 8px; font-size: 16px; }
.evenbox ul { margin: 0; }
@media (max-width: 620px) {
  .evenbox { grid-template-columns: 1fr; }
}

/* ==========================================================================
   SIMILAR CHARACTERS (charchart)
   ========================================================================== */

.charchart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.grid-similar {
  padding: 10px;
  text-align: center;
  font-size: 13px;
}
.grid-similar span { display: block; margin-bottom: 6px; }
.grid-similar ul { text-align: left; margin: 6px 0 0; }
.grid-similar img { max-width: 100%; height: auto; margin-top: 8px; border: 1px solid var(--purple); }
body.dark-mode .grid-similar img { border-color: var(--gold-bright); }

/* ==========================================================================
   AUTOBOX / SCROLLBOX (Philosophy, History)
   ========================================================================== */

.autobox {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin: 18px 0;
}
.autobox img { max-width: 320px; width: 100%; height: auto; }
.scrollbox {
  flex: 1 1 300px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 6px;
}
.scrollbox::-webkit-scrollbar { width: 7px; }
.scrollbox::-webkit-scrollbar-thumb { background: var(--purple); }
body.dark-mode .scrollbox::-webkit-scrollbar-thumb { background: var(--gold-bright); }

.history-era { margin-bottom: 18px; }
.history-era h2 {
  font-variant: small-caps;
  letter-spacing: 1px;
  border-bottom: 1px dotted var(--crimson);
  display: inline-block;
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: normal;
}

/* ==========================================================================
   MINI-GALLERY (borderbox)
   ========================================================================== */

.borderbox {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  border: 3px double var(--purple);
  background-color: rgba(255,255,255,0.15);
}
body.dark-mode .borderbox { border-color: var(--gold-bright); background-color: rgba(0,0,0,0.2); }
.borderbox img { max-height: 260px; width: auto; max-width: 100%; }

details.mini-gallery summary,
details.media-summary summary {
  cursor: pointer;
  font-variant: small-caps;
  letter-spacing: 1px;
  color: var(--crimson);
  margin: 10px 0;
}
body.dark-mode details.mini-gallery summary,
body.dark-mode details.media-summary summary { color: var(--gold-bright); }

/* ==========================================================================
   MEDIA TAB
   ========================================================================== */

.mediabox { text-align: center; margin: 16px 0; }
.mediabox iframe { width: 100%; max-width: 560px; height: 315px; border: 3px double var(--purple); }
body.dark-mode .mediabox iframe { border-color: var(--gold-bright); }

/* ==========================================================================
   QUICK JUMP DROPDOWN (used on Media + Relationships tabs)
   ========================================================================== */

.dropdown { position: relative; display: inline-block; margin-bottom: 14px; }
.dropbtn {
  font-family: var(--font-body);
  font-size: 14px;
  font-variant: small-caps;
  letter-spacing: 1px;
  padding: 7px 16px;
  background-color: var(--purple);
  color: var(--cream);
  border: 1px solid var(--gold);
  cursor: pointer;
  border-radius: 3px;
}
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  z-index: 40;
  background-color: var(--purple);
  border: 1px solid var(--gold);
  padding: 10px;
  min-width: 240px;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.3);
}
.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content { display: block; }
.evennav { display: flex; gap: 14px; }
.evennav > div { display: flex; flex-direction: column; gap: 6px; }
.evennav a { border-bottom: none; }
.evennav img, .evennav .roster-avatar-sm {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background-color: var(--card-fill);
  display: block;
}

/* ==========================================================================
   RELATIONSHIPS TAB
   ========================================================================== */

.h2rel {
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 1px;
  color: var(--crimson);
}
body.dark-mode .h2rel { color: var(--gold-bright); }

.relationship {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin: 16px 0;
  padding: 18px;
}

.chardialogue { flex: 1 1 200px; text-align: center; }
.chardialogue span { display: block; margin-bottom: 6px; }
.chardialogue button {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background-color: var(--card-fill);
  background-size: cover;
  background-position: center;
  cursor: pointer;
}
.chardialogue h1 { font-size: 16px; margin: 6px 0 4px; }
.chardialogue p { margin: 2px 0; text-indent: 0; font-size: 13px; min-height: 1.2em; }

.statdiv { flex: 0 0 auto; text-align: center; }
.statdiv b { display: block; font-variant: small-caps; letter-spacing: 1px; margin-bottom: 6px; font-size: 13px; }

.stat { position: relative; width: 60px; height: 54px; margin: 0 auto; }
.stat-track {
  position: absolute; inset: 0;
  clip-path: path("M30 54C10 40 0 28 0 15C0 6 7 0 16 0C22 0 27 4 30 10C33 4 38 0 44 0C53 0 60 6 60 15C60 28 50 40 30 54Z");
  background-color: rgba(36,29,26,0.15);
  overflow: hidden;
}
body.dark-mode .stat-track { background-color: rgba(248,231,181,0.15); }
.stat-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 100%;
  background-color: var(--npc-accent);
  transform: translateY(calc(100% - (100% * var(--fill, 0))));
  transition: transform .5s ease;
}
.stat-outline {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  fill: none;
  stroke: var(--purple);
  stroke-width: 2;
  pointer-events: none;
}
body.dark-mode .stat-outline { stroke: var(--gold-bright); }

/* ==========================================================================
   PALM LEAF DIVIDER (reused verbatim from the encyclopedia)
   ========================================================================== */

.palm-leaf {
  position: relative;
  width: 100%;
  max-width: 620px;
  min-height: 90px;
  margin: 1.8rem auto;
  background: linear-gradient(180deg, #b89352 0%, #dfc593 15%, #ebdba8 50%, #dfc593 85%, #b89352 100%);
  border-radius: 50px / 25px;
  box-shadow: inset 0 0 15px rgba(93, 52, 31, 0.35), 4px 6px 12px rgba(44, 23, 56, 0.15);
  padding: 16px 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.leaf-hole {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px;
  background-color: var(--purple);
  border-radius: 50%;
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.8), 0 1px 1px rgba(255,255,255,0.4);
}
.hole-left { left: 34px; }
.hole-right { right: 34px; }
.leaf-content { font-size: 13px; line-height: 1.5; text-align: center; letter-spacing: 0.5px; color: var(--ink); }
.leaf-translation { font-style: italic; font-size: 12px; opacity: 0.85; display: inline-block; margin-top: 4px; }

/* ==========================================================================
   TRANSLATION TOOLTIP (reused verbatim from the encyclopedia)
   ========================================================================== */

.translation { position: relative; cursor: help; border-bottom: 1px dotted var(--crimson); }
.translation::after {
  content: attr(data-title);
  position: absolute;
  bottom: 130%; left: 50%;
  transform: translateX(-50%);
  background-color: var(--purple);
  color: var(--cream);
  border: 1px solid var(--crimson);
  font-family: var(--font-body);
  font-size: 11px;
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 100;
  box-shadow: 3px 3px 0px rgba(44,23,56,0.25);
}
.translation:hover::after { opacity: 1; transform: translateX(-50%) translateY(-2px); }
body.dark-mode .translation { border-bottom-color: var(--gold-bright); }
body.dark-mode .translation::after { background-color: var(--dark-bg); border-color: var(--gold-bright); }

/* ==========================================================================
   BADGES (reused verbatim from the encyclopedia's category key)
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-body);
  font-size: 10px;
  font-variant: small-caps;
  letter-spacing: 1.5px;
  font-weight: bold;
  text-transform: lowercase;
  margin-right: 8px;
  border: 1px solid currentColor;
  vertical-align: middle;
  position: relative;
  top: -2px;
}
.badge-manithan { background-color: var(--hue-manithan); color: #fff3df; border-color: var(--hue-manithan); }
.badge-kingdom { background-color: var(--hue-kingdom); color: #eefbfb; border-color: var(--hue-kingdom); }
.badge-location { background-color: var(--hue-location); color: #fff6df; border-color: var(--hue-location); }
.badge-geography { background-color: var(--hue-geography); color: #fbf7ee; border-color: var(--hue-geography); }
.badge-jaadhi { background-color: var(--hue-jaadhi); color: #f7effb; border-color: var(--hue-jaadhi); }
.badge-creature { background-color: var(--hue-creature); color: #f4faee; border-color: var(--hue-creature); }
.badge-item { background-color: var(--hue-item); color: var(--ink); border-color: #765017; }
.badge-threat { background-color: var(--hue-threat); color: #fbe7df; border-color: var(--hue-threat); }
.badge-kadavul { background-color: var(--hue-kadavul); color: var(--cream); border-color: var(--hue-kadavul); }
.badge-concept { background-color: var(--hue-concept); color: var(--ink); border-color: var(--ink); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 860px) {
  #dossier { margin-left: calc(-1 * var(--sidebar-w)); }
  main { margin-left: 0; }
  #buttons { left: 6px; }
  #container:not(.sidebar-collapsed) #dossier { margin-left: 0; box-shadow: 6px 0 20px rgba(0,0,0,0.35); }
  #container:not(.sidebar-collapsed) #buttons { left: calc(var(--sidebar-w) - 18px); }
  #container:not(.sidebar-collapsed) #sidebarToggle { transform: rotate(180deg); }
  .infobox { flex-direction: column; }
  .relationship { justify-content: center; }
}

@media (max-width: 480px) {
  .content-pane { padding: 22px 14px; border-radius: 8px; }
  .npc-banner h1.npc-name-main { font-size: 24px; }
}

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

/* ==========================================================================
   STAT MATRIX MODAL FRAMEWORK & TABLE STYLES (COMBINED)
   ========================================================================== */

/* 1. The semi-transparent backdrop that hides the matrix by default */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(20, 13, 26, 0.75);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

/* 2. The active state triggered by your JavaScript click */
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* 3. The parchment card container inside the popup */
.modal-content {
    max-width: 440px;
    width: 90%;
    position: relative;
    padding: 24px;
    animation: modalSlide 0.25s ease-out;
}

@keyframes modalSlide {
    from { transform: translateY(-15px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 4. The close button configuration */
.close-modal {
    position: absolute;
    top: 6px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--purple);
    font-size: 26px;
    cursor: pointer;
}
body .dark-mode .close-modal { color: var(--gold-bright); }

.matrix-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

/* 5. Ability Scores Typography & Borders */
.modal-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-body);
    font-size: 14px;
    text-align: left;
}

.modal-stats-table th {
    font-variant: small-caps;
    letter-spacing: 1px;
    color: var(--purple);
    border-bottom: 2px solid var(--purple);
    padding: 6px 4px;
}
body .dark-mode .modal-stats-table th {
    color: var(--gold-bright);
    border-bottom-color: var(--gold-bright);
}

.modal-stats-table td {
    padding: 8px 4px;
    vertical-align: middle;
    color: var(--ink);
}
body .dark-mode .modal-stats-table td { color: var(--cream); }

.score-val { font-weight: bold; text-align: center; }
.mod-val { color: var(--teal) !important; font-weight: bold; text-align: center; }
body .dark-mode .mod-val { color: var(--gold) !important; }

/* 6. Retro Progress Bar Fills */
.bar-bg {
    width: 100%;
    height: 12px;
    background-color: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(44, 23, 56, 0.3);
    border-radius: 2px;
    overflow: hidden;
}
body .dark-mode .bar-bg {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(248, 231, 181, 0.3);
}

.bar-fill {
    height: 100%;
    width: 0%; /* Dynamic fallback width */
    background-color: var(--crimson);
    transition: width 0.4s ease-out;
}
body .dark-mode .bar-fill {
    background-color: var(--gold-bright);
}