:root {
  --bg: #0f0f12;
  --panel: #17171c;
  --panel-2: rgba(18, 18, 23, 0.72);
  --text: #eae7df;
  --muted: #cbbfa6;
  --line: rgba(234, 231, 223, 0.08);
  --accent: #d7b76e; /* brass */
  --ok: #59c07a;
  --err: #f26b6b;
  --topbar-label-width: 36px;
  --radius: 12px;
  --shadow-1: 0 8px 24px rgba(0,0,0,.35);
  --font-ui: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-display: 'Cinzel', ui-serif, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  /* Layered background: subtle dark overlay over the fantasy map, with the prior radial gradient and base color beneath */
  background:
    /* Edge vignette */
    radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0) 56%, rgba(0,0,0,0.30) 84%, rgba(0,0,0,0.50) 100%) no-repeat fixed,
    /* Bottom fade */
    linear-gradient(to bottom, rgba(0,0,0,0) 46%, rgba(0,0,0,0.55) 100%) no-repeat fixed,
    /* Base overlay */
    linear-gradient(180deg, rgba(9, 9, 12, 0.72), rgba(9, 9, 12, 0.78)) no-repeat fixed,
    /* Map image */
    url('/image_resources/fantasy_map.png') center / cover no-repeat fixed,
    /* Original subtle radial tint and solid fallback */
    radial-gradient(1200px 600px at 70% -10%, #1c1c22 20%, var(--bg) 60%),
    var(--bg);
  color: var(--text);
  padding-top: 64px; /* space for redesigned fixed topbar */
}

/* Preserve alignment across tabs by forcing a stable (hidden) vertical scrollbar */
html { overflow-y: scroll; scrollbar-width: none; }
html::-webkit-scrollbar { width: 0; height: 0; }
body { -ms-overflow-style: none; }

main {
  max-width: 900px;
  margin: 32px auto;
  padding: 24px;
  /* Slight translucency with blur to let the map peek through without hurting readability */
  background: var(--panel-2);
  -webkit-backdrop-filter: blur(6px) saturate(1.06);
  backdrop-filter: blur(6px) saturate(1.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
}

/* Title bar above tabs */
.title-bar {
  position: relative;
  margin: -6px -6px 8px;
  padding: 8px 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(35,35,42,0.55), rgba(18,18,23,0.55));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

/* Title logo replaces text */
.title-logo {
  display: block;
  max-width: min(200px, 36%);
  width: 100%;
  height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 1px 6px rgba(0,0,0,0.45));
}
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  min-height: 64px;
  padding: 10px 12px; /* breathing room around the centered pill */
  background: transparent; /* let map + vignette show; inner pill provides chrome */
  z-index: 900;
}

/* Inline VU inside the pill */
.topbar canvas#vu {
  height: 10px;
  width: clamp(80px, 12vw, 140px);
  background: #23232a;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 14px;
  min-height: 44px; /* compact pill */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(35,35,42,0.55), rgba(18,18,23,0.62));
  -webkit-backdrop-filter: blur(6px) saturate(1.06);
  backdrop-filter: blur(6px) saturate(1.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.tb-left, .tb-center, .tb-right { display: flex; align-items: center; gap: 10px; }
.tb-left { justify-content: center; min-width: 0; }
.tb-left .conn-toggle { gap: 6px; }
.tb-left #mute { margin-left: 6px; }
.tb-left canvas#vu { margin-left: 10px; }
.tb-center, .tb-right { display: none; }
.tb-center { justify-content: center; gap: 12px; min-width: 0; max-width: 100%; overflow: hidden; }
.tb-right { justify-content: flex-end; gap: 8px; flex-wrap: wrap; min-width: 0; row-gap: 6px; }

/* Remove in-center VU sizing (now anchored left) */

/* Ensure VU and Mute button do not overlap; allow center to wrap smartly */
.tb-left { gap: 8px; }
.tb-left .conn-toggle { display: inline-flex; gap: 8px; }
.tb-left #mute { flex: 0 0 auto; }
.tb-center { flex-wrap: nowrap; }
.tb-center canvas#vu { flex: 0 1 auto; max-width: 100%; }

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 8px; min-height: 56px; }
  .tb-left { flex-wrap: wrap; }
}

/* Status chip */
.topbar #statusText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(120px, 28vw, 280px);
  font-size: 12px;
  line-height: 1.1;
  color: var(--muted);
  position: relative;
  padding: 6px 10px 6px 22px;
  background: rgba(18,18,23,0.55);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.topbar #statusText::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #777;
}
.topbar #statusText[data-state="connected"]::before { background: var(--ok); }
.topbar #statusText[data-state="progress"]::before { background: var(--accent); }
.topbar #statusText[data-state="error"]::before { background: var(--err); }
.topbar #statusText[data-state="idle"]::before, .topbar #statusText[data-state="disconnected"]::before { background: #777; }

/* Mic label */
.mic-label {
  margin-left: 10px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18,18,23,0.55);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact controls inside the top bar */
.topbar select, .topbar button { padding: 6px 10px; }

/* Controls styling to match app components */
.topbar select, .topbar button {
  background: #23232a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}
.topbar button:hover:not(:disabled) { background: #2a2a31; }
.topbar button:active:not(:disabled) { transform: translateY(1px); }
.topbar #connect { border-color: var(--accent); color: var(--accent); }
.topbar #disconnect { border-color: rgba(242,107,107,0.85); color: var(--err); }

.debug-panel {
  position: static;
  max-height: 260px;
  overflow: auto;
  padding: 8px 0 0 0;
  margin-top: 8px;
}

.debug-inner { padding: 0; }
.debug-panel .log { margin-top: 0; }


h1 { margin-top: 0; font-size: 22px; }

.tabs { margin: 4px 0 8px; display: flex; gap: 2px; justify-content: center; padding-left: 0; background: transparent; position: relative; }
.tabs::before {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--line);
  z-index: 1;
}
.tabs::after {
  content: '';
  position: absolute;
  left: calc(var(--tab-active-left, 0px) - 1px);
  width: calc(var(--tab-active-width, 0px) + 2px);
  bottom: 0; height: 1px;
  background: var(--panel-2); /* mask the rail under the active tab */
  z-index: 2; /* ensure mask sits above the rail (and just at the bottom of tabs) */
  pointer-events: none;
}
.tabs [role="tab"] {
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-top-left-radius: 8px !important;
  border-top-right-radius: 8px !important;
  border-bottom-left-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  margin-bottom: -1px; /* overlap the bottom border to look connected when selected */
  font-weight: 600;
  font-size: 14px;
  position: relative;
  font-family: var(--font-display);
}
.tabs [role="tab"]:hover { background: rgba(255,255,255,.04); color: var(--text); }
.tabs [role="tab"][aria-selected="true"] {
  background: transparent; /* let the main panel's blurred surface show through */
  border-top-color: var(--line);
  border-left-color: var(--line);
  border-right-color: var(--line);
  color: var(--text);
  z-index: 1;
}
.tab-content.hidden { display: none; }
.tab-content[hidden] { display: none; }

.controls {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select, button {
  padding: 8px 10px;
  background: #23232a;
  color: var(--text);
  border: 1px solid #2f2f37;
  border-radius: 8px;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}

button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:hover:not(:disabled) { background: #2a2a31; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.status {
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}

.meters { margin-top: 16px; }

.log {
  margin-top: 16px;
  padding: 12px;
  background: #121217;
  border: 1px solid #262630;
  border-radius: 8px;
  max-height: 280px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

.log .item { margin: 6px 0; }
.log .ok { color: var(--ok); }
.log .err { color: var(--err); }


/* Transcript UI */
.transcript {
  margin-top: 12px;
  padding: 10px 12px;
  background: #121217;
  border: 1px solid #262630;
  border-radius: 8px;
  height: clamp(360px, 55vh, 600px);
  overflow: visible; /* allow the header to sit visually above the box */
  position: relative;
  -ms-overflow-style: none; /* IE and legacy Edge */
  scrollbar-width: none; /* Firefox */
}

.transcript::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* removed floating transcript header */

/* Scroll area for transcript content */
.transcript-scroll {
  height: 100%;
  overflow: auto;
  position: relative;
  -ms-overflow-style: none; scrollbar-width: none;
}
.transcript-scroll::-webkit-scrollbar { width: 0; height: 0; }

/* Subtle top fade to soften the first message under the sticky header */
.transcript-scroll::before {
  content: '';
  position: absolute;
  top: 0px; left: 12px; right: 12px; /* inside borders */
  height: 16px;
  background: linear-gradient(to bottom, rgba(18,18,23,0.9), rgba(18,18,23,0));
  pointer-events: none;
  z-index: 1;
}

.transcript .row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  margin: 12px auto;
  max-width: 72ch;
  align-items: start;
}

/* Role caption (no pill) */
.transcript .role {
  align-self: start;
  padding: 0;
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Themed role accents */
.transcript .row[data-role="assistant"] .role { color: var(--accent); }
.transcript .row[data-role="user"] .role { color: var(--muted); }
.transcript .row[data-role="mechanic"] .role { color: #7fb0ff; }

/* Message bubble */
.transcript .text {
  position: relative;
  white-space: pre-wrap;
  background: rgba(18,18,23,.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.5;
}

/* Subtle parchment tint for narrator only; player untinted */
.transcript .row[data-role="assistant"] .text {
  background: linear-gradient(180deg, rgba(215,183,110,0.09), rgba(18,18,23,0.6));
  border-color: rgba(215,183,110,0.22);
}
.transcript .row[data-role="user"] .text {
  background: rgba(18,18,23,.6);
  border-color: var(--line);
}

/* Mechanic events: distinct pill style with bluish accent and mono-ish formatting */
.transcript .row[data-role="mechanic"] .text {
  background: linear-gradient(180deg, rgba(80,140,255,0.10), rgba(18,18,23,0.65));
  border-color: rgba(120,170,255,0.35);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
}
.transcript .row[data-role="mechanic"] .text .mech-list { margin: 8px 0 0 0; padding-left: 0; list-style: none; }
.transcript .row[data-role="mechanic"] .text .mech-list li { margin: 4px 0; }
.transcript .row[data-role="mechanic"] .text .mech-list .op { display: inline-block; width: 16px; text-align: center; color: #cfe2ff; }
.transcript .row[data-role="mechanic"] .text .mech-list .name { font-weight: 600; color: #eaeffb; }
.transcript .row[data-role="mechanic"] .text .mech-list .qty { color: #9ec2ff; margin-left: 4px; }
.transcript .row[data-role="mechanic"] .text .mech-list .now { color: rgba(200,210,225,0.8); margin-left: 4px; }
.transcript .row[data-role="mechanic"] .text .mech-list .notes { color: rgba(200,210,225,0.8); }
.transcript .row[data-role="mechanic"] .text .mech-title {
  display: inline-block;
  font-weight: 700;
  letter-spacing: .02em;
  color: #9ec2ff;
  margin-right: 8px;
}
.transcript .row[data-role="mechanic"] .text .mech-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(120,170,255,0.12);
  border: 1px solid rgba(120,170,255,0.28);
  color: #cfe2ff;
  font-size: 11px;
  margin-right: 8px;
}
/* Outcome color variants for roll result badges */
.transcript .row[data-role="mechanic"] .text .mech-badge.success { background: rgba(120,170,255,0.12); border-color: rgba(120,170,255,0.35); color: #cfe2ff; }
.transcript .row[data-role="mechanic"] .text .mech-badge.fail { background: rgba(255,120,120,0.12); border-color: rgba(255,120,120,0.35); color: #ffd6d6; }
.transcript .row[data-role="mechanic"] .text .mech-badge.crit.success { box-shadow: 0 0 10px rgba(120,170,255,0.35) inset, 0 0 10px rgba(120,170,255,0.25); border-color: rgba(120,170,255,0.5); }
.transcript .row[data-role="mechanic"] .text .mech-badge.crit.fail { box-shadow: 0 0 10px rgba(255,80,80,0.35) inset, 0 0 10px rgba(255,80,80,0.25); border-color: rgba(255,80,80,0.5); }
.transcript .row[data-role="mechanic"] .text .mech-sep { color: rgba(200,210,225,0.5); margin: 0 6px; }
.transcript .row[data-role="mechanic"] .text .mech-kv { color: #eaeffb; }
.transcript .row[data-role="mechanic"] .text .mech-kv .k { color: #9fb8ff; }
.transcript .row[data-role="mechanic"] .text .mech-kv .v { color: #eaeffb; font-weight: 600; }

.transcript .partial .text { opacity: 0.85; }

/* Player/Character tab */
.player-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: stretch; }
.card {
  /* Cohesive surface to match transcript/main panels */
  background: linear-gradient(180deg, rgba(215,183,110,0.06), rgba(18,18,23,0.60));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow-1);
}
.card.identity { grid-column: 1 / -1; }
.card.bio { grid-column: 1 / -1; }
.identity-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; }
.card h3 { margin: 0 0 10px 0; font-size: 16px; font-family: var(--font-display); letter-spacing: 0.2px; position: relative; padding-left: 2px; }
.card h3::after { content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px; background: linear-gradient(90deg, var(--accent), rgba(215,183,110,0)); border-radius: 2px; }
.identity-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.player-grid input[type="text"],
.player-grid input[type="number"],
.player-grid textarea,
.player-grid select { padding: 8px 10px; background: #0f0f12; color: var(--text); border: 1px solid #2f2f37; border-radius: 8px; }
.player-grid input:disabled { opacity: 0.9; background: #111116; color: var(--muted); }
.field-row { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; gap: 10px; }
.num-group { display: inline-flex; align-items: center; gap: 6px; }
.num-group input { width: 80px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stats-grid label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); padding: 8px 10px; background: #0f0f12; border: 1px solid #2f2f37; border-radius: 8px; }
.stats-grid .value { color: var(--accent); font-weight: 700; }
.stats-grid input[type="text"], .stats-grid input[type="number"] { padding: 8px 10px; background: #0f0f12; color: var(--text); border: 1px solid #2f2f37; border-radius: 8px; }
.vitals-grid { grid-template-columns: repeat(2, 1fr); }
.inventory-list { grid-column: 1 / -1; }
.card.attributes { grid-column: 1 / 5; display: grid; gap: 16px; grid-auto-rows: min-content; }
.right-col { grid-column: 5 / -1; display: grid; gap: 16px; grid-template-rows: 1fr 1fr; align-content: stretch; height: 100%; }
.card.spells { grid-column: 1 / -1; }
.card.inventory { grid-column: 1 / -1; }
.card.spells, .card.inventory { height: 100%; display: flex; flex-direction: column; }
.right-col .spells-list, .right-col .inventory-list { flex: 1 1 auto; max-height: none; }

/* Attributes layout: vitals + stats in one card */
.attrs-grid { display: grid; grid-template-columns: 1fr; gap: 12px; align-content: stretch; height: 100%; }
.attrs-grid .vitals-col .field-row { margin: 6px 0; }
@media (min-width: 720px) {
  .attrs-grid { grid-template-columns: 1fr; }
}
textarea { width: 100%; resize: vertical; background: #0f0f12; color: var(--text); border: 1px solid #2f2f37; border-radius: 8px; padding: 8px; }
.actions { display: flex; align-items: center; justify-content: flex-start; }

.inventory-list {
  margin: 8px 0;
  padding-left: 0;
  list-style: none;
  max-height: clamp(180px, 30vh, 320px);
  overflow-y: auto;
  overflow-x: visible;
  -ms-overflow-style: none;
  scrollbar-width: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 16px;
  row-gap: 6px;
  align-items: start;
}
.inventory-list::-webkit-scrollbar { width: 0; height: 0; }
.inventory-list li {
  margin: 0;
  display: grid;
  grid-template-columns: max-content auto 1fr;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-left: 14px;
}
.inventory-list li::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: block; filter: drop-shadow(0 0 6px rgba(215,183,110,0.35)); }
.inventory-list .inv-row { gap: 10px; }
.inventory-list .inv-name { font-weight: 600; color: var(--text); align-self: center; white-space: nowrap; }
.inventory-list .inv-qty { justify-self: start; padding: 2px 6px; border-radius: 999px; background: rgba(215,183,110,0.10); border: 1px solid rgba(215,183,110,0.28); color: var(--accent); font-size: 11px; white-space: nowrap; }
.inventory-list .inv-notes { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spells-list li::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: none; }
.inventory-actions { display: flex; gap: 8px; margin-top: 8px; }
.hidden { display: none !important; }

/* Spells list styling (mirrors inventory for cohesion) */
.spells-list {
  margin: 8px 0;
  padding-left: 0;
  list-style: none;
  max-height: clamp(120px, 22vh, 220px);
  overflow-y: auto;
  -ms-overflow-style: none; scrollbar-width: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 16px;
  row-gap: 6px;
}
.spells-list::-webkit-scrollbar { width: 0; height: 0; }
.spells-list li { margin: 0; display: grid; grid-template-columns: 1fr max-content; gap: 10px; align-items: center; }
.spells-list .spell-name { font-weight: 600; color: var(--text); }
.spells-list .spell-dc { justify-self: end; padding: 2px 6px; border-radius: 999px; background: rgba(215,183,110,0.10); border: 1px solid rgba(215,183,110,0.28); color: var(--accent); font-size: 11px; white-space: nowrap; }
.spells-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Settings tab */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.settings .settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings .settings-fields.connection { grid-template-columns: 1fr 1fr; }
.settings .settings-fields.audio { grid-template-columns: 1fr; }
.settings .range-group { display: grid; gap: 6px; }
.settings .range-row { display: grid; grid-template-columns: 1fr max-content; align-items: center; gap: 10px; }
.settings input[type="range"] { width: 100%; accent-color: var(--accent); }
.settings .range-val { font-variant-numeric: tabular-nums; color: var(--muted); }
.settings .settings-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
@media (max-width: 700px) {
  .settings .settings-fields { grid-template-columns: 1fr; }
}

/* Responsive cohesion for Character tab */
@media (max-width: 900px) {
  .card.attributes, .card.spells, .card.inventory { grid-column: 1 / -1; }
  .identity-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}

/* Inventory responsive: collapse to single column on smaller widths */
@media (max-width: 900px) {
  .inventory-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .inventory-list { grid-template-columns: 1fr; }
}

/* Spells responsive */
@media (max-width: 700px) {
  .spells-list { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .identity-grid { grid-template-columns: 1fr; }
}

/* Dice Roller UI */
.dice-roller {
  position: static;
  margin: 16px auto 0;
  width: 100%;
  display: block;
}
.dice-roller-card {
  background: #121217;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  width: min(900px, calc(100vw - 32px));
  margin: 0 auto;
  box-shadow: var(--shadow-1);
}
.dice-roller-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dice-roller-header .row { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.dice-roller-header .field { display: grid; gap: 2px; }
.dice-roller-header .label { font-size: 10px; color: var(--muted); }
.dice-roller-header .value { font-size: 14px; color: var(--text); }
.dice-roller-header .actions { display: flex; gap: 8px; }
.btn { padding: 6px 10px; background: #23232a; color: var(--text); border: 1px solid #2f2f37; border-radius: 8px; cursor: pointer; }
.btn.btn-accent { border-color: var(--accent); color: var(--accent); }

.dice-roller-track {
  --hex-gap: 10px;
  --hex-size: min(66px, calc((100% - (19 * var(--hex-gap))) / 20));
  margin-top: 12px;
  display: flex;
  gap: var(--hex-gap);
  align-items: center;
  justify-content: space-between;
  overflow: visible;
}
.hex {
  position: relative;
  --hex-border: #3a3a45;
  width: var(--hex-size);
  /* regular point-up hex: width ≈ 0.866 * height */
  aspect-ratio: 0.866 / 1;
  /* point-up hexagon */
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: grid; place-items: center;
  color: var(--text);
  transition: box-shadow 120ms ease, transform 120ms ease, filter 120ms ease;
}
.hex::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hex-border);
  /* point-up outline */
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  z-index: 0;
}
.hex::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #0f0f12;
  /* slightly inset inner hex to create uniform border */
  clip-path: polygon(50% 6%, 94% 31%, 94% 69%, 50% 94%, 6% 69%, 6% 31%);
  z-index: 1;
}
.hex > * { position: relative; z-index: 2; }
.hex span { font-size: 14px; line-height: 1; font-weight: 600; letter-spacing: 0.2px; text-shadow: 0 100px 0 rgba(0,0,0,0.4); }
.hex.is-dc { color: var(--text); text-decoration: underline; text-underline-offset: 3px; --hex-border: #8a722469; }
.hex.is-dc::after { background: rgba(255,215,64,0.28); mix-blend-mode: multiply; clip-path: polygon(50% 8%, 92% 33%, 92% 67%, 50% 92%, 8% 67%, 8% 33%); }
.hex.active { --hex-border: #ffffff; box-shadow: 0 0 14px rgba(255,255,255,0.35); transform: translateY(-2px); }
.hex.success { --hex-border: #547fc2; box-shadow: 0 0 14px rgba(80,180,255,0.45), 0 0 1px rgba(80,180,255,0.3) inset; }
.hex.fail { --hex-border: #c55a5a; box-shadow: 0 0 14px rgba(255,80,80,0.45), 0 0 1px rgba(255,80,80,0.3) inset; }
.hex.crit.success { box-shadow: 0 0 18px rgba(80,180,255,0.95), 0 0 4px rgba(80,180,255,0.75) inset; }
.hex.crit.fail { box-shadow: 0 0 18px rgba(255,80,80,0.95), 0 0 4px rgba(255,80,80,0.75) inset; }
.hex.bg-success::after { background: rgba(60,110,200,0.35); mix-blend-mode: multiply; }
.hex.bg-fail::after { background: rgba(200,60,60,0.35); mix-blend-mode: multiply; }
/* Improve numeral legibility over tinted backgrounds */
.hex.bg-success span, .hex.bg-fail span, .hex.is-dc span { text-shadow: 0 1px 2px rgba(0,0,0,0.65); }
.dice-roller-status { margin-top: 10px; font-size: 12px; color: var(--muted); }
.dice-roller-status:empty::before { content: '\00a0'; }

/* Bottom-right debug rail */
.debug-rail {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
}
.debug-rail .rail-btn {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 10px 8px;
  min-height: 72px;
  background: #23232a;
  color: var(--text);
  border: 1px solid #2f2f37;
  border-radius: 10px;
  opacity: 0.9;
}
.debug-rail .rail-btn:hover { opacity: 1; }

/* Character Creator */
#panel-creator .identity h3::after { background: linear-gradient(90deg, var(--accent), rgba(215,183,110,0)); }
.creator-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
#panel-creator .card.identity { grid-column: 1 / -1; }
#panel-creator .card.attributes { grid-column: 1 / 5; display: grid; gap: 16px; grid-auto-rows: min-content; }
#panel-creator .right-col { grid-column: 5 / -1; display: grid; gap: 16px; grid-template-rows: 1fr 1fr; align-content: stretch; height: 100%; }
#panel-creator .card.spells { grid-column: 1 / -1; }
#panel-creator .card.inventory { grid-column: 1 / -1; }
#panel-creator .card.bio { grid-column: 1 / -1; }
#panel-creator .card.finish-card { grid-column: 1 / -1; text-align: right; }
#panel-creator .stat-rules { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
#panel-creator .points-remaining { color: var(--accent); font-weight: 700; margin-left: 8px; }
#panel-creator .stats-editor { display: grid; gap: 8px; }
#panel-creator .stat-row { display: flex; align-items: center; justify-content: space-between; background: #0f0f12; border: 1px solid #2f2f37; border-radius: 8px; padding: 8px 10px; }
#panel-creator .stat-row .num-group { display: inline-flex; align-items: center; gap: 8px; }
#panel-creator .stat-row .value { color: var(--accent); font-weight: 700; min-width: 28px; text-align: center; }
#panel-creator .stat-row button { padding: 4px 10px; }
#panel-creator .actions-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.actions-card { grid-column: 1 / -1; }

/* CTA button styling for Finish Character */
#panel-creator .btn-cta {
  position: relative;
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(215,183,110,0.16), rgba(215,183,110,0.05));
  border: 1px solid rgba(215,183,110,0.55);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(215,183,110,0.18), inset 0 0 0 1px rgba(0,0,0,0.2);
  transition: transform .06s ease, box-shadow .15s ease, background .2s ease, filter .15s ease;
}
#panel-creator .btn-cta:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(215,183,110,0.22), rgba(215,183,110,0.08));
  box-shadow: 0 6px 22px rgba(215,183,110,0.26), inset 0 0 0 1px rgba(0,0,0,0.25);
  filter: drop-shadow(0 0 8px rgba(215,183,110,0.25));
}
#panel-creator .btn-cta:active:not(:disabled) { transform: translateY(1px); }
#panel-creator .btn-cta:disabled { opacity: 0.6; }

@media (max-width: 900px) {
  #panel-creator .card.attributes, #panel-creator .card.spells, #panel-creator .card.inventory { grid-column: 1 / -1; }
}

/* Fancy inputs to match textarea look */
#panel-creator .fancy-input {
  width: 100%;
  padding: 10px 12px;
  background: #0f0f12;
  color: var(--text);
  border: 1px solid #2f2f37;
  border-radius: 8px;
}
#panel-creator .fancy-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

