/* ====================================================
   RPG Adventure — Dark Fantasy Styles
   ==================================================== */

:root {
  --rpg-bg:       #0a0a0f;
  --rpg-surface:  #12121a;
  --rpg-surface2: #1a1a26;
  --rpg-border:   rgba(201,168,76,.2);
  --rpg-gold:     #c9a84c;
  --rpg-gold-dim: rgba(201,168,76,.12);
  --rpg-text:     #e8dfc8;
  --rpg-muted:    #7a6f5a;
  --rpg-hp:       #cc3333;
  --rpg-xp:       #3a7abf;
  --rpg-danger:   #8b2020;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.rpg-body {
  font-family: 'IM Fell English', Georgia, serif;
  background: var(--rpg-bg);
  color: var(--rpg-text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* --- Back link ---------------------------------------------------- */
.rpg-back {
  display: inline-block;
  font-family: 'Cinzel', serif;
  font-size: .78rem;
  color: var(--rpg-muted);
  text-decoration: none;
  transition: color .2s;
}
.rpg-back:hover { color: var(--rpg-gold); }
.rpg-back--game {
  color: rgba(232,223,200,.7);
  font-size: .78rem;
}
.rpg-back--game:hover { color: #fff; }

/* ================================================================
   CHARACTER CREATION
   ================================================================ */

.rpg-screen { min-height: 100vh; }

.creation-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.creation-card {
  background: var(--rpg-surface);
  border: 1px solid var(--rpg-border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  margin-top: 1rem;
  box-shadow: 0 0 60px rgba(201,168,76,.06);
}

.creation-header {
  text-align: center;
  margin-bottom: 2rem;
}
.creation-crest {
  font-size: 3rem;
  display: block;
  margin-bottom: .5rem;
  filter: drop-shadow(0 0 12px rgba(201,168,76,.5));
}
.creation-header h1 {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--rpg-gold);
  letter-spacing: .08em;
}
.creation-sub {
  color: var(--rpg-muted);
  font-size: .9rem;
  margin-top: .4rem;
  font-style: italic;
}

/* Form */
.creation-form { display: flex; flex-direction: column; gap: 1.5rem; }

.form-group { display: flex; flex-direction: column; gap: .5rem; }
.form-group label {
  font-family: 'Cinzel', serif;
  font-size: .8rem;
  font-weight: 600;
  color: var(--rpg-gold);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.form-group input[type="text"] {
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 6px;
  color: var(--rpg-text);
  padding: .65rem .9rem;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 1rem;
}
.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--rpg-gold);
  box-shadow: 0 0 0 2px rgba(201,168,76,.15);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* Class grid */
.class-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}
.class-card, .race-card {
  cursor: pointer;
}
/* Visually hidden but focusable + in the a11y tree (clip pattern, not display:none). */
.class-card input, .race-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  pointer-events: none;
}
.class-card input:focus-visible ~ .class-inner,
.race-card input:focus-visible ~ .race-inner {
  outline: 2px solid var(--rpg-gold);
  outline-offset: 2px;
}
.class-inner, .race-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .75rem .5rem;
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  background: var(--rpg-bg);
  transition: all .2s;
  text-align: center;
}
.class-card input:checked ~ .class-inner,
.race-card input:checked ~ .race-inner {
  border-color: var(--rpg-gold);
  background: var(--rpg-gold-dim);
}
.class-inner:hover, .race-inner:hover {
  border-color: rgba(201,168,76,.5);
}
.class-icon, .race-icon { font-size: 1.4rem; }
.class-name, .race-name {
  font-family: 'Cinzel', serif;
  font-size: .75rem;
  font-weight: 600;
  color: var(--rpg-gold);
}
.class-desc {
  font-size: .68rem;
  color: var(--rpg-muted);
  font-style: italic;
}

/* Race grid */
.race-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

/* Buttons */
.rpg-btn {
  font-family: 'Cinzel', serif;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .06em;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
  padding: .7rem 1.4rem;
}
.rpg-btn--gold {
  background: linear-gradient(135deg, #c9a84c, #a07830);
  color: #1a1000;
}
.rpg-btn--gold:hover { opacity: .9; transform: translateY(-1px); }
.rpg-btn--gold:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.rpg-btn--sm { padding: .35rem .75rem; font-size: .72rem; }
.rpg-btn--danger {
  background: rgba(139,32,32,.4);
  color: #e8a0a0;
  border: 1px solid rgba(139,32,32,.6);
}
.rpg-btn--danger:hover { background: rgba(139,32,32,.7); }

.rpg-error {
  color: #e08080;
  font-size: .82rem;
  font-style: italic;
  text-align: center;
  margin-top: .25rem;
}

.rpg-guest-hint {
  color: var(--rpg-muted);
  font-size: .78rem;
  font-style: italic;
  text-align: center;
  margin-top: .25rem;
}

/* ================================================================
   GAME SCREEN
   ================================================================ */

/* Scene banner */
.scene-banner {
  position: relative;
  height: 200px;
  overflow: hidden;
}
.scene-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .6s;
}
.scene-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10,10,15,.3) 0%, rgba(10,10,15,.85) 100%);
}
.scene-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  gap: 1rem;
}
.scene-title {
  font-family: 'Cinzel', serif;
  font-size: .95rem;
  font-weight: 700;
  color: var(--rpg-gold);
  letter-spacing: .06em;
}

/* Layout */
.game-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: calc(100vh - 200px);
}

/* Sidebar */
.game-sidebar {
  background: var(--rpg-surface);
  border-right: 1px solid var(--rpg-border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  overflow-y: auto;
}

.char-portrait {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--rpg-gold-dim);
  border: 2px solid var(--rpg-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--rpg-gold);
  margin: 0 auto;
}

.char-name {
  text-align: center;
  font-family: 'Cinzel', serif;
  font-size: .9rem;
  font-weight: 700;
  color: var(--rpg-gold);
}
.char-class {
  font-size: .72rem;
  color: var(--rpg-muted);
  font-style: italic;
}

/* Stats */
.stat-block {
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.stat-label {
  font-family: 'Cinzel', serif;
  font-size: .65rem;
  font-weight: 600;
  color: var(--rpg-muted);
  width: 28px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.stat-bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}
.stat-fill--hp { background: linear-gradient(90deg, #8b2020, #e04444); }
.stat-fill--xp { background: linear-gradient(90deg, #1a4f8a, #3a8abf); }
.stat-value {
  font-size: .72rem;
  color: var(--rpg-text);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stat-gold {
  border-top: 1px solid var(--rpg-border);
  padding-top: .5rem;
  justify-content: space-between;
}
.stat-gold .stat-label { width: auto; }
.stat-gold .stat-value { color: var(--rpg-gold); font-weight: 600; }

/* Inventory */
.inventory-block {
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  padding: .75rem;
  flex: 1;
}
.inventory-title {
  font-family: 'Cinzel', serif;
  font-size: .7rem;
  font-weight: 600;
  color: var(--rpg-gold);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
}
.inventory-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.inventory-list li {
  font-size: .78rem;
  color: var(--rpg-text);
  padding: .2rem .4rem;
  border-radius: 4px;
  background: rgba(255,255,255,.03);
}
.inv-empty { color: var(--rpg-muted) !important; font-style: italic; }

/* Narrative log */
.game-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.narrative-log {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}
.narrative-log::-webkit-scrollbar { width: 6px; }
.narrative-log::-webkit-scrollbar-track { background: transparent; }
.narrative-log::-webkit-scrollbar-thumb { background: var(--rpg-border); border-radius: 3px; }

.msg { display: flex; }
.msg--user { justify-content: flex-end; }
.msg--assistant { justify-content: flex-start; }

.msg-bubble {
  max-width: 78%;
  padding: .75rem 1rem;
  border-radius: 10px;
  font-size: .92rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg--assistant .msg-bubble {
  background: var(--rpg-surface2);
  border: 1px solid var(--rpg-border);
  color: var(--rpg-text);
  border-top-left-radius: 2px;
}
.msg--user .msg-bubble {
  background: var(--rpg-gold-dim);
  border: 1px solid rgba(201,168,76,.3);
  color: var(--rpg-gold);
  font-style: italic;
  border-top-right-radius: 2px;
}

/* DM header above each DM message */
.dm-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .3rem;
  padding-left: .2rem;
}
.dm-icon { font-size: .85rem; }
.dm-label {
  font-family: 'Cinzel', serif;
  font-size: .65rem;
  font-weight: 700;
  color: var(--rpg-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Login-gate message shown when a guest hits the free-action limit */
.msg--login-gate .msg-bubble {
  background: var(--rpg-gold-dim);
  border: 1px solid rgba(201,168,76,.4);
}
.rpg-login-link {
  display: inline-block;
  margin-top: .4rem;
  color: var(--rpg-gold);
  font-weight: 700;
  text-decoration: underline;
}
.rpg-login-link:hover { color: var(--rpg-text); }

/* Narrative bubble paragraphs */
.msg-bubble p {
  margin: 0 0 .5rem;
  line-height: 1.7;
}
.msg-bubble p:last-child { margin-bottom: 0; }

/* Choice buttons */
.choice-wrap {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-top: .75rem;
  max-width: 78%;
}
.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .55rem .8rem;
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all .18s;
  width: 100%;
  color: var(--rpg-text);
  font-family: 'IM Fell English', Georgia, serif;
  font-size: .88rem;
  line-height: 1.45;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--rpg-gold);
  background: var(--rpg-gold-dim);
  transform: translateX(3px);
}
.choice-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.choice-btn--chosen {
  border-color: var(--rpg-gold) !important;
  background: rgba(201,168,76,.18) !important;
  opacity: 1 !important;
}
.choice-icon {
  font-size: 1rem;
  line-height: 1.4;
  min-width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}
.choice-text { flex: 1; }

/* Quest tracker block */
.quest-block {
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  padding: .65rem .75rem;
}
.quest-note {
  font-size: .76rem;
  color: var(--rpg-text);
  font-style: italic;
  line-height: 1.5;
  margin-top: .35rem;
  min-height: 1.2rem;
}

/* Dice roll highlights */
.dice-roll {
  display: inline-block;
  background: rgba(201,168,76,.2);
  border: 1px solid rgba(201,168,76,.4);
  color: var(--rpg-gold);
  padding: .05rem .35rem;
  border-radius: 4px;
  font-style: normal;
  font-size: .88em;
}

/* Loading dots */
.loading-dots span {
  animation: blink 1.2s infinite;
  opacity: 0;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* Action bar */
.action-bar {
  border-top: 1px solid var(--rpg-border);
  padding: .75rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .4rem;
  background: var(--rpg-surface);
}
.action-input-row {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
}
.action-input {
  flex: 1;
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 6px;
  color: var(--rpg-text);
  padding: .6rem .8rem;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: .92rem;
  resize: none;
  line-height: 1.4;
}
.action-input:focus { outline: none; border-color: var(--rpg-gold); }
.action-input::placeholder { color: var(--rpg-muted); font-style: italic; }

#game-error { padding: .25rem 1rem .5rem; }

/* ================================================================
   STORY TYPE SELECTOR
   ================================================================ */
.story-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .6rem;
}
.story-card { cursor: pointer; }
.story-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  pointer-events: none;
}
.story-card input:focus-visible ~ .story-inner {
  outline: 2px solid var(--rpg-gold);
  outline-offset: 2px;
}
.story-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .75rem .5rem;
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  background: var(--rpg-bg);
  transition: all .2s;
  text-align: center;
}
.story-card input:checked ~ .story-inner {
  border-color: var(--rpg-gold);
  background: var(--rpg-gold-dim);
}
.story-inner:hover { border-color: rgba(201,168,76,.5); }
.story-icon { font-size: 1.4rem; }
.story-name {
  font-family: 'Cinzel', serif;
  font-size: .75rem;
  font-weight: 600;
  color: var(--rpg-gold);
}
.story-desc {
  font-size: .65rem;
  color: var(--rpg-muted);
  font-style: italic;
  line-height: 1.3;
}

/* ================================================================
   PROFILE CARDS (character + companion)
   ================================================================ */
.profile-card {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 10px;
  padding: .75rem;
}
.companion-card {
  border-color: rgba(160,140,100,.25);
  opacity: .92;
}
.portrait-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
}
.profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.char-portrait-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--rpg-gold);
  object-fit: cover;
  background: var(--rpg-gold-dim);
  display: block;
}
.companion-portrait-img { border-color: var(--rpg-muted); width: 48px; height: 48px; }
.portrait-label {
  font-family: 'Cinzel', serif;
  font-size: .75rem;
  font-weight: 600;
  color: var(--rpg-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.companion-label { color: var(--rpg-muted); font-size: .7rem; }
.companion-class { font-size: .68rem; }

/* Companion HP bar */
.stat-fill--companion { background: linear-gradient(90deg, #2a5a22, #4abf36); }

/* Turn counter */
.turn-block {
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  padding: .5rem .75rem;
}
.turn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .35rem;
}
.turn-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--rpg-muted);
  font-family: 'Cinzel', serif;
}
.turn-value {
  font-size: .72rem;
  font-family: 'Cinzel', serif;
  color: var(--rpg-gold);
  font-weight: 600;
}
.turn-bar-bg {
  height: 5px;
  background: rgba(255,255,255,.08);
  border-radius: 3px;
  overflow: hidden;
}
.turn-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--rpg-gold-dim), var(--rpg-gold));
  border-radius: 3px;
  transition: width .4s ease;
}

/* ================================================================
   DICE PANEL
   ================================================================ */
.dice-panel {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem 0;
  flex-wrap: wrap;
}
.dice-label {
  font-family: 'Cinzel', serif;
  font-size: .68rem;
  color: var(--rpg-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-right: .1rem;
}
.dice-btn {
  font-family: 'Cinzel', serif;
  font-size: .72rem;
  font-weight: 700;
  padding: .22rem .48rem;
  border: 1px solid var(--rpg-border);
  border-radius: 4px;
  background: var(--rpg-bg);
  color: var(--rpg-gold);
  cursor: pointer;
  transition: all .15s;
  letter-spacing: .04em;
}
.dice-btn:hover {
  border-color: var(--rpg-gold);
  background: var(--rpg-gold-dim);
}
.dice-btn:active { transform: scale(.92); }
.dice-result {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rpg-gold);
  min-width: 2.2rem;
  text-align: center;
  transition: color .1s;
}
.dice-result--rolling { color: var(--rpg-muted); }
.dice-result--settled {
  color: #fff;
  text-shadow: 0 0 8px var(--rpg-gold);
}

/* ================================================================
   TERMINAL OVERLAYS (defeat / victory)
   ================================================================ */
.terminal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
.terminal-overlay--defeat  { background: rgba(10,5,5,.9); }
.terminal-overlay--victory { background: rgba(5,10,5,.9); }
.terminal-card {
  background: var(--rpg-surface);
  border: 1px solid var(--rpg-border);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 0 80px rgba(201,168,76,.1);
}
.terminal-icon { font-size: 3.5rem; line-height: 1; }
.terminal-title {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--rpg-gold);
}
.terminal-sub {
  font-size: .9rem;
  color: var(--rpg-muted);
  font-style: italic;
  line-height: 1.5;
}
.terminal-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  background: var(--rpg-bg);
  border: 1px solid var(--rpg-border);
  border-radius: 8px;
  padding: .75rem;
}
.ts-item {
  font-family: 'Cinzel', serif;
  font-size: .75rem;
  color: var(--rpg-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}
.ts-item strong {
  color: var(--rpg-gold);
  font-size: 1.15rem;
}

/* ================================================================
   SCENE ATMOSPHERE — full-screen background gradients
   ================================================================ */

/* Make panels semi-transparent so the background shows through */
.game-sidebar {
  background: rgba(12, 12, 18, 0.82) !important;
  backdrop-filter: blur(2px);
}
.action-bar {
  background: rgba(12, 12, 18, 0.88) !important;
  backdrop-filter: blur(2px);
}

/* Base transition on the game screen */
#game-screen {
  transition: background 1.4s ease;
}

/* Default / dungeon — cold underground stone, deep violet torch glow from below */
#game-screen,
#game-screen[data-scene="dungeon"] {
  background:
    radial-gradient(ellipse at 50% 110%, #3a1800 0%, #1a0830 35%, #08060f 75%);
}

/* Forest — silver-green moonlight through a dark canopy */
#game-screen[data-scene="forest"] {
  background:
    radial-gradient(ellipse at 30% -5%, #052210 0%, #031508 45%, #020a04 100%);
}

/* Meadow — open night sky, cool green ground glow, firefly warmth */
#game-screen[data-scene="meadow"] {
  background:
    radial-gradient(ellipse at 55% 0%, #0c1e04 0%, #071204 45%, #040a02 100%);
}

/* Village / town — warm amber lantern glow to the right */
#game-screen[data-scene="village"] {
  background:
    radial-gradient(ellipse at 68% 38%, #281604 0%, #160a02 45%, #0a0601 100%);
}

/* Castle — cold blue-grey stone, moonlight from high above */
#game-screen[data-scene="castle"] {
  background:
    radial-gradient(ellipse at 50% -8%, #0a1628 0%, #060d1a 42%, #030609 100%);
}

/* Combat — fiery orange-red from the right, blood on stone */
#game-screen[data-scene="combat"] {
  background:
    radial-gradient(ellipse at 78% 48%, #2e0606 0%, #180303 42%, #0a0202 100%);
}

/* Victory — warm golden radiance from the centre */
#game-screen[data-scene="victory"] {
  background:
    radial-gradient(ellipse at 50% 55%, #201900 0%, #120e00 45%, #080600 100%);
}

/* Defeat — grim dark crimson, near-black */
#game-screen[data-scene="defeat"] {
  background:
    radial-gradient(ellipse at 50% 50%, #1c0202 0%, #0e0101 55%, #070101 100%);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 680px) {
  .form-row { grid-template-columns: 1fr; }
  .class-grid { grid-template-columns: repeat(4, 1fr); }
  .race-grid  { grid-template-columns: repeat(4, 1fr); }
  .story-grid { grid-template-columns: 1fr 1fr; }
  .class-desc, .story-desc { display: none; }
  .creation-card { padding: 1.5rem 1rem; }

  /* Shrink the banner and cap the sidebar so the story log keeps real height
     (was collapsing to a ~57px sliver at 375px). */
  .scene-banner { height: 120px; }
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 120px);
  }
  .game-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .75rem;
    border-right: none;
    border-bottom: 1px solid var(--rpg-border);
    max-height: 34vh;
    overflow-y: auto;
  }
  .portraits-row { gap: .5rem; }
  .char-portrait-img { width: 40px; height: 40px; }
  .portrait-label { font-size: .6rem; max-width: 44px; }
  .inventory-block { display: none; }
  .stat-block { flex: 1; min-width: 180px; }
  /* 40px minimum tap target for dice on touch screens. */
  .dice-btn { min-height: 40px; padding: .35rem .7rem; font-size: .8rem; }
}
