* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --scrollbar-track: #050505;
  --scrollbar-thumb: #3f3a29;
  --scrollbar-thumb-hover: #8b8055;
  --scrollbar-corner: #0a0a0a;
}
* {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-left: 1px solid #1b1b1b;
}
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 2px solid var(--scrollbar-track);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
*::-webkit-scrollbar-corner {
  background: var(--scrollbar-corner);
}
body {
  background: #0a0a0a;
  color: #c8c8a0;
  font-family: "Courier New", monospace;
  font-size: 15px;
  height: 100vh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
#landing {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: #000;
  opacity: 1;
  visibility: visible;
}
#landing img {
  display: block;
  width: min(78vw, 720px);
  max-height: 62vh;
  object-fit: contain;
}
#enter-button {
  -webkit-tap-highlight-color: transparent;
  background: #050505;
  border: 1px solid #57513a;
  color: #d4c98a;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 18px;
  touch-action: manipulation;
  user-select: none;
}
#enter-button:hover,
#enter-button:focus {
  border-color: #8b8055;
  color: #efe5a8;
  outline: none;
}
#srd-attribution {
  color: #555;
  font-size: 10px;
  line-height: 1.4;
  margin-top: 18px;
  max-width: min(680px, 86vw);
  text-align: center;
}
#srd-attribution a {
  color: #777;
  text-decoration: none;
}
#srd-attribution a:hover,
#srd-attribution a:focus {
  color: #999;
  text-decoration: underline;
}
body.intro-exiting #landing,
body.intro-complete #landing {
  pointer-events: none;
}
body.intro-exiting #landing {
  animation: landing-fade-out 900ms ease forwards;
}
body.intro-complete #landing {
  opacity: 0;
  visibility: hidden;
}
body.intro-active #auth,
body.intro-active #app {
  opacity: 0;
}
body.intro-exiting #auth,
body.intro-exiting #app {
  animation: content-fade-in 900ms ease forwards;
}
#app {
  position: relative;
  z-index: 1;
  opacity: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  gap: 8px;
}
.hidden { display: none !important; }
#auth {
  position: relative;
  z-index: 1;
  opacity: 1;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
  display: grid;
  gap: 16px;
}
@keyframes landing-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes content-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
#auth h1,
#auth h2 {
  font-weight: normal;
}
#auth h1 {
  margin-bottom: -10px;
}
.version-label {
  color: #666;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
#auth-version {
  margin-bottom: 2px;
}
#auth form {
  border: 1px solid #333;
  padding: 16px;
  display: grid;
  gap: 10px;
}
#character-select {
  border: 1px solid #333;
  padding: 16px;
  display: grid;
  gap: 10px;
}
#register-form {
  border: 1px solid #333;
  padding: 16px;
  display: grid;
  gap: 10px;
}
#about-button {
  background: transparent;
  border-color: #333;
  color: #888;
  justify-self: start;
  margin-bottom: 2px;
}
#about-button:hover,
#about-button:focus {
  border-color: #57513a;
  color: #c8c8a0;
  outline: none;
}
#sound-notice {
  background: #0d0d0d;
  border: 1px solid #3f3a29;
  color: #d4c98a;
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
}
#auth input,
#auth textarea,
#auth button {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 8px;
}
#auth textarea {
  min-height: 72px;
  resize: vertical;
  scrollbar-gutter: stable;
}
#auth button {
  cursor: pointer;
}
#auth button:disabled {
  color: #555;
  border-color: #2a2a2a;
  cursor: not-allowed;
}
.alpha-state {
  display: grid;
  gap: 10px;
}
.alpha-back {
  background: transparent !important;
  border-color: #333 !important;
  color: #888 !important;
  justify-self: start;
}
.alpha-success {
  border: 1px solid #333;
  color: #a8c87e;
  line-height: 1.5;
  padding: 12px;
}
#alpha-code-verify,
#alpha-account-create {
  display: grid;
  gap: 10px;
}
.alpha-help {
  color: #777;
  font-size: 12px;
  line-height: 1.45;
}
#alpha-message {
  min-height: 22px;
  color: #c87e7e;
}
#alpha-welcome {
  color: #d4c98a;
  line-height: 1.5;
}
#admin-choice-modal,
#app-confirm-modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 10;
}
#app-confirm-modal {
  z-index: 60;
}
#admin-choice-panel,
#app-confirm-panel {
  background: #0a0a0a;
  border: 1px solid #57513a;
  display: grid;
  gap: 14px;
  max-width: 340px;
  padding: 24px;
  width: 100%;
}
#admin-choice-panel h2,
#app-confirm-panel h2 {
  color: #d4c98a;
  font-size: 18px;
  font-weight: normal;
  letter-spacing: 0.08em;
  text-align: center;
}
#app-confirm-message {
  color: #c8c8a0;
  line-height: 1.5;
  text-align: center;
}
.app-confirm-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#admin-choice-panel button,
#app-confirm-panel button {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 10px;
}
#app-confirm-ok.danger {
  border-color: #8a3a3a;
  color: #c87e7e;
}
#admin-choice-panel button:hover,
#admin-choice-panel button:focus,
#app-confirm-panel button:hover,
#app-confirm-panel button:focus {
  border-color: #8b8055;
  color: #efe5a8;
  outline: none;
}
#app-confirm-ok.danger:hover,
#app-confirm-ok.danger:focus {
  border-color: #c87e7e;
  color: #ffc0c0;
}
#character-slots {
  display: grid;
  gap: 8px;
}
.character-slot {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 42px;
  gap: 8px;
  min-height: 64px;
  align-items: stretch;
}
.character-slot-portrait {
  background: #0b0b0b;
  border: 1px solid #333;
  min-height: 64px;
  overflow: hidden;
}
.character-slot-portrait img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}
.character-slot-main {
  display: grid;
  grid-template-rows: auto auto 1fr;
  line-height: 1.25;
  min-width: 0;
  text-align: left;
}
.character-slot-main.empty {
  color: #888;
}
.character-slot-meta {
  color: #777;
  display: block;
  font-size: 12px;
  margin-top: 3px;
}
.character-slot button:disabled {
  color: #555;
  cursor: not-allowed;
}
.character-delete {
  font-size: 18px;
  line-height: 1;
}
#attribute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(106px, 1fr));
  column-gap: 8px;
  row-gap: 14px;
}
#attribute-grid label {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 0;
}
#point-buy-status {
  color: #888;
}
.attribute-stepper {
  display: grid;
  grid-template-columns: 28px 42px 28px;
  gap: 4px;
  align-items: center;
  justify-content: center;
}
.attribute-stepper button {
  width: 28px;
  height: 34px;
  padding: 0;
}
.attribute-stepper input {
  text-align: center;
  height: 34px;
  line-height: 34px;
  padding-left: 0;
  padding-right: 0;
  width: 42px;
}
.attribute-stepper button:disabled {
  color: #555;
  cursor: not-allowed;
}
#auth-message {
  min-height: 24px;
  color: #c87e7e;
}
#output {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-gutter: stable;
}
.msg {
  line-height: 1.6;
  white-space: pre-wrap;
}
.msg.description { color: #d4c98a; }
.msg.chat        { color: #7ec8c8; }
.msg.error       { color: #c87e7e; }
.msg.encounter   { color: #e08050; font-style: italic; white-space: pre-wrap; }
.msg.awareness   { color: #a8c87e; font-style: italic; }
.msg.system      { color: #888; }
.msg.traveling   { font-style: italic; }
.msg.level-up {
  border-left: 3px solid #d4c98a;
  color: #efe5a8;
  padding-left: 10px;
}
.msg.asi-prompt {
  border: 1px solid #4a442f;
  color: #d4c98a;
  padding: 10px;
}
.msg.image img {
  display: block;
  max-width: min(100%, 960px);
  max-height: 70vh;
  border: 1px solid #333;
}
.msg.map canvas {
  display: block;
  width: 512px;
  max-width: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  border: 1px solid #333;
}
#char-summary {
  color: #d4c98a;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.35;
  min-height: 1.4em;
  padding: 4px 8px;
  text-align: center;
  white-space: normal;
}
#character-modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.84);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 30;
}
#character-modal-panel {
  background: #0a0a0a;
  border: 1px solid #57513a;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  height: min(86vh, 760px);
  max-height: min(86vh, 760px);
  max-width: min(900px, 94vw);
  overflow: hidden;
  padding: 20px;
  position: relative;
  width: 100%;
}
#character-modal-close {
  align-items: center;
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  cursor: pointer;
  display: flex;
  font-family: inherit;
  height: 32px;
  justify-content: center;
  left: 12px;
  position: absolute;
  top: 12px;
  width: 32px;
  z-index: 1;
}
#character-modal-close:hover,
#character-modal-close:focus {
  border-color: #8b8055;
  color: #efe5a8;
  outline: none;
}
#character-modal-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-left: 44px;
}
.character-modal-tab {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  min-width: 0;
  padding: 8px 6px;
  text-align: center;
}
.character-modal-tab:hover,
.character-modal-tab:focus {
  border-color: #8b8055;
  color: #efe5a8;
  outline: none;
}
.character-modal-tab.active {
  background: #1a1710;
  border-color: #d4c98a;
  color: #efe5a8;
}
.character-modal-page {
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}
#character-modal-page-character {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(160px, 240px) minmax(0, 1fr);
}
#character-modal-page-character.hidden {
  display: none !important;
}
#character-modal-portrait-wrap {
  align-self: start;
}
#character-modal-stats,
#character-modal-inventory {
  color: #c8c8a0;
  font-family: "Courier New", monospace;
  line-height: 1.45;
  min-width: 0;
  padding-right: 28px;
  white-space: pre-wrap;
}
#character-modal-map {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
#character-modal-map canvas {
  border: 1px solid #333;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  width: auto;
}
.character-modal-message {
  color: #888;
  line-height: 1.45;
  text-align: center;
}
#action-bar {
  --action-button-size: 42px;
  --action-button-gap: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-top: 1px solid #252525;
  padding-top: 8px;
}
#combat-actions {
  display: grid;
  grid-template-columns: var(--action-button-size);
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
  visibility: hidden;
}
#combat-actions.has-side-actions {
  grid-template-columns: repeat(2, var(--action-button-size));
}
#combat-actions.has-side-actions .combat-button {
  grid-column: 2;
}
#combat-actions.has-side-actions .combat-side-button {
  grid-column: 1;
}
#combat-actions .combat-button[data-action="shove"] {
  grid-row: 1;
}
#combat-actions .combat-button[data-action="steady_aim_attack"] {
  grid-row: 2;
}
#combat-actions .combat-button[data-action="reckless_attack"] {
  grid-row: 2;
}
#combat-actions .combat-button[data-action="action_surge"] {
  grid-row: 3;
}
#action-bar.in-combat #combat-actions {
  visibility: visible;
}
#bonus-actions {
  display: none;
  grid-auto-flow: column;
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
}
#action-bar.bonus-selecting #bonus-actions {
  display: grid;
}
#combat-choice-actions {
  display: none;
  grid-auto-flow: column;
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
}
#action-bar.combat-choice-selecting #combat-choice-actions {
  display: grid;
}
#action-bar.combat-choice-selecting #bonus-actions,
#action-bar.combat-choice-selecting #utility-actions,
#action-bar.combat-choice-selecting #rest-actions {
  display: none;
}
#action-bar.combat-yn-selecting #combat-actions,
#action-bar.combat-yn-selecting #bonus-actions,
#action-bar.combat-yn-selecting #compass-pad,
#action-bar.combat-yn-selecting #utility-actions,
#action-bar.combat-yn-selecting #rest-actions {
  display: none;
}
#ability-actions {
  display: none;
  grid-auto-flow: column;
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
}
#action-bar.asi-selecting #ability-actions {
  display: grid;
}
#action-bar.asi-selecting #combat-actions,
#action-bar.asi-selecting #bonus-actions,
#action-bar.asi-selecting #compass-pad,
#action-bar.asi-selecting #utility-actions,
#action-bar.asi-selecting #choice-actions,
#action-bar.asi-selecting #rest-actions {
  display: none;
}
#ability-actions .ability-action-button {
  min-width: 56px;
  padding: 0 8px;
}
#compass-pad {
  display: grid;
  grid-template-columns: repeat(3, var(--action-button-size));
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
}
#action-bar.in-combat #compass-pad {
  display: none;
}
.compass-n { grid-column: 2; grid-row: 1; }
.compass-w { grid-column: 1; grid-row: 2; }
.compass-e { grid-column: 3; grid-row: 2; }
.compass-s { grid-column: 2; grid-row: 3; }
#utility-actions {
  display: grid;
  grid-template-columns: var(--action-button-size);
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
}
#choice-actions {
  display: none;
  grid-auto-flow: column;
  grid-template-rows: repeat(3, var(--action-button-size));
  gap: var(--action-button-gap);
}
#action-bar.choice-selecting #choice-actions {
  display: grid;
}
#rest-actions {
  display: none;
  grid-column: 1;
  grid-row: 4;
  grid-template-columns: repeat(2, var(--action-button-size));
  grid-template-rows: var(--action-button-size);
  gap: var(--action-button-gap);
}
#action-bar.rest-selecting #rest-actions,
#action-bar.short-rest-selecting #rest-actions {
  display: grid;
}
#action-bar.in-combat #rest-actions {
  display: none;
}
.rest-action-button {
  grid-row: 1;
}
.action-button {
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  background: #0d0d0d;
  border: 1px solid #3f3a29;
  color: #c8c8a0;
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 15px;
  justify-content: center;
  height: var(--action-button-size);
  min-height: var(--action-button-size);
  min-width: var(--action-button-size);
  padding: 0;
  touch-action: manipulation;
  user-select: none;
}
.action-button:hover:not(:disabled),
.action-button:focus-visible:not(:disabled) {
  border-color: #8b8055;
  color: #efe5a8;
  outline: none;
}
.action-button:disabled {
  border-color: #242424;
  color: #4f4f42;
  cursor: not-allowed;
  opacity: 0.55;
}
.compass-button {
  padding: 0;
}
.utility-button {
  border-color: #4b442e;
  font-size: 12px;
}
#input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid #333;
  padding-top: 8px;
}
#prompt { color: #888; }
#cmd {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  outline: none;
}
#input-version {
  flex: 0 0 auto;
  padding-left: 12px;
  text-align: right;
}
#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
body.game-active #bg-canvas {
  display: none;
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  #landing {
    gap: 22px;
    padding: calc(20px + env(safe-area-inset-top)) 20px
      calc(20px + env(safe-area-inset-bottom));
  }

  #landing img {
    width: min(90vw, 420px);
    max-height: 52vh;
  }

  #enter-button {
    font-size: 16px;
    min-height: 44px;
    padding: 12px 18px;
  }

  #auth {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(18px + env(safe-area-inset-top)) 14px
      calc(18px + env(safe-area-inset-bottom));
    align-content: start;
    gap: 14px;
  }

  #auth h1 {
    font-size: 28px;
    line-height: 1.2;
  }

  .version-label {
    font-size: 12px;
  }

  #auth h2 {
    font-size: 20px;
    line-height: 1.25;
  }

  #auth form {
    padding: 14px;
    gap: 12px;
  }

  #auth input,
  #auth textarea,
  #auth button {
    font-size: 16px;
    min-height: 44px;
    padding: 10px;
  }

  #attribute-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 12px;
    row-gap: 16px;
  }

  .attribute-stepper {
    grid-template-columns: 34px 48px 34px;
    gap: 6px;
  }

  .attribute-stepper button {
    width: 34px;
    height: 40px;
  }

  .attribute-stepper input {
    width: 48px;
    height: 40px;
    line-height: 40px;
  }

  #app {
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(12px + env(safe-area-inset-top)) 12px
      calc(10px + env(safe-area-inset-bottom));
    gap: 10px;
  }

  #output {
    gap: 5px;
    min-height: 0;
    overflow-wrap: anywhere;
    -webkit-overflow-scrolling: touch;
  }

  .msg {
    font-size: 14px;
    line-height: 1.35;
  }

  #char-summary {
    font-size: 12px;
    line-height: 1.3;
  }

  #character-modal {
    padding: 12px;
  }

  #character-modal-panel {
    grid-template-columns: 1fr;
    height: 90vh;
    height: 90dvh;
    max-height: 90vh;
    padding: 16px;
  }

  #character-modal-tabs {
    gap: 6px;
    padding-left: 38px;
  }

  .character-modal-tab {
    font-size: 12px;
    padding: 8px 3px;
  }

  #character-modal-page-character {
    grid-template-columns: 1fr;
  }

  #character-modal-portrait-wrap {
    margin: 0 auto;
    max-width: 220px;
    width: 100%;
  }

  #character-modal-stats,
  #character-modal-inventory {
    font-size: 13px;
    padding-right: 0;
  }

  #character-modal-map {
    min-height: 0;
  }

  #action-bar {
    --action-button-size: 44px;
    --action-button-gap: 6px;
    gap: 12px;
    justify-content: space-between;
  }

  .action-button {
    font-size: 16px;
  }

  #input-row {
    align-items: center;
    padding-top: 10px;
  }

  #cmd {
    font-size: 14px;
    min-height: 44px;
  }

  #input-version {
    padding-left: 8px;
  }
}

@media (max-width: 600px) {
  .msg.map canvas {
    width: 100%;
    max-width: 100vw;
  }
}

/* ── Character Creation Wizard ─────────────────────────── */

/* Persistent stat block */
#wizard-stat-block {
  border: 1px solid #333;
  padding: 10px;
  margin-bottom: 12px;
  display: grid;
  gap: 8px;
}
.wsb-abilities {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.wsb-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid transparent;
  padding: 2px 0;
}
.wsb-cell.primary {
  background: #1a1710;
  border-color: rgba(212, 201, 138, 0.55);
  box-shadow: inset 0 0 0 1px rgba(212, 201, 138, 0.2), 0 0 8px rgba(212, 201, 138, 0.1);
}
.wsb-label {
  color: #666;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.wsb-label.primary {
  color: #d4c98a;
}
.wsb-label.save-prof {
  color: #a99f72;
  text-decoration: underline;
  text-decoration-color: #d4c98a;
  text-underline-offset: 2px;
}
.wsb-value {
  color: #c8c8a0;
  font-size: 15px;
}
.wsb-mod {
  color: #777;
  font-size: 12px;
}
.wsb-derived {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border-top: 1px solid #252525;
  padding-top: 8px;
}
/* Gold for saving throw proficiency, cyan for expertise */
.wsb-value.save-prof { color: #d4c98a; }
.wsb-value.primary {
  color: #fff0a8;
  font-weight: bold;
}
.wsb-value.expert { color: #7ec8c8; }

/* Wizard navigation */
#wizard-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid #252525;
  padding-top: 12px;
}
#wizard-step-label {
  color: #666;
  font-size: 12px;
  text-align: center;
}
#wizard-back,
#wizard-next {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 38px;
}
#wizard-back:disabled,
#wizard-next:disabled {
  color: #444;
  border-color: #2a2a2a;
  cursor: not-allowed;
}

/* Wizard step content */
#wizard-content {
  display: grid;
  gap: 10px;
}
.wizard-step-title {
  font-size: 14px;
  color: #888;
  margin-bottom: 2px;
}
.wizard-step-heading {
  font-size: 17px;
  font-weight: normal;
  color: #d4c98a;
  margin-bottom: 4px;
}
.wizard-class-context {
  color: #b8ad7a;
  font-size: 14px;
  margin-bottom: 2px;
}

/* Class selection grid */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}
.class-option {
  background: #111;
  border: 1px solid #333;
  color: #c8c8a0;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 6px;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 2px;
}
.class-option:hover {
  border-color: #57513a;
}
.class-option.selected,
.method-option.selected,
.rolled-value.selected,
.equipment-option.selected,
.soul-option.selected,
.gender-option.selected {
  background: #1a1710;
  border-color: #d4c98a;
  color: #efe5a8;
  box-shadow: inset 0 0 0 1px rgba(212, 201, 138, 0.35), 0 0 10px rgba(212, 201, 138, 0.12);
}
.class-option.selected .class-option-meta {
  color: #b8ad7a;
}
.class-option-name {
  font-size: 14px;
}
.class-option-meta {
  font-size: 11px;
  color: #666;
}

/* Method selection */
.method-options {
  display: grid;
  gap: 6px;
}
.method-option {
  background: #111;
  border: 1px solid #333;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 3px;
}
.method-option:hover {
  border-color: #57513a;
}
.method-option-desc {
  font-size: 12px;
  color: #666;
}
.method-option.selected .method-option-desc {
  color: #b8ad7a;
}

/* Ability score assignment */
.score-assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.score-assign-cell {
  display: grid;
  gap: 4px;
  align-items: center;
  justify-items: center;
}
.score-assign-label {
  font-size: 12px;
  color: #888;
  letter-spacing: 0.06em;
}
.score-assign-label.primary,
.wizard-ability-name.primary {
  color: #fff0a8;
  font-weight: bold;
}
.score-assign-label.save-prof,
.wizard-ability-name.save-prof {
  color: #d4c98a;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.score-assign-select {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 6px;
  width: 80px;
  text-align: center;
}

/* Point-buy in wizard (reuses attribute-stepper) */
.wizard-point-buy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 12px;
}
.wizard-point-buy-label {
  display: grid;
  gap: 6px;
  justify-items: center;
}
#wizard-points-remaining {
  color: #888;
  font-size: 13px;
}

/* Rolled scores pool */
.rolled-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border: 1px solid #2a2a2a;
  margin-bottom: 8px;
  min-height: 44px;
}
.rolled-value {
  background: #1a1a1a;
  border: 1px solid #444;
  color: #c8c8a0;
  font-family: inherit;
  font-size: 15px;
  padding: 4px 10px;
  cursor: pointer;
  min-width: 38px;
  text-align: center;
}
.rolled-value.used {
  color: #333;
  border-color: #2a2a2a;
  cursor: not-allowed;
  opacity: 0.65;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}
.array-assign-grid,
.rolled-assign-grid {
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: 4px;
}
.array-assign-grid .score-assign-cell {
  gap: 2px;
  min-width: 0;
}
.rolled-assign-grid .score-assign-cell.method-option {
  gap: 2px;
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  justify-items: center;
}

/* Skill selection */
.skill-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
}
.skill-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  color: #c8c8a0;
  font-size: 14px;
  user-select: none;
}
.skill-item input[type="checkbox"] {
  accent-color: #d4c98a;
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.skill-item.selected {
  color: #d4c98a;
}
.skill-item.disabled {
  color: #444;
  cursor: not-allowed;
}
#wizard-skill-status {
  color: #888;
  font-size: 13px;
}

/* Tool selection */
.tool-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px;
}
.tool-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  color: #c8c8a0;
  font-size: 14px;
  user-select: none;
}
.tool-item input[type="checkbox"],
.tool-item input[type="radio"] {
  accent-color: #d4c98a;
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.tool-item.selected {
  color: #d4c98a;
}

/* Equipment choice */
.equipment-options {
  display: grid;
  gap: 8px;
}
.equipment-option {
  background: #111;
  border: 1px solid #333;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 4px;
}
.equipment-option:hover {
  border-color: #57513a;
}
.equipment-option.selected .equipment-option-key {
  color: #b8ad7a;
}
.equipment-option-key {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.equipment-option-items {
  font-size: 13px;
  color: #999;
  line-height: 1.5;
}
.equipment-option.selected .equipment-option-items {
  color: #b8ad7a;
}

/* Persona steppers */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.persona-cell {
  display: grid;
  gap: 8px;
  justify-items: center;
}
.persona-cell-name {
  font-size: 15px;
  color: #888;
  letter-spacing: 0.04em;
}
.persona-desc {
  font-size: 13px;
  color: #555;
  text-align: center;
  line-height: 1.4;
}
#wizard-persona-pool {
  color: #888;
  font-size: 15px;
  text-align: center;
}
.persona-cell .wsb-value {
  font-size: 17px;
}
.persona-stepper {
  grid-template-columns: repeat(2, 40px);
  gap: 6px;
  justify-content: center;
}
.persona-stepper button {
  width: 40px;
  height: 36px;
  padding: 0;
  text-align: center;
}

/* Soul selection */
.soul-options {
  display: grid;
  gap: 6px;
}
.soul-option {
  background: #111;
  border: 1px solid #333;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 3px;
}
.soul-option:hover {
  border-color: #57513a;
}
.soul-option-label {
  font-size: 14px;
}
.soul-option-desc {
  font-size: 12px;
  color: #666;
}
.soul-option.selected .soul-option-desc {
  color: #b8ad7a;
}

/* Identity step (name, gender, description) */
.identity-grid {
  display: grid;
  gap: 12px;
}
.gender-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.gender-option {
  background: #111;
  border: 1px solid #333;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 8px 6px;
  cursor: pointer;
  text-align: center;
}
.gender-option:hover {
  border-color: #57513a;
}
#wizard-description {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  font-family: inherit;
  font-size: 14px;
  padding: 8px;
  resize: vertical;
  min-height: 80px;
  width: 100%;
  scrollbar-gutter: stable;
}
.char-count {
  color: #555;
  font-size: 11px;
  text-align: right;
}

/* Review sheet */
.review-sheet {
  display: grid;
  gap: 12px;
  font-size: 14px;
}
.review-section {
  border: 1px solid #222;
  padding: 10px;
  display: grid;
  gap: 6px;
}
.review-section-title {
  color: #666;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid #1e1e1e;
  padding-bottom: 4px;
  margin-bottom: 2px;
}
.review-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
}
.review-label {
  color: #666;
}
.review-value {
  color: #c8c8a0;
}
.review-value.prof {
  color: #d4c98a;
}
.review-value.muted {
  color: #666;
}
.review-submit {
  background: #111;
  border: 1px solid #57513a;
  color: #d4c98a;
  font-family: inherit;
  font-size: inherit;
  padding: 10px;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
}
.review-submit:hover {
  border-color: #8b8055;
  color: #efe5a8;
}
.review-submit:disabled {
  color: #444;
  border-color: #2a2a2a;
  cursor: not-allowed;
}

/* Portrait placeholder */
.portrait-placeholder {
  border: 1px solid #252525;
  padding: 24px 16px;
  text-align: center;
  color: #666;
  display: grid;
  gap: 16px;
  line-height: 1.6;
}
.portrait-skip {
  background: #111;
  border: 1px solid #444;
  color: #c8c8a0;
  font-family: inherit;
  font-size: inherit;
  padding: 10px 16px;
  cursor: pointer;
}
.portrait-skip:hover {
  border-color: #8b8055;
  color: #efe5a8;
}

.character-portrait {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--amber);
  filter: sepia(0.3) saturate(0.85) brightness(0.9);
  box-shadow: 0 0 8px rgba(255, 176, 0, 0.2);
}

.portrait-disclaimer {
  font-size: 0.75rem;
  opacity: 0.55;
  font-style: italic;
  margin: 0.25rem 0 0.75rem;
}

/* Scanline overlay — adjust rgba opacity to taste */
.character-portrait-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.character-portrait-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0, 0, 0, 0.08) 2px,
      rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
}

#cutscene-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  overflow: hidden;
  cursor: default;
}
#cutscene-overlay.hidden {
  display: none;
}
#cutscene-stage {
  position: absolute;
  inset: 0;
}
.cs-element {
  position: absolute;
  transform-origin: center center;
  pointer-events: none;
  white-space: pre-wrap;
}
#cutscene-skip-hint {
  position: absolute;
  bottom: 24px;
  right: 28px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: rgba(200, 150, 12, 0.35);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
#cutscene-overlay.skippable #cutscene-skip-hint {
  opacity: 1;
}

/* Mobile overrides */
@media (max-width: 640px) {
  .wsb-abilities {
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
  }
  .wsb-label { font-size: 10px; }
  .wsb-value { font-size: 13px; }
  .wsb-mod   { font-size: 11px; }

  .class-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .persona-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .gender-options {
    grid-template-columns: repeat(3, 1fr);
  }
  .score-assign-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .array-assign-grid,
  .rolled-assign-grid {
    grid-template-columns: repeat(6, minmax(38px, 1fr));
    gap: 3px;
  }
  .wizard-point-buy-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .skill-list {
    grid-template-columns: 1fr;
  }
  .tool-list {
    grid-template-columns: 1fr;
  }
  .review-row {
    grid-template-columns: 110px 1fr;
  }
}
