:root {
  --bg: #14100d;
  --bg-elevated: #1f1712;
  --bg-card: #241a13;
  --ember: #e8843a;
  --ember-bright: #ffb15e;
  --gold: #d4af6a;
  --text: #f4ead9;
  --text-muted: #b8a98f;
  --danger: #c1443c;
  --trust: #4a9d7f;
  --border: #3a2a1d;
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Author rules that set `display` (e.g. `.end-screen { display: flex }`)
   otherwise beat the browser's default `[hidden] { display: none }` UA
   rule regardless of selector specificity, since author styles always win
   over UA styles. Without this, toggling the `hidden` DOM property has no
   visual effect on any element whose class also declares `display`. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

/* On some Android keyboards, 100vh does not account for the on-screen
   keyboard covering part of the viewport; dvh (dynamic viewport height)
   does. Falls back to the min-height above on browsers that don't
   support it yet — never a regression, only an upgrade where available. */
@supports (min-height: 100dvh) {
  html, body { min-height: 100dvh; }
}

.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;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  /* env(safe-area-inset-*) keeps content clear of a notch/home-indicator
     on phones that report one; add()s to 0 on every other device. */
  padding: calc(16px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.app-header {
  text-align: center;
}
.app-header .eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ember-bright);
}
.app-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 4px 0 2px;
  color: var(--text);
}
.app-header .tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.offer-card-toggle {
  align-self: center;
  min-height: 44px;
  background: none;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.offer-card-toggle:hover { filter: brightness(1.15); }

/* Compact by design: one title, one subtitle, three short lines — never
   a scrollable document. No max-height/overflow-y here on purpose, since
   this card must never grow long enough to need it. */
.offer-card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.offer-card-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}
.offer-card-subtitle {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
}
.offer-card-line {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text);
}
.offer-card-line strong {
  color: var(--ember-bright);
  font-weight: 700;
}

.mission-card, .end-screen {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mission-card p, .end-screen p { margin: 0; line-height: 1.5; }
.turn-limit-note { color: var(--gold); font-size: 0.88rem; }
.knowledge-note { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

.primary-btn {
  background: linear-gradient(180deg, var(--ember-bright), var(--ember));
  color: #1a0f04;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  min-height: 44px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  align-self: center;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:focus-visible, .item-btn:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 2px;
}

.game-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stage-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.character-stage {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #3a2415, var(--bg-elevated) 70%);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  --emotion-intensity: 0.5;
}
.dragon-name {
  margin: 6px 0 0;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.95rem;
}

.dragon-portrait {
  width: 160px; height: 160px;
  object-fit: contain;
  display: block;
  /* Until the real PNGs land (see public/assets/dragon/grimbold/README.md)
     this renders as a broken-image icon — expected, not a bug; see that
     file for exactly what to add. */
}
@media (prefers-reduced-motion: no-preference) {
  .dragon-portrait { animation: breathe 3.2s ease-in-out infinite; }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.stage-effect {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
}
.stage-effect.effect-play { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .stage-effect.effect-play { animation: effect-pulse 0.9s ease-out; }
}
@keyframes effect-pulse {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}
.stage-effect[data-effect="smoke"] { background: radial-gradient(circle at 50% 30%, rgba(160,160,160,0.5), transparent 60%); }
.stage-effect[data-effect="fire"] { background: radial-gradient(circle at 50% 60%, rgba(232,132,58,0.6), transparent 60%); }
.stage-effect[data-effect="sparkle"] { background: radial-gradient(circle at 50% 40%, rgba(212,175,106,0.6), transparent 55%); }
.stage-effect[data-effect="treasure_glint"] { background: radial-gradient(circle at 50% 50%, rgba(255,215,120,0.55), transparent 55%); }
.stage-effect[data-effect="victory"] { background: radial-gradient(circle at 50% 50%, rgba(74,157,127,0.55), transparent 60%); }
.stage-effect[data-effect="failure"] { background: radial-gradient(circle at 50% 50%, rgba(193,68,60,0.5), transparent 60%); }

.meters {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.meter { display: flex; flex-direction: column; gap: 2px; }
.meter label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.meter progress { width: 100%; height: 8px; border-radius: 6px; overflow: hidden; }
progress { appearance: none; border: none; background: var(--bg-elevated); }
progress::-webkit-progress-bar { background: var(--bg-elevated); border-radius: 6px; }
.meter-persuasion progress::-webkit-progress-value { background: var(--ember-bright); }
.meter-trust progress::-webkit-progress-value { background: var(--trust); }
.meter-suspicion progress::-webkit-progress-value { background: var(--danger); }
.meter-patience progress::-webkit-progress-value { background: #6fa8c9; }
.meter-persuasion progress::-moz-progress-bar { background: var(--ember-bright); }
.meter-trust progress::-moz-progress-bar { background: var(--trust); }
.meter-suspicion progress::-moz-progress-bar { background: var(--danger); }
.meter-patience progress::-moz-progress-bar { background: #6fa8c9; }

/* B+ playtest engine only (TEN_TURNS_ENGINE=bplus) — one stance bar
   replaces the four meters above; see ui-controller.js#_renderStanceBar. */
.stance-bar { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.stance-bar label { font-size: 0.85rem; font-weight: 600; letter-spacing: 0.02em; }
.stance-bar progress { width: 100%; height: 10px; border-radius: 6px; overflow: hidden; }
.stance-bar progress::-webkit-progress-value { background: var(--ember-bright); }
.stance-bar progress::-moz-progress-bar { background: var(--ember-bright); }
.stance-points {
  align-self: flex-end;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
}

.turn-counter {
  margin: 0;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.95rem;
}

.conversation-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hints-panel button {
  min-height: 44px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.hints-panel button:disabled {
  opacity: 0.6;
  cursor: default;
}
.hints-panel ul {
  margin: 6px 0 0;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  list-style: disc;
}

.voice-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.voice-picker select {
  flex: 1 1 220px;
  min-width: 0;
}

.debug-panel {
  margin: 0;
  padding: 10px 12px;
  background: #0b0e0c;
  color: #7fdca4;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.4;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.conversation-log {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  max-height: 38vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.bubble-dragon {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.bubble-player {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--ember-bright), var(--ember));
  color: #1a0f04;
}
.bubble-system {
  align-self: center;
  font-style: italic;
  color: var(--text-muted);
  background: none;
}

.message-form {
  display: flex;
  gap: 8px;
}
.message-form input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  /* 16px minimum is deliberate: iOS Safari auto-zooms the whole page on
     focus for any input with a smaller computed font-size — this was
     0.95rem (~15.2px) and would trigger that zoom on a real phone. */
  font-size: 16px;
  min-height: 44px;
}
.message-form input:disabled { opacity: 0.6; }

.mic-btn {
  flex: 0 0 auto;
  min-height: 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}
.mic-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* Recording — a clear, unmissable state distinct from every other button on the page. */
.mic-btn[aria-pressed="true"] {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.item-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.item-btn {
  flex: 1 1 auto;
  min-width: 100px;
  min-height: 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}
.item-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.item-count {
  display: inline-block;
  margin-left: 4px;
  background: var(--ember);
  color: #1a0f04;
  border-radius: 999px;
  padding: 0 6px;
  font-weight: 700;
  font-size: 0.75rem;
}

.end-screen h2 {
  font-family: var(--font-display);
  margin: 0;
  color: var(--gold);
}
.end-transcript-heading {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.end-transcript {
  max-height: 30vh;
}
.achievements {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.achievement-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}
.achievement-badge strong { color: var(--ember-bright); font-size: 0.85rem; }
.achievement-badge span { color: var(--text-muted); font-size: 0.78rem; }

.mock-mode-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

@media (max-width: 340px) {
  .app-shell { padding: 12px 10px 20px; }
  .character-stage { width: 150px; height: 150px; }
  .dragon-portrait { width: 132px; height: 132px; }
}

/* World/home screen ("/" — see index.html/js/world.js). Reuses the same
   tokens/shell as every other screen — no new colors, no redesign, just a
   card list where the game screen normally is. */
.world-shell .app-header { margin-bottom: 2px; }
.world-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  margin: 6px 0 2px;
  color: var(--text);
}
.world-shell .tagline { font-size: 0.95rem; }

.world-progress {
  text-align: center;
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  margin: 0;
}

.world-characters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.character-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  transition: filter 0.15s ease;
}
a.character-card:hover, a.character-card:focus-visible { filter: brightness(1.08); }
a.character-card:focus-visible { outline: 2px solid var(--ember-bright); outline-offset: 2px; }

.character-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ember-bright);
}
.character-species {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.character-mission {
  margin: 2px 0 6px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
}
.character-status {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a0f04;
  background: linear-gradient(180deg, var(--ember-bright), var(--ember));
  border-radius: 6px;
  padding: 3px 10px;
}
.character-status-defeated {
  color: var(--text);
  background: none;
  border: 1px solid var(--gold);
}
.character-card-defeated { border-color: var(--gold); }
.character-card-defeated .character-species { color: var(--gold); }

.character-card-locked {
  opacity: 0.6;
  cursor: default;
}
.character-card-locked .character-status {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.character-card-mystery {
  align-items: center;
  text-align: center;
  border-style: dashed;
  opacity: 0.75;
}
.character-card-mystery h2 { color: var(--text-muted); letter-spacing: 0.3em; }
.character-card-mystery .character-mission { color: var(--text-muted); font-style: italic; }

.end-screen-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.secondary-btn {
  display: inline-block;
  background: none;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 10px;
  padding: 9px 16px;
  min-height: 44px;
  line-height: 26px;
  font-size: 0.9rem;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.secondary-btn:hover { filter: brightness(1.15); }
.secondary-btn:focus-visible { outline: 2px solid var(--ember-bright); outline-offset: 2px; }

/* Public beta: start/refusal message under the start buttons. */
.start-note {
  margin: 0;
  color: var(--ember-bright);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Optional post-game question ("Would you play another character?"). */
.feedback-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
}
.feedback-question {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1rem;
}
.feedback-choices {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.feedback-choice {
  flex: 0 1 120px;
  min-height: 44px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.feedback-choice[aria-pressed="true"] {
  border-color: var(--ember-bright);
  color: var(--ember-bright);
  font-weight: 700;
}
.feedback-choice:disabled { cursor: default; opacity: 0.7; }
.feedback-choice[aria-pressed="true"]:disabled { opacity: 1; }
.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.feedback-form label { font-size: 0.85rem; color: var(--text-muted); }
.feedback-optional { font-style: italic; }
.feedback-form textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-body);
  /* 16px: no iOS focus zoom (see .message-form input). */
  font-size: 16px;
  resize: vertical;
}
.feedback-form .secondary-btn { align-self: center; }
.feedback-thanks { color: var(--trust); font-size: 0.9rem; }
.primary-btn:disabled { opacity: 0.6; cursor: progress; }
textarea:focus-visible { outline: 2px solid var(--ember-bright); outline-offset: 2px; }

/* ---- Mobile-first play layout (public beta) -------------------------- */

/* A flex item's default min-width is its intrinsic width — without this
   the input refuses to shrink and pushes Send off-screen on phones. */
.message-form input { min-width: 0; }
.message-form .primary-btn { flex: 0 0 auto; }

@supports (max-height: 1dvh) {
  .conversation-log { max-height: 38dvh; }
  .end-transcript { max-height: 30dvh; }
}

@media (max-width: 520px) {
  /* Phone keyboards have built-in dictation, and the extra button is what
     crowds Send off a narrow screen. Desktop keeps it. */
  .mic-btn { display: none !important; }

}

/* ---- Fixed play screen ----------------------------------------------
   While a game is on screen the page itself never scrolls: one frame the
   height of the VISIBLE area (--vv-height / --vv-top come from
   window.visualViewport in app.js, so an open keyboard shrinks the frame
   instead of scrolling the page). Character + status stay at the top, the
   input + items at the bottom, and only the conversation scrolls between
   them. The mission card and end screen still scroll normally. */
html:has(#game-view:not([hidden])),
html:has(#game-view:not([hidden])) body { overflow: hidden; overscroll-behavior: none; }

.app-shell:has(#game-view:not([hidden])) {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  height: var(--vv-height, 100vh);
  margin: 0 auto;
  overflow: hidden;
  gap: 8px;
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
@supports (height: 100dvh) {
  .app-shell:has(#game-view:not([hidden])) { height: var(--vv-height, 100dvh); }
}
.app-shell:has(#game-view:not([hidden])) .app-header { flex: none; }
.app-shell:has(#game-view:not([hidden])) .app-header .eyebrow,
.app-shell:has(#game-view:not([hidden])) .app-header .tagline,
.app-shell:has(#game-view:not([hidden])) .mock-mode-note { display: none; }
.app-shell:has(#game-view:not([hidden])) .app-header h1 {
  font-size: 1rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-shell:has(#game-view:not([hidden])) .game-view { flex: 1 1 auto; min-height: 0; gap: 8px; }

/* Character on the left, stance + turn on the right — always visible. */
.app-shell:has(#game-view:not([hidden])) .stage-column {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  row-gap: 6px;
  align-items: center;
}
.app-shell:has(#game-view:not([hidden])) .character-stage { grid-row: 1 / span 2; width: 104px; height: 104px; }
.app-shell:has(#game-view:not([hidden])) .dragon-portrait { width: 96px; height: 96px; }
.app-shell:has(#game-view:not([hidden])) .dragon-name {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0 8px;
  background: var(--bg);
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}
.app-shell:has(#game-view:not([hidden])) .stance-bar { grid-column: 2; }
.app-shell:has(#game-view:not([hidden])) .turn-counter { grid-column: 2; text-align: left; font-size: 0.9rem; }

.app-shell:has(#game-view:not([hidden])) .conversation-column { flex: 1 1 auto; min-height: 0; gap: 8px; }
.app-shell:has(#game-view:not([hidden])) .hints-panel { flex: none; }
.app-shell:has(#game-view:not([hidden])) .hints-panel ul { max-height: 22vh; overflow-y: auto; }
.app-shell:has(#game-view:not([hidden])) .conversation-log { flex: 1 1 auto; min-height: 0; max-height: none; }
.app-shell:has(#game-view:not([hidden])) .message-form,
.app-shell:has(#game-view:not([hidden])) .item-controls { flex: none; }
.app-shell:has(#game-view:not([hidden])) .item-controls { flex-wrap: nowrap; gap: 6px; }
.app-shell:has(#game-view:not([hidden])) .item-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 6px 4px;
  font-size: 0.76rem;
  line-height: 1.2;
}

/* Keyboard open (phones — app.js sets html.kb-open): keep the character
   visible but small, and give everything else to the conversation. */
html.kb-open .app-shell:has(#game-view:not([hidden])) .app-header,
html.kb-open .app-shell:has(#game-view:not([hidden])) .hints-panel,
html.kb-open .app-shell:has(#game-view:not([hidden])) .item-controls { display: none; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .character-stage { width: 52px; height: 52px; grid-row: 1 / span 2; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .dragon-portrait { width: 48px; height: 48px; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .dragon-name { display: none; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .stance-bar label { font-size: 0.78rem; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .stance-bar progress { height: 6px; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .stance-points { display: none; }
html.kb-open .app-shell:has(#game-view:not([hidden])) .turn-counter { font-size: 0.8rem; }

/* World-screen card thumbnails: image on the left, text on the right. */
.character-card-with-image {
  display: grid;
  grid-template-columns: 88px 1fr;
  column-gap: 14px;
  align-content: center;
}
.character-card-with-image > :not(.character-card-image) { grid-column: 2; }
.character-card-image {
  grid-column: 1;
  grid-row: 1 / span 4;
  align-self: center;
  width: 88px;
  height: 88px;
  border-radius: 12px;
  object-fit: cover;
  background: radial-gradient(circle at 50% 40%, #3a2415, var(--bg-elevated) 70%);
  border: 1px solid var(--border);
}
@media (max-width: 340px) {
  .character-card-with-image { grid-template-columns: 72px 1fr; column-gap: 12px; }
  .character-card-image { width: 72px; height: 72px; }
}

/* Waiting for a reply: read-only (keeps the phone keyboard up), dimmed. */
.message-form input[readonly] { opacity: 0.6; }

/* Character intro clip on the mission screen (see js/intro-video.js). */
.intro-video {
  position: relative;
  margin: -4px -4px 2px;
  aspect-ratio: 636 / 478;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0806;
  border: 1px solid var(--border);
}
.intro-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.intro-video-sound {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.intro-video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
/* Phones: the Start button stays reachable below a tall intro. */
@media (max-width: 520px) {
  #mission-start-btn {
    position: sticky;
    bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
    z-index: 2;
  }
}
