:root {
  --bg: #0f0d1a;
  --bg-2: #181527;
  --card: #1f1b31;
  --card-2: #2a2440;
  --border: #35304d;
  --text: #f3eeff;
  --muted: #a79fc6;
  --accent: #e9b54d;
  --accent-2: #f8d283;
  --accent-glow: rgba(233,181,77,.35);
  --danger: #e0565b;
  --ok: #58c88a;
  --radius: 16px;
  --shadow: 0 14px 40px rgba(0,0,0,.45);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --display: "Cinzel", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(94,64,160,.45) 0%, transparent 60%),
    radial-gradient(700px 400px at 95% 10%, rgba(233,181,77,.12) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}
/* faint star field */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 20%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 65%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 45%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 10%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 90%, #fff 50%, transparent 51%);
  background-size: 900px 700px;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .2px; margin: 0 0 .35em; line-height: 1.15; }
h1 { font-size: 2.6rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1.4rem;
  background: rgba(15,13,26,.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--display); font-size: 1.15rem; letter-spacing: .06em; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent-2); }
.topbar nav { display: flex; gap: 1.1rem; align-items: center; }
.nav-link { color: var(--muted); font-weight: 500; }
.nav-link:hover { color: var(--text); text-decoration: none; }

/* Layout */
main { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 2rem 1.25rem 5rem; animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.subtitle { color: var(--muted); margin: 0; font-size: 1.05rem; }
.eyebrow { font-family: var(--display); font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); margin-bottom: .4rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .65rem 1.2rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:hover { background: #352e50; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; color: #2a1f05; box-shadow: 0 6px 18px var(--accent-glow); }
.btn-primary:hover { background: linear-gradient(135deg, #ffe0a0, var(--accent-2)); box-shadow: 0 8px 24px var(--accent-glow); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(224,86,91,.4); }
.btn-danger:hover { background: rgba(224,86,91,.12); }
.btn-sm { padding: .45rem .9rem; font-size: .9rem; }
.btn-lg { padding: .9rem 1.6rem; font-size: 1.05rem; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.grid { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

.world-card { transition: transform .15s, box-shadow .15s, border-color .15s; }
.world-card:hover { transform: translateY(-3px); border-color: rgba(233,181,77,.5); box-shadow: 0 18px 44px rgba(0,0,0,.55), 0 0 0 1px rgba(233,181,77,.15); }
.world-card .banner { height: 110px; display: flex; align-items: end; padding: .7rem 1rem; position: relative; }
.world-card .banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.35), transparent 60%); }
.world-card .icon { font-size: 2.4rem; position: relative; z-index: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.world-card .body { padding: 1rem 1.1rem 1.1rem; }
.world-card h3 { margin-bottom: .25rem; }
.world-card .desc { color: var(--muted); font-size: .95rem; margin-bottom: 1rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chip { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 600; letter-spacing: .02em;
  background: rgba(233,181,77,.14); color: var(--accent-2); border: 1px solid rgba(233,181,77,.3); margin-right: .4rem; }

.new-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 240px; border: 2px dashed var(--border); background: transparent; color: var(--muted);
  cursor: pointer; text-align: center; padding: 1rem; box-shadow: none; transition: border-color .15s, color .15s, background .15s;
}
.new-card:hover { border-color: var(--accent); color: var(--accent-2); background: rgba(233,181,77,.05); text-decoration: none; }
.new-card .plus { font-size: 2.8rem; line-height: 1; margin-bottom: .3rem; }

.empty { text-align: center; color: var(--muted); padding: 4rem 1rem; }
.empty .big { font-size: 3.5rem; margin-bottom: .5rem; }

/* Forms */
.form-section { padding: 1.4rem 1.6rem; margin-bottom: 1.2rem; }
.form-section h2 { display: flex; align-items: center; gap: .7rem; }
.form-section .step {
  display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #2a1f05;
  font: 700 .9rem var(--sans); box-shadow: 0 4px 12px var(--accent-glow);
}
.form-section .hint { color: var(--muted); margin: -.2rem 0 1.1rem; font-size: .95rem; }
.optional { font-size: .78rem; color: var(--muted); font-weight: 500; font-family: var(--sans); letter-spacing: .04em; text-transform: uppercase; margin-left: .3rem; }
label { display: block; font-weight: 600; margin: 1rem 0 .4rem; }
label:first-of-type { margin-top: 0; }
input[type=text], textarea, select {
  width: 100%; padding: .75rem .9rem; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #6f6890; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea { min-height: 110px; resize: vertical; }
textarea.tall { min-height: 170px; }
.field-hint { color: var(--muted); font-size: .85rem; margin-top: .35rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

.picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.picker .opt {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  font-size: 1.55rem; border-radius: 12px; border: 2px solid var(--border); background: var(--bg-2); cursor: pointer;
  transition: transform .1s, border-color .15s, background .15s;
}
.picker .opt:hover { border-color: var(--muted); transform: scale(1.08); }
.picker .opt.selected { border-color: var(--accent); background: rgba(233,181,77,.15); box-shadow: 0 0 0 3px var(--accent-glow); }
.picker.banners .opt { width: 104px; height: 58px; font-size: .78rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); font-weight: 600; letter-spacing: .03em; }

.preview { display: flex; align-items: center; gap: .9rem; margin-top: 1.2rem; padding: 1rem 1.2rem; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); }
.preview .icon { font-size: 2.2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.preview .name { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.preview .small { font-size: .8rem; color: rgba(255,255,255,.8); text-shadow: 0 1px 3px rgba(0,0,0,.6); }

.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .6rem; }

/* World hero used on character + play screens */
.world-hero { padding: 1.8rem 1.8rem; margin-bottom: 1.4rem; display: flex; gap: 1.2rem; align-items: center; position: relative; }
.world-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to right, rgba(0,0,0,.35), transparent 70%); pointer-events: none; }
.world-hero > * { position: relative; z-index: 1; }
.world-hero .icon { font-size: 3.4rem; filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.world-hero h1 { margin: 0; text-shadow: 0 2px 8px rgba(0,0,0,.6); font-size: 2.3rem; }
.world-hero .meta { color: rgba(255,255,255,.88); text-shadow: 0 1px 3px rgba(0,0,0,.6); font-size: .95rem; }

/* Characters */
.char-card { padding: 1.1rem 1.2rem; cursor: pointer; border: 2px solid var(--border); transition: border-color .15s, transform .12s, box-shadow .15s; }
.char-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 18px 44px rgba(0,0,0,.55), 0 0 0 3px var(--accent-glow); }
.char-card .head { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.char-card .avatar { font-size: 2.2rem; width: 58px; height: 58px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--card-2), var(--bg-2)); border-radius: 14px; border: 1px solid var(--border); }
.char-card .role { color: var(--muted); font-size: .9rem; }
.char-card .bio { color: var(--muted); font-size: .95rem; margin-bottom: .7rem; }
.traits { display: flex; flex-wrap: wrap; gap: .35rem; }
.trait { font-size: .75rem; padding: .12rem .6rem; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); color: var(--text); }
.section-label { font-family: var(--display); color: var(--muted); text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; margin: 1.8rem 0 .9rem; display: flex; align-items: center; gap: .8rem; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.char-card .tools { display: flex; justify-content: flex-end; margin-top: .7rem; }
.char-card.mine { border-style: solid; border-color: rgba(88,200,138,.35); }

/* Play screen */
.play-layout { display: grid; grid-template-columns: 1fr 230px; gap: 1.3rem; }
@media (max-width: 820px) { .play-layout { grid-template-columns: 1fr; } }
.story { padding: 1.4rem 1.6rem; min-height: 380px; display: flex; flex-direction: column; }
.story .log { flex: 1; }
.story .gm { font-family: var(--serif); font-size: 1.22rem; line-height: 1.7; }
.story .gm .who { color: var(--accent); font-family: var(--display); font-size: .7rem; text-transform: uppercase; letter-spacing: .2em; display: block; margin-bottom: .3rem; }
.story .notice { background: rgba(233,181,77,.08); border: 1px dashed rgba(233,181,77,.4); border-radius: 12px; padding: .9rem 1.1rem; color: var(--accent-2); font-size: .95rem; margin-top: 1.2rem; }
.story form { display: flex; gap: .6rem; margin-top: 1.2rem; }
.story form input { flex: 1; }
.side .card { padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.side h3 { margin-bottom: .5rem; }
.side .muted { color: var(--muted); font-size: .95rem; }
.notes-box { white-space: pre-wrap; }
.side .char-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.side .char-head .avatar { font-size: 2rem; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.toggle-row .label { font-weight: 600; }
.toggle-row .sub { color: var(--muted); font-size: .9rem; }
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); transition: background .2s, border-color .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + .track { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; box-shadow: 0 0 0 3px var(--accent-glow); }
.switch input:checked + .track::after { transform: translateX(22px); background: #2a1f05; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mystery editor */
.mystery-list { margin-top: 1.1rem; display: grid; gap: .9rem; }
.mystery { padding: 1rem 1.1rem; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); animation: fadeUp .25s ease both; }
.mystery .mhead { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .2rem; }
.mystery .mhead .num { font-family: var(--display); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.mystery label { margin-top: .7rem; font-size: .92rem; }
.mystery textarea { min-height: 70px; }
.mystery-empty { color: var(--muted); font-style: italic; margin-top: 1rem; }
.hidden { display: none !important; }

/* Mysteries on the play screen */
.mystery-item { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--border); }
.mystery-item:first-of-type { border-top: 0; }
.mystery-item .q { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--card-2); border: 1px solid var(--border); color: var(--accent-2); font-size: .85rem; font-weight: 700; }
.mystery-item .status { margin-left: auto; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* Adventure (session) cards */
.session-card { display: flex; gap: .9rem; padding: 1rem 1.1rem; align-items: center; transition: transform .15s, border-color .15s; }
.session-card:hover { transform: translateY(-2px); border-color: rgba(233,181,77,.5); }
.session-card .thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 2rem; position: relative; }
.session-card .thumb .av { position: absolute; right: -8px; bottom: -8px; font-size: 1.3rem; background: var(--card); border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); }
.session-card .info { flex: 1; min-width: 0; }
.session-card h3 { margin: 0 0 .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-card .sub { color: var(--muted); font-size: .9rem; }
.session-card .actions { flex-shrink: 0; }
.list { display: grid; gap: .9rem; }
.pill-ok { color: var(--ok); font-weight: 600; }

/* Story log */
.story .log { display: flex; flex-direction: column; gap: 1.1rem; max-height: 60vh; overflow-y: auto; padding-right: .4rem; scroll-behavior: smooth; }
.story .turn { animation: fadeUp .25s ease both; }
.story .turn.player { align-self: flex-end; max-width: 85%; background: var(--card-2); border: 1px solid var(--border); border-radius: 14px 14px 4px 14px; padding: .7rem 1rem; }
.story .turn.player .who { color: var(--ok); font-family: var(--display); font-size: .7rem; text-transform: uppercase; letter-spacing: .2em; display: block; margin-bottom: .2rem; }
.story .turn.player .text { font-size: 1rem; }
.story .turn.gm { font-family: var(--serif); font-size: 1.22rem; line-height: 1.7; }
.story .turn.gm .who { color: var(--accent); font-family: var(--display); font-size: .7rem; text-transform: uppercase; letter-spacing: .2em; display: block; margin-bottom: .3rem; }
.story .turn.system { text-align: center; color: var(--muted); font-size: .85rem; font-style: italic; }
.saved { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.saved .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.story-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; gap: .8rem; flex-wrap: wrap; }
.finished-banner { background: rgba(88,200,138,.1); border: 1px solid rgba(88,200,138,.35); border-radius: 12px; padding: .9rem 1.1rem; margin-top: 1.2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.side .stack { display: grid; gap: .5rem; }
.side .stack .btn { justify-content: center; }

/* Quick actions under the story input */
.quick { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .8rem; }
.quick .chip-btn { padding: .45rem .85rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; transition: background .15s, border-color .15s, transform .08s; }
.quick .chip-btn:hover { border-color: var(--accent); background: rgba(233,181,77,.1); }
.quick .chip-btn:active { transform: translateY(1px); }
.src-tag { display: inline-block; margin-left: .5rem; font-family: var(--sans); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.src-tag.ai { border-color: rgba(233,181,77,.5); color: var(--accent-2); }
.story .turn.gm.ai-needed { opacity: .85; }
.side .kv { display: flex; justify-content: space-between; gap: .6rem; font-size: .9rem; padding: .25rem 0; border-top: 1px solid var(--border); }
.side .kv:first-of-type { border-top: 0; }
.side .kv .v { color: var(--text); text-align: right; }
.side ul.plain { list-style: none; margin: 0; padding: 0; }
.side ul.plain li { padding: .25rem 0; border-top: 1px solid var(--border); font-size: .92rem; }
.side ul.plain li:first-child { border-top: 0; }
.mystery-item .status.solved { color: var(--ok); }
@media (max-width: 640px) {
  main { padding: 1.2rem .9rem 4rem; }
  h1 { font-size: 2rem; }
  .world-hero { padding: 1.2rem; }
  .world-hero .icon { font-size: 2.4rem; }
  .story { padding: 1rem; }
  .story .log { max-height: 50vh; }
  .story .turn.gm { font-size: 1.1rem; }
  .story form input { font-size: 16px; } /* stops iOS zooming on focus */
  .topbar { padding: .6rem .9rem; }
  .brand { font-size: .95rem; }
}
@media (max-width: 640px) {
  .topbar { gap: .5rem; }
  .brand { white-space: nowrap; font-size: .85rem; letter-spacing: .03em; }
  .topbar nav { gap: .6rem; }
  .nav-link { white-space: nowrap; font-size: .9rem; }
  .topbar .btn-sm { white-space: nowrap; padding: .4rem .7rem; font-size: .85rem; }
  .play-layout { gap: 1rem; }
  .quick .chip-btn { font-size: .85rem; padding: .5rem .8rem; }
}

/* Profiles */
.profiles { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); max-width: 900px; margin: 0 auto; }
.profile-card { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2rem 1rem 1.6rem; cursor: pointer; border: 2px solid var(--border); text-align: center; transition: transform .15s, border-color .15s, box-shadow .15s; position: relative; overflow: hidden; }
.profile-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 70px; opacity: .85; background: var(--pc); }
.profile-card > * { position: relative; }
.profile-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 18px 44px rgba(0,0,0,.55), 0 0 0 3px var(--accent-glow); }
.profile-card .big-avatar { font-size: 3.2rem; width: 92px; height: 92px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--card); border: 3px solid var(--card-2); box-shadow: 0 6px 18px rgba(0,0,0,.4); margin-top: .4rem; }
.profile-card h3 { margin: .2rem 0 0; font-size: 1.5rem; }
.profile-card .muted { font-size: .85rem; }
.profile-card.loading { opacity: .6; pointer-events: none; }
.center { text-align: center; }

/* Profile chip + sync status in the top bar */
.who-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .7rem .3rem .4rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: .9rem; font-weight: 600; }
.who-chip:hover { border-color: var(--accent); text-decoration: none; }
.who-chip .av { font-size: 1.1rem; }
.sync { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sync.saved .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.sync.saving .dot { background: var(--accent); animation: pulse 1s infinite; }
.sync.offline .dot { background: var(--muted); }
.sync.error .dot { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (max-width: 640px) {
  .sync { display: none; }
  .who-chip .name { display: none; }
  .profile-card { padding: 1.4rem 1rem 1.2rem; }
}

[hidden] { display: none !important; }

/* Sample buttons on forms */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin: 1rem 0 .4rem; }
.label-row label { margin: 0; }
.label-row:first-of-type { margin-top: 0; }
.sample-btn { font-size: .75rem; padding: .25rem .65rem; border-radius: 999px; border: 1px dashed var(--border); background: transparent; color: var(--muted); font-family: var(--sans); font-weight: 600; cursor: pointer; letter-spacing: .04em; white-space: nowrap; }
.sample-btn:hover { border-color: var(--accent); color: var(--accent-2); background: rgba(233,181,77,.08); }

/* Version number, top bar menu */
.ver { font-size: .62rem; color: var(--muted); opacity: .7; margin-left: .5rem; letter-spacing: .05em; align-self: flex-end; padding-bottom: .15rem; }
.topbar .left { display: flex; align-items: baseline; }
.menu-wrap { position: relative; }
.who-chip { cursor: pointer; }
.menu { position: absolute; right: 0; top: calc(100% + .5rem); min-width: 180px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: .4rem; z-index: 20; animation: fadeUp .15s ease both; }
.menu a, .menu button { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; padding: .6rem .8rem; border-radius: 8px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .95rem; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--card-2); text-decoration: none; }
.menu .sep { height: 1px; background: var(--border); margin: .3rem .4rem; }

/* Preferences */
.pref-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem; padding: 1rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pref-row:first-of-type { border-top: 0; padding-top: 0; }
.pref-row .about { max-width: 420px; }
.pref-row .about .muted { font-size: .9rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--bg-2); }
.seg button { padding: .5rem 1rem; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #2a1f05; }
.pref-preview { margin-top: 1rem; padding: 1rem 1.2rem; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); font-family: var(--serif); font-size: 1.1rem; line-height: 1.6; }

/* Reading modes for the story log */
.story .turn.gm p { margin: 0; }
.story.screenplay .turn.gm p + p { margin-top: .9em; }
.story.novel .turn.gm p + p { text-indent: 1.4em; }
.story.novel .log { gap: .7rem; }
.story.novel .turn.gm .who { margin-bottom: .1rem; }
.story.novel .turn.player { margin: .2rem 0; padding: .45rem .9rem; }
.story.large .turn.gm { font-size: 1.4rem; line-height: 1.75; }
.story.large .turn.player .text { font-size: 1.1rem; }
@media (max-width: 640px) { .ver { display: none; } .story.large .turn.gm { font-size: 1.25rem; } }

/* Keep the top bar on one line */
.brand, .nav-link, .topbar .btn, .who-chip, .sync { white-space: nowrap; }
.topbar nav { flex-wrap: nowrap; }
@media (max-width: 900px) { .topbar .nav-link { display: none; } .sync { display: none; } .ver { display: none; } }

/* Update toast */
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 50; background: var(--card); border: 1px solid rgba(233,181,77,.5); color: var(--text); padding: .7rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow); font-size: .9rem; display: flex; align-items: center; gap: .8rem; animation: fadeUp .25s ease both; max-width: calc(100% - 2rem); }
.toast .btn { padding: .35rem .8rem; font-size: .85rem; }

/* Access gate */
.gate { max-width: 420px; margin: 3rem auto; text-align: center; padding: 2rem 1.6rem; }
.gate input { text-align: center; font-size: 1.8rem; letter-spacing: .5em; padding: .8rem; font-family: var(--sans); }
.gate .err { color: var(--danger); margin-top: .8rem; min-height: 1.4em; font-size: .95rem; }

/* Text arrival animations */
.story .turn.gm span.w { opacity: 0; transition: opacity .45s ease; display: inline; }
.story .turn.gm span.w.on { opacity: 1; }
.story .turn.gm p.fade-p { opacity: 0; transition: opacity .7s ease; }
.story .turn.gm p.fade-p.on { opacity: 1; }
.speed { margin-top: .9rem; }
.speed label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin: 0 0 .3rem; font-weight: 500; }
.speed input[type=range] { width: 100%; accent-color: var(--accent); }
.story .turn.gm.arriving { cursor: pointer; }

/* Power moment card (superhero worlds) */
.power-card { margin-top: 1rem; padding: 1.1rem 1.2rem; border-radius: 12px; border: 1px solid rgba(233,181,77,.5); background: rgba(233,181,77,.07); animation: fadeUp .3s ease both; }
.power-card h3 { margin: 0 0 .2rem; }
.power-card .muted { font-size: .92rem; margin-bottom: .8rem; }
.power-card label { margin: .6rem 0 .3rem; font-size: .92rem; }
.power-card .actions { margin-top: .9rem; }

/* Compact speed control under the entry box */
.speed-mini { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; }
.speed-mini input[type=range] { width: 110px; accent-color: var(--accent); }
.finished-banner .actions { gap: .5rem; }
