/* =============================================================================
 * styles.css — Realmbound: Encounters
 * Dark-fantasy, mobile-first, readability over decoration.
 * Brand fonts: Cinzel (display) + IM Fell English (body).
 * Tweak the variables in :root to re-skin the whole game.
 * ===========================================================================*/

:root {
  /* palette */
  --bg-0: #14110f;          /* deepest */
  --bg-1: #1d1a17;          /* panel */
  --bg-2: #2a2521;          /* raised */
  --ink: #ece3d4;           /* primary text (warm parchment) */
  --ink-dim: #b3a892;       /* secondary text */
  --ink-faint: #7c7361;     /* tertiary */
  --gold: #d9a441;          /* primary accent */
  --gold-deep: #a87a26;
  --blood: #b5482f;         /* danger / lives */
  --line: #3a332b;          /* hairlines */

  /* rarity (mirrors data.js TIERS) */
  --rar-basic: #9aa0a6;
  --rar-fine: #4caf7d;
  --rar-rare: #4a90d9;
  --rar-epic: #a566d4;
  --rar-legendary: #d9a441;

  /* type */
  --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --font-body: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --font-mono: 'Courier New', Courier, monospace;

  /* scale (overridden by settings -> font scaling) */
  --fs: 1;
  --radius: 10px;
  --maxw: 480px;
  --tap: 52px;              /* min tap target */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(18px * var(--fs));
  line-height: 1.5;
  min-height: 100%;
}

/* Atmospheric backdrop: layered radial glows + a faint vignette. */
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(217,164,65,0.08), transparent 60%),
    radial-gradient(800px 500px at 90% 110%, rgba(74,144,217,0.06), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---- typography --------------------------------------------------------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em; margin: 0; }
.title-xl { font-size: calc(2.1rem * var(--fs)); color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 24px rgba(217,164,65,0.25); }
.title-sm { font-size: calc(1.15rem * var(--fs)); color: var(--gold); }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.tiny { font-size: calc(0.8rem * var(--fs)); }
.center { text-align: center; }

/* ---- layout regions ----------------------------------------------------- */
.screen { flex: 1; display: flex; flex-direction: column; padding: 16px; gap: 14px; }
.screen.center-screen { justify-content: center; align-items: center; text-align: center; }
.spacer { flex: 1; }

.panel {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.panel + .panel { margin-top: 0; }

/* ---- buttons ------------------------------------------------------------ */
button {
  font-family: var(--font-body);
  font-size: calc(1rem * var(--fs));
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-2), #221e1a);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: var(--tap);
  padding: 12px 16px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
button:hover { border-color: var(--gold-deep); }
button:active { transform: scale(0.985); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  text-align: center;
  font-family: var(--font-display);
  color: #1a1510;
  background: linear-gradient(180deg, #e6b85a, var(--gold-deep));
  border-color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.03em;
}
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; }
button.danger { color: #f3c9bf; border-color: var(--blood); }
button.danger:hover { background: rgba(181,72,47,0.15); }

.choice .cost { float: right; color: var(--gold); font-family: var(--font-mono); font-size: 0.85em; }
.choice.universal { border-style: dashed; color: var(--ink-dim); }

.btn-row { display: flex; gap: 10px; }
.btn-row > button { flex: 1; }

/* ---- HUD (gameplay header) --------------------------------------------- */
.hud { background: linear-gradient(180deg, var(--bg-1), var(--bg-0)); border-bottom: 1px solid var(--line); padding: 12px 16px; }
.hud .who { font-family: var(--font-display); color: var(--gold); font-size: calc(1.05rem * var(--fs)); }
.hud .sub { color: var(--ink-dim); font-size: 0.85em; }
.stats { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.stat { display: flex; align-items: baseline; gap: 5px; font-size: 0.9em; }
.stat b { font-family: var(--font-mono); color: var(--ink); }
.stat.lives b { color: var(--blood); }
.stat.grains b { color: var(--gold); }
.stat.mana b { color: var(--rar-rare); }

/* hearts / pips */
.pips { letter-spacing: 2px; }
.pip-on { color: var(--gold); }
.pip-off { color: var(--ink-faint); }

/* ---- scenario body ------------------------------------------------------ */
.scenario-text { font-size: calc(1.12rem * var(--fs)); line-height: 1.6; }
.scenario-title { color: var(--gold); margin-bottom: 6px; }
.choices { display: flex; flex-direction: column; gap: 10px; }

/* ---- result panel ------------------------------------------------------- */
.result .verdict { font-family: var(--font-display); font-size: calc(1.4rem * var(--fs)); text-align: center; }
.verdict.success { color: var(--rar-fine); }
.verdict.failure { color: var(--blood); }
.verdict.mana { color: var(--rar-rare); }
.roll-line { text-align: center; color: var(--ink-dim); font-family: var(--font-mono); font-size: 0.85em; }
.outcomes { list-style: none; padding: 0; margin: 10px 0 0; }
.outcomes li { padding: 6px 0; border-top: 1px solid var(--line); }
.levelup { text-align:center; color: var(--gold); font-family: var(--font-display); }

/* ---- bottom nav --------------------------------------------------------- */
.nav { display: flex; gap: 8px; padding: 10px 16px 16px; }
.nav button { text-align: center; font-size: 0.85em; min-height: 46px; padding: 8px; }

/* ---- character / party sheets ------------------------------------------ */
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-dim); }
.attr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.attr-grid .kv { border-bottom: 1px dotted var(--line); }
.equip-line { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px dotted var(--line); }
.equip-line .nm { font-weight: 600; }
.equip-line .bonus { font-family: var(--font-mono); color: var(--ink-dim); }
.tier-badge { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.08em; padding: 1px 6px; border-radius: 4px; border: 1px solid currentColor; }
.t-Basic { color: var(--rar-basic); }
.t-Fine { color: var(--rar-fine); }
.t-Rare { color: var(--rar-rare); }
.t-Epic { color: var(--rar-epic); }
.t-Legendary { color: var(--rar-legendary); text-shadow: 0 0 8px rgba(217,164,65,0.4); }

.morale-pips .pip-on { color: var(--rar-fine); }
.member { margin-bottom: 10px; }
.member .hd { display: flex; justify-content: space-between; align-items: baseline; }

.section-label { font-family: var(--font-display); color: var(--gold); font-size: 0.95rem; margin: 4px 0; letter-spacing: 0.05em; }

/* ---- character select --------------------------------------------------- */
.select-card { text-align: center; }
.select-card .name { font-family: var(--font-display); font-size: calc(1.6rem * var(--fs)); color: var(--gold); }
.tags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.tag { font-size: 0.78em; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-dim); }

/* ---- settings ----------------------------------------------------------- */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dotted var(--line); }
.setting label { color: var(--ink); }
.seg { display: flex; gap: 6px; }
.seg button { width: auto; min-width: 44px; min-height: 40px; padding: 6px 10px; text-align: center; }
.seg button.on { border-color: var(--gold); color: var(--gold); }
.toggle { width: 56px; min-width: 56px; min-height: 32px; border-radius: 999px; position: relative; padding: 0; }
.toggle.on { background: var(--gold-deep); border-color: var(--gold); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); transition: left .15s ease; }
.toggle.on .knob { left: 29px; background: #1a1510; }

/* ---- GAME OVER : Blue Screen of Death parody --------------------------- */
.bsod {
  background: #1144cc;
  color: #ffffff;
  font-family: var(--font-mono);
  min-height: 100vh; min-height: 100dvh;
  padding: 28px 22px;
  display: flex; flex-direction: column; gap: 18px;
  justify-content: center;
}
.bsod .face { font-size: 3rem; }
.bsod h2 { font-family: var(--font-mono); font-weight: bold; font-size: 1.3rem; }
.bsod p, .bsod li { font-size: 0.95rem; line-height: 1.5; }
.bsod .summary { background: rgba(255,255,255,0.1); padding: 12px; border-radius: 4px; }
.bsod .summary .row { display: flex; justify-content: space-between; padding: 3px 0; }
.bsod button.primary { background: #fff; color: #1144cc; border-color:#fff; font-family: var(--font-mono); }
.bsod .blink { animation: blink 1.1s steps(2,start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---- entrance animation (respect reduced motion) ----------------------- */
.fade-in { animation: fadeIn .28s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.reduce-motion .fade-in, .reduce-motion .blink { animation: none !important; }

/* ---- high contrast ------------------------------------------------------ */
.high-contrast {
  --bg-0:#000; --bg-1:#0a0a0a; --bg-2:#141414; --ink:#fff; --ink-dim:#ddd; --line:#777;
}

/* small screens */
@media (max-height: 640px) { .screen { gap: 10px; padding: 12px; } }
