:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #141922;
  --panel-2: #1b2230;
  --line: #2b3445;
  --text: #eef2f7;
  --muted: #9da9ba;
  --accent: #d5a84a;
  --accent-strong: #f0c76a;
  --danger-bg: #3a1e23;
  --danger-line: #7e3945;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; background: radial-gradient(circle at top, #171d28 0, var(--bg) 32rem); color: var(--text); min-height: 100vh; }
a { color: inherit; }
.shell { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; }
.site-header { border-bottom: 1px solid var(--line); background: rgba(12, 15, 20, .88); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { text-decoration: none; font-size: 1.1rem; font-weight: 800; letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 1rem; color: var(--muted); }
.nav a, .link-button { color: var(--muted); text-decoration: none; }
.nav a:hover, .link-button:hover { color: var(--text); }
.user-label { color: var(--text); }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: transparent; font: inherit; padding: 0; cursor: pointer; }
.page { padding: 3rem 0 5rem; }
.hero { min-height: 55vh; display: grid; align-content: center; justify-items: start; }
.hero h1, .page-heading h1, .auth-card h1 { font-size: clamp(2.25rem, 6vw, 4.5rem); margin: 0; line-height: .98; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .76rem; font-weight: 800; color: var(--accent-strong); margin: 0 0 .7rem; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 700px; line-height: 1.65; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.button { display: inline-block; border: 1px solid #e2bc66; background: var(--accent); color: #17120a; padding: .75rem 1rem; border-radius: .55rem; text-decoration: none; font-weight: 800; cursor: pointer; }
.button:hover { background: var(--accent-strong); }
.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: .8rem; padding: 1.35rem; box-shadow: 0 16px 44px rgba(0,0,0,.18); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.game-card { text-decoration: none; transition: transform .15s ease, border-color .15s ease; min-height: 190px; }
.game-card:hover { transform: translateY(-2px); border-color: #5b687d; }
.game-card h2 { margin: .8rem 0 .4rem; }
.card-link { display: block; margin-top: 1.2rem; color: var(--accent-strong); font-weight: 700; }
.card-topline { display: flex; justify-content: flex-end; }
.role-badge { border: 1px solid var(--line); background: #202837; border-radius: 999px; color: #c8d1df; padding: .25rem .55rem; font-size: .74rem; font-weight: 800; }
.role-badge.gm { border-color: #775f2e; background: #2e2718; color: #f0ca70; }
.page-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.5rem; }
.page-heading h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.two-column { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1rem; }
.member-list { display: grid; gap: .6rem; margin-top: .75rem; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.member-row:first-child { border-top: 0; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 1.4rem; }
.back-link:hover { color: var(--text); }
.auth-card { width: min(430px, 100%); margin: 6vh auto; }
.stack-form { display: grid; gap: .65rem; }
.stack-form label { font-size: .85rem; font-weight: 700; margin-top: .35rem; }
.stack-form input { width: 100%; border: 1px solid var(--line); border-radius: .5rem; background: #0f141c; color: var(--text); padding: .75rem; font: inherit; }
.stack-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error-box { border: 1px solid var(--danger-line); background: var(--danger-bg); border-radius: .55rem; padding: .8rem; margin: 1rem 0; }
.empty-state { max-width: 650px; }
.messages { margin-bottom: 1rem; }
.message { border: 1px solid var(--line); background: var(--panel); border-radius: .5rem; padding: .7rem; }
@media (max-width: 720px) {
  .two-column { grid-template-columns: 1fr; }
  .nav { gap: .7rem; font-size: .9rem; }
  .user-label { display: none; }
  .page { padding-top: 2rem; }
}

/* Phase 3: character management */
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.character-list, .access-list { display: grid; gap: .55rem; margin-top: .9rem; }
.character-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: .6rem; background: #111721; text-decoration: none; }
.character-row:hover { border-color: #59687d; background: #151c28; }
.role-badge.owner { border-color: #4f6f86; background: #182936; color: #9ed6ff; }
.action-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.button.secondary { background: #202837; border-color: #46536a; color: var(--text); }
.button.secondary:hover { background: #2a3446; }
.button.danger { background: #49242b; border-color: #82414d; color: #ffd9df; }
.button.danger:hover { background: #5a2b34; }
.small-button { padding: .45rem .65rem; font-size: .78rem; }
.placeholder-panel { border: 1px dashed #46536a; border-radius: .65rem; padding: 1rem; margin-top: 1rem; background: #101620; }
.permission-list { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 1rem; }
.permission-chip { border: 1px solid #46536a; background: #111923; border-radius: 999px; padding: .3rem .6rem; font-size: .74rem; font-weight: 800; letter-spacing: .04em; }
.form-card { max-width: 720px; }
.field-group { display: grid; gap: .4rem; }
.stack-form select, .stack-form textarea { width: 100%; border: 1px solid var(--line); border-radius: .5rem; background: #0f141c; color: var(--text); padding: .75rem; font: inherit; }
.stack-form input[type="checkbox"] { width: auto; }
.field-error { color: #ffafb9; font-size: .86rem; }
.empty-inline { border: 1px dashed var(--line); border-radius: .6rem; padding: 1rem; color: var(--muted); margin-top: .8rem; }
@media (max-width: 720px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .character-row { align-items: flex-start; }
}
.role-badge.inactive { border-color: #70444b; background: #302126; color: #e8aab4; margin-left: .35rem; }

/* Phase 4: structured character sheets */
.character-description { margin-bottom: 1rem; }
.sheet-block { margin-bottom: 1rem; }
.sheet-sections { display: grid; gap: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .7rem; margin-top: 1rem; }
.stat-card { background: #101620; border: 1px solid var(--line); border-radius: .65rem; padding: .85rem; display: grid; gap: .35rem; }
.stat-label { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 1.65rem; }
.stat-max { color: var(--muted); font-size: .95rem; font-weight: 600; }
.sheet-entry-list { margin-top: .8rem; }
.sheet-entry-row { display: grid; grid-template-columns: minmax(150px, .35fr) 1fr; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.sheet-entry-row:first-child { border-top: 0; }
.sheet-entry-value { color: #d7deea; white-space: normal; }
.sheet-entry-value.long { line-height: 1.55; }
.access-summary { margin-top: 1rem; }
.edit-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .75rem; margin-top: 1rem; }
.inline-edit-card { display: grid; gap: .55rem; border: 1px solid var(--line); border-radius: .65rem; background: #101620; padding: .8rem; }
.inline-edit-card label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; }
.inline-edit-card input, .entry-edit-form input, .entry-edit-form textarea, .compact-form input, .compact-form select, .compact-form textarea, .access-role-form select {
  width: 100%; border: 1px solid var(--line); border-radius: .5rem; background: #0f141c; color: var(--text); padding: .65rem; font: inherit;
}
.entry-editor-list { display: grid; gap: .8rem; margin-top: .9rem; }
.entry-editor { border-top: 1px solid var(--line); padding-top: .8rem; display: grid; grid-template-columns: 1fr auto; gap: .7rem; align-items: end; }
.entry-editor:first-child { border-top: 0; }
.entry-edit-form { display: grid; grid-template-columns: minmax(160px, .35fr) 1fr auto; gap: .7rem; align-items: end; }
.entry-edit-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; }
.add-entry-panel { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .8rem; }
.add-entry-panel summary { cursor: pointer; color: var(--accent-strong); font-weight: 800; }
.compact-form { margin-top: .8rem; }
.role-badge.fixed { border-color: #536176; background: #1a2230; color: #bdc8d8; }
.structure-list { margin-bottom: .8rem; }
.roll-set-view { border-top: 1px solid var(--line); padding: 1rem 0; }
.roll-set-view:first-of-type { border-top: 0; }
.roll-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 0; }
.roll-set-editor { margin-bottom: 1rem; }
.roll-definition-list { display: grid; gap: 1rem; margin-top: 1rem; }
.roll-definition-editor { border: 1px solid var(--line); background: #101620; border-radius: .65rem; padding: 1rem; }
.term-list { margin-top: .8rem; }
.danger-zone { border-top: 1px solid var(--danger-line); margin-top: 1rem; padding-top: .8rem; }
.access-edit-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(210px, auto) auto; gap: .65rem; align-items: center; padding: .8rem 0; border-top: 1px solid var(--line); }
.access-role-form { display: flex; gap: .5rem; align-items: center; }
@media (max-width: 760px) {
  .sheet-entry-row { grid-template-columns: 1fr; gap: .35rem; }
  .entry-editor { grid-template-columns: 1fr; }
  .entry-edit-form { grid-template-columns: 1fr; }
  .access-edit-row { grid-template-columns: 1fr; }
  .access-role-form { align-items: stretch; }
}

/* Phase 5: server-side rolls, guidance, and history */
.help-card { margin-bottom: 1rem; border-color: #46536a; }
.help-card h2 { margin-top: 0; }
.instruction-list { display: grid; gap: .45rem; padding-left: 1.35rem; line-height: 1.5; }
.example-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .65rem; margin: .9rem 0; }
.example-grid > div { display: grid; gap: .25rem; border: 1px solid var(--line); background: #101620; border-radius: .6rem; padding: .75rem; }
.field-help { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.inline-help { border: 1px solid #39465b; background: #111923; border-radius: .55rem; padding: .7rem; margin-top: .75rem; line-height: 1.45; }
.pool-preview { border: 1px solid #39465b; background: #0d131b; border-radius: .6rem; padding: .75rem; margin: .85rem 0; }
.pool-preview-heading, .pool-preview-row { display: flex; justify-content: space-between; gap: 1rem; }
.pool-preview-heading { padding-bottom: .45rem; border-bottom: 1px solid var(--line); }
.pool-preview-row { padding: .35rem 0; color: #d7deea; }
.role-badge.ready { border-color: #3d7358; background: #152b21; color: #9ee3bd; }
.roll-action-row { align-items: center; }
.roll-description { min-width: 0; }
.pool-inline-breakdown { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.pool-inline-breakdown span { border: 1px solid var(--line); border-radius: 999px; padding: .18rem .42rem; color: var(--muted); font-size: .72rem; }
.roll-controls { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pool-total { font-size: 1.15rem; white-space: nowrap; }
.roll-button { min-width: 88px; text-align: center; }
.roll-result-card { background: linear-gradient(180deg, #202737, #151a24); border: 1px solid #6f5a30; border-radius: .8rem; padding: 1.2rem; margin-bottom: 1rem; }
.roll-result-card h3 { margin: 0; font-size: 1.45rem; }
.roll-success-total { display: grid; justify-items: center; min-width: 92px; }
.roll-success-total strong { font-size: 2.2rem; line-height: 1; color: var(--accent-strong); }
.roll-success-total span { color: var(--muted); font-size: .78rem; }
.dice-tray { display: flex; flex-wrap: wrap; gap: .45rem; padding: 1rem 0; }
.die { display: inline-grid; place-items: center; min-width: 42px; min-height: 42px; padding: .3rem; border-radius: .55rem; border: 1px solid var(--line); background: #101620; font-weight: 900; font-size: 1.05rem; }
.die-minor { border-color: #5b6f3f; background: #1d2818; }
.die-major { border-color: #876d36; background: #312719; }
.die-lfi { border-color: #8a4650; background: #351b21; color: #ffd3d9; }
.die-miss { color: var(--muted); }
.injury-grid, .score-rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.injury-grid > div, .score-rules > div { display: grid; gap: .2rem; border: 1px solid var(--line); border-radius: .6rem; background: #101620; padding: .7rem; }
.injury-grid strong { font-size: 1.45rem; }
.score-rules strong { font-size: 1.15rem; }
.tiny { font-size: .7rem; }
.roll-meta { margin-bottom: 0; }
.history-list { display: grid; margin-top: .6rem; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--line); text-decoration: none; }
.history-row:first-child { border-top: 0; }
.history-row:hover strong { color: var(--accent-strong); }
.history-score { display: grid; justify-items: end; }
.history-score strong { font-size: 1.3rem; }
.history-cards { display: grid; gap: 1rem; }

@media (max-width: 720px) {
  .roll-action-row { align-items: flex-start; flex-direction: column; }
  .roll-controls { justify-content: flex-start; }
  .injury-grid, .score-rules { grid-template-columns: 1fr; }
  .roll-success-total { justify-items: start; }
}

/* Phase 5 v3: visual tabletop roll builder */
.visual-roll-builder { display: grid; gap: 1rem; margin-top: 1rem; }
.builder-basics { display: grid; grid-template-columns: minmax(220px, .75fr) minmax(260px, 1.25fr); gap: .8rem; }
.builder-fieldset { border: 1px solid var(--line); border-radius: .7rem; padding: .9rem; margin: 0; background: #0d131b; }
.builder-fieldset legend { padding: 0 .35rem; font-weight: 900; color: var(--text); }
.dice-button-grid { display: grid; grid-template-columns: repeat(7, minmax(64px, 1fr)); gap: .55rem; margin-top: .8rem; }
.dice-choice-input, .stat-choice-input { position: absolute; opacity: 0; pointer-events: none; }
.dice-choice { min-height: 76px; display: grid; place-items: center; cursor: pointer; border: 1px solid var(--line); border-radius: .65rem; background: #101620; transition: border-color .12s ease, background .12s ease, transform .12s ease; }
.dice-choice:hover, .stat-choice:hover { border-color: #68778f; }
.dice-choice-input:focus-visible + .dice-choice, .stat-choice-input:focus-visible + .stat-choice { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.dice-choice-input:checked + .dice-choice, .stat-choice-input:checked + .stat-choice { border-color: var(--accent-strong); background: #2a2516; box-shadow: inset 0 0 0 1px var(--accent-strong); }
.dice-shape { width: 54px; height: 54px; display: grid; place-items: center; background: #273144; color: #f3f6fb; font-weight: 950; letter-spacing: -.03em; border: 2px solid #7f8da3; }
.dice-choice-input:checked + .dice-choice .dice-shape { background: #5a471c; border-color: #e0b954; }
.dice-d4 .dice-shape { clip-path: polygon(50% 2%, 98% 94%, 2% 94%); padding-top: 13px; }
.dice-d6 .dice-shape { border-radius: .25rem; }
.dice-d8 .dice-shape { clip-path: polygon(50% 0, 96% 50%, 50% 100%, 4% 50%); }
.dice-d10 .dice-shape { clip-path: polygon(50% 0, 95% 34%, 78% 100%, 22% 100%, 5% 34%); }
.dice-d12 .dice-shape { clip-path: polygon(50% 0, 88% 12%, 100% 50%, 82% 90%, 50% 100%, 18% 90%, 0 50%, 12% 12%); }
.dice-d20 .dice-shape { clip-path: polygon(50% 0, 91% 24%, 100% 68%, 70% 100%, 30% 100%, 0 68%, 9% 24%); }
.dice-d100 .dice-shape { border-radius: 50%; font-size: .86rem; }
.stat-button-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .5rem; margin-top: .8rem; }
.stat-choice { cursor: pointer; border: 1px solid var(--line); border-radius: .58rem; background: #101620; min-height: 48px; padding: .55rem .65rem; display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.stat-choice span { font-size: .8rem; font-weight: 850; text-transform: uppercase; letter-spacing: .035em; overflow-wrap: anywhere; }
.stat-choice strong { font-size: 1.15rem; }
.modifier-control { display: grid; grid-template-columns: 1fr minmax(88px, 110px) 1fr; gap: .6rem; align-items: stretch; margin-top: .8rem; }
.modifier-adjust-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.modifier-adjust { border: 1px solid var(--line); border-radius: .5rem; background: #18202d; color: var(--text); font: inherit; font-weight: 850; cursor: pointer; min-height: 46px; }
.modifier-adjust:hover { border-color: #68778f; background: #202a39; }
.modifier-adjust:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.modifier-value-wrap { display: grid; }
.modifier-value { width: 100%; min-height: 46px; text-align: center; font-size: 1.15rem; font-weight: 900; border: 1px solid var(--accent-strong); border-radius: .5rem; background: #0f141c; color: var(--text); padding: .5rem; }
.builder-preview { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; border: 1px solid #46536a; background: #111923; border-radius: .7rem; padding: .85rem; }
.builder-preview > div { display: grid; gap: .2rem; }
.builder-pool-summary { justify-items: end; min-width: 110px; }
.builder-formula { overflow-wrap: anywhere; }
.builder-pool { font-size: 1.35rem; color: var(--accent-strong); }
.ready-text { color: #9ee3bd; font-weight: 800; }
.builder-active-toggle { display: flex; align-items: center; gap: .55rem; font-size: .9rem; }
.builder-active-toggle input { width: auto; }
.builder-save { justify-self: start; min-width: 120px; }
.readiness-reason { margin-top: -.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 860px) {
  .dice-button-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)); }
  .builder-basics { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .dice-button-grid { grid-template-columns: repeat(3, minmax(64px, 1fr)); }
  .modifier-control { grid-template-columns: 1fr; }
  .modifier-value-wrap { grid-row: 1; }
  .modifier-negative { grid-row: 2; }
  .modifier-positive { grid-row: 3; }
  .builder-preview { grid-template-columns: 1fr; }
  .builder-pool-summary { justify-items: start; }
}
.visual-roll-builder input[type="text"], .visual-roll-builder textarea { width: 100%; border: 1px solid var(--line); border-radius: .5rem; background: #0f141c; color: var(--text); padding: .65rem; font: inherit; }
.visual-roll-builder textarea { resize: vertical; }
.builder-active-toggle input { accent-color: var(--accent-strong); }

/* Phase 6: mixed dice sources and passive dice features */
.stat-dice-summary { color: var(--accent-strong); font-size: .82rem; font-weight: 850; }
.source-structure-row { align-items: flex-start; }
.two-field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.source-group { margin-top: 1rem; }
.source-group:first-of-type { margin-top: .65rem; }
.source-group h4 { margin: 0 0 .45rem; color: var(--muted); font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; }
.source-choice { min-height: 68px; display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto auto; align-items: center; }
.source-choice span { grid-column: 1; }
.source-choice strong { grid-column: 2; grid-row: 1 / span 2; color: var(--accent-strong); white-space: nowrap; }
.source-choice small { grid-column: 1; color: var(--muted); font-size: .72rem; }
.legacy-bonus-panel { border: 1px solid #6f5a30; background: #1a1811; border-radius: .7rem; padding: .85rem; }
.mixed-dice-results { display: grid; gap: .75rem; padding: .8rem 0; }
.die-band { display: grid; grid-template-columns: 54px 1fr; align-items: start; gap: .6rem; border-top: 1px solid var(--line); padding-top: .65rem; }
.die-band:first-child { border-top: 0; padding-top: 0; }
.die-band-label { color: var(--accent-strong); padding-top: .35rem; }
.die-band .dice-tray { padding: 0; }
.dice-source-die-picker .dice-button-grid { margin-top: .45rem; }

@media (max-width: 650px) {
  .two-field-row { grid-template-columns: 1fr; }
  .die-band { grid-template-columns: 1fr; }
}

/* Phase 8: rules foundation, live combat state, and spell catalog */
.rules-callout { display: grid; gap: .25rem; border-left: 3px solid var(--accent); background: #161912; padding: .7rem .8rem; border-radius: .25rem .55rem .55rem .25rem; }
.visual-roll-builder select, .combat-state-form input, .combat-state-form select { width: 100%; border: 1px solid var(--line); border-radius: .5rem; background: #0f141c; color: var(--text); padding: .62rem; font: inherit; }
.combat-state-panel { border-color: #47546b; }
.combat-state-form { display: grid; gap: 1rem; }
.combat-state-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; }
.combat-state-group { display: grid; align-content: start; gap: .55rem; border: 1px solid var(--line); background: #0f151e; border-radius: .65rem; padding: .8rem; }
.combat-state-group h3 { margin: 0 0 .15rem; font-size: .95rem; }
.combat-state-group label { display: grid; gap: .25rem; font-size: .78rem; color: var(--muted); }
.injury-input-row { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: .4rem; align-items: end; }
.injury-input-row strong { color: var(--accent-strong); padding-bottom: .65rem; }
.resource-highlight { display: grid; justify-items: end; }
.resource-highlight strong { color: var(--accent-strong); font-size: 1.8rem; line-height: 1; }
.combat-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)); gap: .7rem; }
.combat-summary-grid > div { display: grid; gap: .15rem; border: 1px solid var(--line); background: #0f151e; border-radius: .6rem; padding: .75rem; }
.combat-summary-grid strong { font-size: 1.35rem; color: var(--accent-strong); }
.spell-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .8rem; }
.spell-card { display: grid; align-content: start; gap: .7rem; border: 1px solid var(--line); border-radius: .7rem; background: #0f151e; padding: .9rem; }
.spell-card p { margin: 0; line-height: 1.5; }
.spell-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.spell-card-head > div { display: grid; gap: .15rem; }
.spell-known { border-color: #6f5a30; }
.spell-meta { display: flex; flex-wrap: wrap; gap: .35rem; }
.spell-meta span { border: 1px solid var(--line); border-radius: 999px; padding: .2rem .48rem; color: var(--muted); font-size: .72rem; }
.known-spell-list { display: grid; }
.known-spell-row { display: flex; justify-content: space-between; gap: .8rem; align-items: center; border-top: 1px solid var(--line); padding: .7rem 0; }
.known-spell-row:first-child { border-top: 0; }
.known-spell-row > div { display: grid; gap: .12rem; }
.attrition-notice { display: grid; gap: .2rem; border: 1px solid #6f5a30; background: #1a1811; border-radius: .65rem; padding: .75rem; margin-top: .6rem; }
.success-resolution-row { display: flex; flex-wrap: wrap; gap: .75rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.success-resolution-row strong { color: var(--accent-strong); }
@media (max-width: 680px) {
  .combat-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .injury-input-row { grid-template-columns: 1fr auto 1fr; }
  .injury-input-row strong { grid-column: 1 / -1; padding-bottom: 0; }
  .resource-highlight { justify-items: start; }
}
.roll-type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .45rem; margin-top: .7rem; }
.roll-type-option { position: relative; }
.roll-type-option input { position: absolute; opacity: 0; pointer-events: none; }
.roll-type-option label { display: grid; place-items: center; min-height: 44px; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .55rem; background: #101620; cursor: pointer; font-size: .78rem; font-weight: 850; text-align: center; }
.roll-type-option input:checked + label { border-color: var(--accent-strong); background: #2a2516; box-shadow: inset 0 0 0 1px var(--accent-strong); }
.roll-type-option input:focus-visible + label { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* Phase 8 v3: catalog-backed Silver Skill management */
.skill-inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr)) auto;
  gap: .65rem;
  align-items: end;
  margin: .8rem 0;
}
.skill-inline-form label { display: grid; gap: .25rem; font-size: .82rem; color: var(--muted); }
.skill-inline-form input, .skill-inline-form select { width: 100%; min-width: 0; }
@media (max-width: 760px) {
  .skill-inline-form { grid-template-columns: 1fr 1fr; }
  .skill-inline-form .button { grid-column: 1 / -1; }
}

/* Phase 8 v4: denser two-column character sheet */
.shell.character-page-shell {
  width: min(1320px, calc(100% - 2rem));
}
.character-page-shell .sheet-sections,
.character-paired-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.character-page-shell .sheet-sections .sheet-block,
.character-paired-grid .sheet-block,
.character-paired-grid .access-summary {
  min-width: 0;
  margin-bottom: 0;
}
.character-page-shell .sheet-sections {
  margin-bottom: 1rem;
}
.character-paired-grid {
  margin-bottom: 1rem;
}
.character-footer-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr);
}
.character-page-shell .stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
}
.character-page-shell .sheet-entry-row {
  grid-template-columns: minmax(120px, .4fr) minmax(0, 1fr);
  gap: .7rem;
}

@media (max-width: 900px) {
  .character-page-shell .sheet-sections,
  .character-paired-grid,
  .character-footer-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .shell.character-page-shell {
    width: min(100% - 1rem, 1320px);
  }
  .character-page-shell .sheet-entry-row {
    grid-template-columns: 1fr;
    gap: .35rem;
  }
}

/* Phase 8 v6: Roll20 bridge */
.roll-submit-pair { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; }
.roll-submit-pair form { margin: 0; }
.roll20-roll-button { white-space: nowrap; }
.roll20-bridge-summary { display: flex; flex-wrap: wrap; gap: .45rem .75rem; align-items: center; margin-top: .55rem; font-size: .78rem; }
.roll20-bridge-summary strong { color: var(--accent-strong); }
[data-roll20-status][data-state="ok"] { color: #9fd29f; }
[data-roll20-status][data-state="warn"] { color: #e1c37a; }
[data-roll20-status][data-state="error"] { color: #e39a9a; }
[data-roll20-status][data-state="pending"] { color: var(--accent-strong); }
.roll20-result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: .85rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.roll20-bridge-inline { font-size: .78rem; color: var(--muted); }
@media (max-width: 680px) {
  .roll-submit-pair { justify-content: stretch; }
  .roll-submit-pair form, .roll-submit-pair button { width: 100%; }
}
.setup-steps { display: grid; gap: .55rem; padding-left: 1.3rem; }
.setup-steps code { color: var(--accent-strong); }

/* Phase 8 v7: portable DOCX -> JSON character imports */
.import-intro-grid { margin-bottom: 1rem; }
.code-example { border: 1px solid var(--line); border-radius: .55rem; background: #0d131b; padding: .75rem; margin: .8rem 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.import-preview-card { margin-bottom: 1rem; }
.import-summary-grid { display: grid; grid-template-columns: repeat(6, minmax(80px, 1fr)); gap: .65rem; margin: 1rem 0; }
.import-summary-grid > div { display: grid; gap: .2rem; border: 1px solid var(--line); border-radius: .6rem; background: #101620; padding: .7rem; }
.import-summary-grid strong { font-size: 1.4rem; }
.import-warning-box { border: 1px solid #876d36; background: #312719; border-radius: .6rem; padding: .8rem; margin: .8rem 0 1rem; }
.import-warning-box ul { margin-bottom: 0; }
.import-upload-card input[type="file"] { padding: .6rem; }
@media (max-width: 820px) { .import-summary-grid { grid-template-columns: repeat(3, minmax(80px, 1fr)); } }
@media (max-width: 520px) { .import-summary-grid { grid-template-columns: repeat(2, minmax(80px, 1fr)); } }

/* Phase 8 v7.2: grouped stat presentation */
.stat-group-list { display: grid; gap: .85rem; margin-top: 1rem; }
.stat-group-row {
  display: grid;
  grid-template-columns: minmax(145px, 175px) minmax(0, 1fr);
  gap: .9rem;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: .85rem;
}
.stat-group-row:first-child { border-top: 0; padding-top: 0; }
.stat-group-heading { display: grid; gap: .2rem; padding-top: .15rem; }
.stat-group-heading h3 { margin: 0; font-size: .9rem; line-height: 1.2; }
.stat-group-row .stat-grid { margin-top: 0; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
@media (max-width: 760px) {
  .stat-group-row { grid-template-columns: 1fr; gap: .55rem; }
  .stat-group-heading { grid-template-columns: 1fr auto; align-items: baseline; }
}

/* Phase 8 v7.4: combat-first roll dashboard and direct Injury Box controls */
.injury-summary-cell { align-content: start; }
.injury-stepper { display: grid; grid-template-columns: 34px minmax(72px, 1fr) 34px; gap: .45rem; align-items: center; }
.injury-stepper form { margin: 0; }
.injury-stepper strong { text-align: center; white-space: nowrap; }
.injury-step-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #151c27;
  color: var(--accent-strong);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.injury-step-button:hover:not(:disabled) { border-color: var(--accent-strong); background: #20283a; }
.injury-step-button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.injury-step-button:disabled { cursor: not-allowed; opacity: .32; }
.rolls-dashboard { margin-bottom: 1rem; }
.roll-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.roll-column-panel { min-width: 0; border: 1px solid var(--line); border-radius: .75rem; background: #0f151e; padding: .85rem; }
.roll-column-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .7rem; padding-bottom: .65rem; border-bottom: 1px solid var(--line); }
.roll-column-heading h3 { margin: 0; color: var(--accent-strong); }
.compact-roll-set { margin-top: .85rem; }
.compact-roll-set:first-of-type { margin-top: .75rem; }
.compact-roll-set h4 { margin: 0 0 .25rem; }
.roll-column-panel .roll-action-row { align-items: flex-start; }
.roll-column-panel .roll-description { min-width: 0; }
.roll-column-panel .roll-controls { min-width: 150px; }
.roll-column-empty { margin: .8rem 0 0; }
@media (max-width: 980px) {
  .roll-columns { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .injury-stepper { grid-template-columns: 32px minmax(68px, 1fr) 32px; }
  .injury-step-button { width: 32px; height: 32px; }
  .roll-column-panel .roll-action-row { display: grid; grid-template-columns: 1fr; }
  .roll-column-panel .roll-controls { min-width: 0; width: 100%; }
}
