:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #08090d;
  --panel: rgba(19, 20, 29, 0.94);
  --panel-2: rgba(29, 31, 43, 0.88);
  --line: rgba(255,255,255,0.10);
  --text: #f7f8fb;
  --muted: #a8adba;
  --combat: #ff4b58;
  --good: #67e6a4;
  --warn: #ffc65c;
  --bad: #ff737d;
  --focus: #f4f7ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 16%, rgba(148,35,55,.20), transparent 34rem),
    radial-gradient(circle at 10% 70%, rgba(57,49,109,.16), transparent 30rem),
    var(--bg);
}
button { font: inherit; }
.shell { width: min(1440px, 100%); margin: 0 auto; padding: 18px clamp(12px, 2vw, 28px) 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.6rem, 5vw, 2.35rem); }
h2 { margin-bottom: 8px; font-size: 1.05rem; }
.eyebrow { color: #ff8a94; font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
.connection { min-height: 44px; display: inline-flex; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.05); border-radius: 999px; padding: 8px 12px; color: var(--muted); font-size: .8rem; }
.connection.live { color: var(--good); border-color: rgba(103,230,164,.35); }
.connection.error { color: var(--bad); border-color: rgba(255,115,125,.35); }
.view-nav { margin: 18px 0 12px; display: flex; gap: 8px; }
.view-tab { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--muted); text-decoration: none; }
.view-tab.active { color: var(--text); background: rgba(255,75,88,.13); border-color: rgba(255,75,88,.35); }
.panel, .state-card { border: 1px solid var(--line); background: var(--panel); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.20); }
.state-card { padding: 30px; text-align: center; color: var(--muted); }
.state-card h2 { color: var(--text); }
.combat-root { display: grid; gap: 12px; }
.combat-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; padding: 12px; }
.combat-summary > div { min-width: 0; padding: 9px 11px; border-radius: 11px; background: var(--panel-2); }
.label { display: block; margin-bottom: 3px; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.combat-summary strong { display: block; overflow-wrap: anywhere; }
.initiative-panel, .battlefield-panel, .tempt-fate-panel, .requester-panel, .range-panel, .inspection-panel, .relationship-panel { padding: 14px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.initiative-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; padding: 4px 1px 2px; }
.initiative-chip { min-width: 0; border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 9px 10px; }
.initiative-chip.current { border-color: rgba(255,75,88,.72); box-shadow: inset 0 0 0 1px rgba(255,75,88,.25); }
.initiative-chip .order { color: var(--muted); font-size: .68rem; }
.initiative-chip .name { display: block; margin: 2px 0; font-weight: 800; overflow-wrap: anywhere; }
.initiative-chip .score { color: #d9dceb; font-size: .78rem; }
.initiative-chip .turn-flag { display: block; margin-top: 5px; color: #ff9aa2; font-size: .68rem; font-weight: 900; letter-spacing: .06em; }
.battle-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(270px, .85fr); gap: 12px; align-items: start; }
.side-stack { display: grid; gap: 12px; }
.truth-note, .intent-note { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.truth-note { border-left: 3px solid var(--warn); padding-left: 10px; }
.intent-note { margin: 12px 0 0; border-top: 1px solid var(--line); padding-top: 10px; }
.battlefield-guide { display: grid; gap: 3px; margin: 2px 0 10px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.035); font-size: .76rem; line-height: 1.4; }
.battlefield-guide strong { color: var(--focus); overflow-wrap: anywhere; }
.battlefield-guide span { color: var(--muted); }
.battlefield { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 285px), 1fr)); gap: 12px; min-height: 310px; padding: clamp(8px,2vw,18px); border-radius: 15px; background: radial-gradient(ellipse at center, rgba(255,75,88,.09), rgba(20,21,29,.45) 58%, rgba(8,9,13,.72)); border: 1px solid rgba(255,255,255,.07); align-items: start; }
.faction-zone { min-width: 0; position: relative; border: 1px solid hsla(var(--faction-hue), 72%, 64%, .32); background: linear-gradient(135deg, hsla(var(--faction-hue), 72%, 54%, .11), rgba(255,255,255,.02)); border-radius: 18px; padding: 12px; }
.faction-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 11px; font-weight: 850; overflow-wrap: anywhere; }
.faction-dot { width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--faction-hue), 72%, 64%); box-shadow: 0 0 18px hsla(var(--faction-hue),72%,64%,.65); }
.token-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); gap: 10px; }
.combatant-token { width: 100%; min-width: 0; min-height: 150px; color: var(--text); text-align: left; cursor: pointer; border: 1px solid var(--line); background: rgba(5,6,10,.65); border-radius: 15px; padding: 10px; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.combatant-token:hover, .combatant-token:focus-visible { transform: translateY(-2px); border-color: hsla(var(--faction-hue),72%,64%,.7); outline: none; }
.combatant-token:focus-visible { box-shadow: 0 0 0 3px rgba(244,247,255,.22); }
.combatant-token.current { border-color: var(--combat); box-shadow: 0 0 0 2px rgba(255,75,88,.12), 0 0 24px rgba(255,75,88,.16); }
.combatant-token.focused { outline: 2px solid rgba(244,247,255,.62); outline-offset: 2px; }
.combatant-token.defeated { opacity: .72; filter: grayscale(.35); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 8px; font-weight: 900; background: hsla(var(--faction-hue),72%,54%,.18); border: 1px solid hsla(var(--faction-hue),72%,64%,.50); }
.token-name { display: block; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.token-hp, .token-state { display: block; margin-top: 6px; color: var(--muted); font-size: .72rem; }
.token-state.current { color: #ff9aa2; font-weight: 900; }
.token-state.defeated { color: #ffb0b6; font-weight: 900; }
.token-range { display: block; margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.07); color: #d9dceb; font-size: .68rem; line-height: 1.3; overflow-wrap: anywhere; }
.token-range.focused { color: var(--focus); font-weight: 850; }
.fact-list { display: grid; gap: 7px; }
.fact-row { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 7px; border-bottom: 1px solid rgba(255,255,255,.06); font-size: .82rem; }
.fact-row span:first-child { color: var(--muted); }
.badge-stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { display: inline-flex; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.05); border-radius: 999px; padding: 5px 8px; font-size: .7rem; }
.badge.hostile { color: #ff969e; border-color: rgba(255,75,88,.35); }
.badge.cooperative { color: #86efb6; border-color: rgba(103,230,164,.35); }
.badge.neutral { color: #d2d6df; }
.badge.engaged { color: #ff979f; }
.badge.nearby { color: #ffd27a; }
.badge.far { color: #9cc5ff; }
.empty { color: var(--muted); font-size: .82rem; }
.relationship-list, .range-list { display: grid; gap: 7px; }
.relationship-list .badge, .range-list .badge { width: 100%; justify-content: flex-start; overflow-wrap: anywhere; white-space: normal; }
.range-list .badge { border-radius: 10px; line-height: 1.35; }
.private-status { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.private-state { padding: 10px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); }
.private-state strong { display: block; margin-top: 3px; }
.private-state.ready strong { color: var(--good); }
.private-state.off strong { color: var(--muted); }
.turn-message { margin-bottom: 10px; color: var(--muted); font-size: .82rem; }
.tempt-fate-panel { border-color: rgba(255,75,88,.45); line-height: 1.55; }
.tempt-fate-odds { font-weight: 800; letter-spacing: .01em; }
.fate-stack { display: grid; gap: 8px; }
.fate-attempt { color: var(--text); line-height: 1.4; overflow-wrap: anywhere; }
.fate-odds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fate-odds > div { padding: 9px 10px; border-radius: 10px; font-weight: 850; text-align: center; }
.fate-failure { background: rgba(255,115,125,.12); border: 1px solid rgba(255,115,125,.35); color: var(--bad); }
.fate-success { background: rgba(103,230,164,.10); border: 1px solid rgba(103,230,164,.30); color: var(--good); }
.fate-result { font-weight: 900; overflow-wrap: anywhere; }
.fate-intent-input { width: 100%; min-height: 96px; resize: vertical; margin: 8px 0; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.22); color: var(--text); padding: 10px 11px; line-height: 1.45; font: inherit; }
.fate-intent-input:focus { outline: 2px solid rgba(255,75,88,.42); outline-offset: 1px; }
.fate-result-card { display: grid; justify-items: center; gap: 4px; margin-top: 10px; padding: 15px; border-radius: 14px; border: 1px solid rgba(255,75,88,.48); background: radial-gradient(circle at 50% 15%, rgba(255,75,88,.18), rgba(255,255,255,.035)); text-align: center; }
.fate-roll-number { font-size: clamp(2.25rem, 8vw, 4.2rem); line-height: 1; font-weight: 950; letter-spacing: -.04em; }
.fate-reveal { animation: fateReveal .72s cubic-bezier(.16,.84,.28,1) both; }
@keyframes fateReveal { 0% { opacity: 0; transform: scale(.84); filter: blur(5px); } 60% { opacity: 1; transform: scale(1.045); filter: blur(0); } 100% { opacity: 1; transform: scale(1); filter: blur(0); } }
.character-workspace { display: grid; grid-template-columns: minmax(220px, .72fr) minmax(0, 2.2fr); gap: 12px; align-items: start; }
.character-library-panel, .character-studio-panel { padding: 14px; min-width: 0; }
.character-list { display: grid; gap: 8px; margin-top: 12px; }
.character-list-item { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; background: var(--panel-2); color: var(--text); text-align: left; cursor: pointer; }
.character-list-item strong, .character-list-item span { display: block; overflow-wrap: anywhere; }
.character-list-item span { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.character-list-item.active { border-color: rgba(255,75,88,.55); background: rgba(255,75,88,.12); }
.studio-heading { align-items: center; }
.studio-nav { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.studio-tab { border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; background: rgba(255,255,255,.04); color: var(--muted); cursor: pointer; }
.studio-tab.active { color: var(--text); border-color: rgba(255,75,88,.45); background: rgba(255,75,88,.12); }
.studio-tab.muted { opacity: .58; }
.studio-content { display: grid; gap: 12px; }
.studio-card { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 12px; min-width: 0; }
.studio-card h3 { margin: 0 0 8px; font-size: .95rem; }
.form-grid { display: grid; gap: 12px; }
.form-field { display: grid; gap: 6px; }
.form-label { color: var(--text); font-size: .82rem; font-weight: 800; }
.form-help { color: var(--muted); font-size: .74rem; line-height: 1.45; }
.omega-input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5,6,10,.72); color: var(--text); padding: 9px 10px; font: inherit; }
.omega-input:focus { outline: 2px solid rgba(244,247,255,.22); border-color: rgba(244,247,255,.42); }
.omega-input:disabled { opacity: .58; cursor: not-allowed; }
.omega-textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
.omega-button { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.06); color: var(--text); padding: 8px 11px; cursor: pointer; }
.omega-button:hover:not(:disabled), .omega-button:focus-visible:not(:disabled) { border-color: rgba(255,255,255,.30); }
.omega-button.primary { background: rgba(255,75,88,.14); border-color: rgba(255,75,88,.42); }
.omega-button.danger { color: #ffb0b6; border-color: rgba(255,115,125,.34); }
.omega-button:disabled { opacity: .5; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,210px),1fr)); gap: 9px; margin: 2px 0; }
.inventory-item-card { min-width: 0; min-height: 74px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); padding: 10px 11px; text-align: left; cursor: pointer; display: grid; gap: 5px; }
.inventory-item-card strong, .inventory-item-card span { overflow-wrap: anywhere; }
.inventory-item-card span { color: var(--muted); font-size: .75rem; }
.inventory-item-card.active { border-color: rgba(255,75,88,.55); background: rgba(255,75,88,.12); }
.inventory-slot-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.06); padding: 6px 0; }
.inventory-slot-row:last-child { border-bottom: 0; }
.check-row { display: inline-flex; gap: 6px; align-items: center; margin: 4px 12px 4px 0; color: var(--text); }
.save-state { max-width: min(48vw, 420px); color: var(--muted); font-size: .75rem; text-align: right; overflow-wrap: anywhere; }
.save-state.ok { color: var(--good); }
.save-state.error { color: var(--bad); }
.error-card { border-color: rgba(255,115,125,.36); }
.portrait-preview { width: min(420px,100%); max-height: 620px; object-fit: contain; justify-self: center; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.25); }
.omega-file { max-width: 100%; color: var(--muted); }
@media (max-width: 860px) {
  .combat-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .battle-layout { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr; }
  .character-workspace { grid-template-columns: 1fr; }
  .character-library-panel { position: static; }
}
@media (max-width: 520px) {
  .shell { padding-left: 9px; padding-right: 9px; }
  .topbar { align-items: end; gap: 10px; }
  .connection { max-width: 48vw; text-align: center; justify-content: center; }
  .combat-summary { grid-template-columns: 1fr 1fr; }
  .initiative-strip { grid-template-columns: 1fr 1fr; }
  .token-row { grid-template-columns: 1fr 1fr; }
  .battlefield { padding: 8px; }
  .view-nav { flex-wrap: wrap; padding-bottom: 4px; }
  .view-tab { white-space: nowrap; }
  .studio-nav { flex-wrap: wrap; padding-bottom: 10px; }
  .studio-tab { white-space: normal; }
  .button-row { align-items: stretch; }
  .button-row > * { flex: 1 1 160px; }
}
@media (max-width: 390px) {
  .combat-summary, .initiative-strip, .token-row, .private-status { grid-template-columns: 1fr; }
  .connection { max-width: 52vw; }
}
@media (prefers-reduced-motion: reduce) {
  .combatant-token { transition: none; }
  .combatant-token:hover, .combatant-token:focus-visible { transform: none; }
  .fate-reveal { animation: none; }
}
