:root {
  color-scheme: dark;
  --ink: #e8f5f4; --muted: #9db7b8; --subtle: #6d898b;
  --bg: #050f12; --bg2: #07181b; --panel: #0a2024; --panel2: #0d292e;
  --line: #173e43; --line2: #23535a; --accent: #61e4de; --accent2: #9184ff;
  --good: #57df8d; --warn: #ffd166; --danger: #ff707a; --radius: 18px;
  --shadow: 0 20px 60px rgba(0,0,0,.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% 0%, rgba(145,132,255,.12), transparent 36rem), radial-gradient(circle at 0 25%, rgba(97,228,222,.09), transparent 30rem), var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 3px solid rgba(97,228,222,.7); }
a { color: var(--accent); }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
.skip-link { position: fixed; top: -60px; left: 12px; z-index: 1000; padding: 10px 16px; background: var(--accent); color: #021011; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 20px var(--good); display: inline-block; margin-right: 10px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.78); } }

.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: rgba(5,15,18,.93); backdrop-filter: blur(14px); }
.brand { min-width: 0; }
.brand-kicker { margin: 0 0 4px; color: var(--subtle); letter-spacing: .17em; font-size: .75rem; text-transform: uppercase; }
.brand-name { margin: 0; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.online { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; }
.online::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 12px var(--good); }
.navbar { display: flex; gap: 5px; flex-wrap: wrap; }
.nav-link, .button, button.button { border: 1px solid var(--line2); background: #0a1b1f; color: var(--ink); border-radius: 11px; padding: 10px 14px; text-decoration: none; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 1.1; }
.nav-link:hover, .button:hover { border-color: var(--accent); background: #0e292d; }
.nav-link.active { color: #031416; background: var(--accent); border-color: var(--accent); }
.button.primary { color: #031416; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { filter: brightness(1.05); }
.button.secondary { background: rgba(145,132,255,.12); border-color: rgba(145,132,255,.5); }
.button.danger { color: #ffdfe2; border-color: rgba(255,112,122,.55); background: rgba(255,112,122,.1); }
.button.ghost { background: transparent; }
.button.small { padding: 7px 10px; font-size: .86rem; }
.button.icon { width: 42px; padding-inline: 0; }

main { width: min(1420px, 100%); margin: 0 auto; padding: 30px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); letter-spacing: .16em; text-transform: uppercase; font-size: .76rem; }
h1, h2, h3, h4 { margin-top: 0; line-height: 1.12; }
h1 { font-size: clamp(2rem, 4vw, 3.7rem); margin-bottom: 10px; letter-spacing: -.04em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.12rem; }
p { line-height: 1.6; }
.lede { color: var(--muted); max-width: 75ch; margin: 0; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.danger-text { color: var(--danger); }
.good-text { color: var(--good); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(11,35,39,.95), rgba(7,23,27,.96)); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.panel.compact { padding: 16px; }
.panel.accent { background: linear-gradient(135deg, rgba(17,65,68,.88), rgba(28,30,67,.9)); }
.panel > :last-child { margin-bottom: 0; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.callout { border-left: 4px solid var(--accent); padding: 14px 17px; background: rgba(97,228,222,.07); border-radius: 0 12px 12px 0; }
.callout.warn { border-color: var(--warn); background: rgba(255,209,102,.07); }
.callout.danger { border-color: var(--danger); background: rgba(255,112,122,.07); }

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.agent-card { position: relative; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(10,35,38,.96), rgba(13,26,45,.95)); padding: 21px; min-height: 215px; display: flex; flex-direction: column; }
.agent-card h2 { font-size: 1.55rem; margin-bottom: 5px; }
.agent-card .callsign { color: var(--accent); letter-spacing: .13em; text-transform: uppercase; font-size: .74rem; }
.agent-card .summary { color: var(--muted); margin: 8px 0 18px; }
.agent-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: auto; }
.stat-mini { background: rgba(0,0,0,.18); border: 1px solid var(--line); border-radius: 10px; padding: 9px; text-align: center; }
.stat-mini span { display: block; font-size: .68rem; color: var(--subtle); text-transform: uppercase; letter-spacing: .1em; }
.stat-mini strong { font-size: 1.15rem; }

.hero { overflow: hidden; padding: 0; }
.hero-main { padding: 28px 32px; min-height: 230px; background: linear-gradient(110deg, rgba(4,62,66,.9), rgba(17,28,66,.88)); display: grid; grid-template-columns: 160px 1fr auto; gap: 28px; align-items: center; }
.avatar { width: 150px; height: 150px; border-radius: 38px; border: 4px solid rgba(145,132,255,.65); background: rgba(145,132,255,.35); display: grid; place-items: center; font-weight: 900; font-size: 2.2rem; }
.hero-meta h1 { margin: 7px 0 12px; }
.hero-actions { align-self: start; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hero-stats { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); border-top: 1px solid var(--line); }
.hero-stat { text-align: center; padding: 19px 10px; border-right: 1px solid var(--line); }
.hero-stat:last-child { border-right: 0; }
.hero-stat span { display: block; color: var(--subtle); text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; margin-bottom: 5px; }
.hero-stat strong { font-size: 1.45rem; }

.tabs { display: flex; gap: 7px; overflow-x: auto; padding: 4px 0 12px; margin: 24px 0 8px; }
.tab { white-space: nowrap; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 9px 14px; font-weight: 700; }
.tab.active { color: #021315; background: var(--accent); border-color: var(--accent); }
.ability-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.ability { text-align: center; border: 1px solid var(--line); border-radius: 16px; padding: 17px 8px; background: rgba(0,0,0,.13); }
.ability .label { color: var(--muted); font-weight: 800; letter-spacing: .12em; }
.ability .mod { display: block; color: var(--accent); font-size: 2rem; font-weight: 900; margin: 7px 0; }
.ability button { border: 0; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--muted); padding: 5px 12px; }

.action-groups { display: grid; gap: 24px; }
.action-card { border: 1px solid var(--line); border-radius: 15px; padding: 17px; background: rgba(0,0,0,.14); }
.action-card-head { display: flex; justify-content: space-between; align-items: start; gap: 15px; }
.action-card h3 { margin: 0 0 5px; }
.action-badges, .badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; border: 1px solid var(--line2); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: .73rem; }
.badge.accent { color: var(--accent); }
.action-card p { color: var(--muted); margin: 11px 0; }
.action-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.action-controls select { width: auto; min-width: 120px; }
.roll-result { border: 1px solid var(--line2); border-radius: 14px; padding: 16px; background: #061518; margin: 14px 0; }
.roll-total { font-size: 2.2rem; color: var(--accent); font-weight: 900; }

form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
label, .field-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; margin-bottom: 7px; }
input, select, textarea { width: 100%; border: 1px solid var(--line2); border-radius: 11px; background: #061619; color: var(--ink); padding: 11px 12px; }
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); }
input:invalid { border-color: var(--danger); }
.field-note { display: block; color: var(--subtle); font-size: .78rem; margin-top: 5px; line-height: 1.45; }
.help { position: relative; display: inline-flex; }
.help-button { border: 1px solid var(--line2); border-radius: 50%; width: 21px; height: 21px; padding: 0; background: rgba(97,228,222,.08); color: var(--accent); font-size: .73rem; font-weight: 900; }
.tooltip { position: absolute; z-index: 80; left: 0; top: calc(100% + 8px); width: min(340px, 80vw); padding: 12px; border: 1px solid var(--line2); border-radius: 10px; background: #0b2428; color: var(--ink); box-shadow: var(--shadow); text-transform: none; letter-spacing: 0; font-weight: 500; line-height: 1.45; font-size: .83rem; display: none; }
.help:hover .tooltip, .help:focus-within .tooltip, .help.open .tooltip { display: block; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.option-card { display: block; position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 15px; background: rgba(0,0,0,.12); cursor: pointer; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 500; margin: 0; }
.option-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: rgba(97,228,222,.08); }
.option-card input { position: absolute; right: 14px; top: 14px; }
.option-card strong { display: block; margin-right: 28px; }
.option-card small { display: block; color: var(--muted); line-height: 1.45; margin-top: 7px; }
.check-list { display: grid; gap: 8px; }
.check-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 12px; padding: 11px; }
.check-row label { display: block; text-transform: none; letter-spacing: 0; margin: 0; color: var(--ink); font-size: .92rem; }
.check-row small { color: var(--muted); display: block; margin-top: 4px; line-height: 1.4; }
.sticky-actions { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; border: 1px solid var(--line2); border-radius: 14px; background: rgba(5,19,22,.96); padding: 12px; box-shadow: var(--shadow); }
.unsaved { color: var(--warn); font-weight: 700; }

.stepper { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin: 0 0 24px; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 9px; color: var(--subtle); background: rgba(0,0,0,.08); text-align: center; font-size: .78rem; }
.step.active { color: #021315; background: var(--accent); border-color: var(--accent); font-weight: 900; }
.step.done { color: var(--good); border-color: rgba(87,223,141,.45); }

.score-rolls { display: grid; gap: 12px; }
.roll-set { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.dice { display: flex; gap: 6px; flex-wrap: wrap; }
.die { min-width: 34px; padding: 6px; text-align: center; border: 1px solid var(--line2); border-radius: 8px; background: rgba(255,255,255,.04); }
.die.dropped { opacity: .4; text-decoration: line-through; }
.score-total { color: var(--accent); font-weight: 900; font-size: 1.5rem; }
.ability-roll-progress { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.12); }
.ability-roll-progress span { color: var(--muted); }

.progression-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.progression-table th, .progression-table td { text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); padding: 12px 10px; }
.progression-table th { color: var(--subtle); text-transform: uppercase; letter-spacing: .07em; font-size: .7rem; position: static; background: var(--panel); }
.progression-table th:first-child, .progression-table td:first-child { width: 64px; min-width: 64px; white-space: nowrap; }
.progression-table th:nth-child(2), .progression-table td:nth-child(2) { width: 112px; min-width: 112px; white-space: nowrap; }
.progression-table td { line-height: 1.45; }
.progression-table li + li { margin-top: .35rem; }
.progression-table tr.earned { opacity: .68; }
.progression-table tr.next { background: rgba(97,228,222,.09); box-shadow: inset 3px 0 var(--accent); }
.progression-table tr.future { color: var(--muted); }
.progression-table ul { margin: 0; padding-left: 18px; }

.library-toolbar { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 13px; }
.library-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: rgba(0,0,0,.12); }
.library-card h3 { margin-bottom: 5px; }
.library-card p { color: var(--muted); font-size: .9rem; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
details + details { margin-top: 9px; }
summary { cursor: pointer; font-weight: 800; }

.auth-shell { width: min(1000px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; display: grid; place-items: center; padding: 30px 0; }
.auth-card { width: 100%; display: grid; grid-template-columns: 1.1fr .9fr; overflow: hidden; padding: 0; }
.auth-intro { padding: 42px; background: linear-gradient(145deg, rgba(7,72,76,.85), rgba(22,27,67,.9)); }
.auth-form { padding: 38px; }
.auth-form .button { width: 100%; margin-top: 10px; }

.empty { text-align: center; padding: 50px 20px; border: 1px dashed var(--line2); border-radius: 16px; color: var(--muted); }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; width: min(390px, calc(100vw - 36px)); }
.toast { border: 1px solid var(--line2); border-left: 4px solid var(--accent); border-radius: 12px; background: #0a2226; color: var(--ink); padding: 13px 15px; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--danger); }
.loading #app { opacity: .6; pointer-events: none; }
.sr-only { position: absolute!important; width: 1px!important; height: 1px!important; overflow: hidden!important; clip: rect(1px,1px,1px,1px)!important; white-space: nowrap!important; }

.character-operation { margin: 20px 0 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 22px; align-items: start; }
.character-operation .action-controls { grid-column: 1 / -1; justify-content: flex-end; }
.danger-zone { border-color: rgba(255,112,122,.6); background: linear-gradient(145deg, rgba(49,18,23,.94), rgba(21,16,25,.96)); }
.compact-check { grid-template-columns: 22px 1fr; height: 100%; align-content: center; }

.dice-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(1,8,10,.84); backdrop-filter: blur(12px); opacity: 1; transition: opacity .14s ease; }
.dice-overlay.closing { opacity: 0; }
.dice-animation-card { width: min(900px, 100%); max-height: min(88vh, 760px); overflow: auto; border: 1px solid var(--line2); border-radius: 24px; padding: 24px; background: radial-gradient(circle at 50% 0%, rgba(97,228,222,.12), transparent 24rem), linear-gradient(145deg, #0b252a, #09171f); box-shadow: 0 32px 100px rgba(0,0,0,.62), 0 0 60px rgba(97,228,222,.1); }
.dice-animation-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.dice-animation-head h2 { margin-bottom: 0; }
.dice-animation-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.dice-animation-group { border: 1px solid var(--line); border-radius: 16px; padding: 15px; background: rgba(0,0,0,.18); }
.dice-animation-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dice-animation-total { min-width: 52px; color: var(--accent); font-size: 1.8rem; line-height: 1; font-weight: 950; text-align: right; opacity: 0; transform: translateY(5px); transition: opacity .18s ease, transform .18s ease; }
.dice-overlay.settled .dice-animation-total { opacity: 1; transform: translateY(0); }
.animated-dice { min-height: 78px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; perspective: 700px; }
.animated-die { --die-bg: linear-gradient(145deg, #65f1ea, #5b82d8); position: relative; width: 68px; height: 68px; display: grid; place-items: center; flex: 0 0 auto; color: #021214; background: var(--die-bg); border: 1px solid rgba(255,255,255,.5); box-shadow: 0 12px 30px rgba(0,0,0,.34), inset 0 0 18px rgba(255,255,255,.25); transform-style: preserve-3d; }
.animated-die small { position: absolute; top: 7px; left: 0; right: 0; color: rgba(2,18,20,.65); font-size: .57rem; font-weight: 900; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.animated-die b { font-size: 1.62rem; line-height: 1; }
.animated-die.d4 { clip-path: polygon(50% 0, 98% 91%, 2% 91%); padding-top: 12px; }
.animated-die.d6 { border-radius: 13px; }
.animated-die.d8 { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.animated-die.d10 { clip-path: polygon(50% 0, 94% 30%, 80% 90%, 50% 100%, 20% 90%, 6% 30%); }
.animated-die.d12 { clip-path: polygon(50% 0, 88% 15%, 100% 53%, 80% 91%, 37% 100%, 4% 71%, 5% 29%); }
.animated-die.d20 { clip-path: polygon(50% 0, 88% 18%, 100% 56%, 76% 92%, 34% 100%, 3% 69%, 8% 25%); }
.dice-overlay:not(.settled) .animated-die { animation: dice-tumble .48s linear infinite; }
.dice-overlay:not(.settled) .animated-die:nth-child(2n) { animation-delay: -.17s; animation-direction: reverse; }
.dice-overlay:not(.settled) .animated-die:nth-child(3n) { animation-delay: -.31s; }
.dice-overlay.settled .animated-die[data-outcome="dropped"], .dice-overlay.settled .animated-die[data-outcome="unselected"] { opacity: .38; filter: grayscale(.65); transform: scale(.9); }
.dice-overlay.settled .animated-die[data-outcome="dropped"] b { text-decoration: line-through; }
.dice-overlay.settled .animated-die[data-outcome="selected"], .dice-overlay.settled .animated-die[data-outcome="kept"] { box-shadow: 0 0 0 3px rgba(97,228,222,.28), 0 15px 38px rgba(0,0,0,.4), 0 0 30px rgba(97,228,222,.35); }
.dice-animation-note { display: block; min-height: 1.3em; margin-top: 9px; color: var(--muted); text-align: center; }
.dice-animation-status { margin-top: 18px; color: var(--muted); text-align: center; font-size: .85rem; letter-spacing: .05em; }
.dice-omitted { color: var(--muted); font-weight: 800; }
@keyframes dice-tumble {
  0% { transform: translateY(4px) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(.94); }
  35% { transform: translateY(-14px) rotateX(150deg) rotateY(85deg) rotateZ(70deg) scale(1.03); }
  70% { transform: translateY(1px) rotateX(280deg) rotateY(205deg) rotateZ(190deg) scale(.97); }
  100% { transform: translateY(4px) rotateX(360deg) rotateY(360deg) rotateZ(360deg) scale(.94); }
}

@media (max-width: 1000px) {
  .hero-main { grid-template-columns: 110px 1fr; }
  .avatar { width: 105px; height: 105px; border-radius: 28px; }
  .hero-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .hero-stat:nth-child(3) { border-right: 0; }
  .hero-stat:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .ability-grid { grid-template-columns: repeat(3, 1fr); }
  .grid.three { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 12px 15px; }
  .brand-name { font-size: 1rem; }
  .online { display: none; }
  main { padding: 22px 14px 70px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid.two, .grid.three, .form-grid, .auth-card { grid-template-columns: 1fr; }
  .hero-main { padding: 23px; grid-template-columns: 82px 1fr; gap: 16px; }
  .avatar { width: 80px; height: 80px; font-size: 1.4rem; border-radius: 22px; }
  .hero-meta h1 { font-size: 2.1rem; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stat { border-bottom: 1px solid var(--line); }
  .hero-stat:nth-child(odd) { border-right: 1px solid var(--line); }
  .hero-stat:nth-child(even) { border-right: 0; }
  .stepper { grid-template-columns: repeat(3, 1fr); }
  .library-toolbar { grid-template-columns: 1fr; }
  .progression-table { display: block; overflow-x: auto; }
  .sticky-actions { bottom: 6px; }
  .character-operation { grid-template-columns: 1fr; }
  .character-operation .action-controls { grid-column: auto; justify-content: flex-start; }
  .ability-roll-progress { align-items: flex-start; flex-direction: column; }
  .dice-animation-card { padding: 18px; border-radius: 18px; }
  .dice-animation-head { align-items: flex-start; }
  .animated-die { width: 58px; height: 58px; }
  .animated-die b { font-size: 1.4rem; }
}
@media (max-width: 430px) {
  .top-actions .nav-link span { display: none; }
  .ability-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 18px; }
  .hero-main { grid-template-columns: 1fr; }
  .avatar { width: 68px; height: 68px; }
  .hero-actions { grid-column: auto; }
}
@media print {
  .topbar, .hero-actions, .tabs, .sticky-actions, .button, .action-controls, .character-operation, .dice-overlay { display: none!important; }
  body { background: white; color: black; }
  .panel, .hero { box-shadow: none; border-color: #aaa; background: white; }
  main { width: 100%; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto!important; animation-duration: .001ms!important; animation-iteration-count: 1!important; transition-duration: .001ms!important; }
  .dice-overlay:not(.settled) .animated-die { animation: none; }
}

/* Continuity 2.3 builder and advancement workspaces */
.stepper { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.class-plan { display: grid; gap: 14px; margin-top: 18px; }
.class-allocation { border: 1px solid var(--line); border-radius: 15px; padding: 17px; background: rgba(0,0,0,.14); }
.class-allocation-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.class-allocation-head h3 { margin-bottom: 0; }
.class-allocation-controls { display: grid; grid-template-columns: minmax(240px, 2fr) minmax(110px, .7fr) auto; gap: 12px; align-items: end; margin-top: 14px; }
.class-row-buttons { padding-bottom: 1px; justify-content: flex-end; }
.allocation-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.allocation-summary.good { border-color: rgba(87,223,141,.55); background: rgba(87,223,141,.08); }
.allocation-summary.bad { border-color: rgba(255,112,122,.58); background: rgba(255,112,122,.08); }
.choice-block { border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.1); padding: 16px; margin: 0 0 15px; }
fieldset.choice-block legend { color: var(--ink); font-weight: 850; padding: 0 7px; max-width: 100%; }
.field.choice-block { display: block; }
.review-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-bottom: 16px; }
.progression-table tr.planned { background: rgba(145,132,255,.09); box-shadow: inset 3px 0 var(--accent2); }
[data-protocol-card][hidden] { display: none; }

@media (max-width: 1000px) {
  .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .class-allocation-controls { grid-template-columns: 1fr 120px; }
  .class-row-buttons { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .class-allocation-head, .allocation-summary { align-items: flex-start; flex-direction: column; }
  .class-allocation-controls { grid-template-columns: 1fr; }
  .review-stats { grid-template-columns: 1fr; }
}

/* Continuity 2.4: full-width progression, custom equipment, and encounter workspaces */
.progression-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  border-radius: 10px;
}
.progression-table {
  width: 100%;
  min-width: 760px;
  table-layout: auto;
  display: table;
  overflow: visible;
}
.progression-table th:nth-child(3),
.progression-table td:nth-child(3) {
  width: auto;
  min-width: 480px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.progression-table td ul { max-width: none; }
.framework-library { grid-template-columns: minmax(0, 1fr); }
.framework-card { width: 100%; min-width: 0; overflow: visible; }
.framework-card details { overflow: visible; }

.selection-explanation {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 16px;
  background: rgba(97,228,222,.055);
}
.selection-explanation p { margin: 8px 0; }
.selection-explanation small { color: var(--muted); }

.custom-item-editor { margin: 0 0 20px; }
.custom-item-action { margin-top: 14px; }
.custom-item-action textarea { min-height: 88px; }

.encounter-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}
.encounter-status > div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  background: rgba(0,0,0,.16);
  text-align: center;
}
.encounter-status span {
  display: block;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: .68rem;
  margin-bottom: 5px;
}
.encounter-status strong { font-size: 1.2rem; }
.encounter-columns { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-items: start; }
.combatant-grid { display: grid; gap: 14px; }
.combatant-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 17px;
  background: linear-gradient(145deg, rgba(10,35,38,.9), rgba(9,22,30,.93));
}
.combatant-card.current-turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(97,228,222,.13), 0 12px 38px rgba(0,0,0,.24);
}
.enemy-health {
  position: relative;
  height: 16px;
  margin: 13px 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
}
.enemy-health-fill { display: block; height: 100%; border-radius: inherit; transition: width .32s ease, background .32s ease; }
.enemy-health-fill.stage-5 { background: linear-gradient(90deg, #33d17a, #78e08f); }
.enemy-health-fill.stage-4 { background: linear-gradient(90deg, #72d86e, #b7dd60); }
.enemy-health-fill.stage-3 { background: linear-gradient(90deg, #e6c84f, #f1a83a); }
.enemy-health-fill.stage-2 { background: linear-gradient(90deg, #ef9a3c, #ef6548); }
.enemy-health-fill.stage-1 { background: linear-gradient(90deg, #e84f4f, #a91f35); }
.enemy-health-fill.stage-0 { background: #54131e; }
.enemy-stat-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 10px 0;
  color: var(--muted);
  font-size: .88rem;
}
.enemy-stat-line b { color: var(--ink); }
.encounter-vitality {
  display: grid;
  grid-template-columns: minmax(90px, .6fr) minmax(120px, 1fr) auto;
  gap: 8px;
  margin: 12px 0;
}
.enemy-actions { margin-top: 16px; display: grid; gap: 10px; }
.enemy-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  background: rgba(0,0,0,.13);
}
.enemy-action p { margin: 7px 0; color: var(--muted); }
.enemy-action .action-controls { justify-content: flex-end; }
.enemy-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 13px;
}
.enemy-picker[hidden] { display: none; }
.enemy-quantity { display: flex; align-items: center; gap: 8px; margin: 0; }
.enemy-quantity input { width: 75px; }
.encounter-search { min-width: min(360px, 100%); }
.encounter-card .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.enemy-library-card { min-width: 0; }

@media (max-width: 900px) {
  .encounter-columns { grid-template-columns: 1fr; }
  .enemy-picker-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .progression-table { display: table; overflow: visible; }
  .progression-table th:nth-child(3), .progression-table td:nth-child(3) { min-width: 360px; }
  .encounter-status { grid-template-columns: 1fr; }
  .encounter-vitality, .enemy-action { grid-template-columns: 1fr; }
  .enemy-action .action-controls { justify-content: flex-start; }
}

/* On phone-sized screens, progression rows become readable stacked records rather than a clipped table. */
@media (max-width: 700px) {
  .progression-scroll { overflow: visible; }
  .progression-table,
  .progression-table thead,
  .progression-table tbody,
  .progression-table tr,
  .progression-table th,
  .progression-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .progression-table { min-width: 0; }
  .progression-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .progression-table tr {
    margin: 0 0 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0,0,0,.12);
  }
  .progression-table td {
    position: relative;
    padding: 11px 12px 11px 118px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .progression-table td:last-child { border-bottom: 0; }
  .progression-table td::before {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 96px;
    color: var(--subtle);
    font-size: .68rem;
    font-weight: 850;
    letter-spacing: .07em;
    text-transform: uppercase;
  }
  .progression-table td:nth-child(1)::before { content: "Level"; }
  .progression-table td:nth-child(2)::before { content: "Proficiency"; }
  .progression-table td:nth-child(3)::before { content: "Features"; }
  .progression-table td:nth-child(3) { min-width: 0; }
  .progression-table ul { padding-left: 18px; }
}
