* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0807;
  font-family: "Georgia", "Palatino Linotype", "Book Antiqua", serif;
  color: #e6dac6;
  user-select: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ---------------- DARK DUNGEON HUD ---------------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(180deg, rgba(24, 19, 16, 0.94), rgba(14, 11, 9, 0.94));
  border: 2px solid #5c4938;
  outline: 1px solid #241b14;
  padding: 8px 20px;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.85), inset 0 0 14px rgba(216, 139, 50, 0.12);
}

#stage-badge {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #e6b86a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

#progress-track {
  position: relative;
  width: 240px;
  height: 10px;
  background: #14100d;
  border: 1px solid #6b5540;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7a1c1c, #c86428, #e6a844);
}

#progress-rika {
  position: absolute;
  top: -4px;
  left: 0%;
  width: 8px;
  height: 16px;
  background: #f0c878;
  border: 1px solid #3a2818;
  box-shadow: 0 0 8px rgba(240, 200, 120, 0.7);
  transform: translateX(-50%);
}

.skull-icon {
  position: absolute;
  right: -56px;
  top: -3px;
  font-size: 10px;
  font-weight: 800;
  color: #d49b54;
  letter-spacing: 1px;
}

#score-box {
  margin-left: 48px;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #c8b89e;
  display: flex;
  align-items: center;
  gap: 14px;
}
#score-box b { color: #e8b868; }

/* ---------------- RIKA'S JOURNEY CHRONICLE RIBBON ---------------- */
#journey-ribbon {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 86vw);
  background: linear-gradient(180deg, rgba(28, 22, 17, 0.95), rgba(16, 12, 10, 0.96));
  border-top: 2px solid #8c6c46;
  border-bottom: 2px solid #8c6c46;
  border-left: 4px solid #d88b32;
  border-right: 4px solid #d88b32;
  padding: 12px 24px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.9), inset 0 0 24px rgba(216, 139, 50, 0.14);
  text-align: center;
  animation: ribbonFadeIn 0.4s ease-out;
  z-index: 8;
}
@keyframes ribbonFadeIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
#journey-zone {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 3.5px;
  color: #c88a3c;
  text-transform: uppercase;
}
#journey-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #f0dfc2;
  margin: 2px 0 6px;
}
#journey-text {
  font-size: 14px;
  font-style: italic;
  line-height: 1.55;
  color: #dfd0b6;
}

/* ---------------- BOSS HEALTH BAR ---------------- */
#boss-hud {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, 84vw);
  text-align: center;
  background: linear-gradient(180deg, rgba(26, 14, 12, 0.94), rgba(14, 8, 8, 0.94));
  border: 2px solid #7c2e28;
  padding: 10px 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.9);
  z-index: 9;
}

#boss-name {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #e8c488;
  text-shadow: 0 2px 8px #000;
}

#boss-phase {
  font-size: 10px;
  letter-spacing: 3px;
  color: #c87a58;
  margin: 2px 0 6px;
}

.boss-bar-outer {
  position: relative;
  width: 100%;
  height: 14px;
  background: #140c0a;
  border: 1px solid #8a4838;
  overflow: hidden;
}

#boss-bar-lag {
  position: absolute;
  inset: 0;
  width: 100%;
  background: #d8b478;
  transition: width 0.35s ease;
}

#boss-bar-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(90deg, #5e1111, #a82020, #cc4422);
}

/* Tip 33: Boss Posture / Stagger Bar */
.boss-stagger-outer {
  position: relative;
  width: 100%;
  height: 5px;
  background: #100a08;
  border: 1px solid #5a3820;
  margin-top: 4px;
  overflow: hidden;
}

#boss-stagger-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, #c87a28, #f5a832, #ffdd55);
  box-shadow: 0 0 8px rgba(255, 210, 60, 0.6);
  transition: width 0.12s ease;
}

/* Stage Banner */
#stage-banner {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(14, 10, 8, 0.92);
  border-top: 2px solid #a87c48;
  border-bottom: 2px solid #a87c48;
  padding: 20px 64px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95);
}
#banner-title {
  font-size: 38px;
  letter-spacing: 8px;
  color: #f0dfc2;
  text-shadow: 0 4px 16px #000;
}
#banner-sub {
  font-size: 14px;
  letter-spacing: 4px;
  color: #c89248;
  margin-top: 6px;
}

/* Bottom-Left Vitals */
#vitals-panel {
  position: absolute;
  left: 20px;
  bottom: 20px;
  width: 450px;
  background: linear-gradient(180deg, rgba(24, 19, 15, 0.94), rgba(14, 11, 9, 0.94));
  border: 2px solid #584534;
  border-left: 4px solid #b87830;
  padding: 12px 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.88);
}

.char-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.eye-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe4a0 10%, #d87a22 55%, #4a1c08 100%);
  box-shadow: 0 0 10px rgba(216, 122, 34, 0.8);
}

.char-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #f0e2c8;
}

#perk-list {
  font-size: 10px;
  color: #c89852;
  letter-spacing: 1px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 11px;
  letter-spacing: 1px;
}
.stat-row span { width: 64px; color: #b8a488; font-weight: 700; }
.stat-row b { width: 58px; text-align: right; font-size: 11px; color: #f0e2c8; }

.bar-wrap {
  flex: 1;
  height: 10px;
  background: #120e0b;
  border: 1px solid #5a4736;
  overflow: hidden;
}
.bar-fill { height: 100%; width: 100%; transition: width 0.1s; }
.bar-fill.hp { background: linear-gradient(90deg, #6e1414, #b82820); }
.bar-fill.shield { background: linear-gradient(90deg, #5e523e, #a89674); }
.bar-fill.rage { background: linear-gradient(90deg, #8a3812, #e08828); }
.bar-fill.xp { background: linear-gradient(90deg, #6b5226, #d4a84c); }

#weapon-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(168, 136, 92, 0.25);
}

.wep {
  font-size: 10px;
  padding: 4px 6px;
  background: rgba(20, 16, 12, 0.85);
  border: 1px solid #4e3e30;
  color: #a6947a;
}
.wep.active {
  background: rgba(168, 104, 36, 0.28);
  border-color: #d89642;
  color: #f4e6cc;
  box-shadow: inset 0 0 8px rgba(216, 150, 66, 0.35);
}
.wep b { color: #e2b05c; }

.ammo-box {
  font-size: 12px;
  font-weight: 800;
  color: #e6b86a;
}
.ammo-box span { font-size: 10px; color: #b89868; }

/* Bottom-Right Abilities */
#abilities-panel {
  position: absolute;
  right: 20px;
  bottom: 20px;
  display: flex;
  gap: 7px;
}

.ability {
  position: relative;
  width: 82px;
  height: 74px;
  background: linear-gradient(180deg, rgba(24, 19, 15, 0.94), rgba(14, 11, 9, 0.94));
  border: 1px solid #68523c;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.85);
}

.ability.ult {
  border-color: #b84228;
  box-shadow: 0 0 16px rgba(184, 66, 40, 0.35);
}

.cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: rgba(140, 32, 20, 0.6);
  transition: height 0.08s linear;
}

.ability .key {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(180, 140, 84, 0.16);
  border: 1px solid rgba(180, 140, 84, 0.35);
  color: #e6b868;
  border-radius: 2px;
  z-index: 1;
}

.ability .ab-name {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #f0e2c8;
  z-index: 1;
}

.ability .ab-desc {
  font-size: 8px;
  color: #b09c82;
  z-index: 1;
}

#messages {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #f2cb78;
  background: rgba(18, 13, 10, 0.92);
  border: 1px solid #785834;
  border-radius: 4px;
  padding: 6px 20px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.9);
  max-width: min(720px, 85vw);
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.4s ease;
}

/* ---------------- INTERACTIVE BOSS & STORY DIALOGUE CUTSCENE MODAL ---------------- */
#dialogue-modal {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 60%, rgba(18, 12, 9, 0.55), rgba(6, 4, 3, 0.88));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 48px;
  z-index: 35;
  pointer-events: auto;
}

.dialogue-box {
  width: min(920px, 92vw);
  background: linear-gradient(180deg, rgba(26, 20, 15, 0.98), rgba(14, 11, 8, 0.99));
  border: 2px solid #8c6a42;
  outline: 2px solid #2a1e14;
  box-shadow: 0 18px 65px rgba(0, 0, 0, 0.96), inset 0 0 36px rgba(216, 139, 50, 0.14);
  padding: 24px 30px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 22px;
  align-items: center;
}

.dialogue-portrait {
  width: 92px;
  height: 92px;
  background: radial-gradient(circle, #38281c 0%, #16100c 100%);
  border: 2px solid #a88250;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: #e8b868;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.85);
}
.dialogue-portrait.boss {
  border-color: #a83228;
  background: radial-gradient(circle, #3e1614 0%, #160808 100%);
  color: #e05244;
}

.dialogue-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid rgba(168, 130, 80, 0.35);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

#dlg-speaker {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #f2d8a4;
}
#dlg-role {
  font-size: 11px;
  letter-spacing: 2.5px;
  color: #b89668;
}
#dlg-text {
  font-size: 16px;
  line-height: 1.65;
  color: #eee2cc;
  min-height: 54px;
}
.dialogue-footer {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#dlg-step {
  font-size: 11px;
  letter-spacing: 2px;
  color: #9e886c;
}
.dlg-actions button {
  font-size: 12px;
  padding: 7px 18px;
  margin: 0 0 0 8px;
}

/* ---------------- Screens & Modals ---------------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(32, 20, 14, 0.9), rgba(6, 5, 4, 0.98));
  z-index: 20;
}

.panel {
  max-width: 840px;
  max-height: 94vh;
  overflow-y: auto;
  padding: 32px 42px;
  background: linear-gradient(180deg, rgba(24, 19, 15, 0.97), rgba(14, 11, 9, 0.98));
  border: 2px solid #785c3c;
  outline: 1px solid #2c2016;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.95), inset 0 0 32px rgba(216, 139, 50, 0.1);
  text-align: center;
}
.panel.small { max-width: 520px; }
.panel.wide { max-width: 980px; }

.badge-2d {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 3px;
  padding: 4px 14px;
  background: rgba(180, 120, 50, 0.18);
  border: 1px solid #b88444;
  color: #e6b86a;
  margin-bottom: 10px;
}

h1 {
  font-size: 44px;
  letter-spacing: 9px;
  color: #f2e4cc;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.95);
}
h1.red { color: #d44238; text-shadow: 0 0 18px rgba(180, 30, 20, 0.7); }
h1.green { color: #e6b868; text-shadow: 0 2px 16px rgba(216, 150, 60, 0.5); font-size: 34px; }

h2 {
  font-size: 13px;
  letter-spacing: 4px;
  color: #c8964c;
  margin: 8px 0 16px;
}

.story {
  font-size: 14px;
  line-height: 1.68;
  text-align: left;
  color: #d8cbb6;
  margin: 12px 0;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 22px;
  font-size: 12px;
  text-align: left;
  margin: 14px 0 18px;
  padding: 12px 16px;
  background: rgba(12, 9, 7, 0.65);
  border: 1px solid #4e3e2e;
  color: #c8b89e;
}
.controls b { color: #e6a84c; }

button {
  pointer-events: auto;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 3px;
  padding: 11px 28px;
  background: linear-gradient(180deg, rgba(140, 84, 32, 0.35), rgba(84, 46, 18, 0.45));
  color: #f4e6cc;
  border: 1px solid #b88444;
  cursor: pointer;
  margin: 8px 6px 0;
  transition: all 0.15s;
}
button:hover {
  background: linear-gradient(180deg, rgba(180, 112, 44, 0.55), rgba(110, 62, 24, 0.65));
  border-color: #e8b868;
  box-shadow: 0 0 18px rgba(216, 150, 60, 0.45);
  transform: translateY(-1px);
}

.btn-row { display: flex; justify-content: center; gap: 12px; margin-top: 12px; }

/* Upgrade Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.upgrade-card {
  pointer-events: auto;
  background: rgba(18, 14, 11, 0.96);
  border: 1px solid #6b543c;
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}
.upgrade-card:hover {
  border-color: #e6b868;
  background: rgba(34, 25, 18, 0.98);
  box-shadow: 0 0 24px rgba(216, 150, 60, 0.35);
  transform: translateY(-4px);
}
.upgrade-card h3 {
  font-size: 15px;
  letter-spacing: 2px;
  color: #e8b868;
  margin-bottom: 8px;
}
.upgrade-card p {
  font-size: 12px;
  line-height: 1.5;
  color: #d4c4ac;
}

.shard-pill {
  padding: 2px 10px;
  background: rgba(216, 150, 60, 0.16);
  border: 1px solid #a87c44;
  color: #e6b86a;
  font-weight: 800;
}
.shard-pill b { color: #fff !important; }

/* Right HUD: Mini-Map & Stylish Combo Meter */
#right-hud {
  position: absolute;
  top: 14px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

#minimap-wrap {
  background: rgba(16, 12, 9, 0.94);
  border: 2px solid #5c4836;
  padding: 6px 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.85);
}

.minimap-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #c8964c;
  margin-bottom: 4px;
  text-align: right;
}

#minimap-canvas {
  display: block;
  background: #0d0a08;
  border: 1px solid #463628;
}

/* Stylish Combo Rank */
#combo-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(22, 14, 10, 0.94);
  border-right: 4px solid #c86428;
  border-top: 1px solid #7a4828;
  padding: 8px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85);
}

#combo-rank {
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  color: #e8b858;
  text-shadow: 0 2px 12px #000;
  line-height: 1;
}

.combo-info { text-align: right; }

#combo-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #d48444;
}

#combo-count {
  font-size: 11px;
  font-weight: 700;
  color: #f0e2c8;
  margin: 2px 0 4px;
}

.combo-bar-bg {
  width: 120px;
  height: 5px;
  background: #18120e;
}

#combo-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #9e281c, #e6a844);
}

/* Dramatic Boss Intro Card */
#boss-intro-card {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(20, 12, 8, 0.96) 20%, rgba(20, 12, 8, 0.96) 80%, transparent);
  border-top: 2px solid #a8743c;
  border-bottom: 2px solid #a8743c;
  padding: 20px 0;
  text-align: center;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95);
}

.boss-intro-line {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #c89248;
  margin-bottom: 4px;
}

#boss-intro-title {
  font-size: 46px;
  letter-spacing: 10px;
  color: #f2e4cc;
  text-shadow: 0 4px 20px #000;
}

#boss-intro-sub {
  font-size: 15px;
  letter-spacing: 6px;
  color: #d48444;
  margin: 4px 0 0;
}

/* World Interact Prompt */
#interact-prompt {
  position: absolute;
  top: 62%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 15, 11, 0.95);
  border: 1px solid #b88444;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #f0d498;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.9);
}

/* Stage Selector on Main Menu */
.stage-select-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.stage-select-row span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #d49c54;
  margin-right: 6px;
}

.stage-btn, .mode-btn, .diff-btn {
  font-size: 11px;
  letter-spacing: 1.5px;
  padding: 7px 12px;
  margin: 0;
  background: rgba(24, 18, 14, 0.85);
  border: 1px solid #6b5238;
  color: #ccbba2;
}
.stage-btn.active, .mode-btn.active, .diff-btn.active {
  background: rgba(180, 116, 44, 0.35);
  border-color: #e6b868;
  color: #fff;
  box-shadow: 0 0 14px rgba(216, 150, 60, 0.35);
}

/* Sanctuary Armory Shop Items */
.shop-status {
  font-size: 14px;
  letter-spacing: 2px;
  color: #e6b868;
  margin-bottom: 10px;
}

.shop-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 18px;
}

.shop-item {
  pointer-events: auto;
  background: rgba(20, 15, 11, 0.95);
  border: 1px solid #6e5438;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.shop-item:hover {
  border-color: #e6b868;
  background: rgba(36, 26, 18, 0.98);
  transform: translateY(-2px);
}
.shop-item h4 {
  font-size: 13px;
  color: #e8b868;
  letter-spacing: 1.5px;
}
.shop-item p {
  font-size: 11px;
  color: #d4c4ac;
  margin: 4px 0 6px;
}
.shop-item .cost {
  font-size: 11px;
  font-weight: 800;
  color: #d49848;
}
.upgrade-card .tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #c89248;
  margin-bottom: 6px;
}
.upgrade-card.selected {
  border-color: #d8a848;
  background: rgba(42, 30, 16, 0.96);
  box-shadow: 0 0 22px rgba(216, 168, 72, 0.4);
}

#left-hud {
  position: absolute;
  top: 74px;
  left: 20px;
  width: 290px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#objectives-panel {
  background: rgba(18, 14, 11, 0.92);
  border: 1px solid #584432;
  border-left: 3px solid #d49844;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.obj-title { font-weight: 900; letter-spacing: 3px; color: #e2b05c; font-size: 10px; margin-bottom: 4px; }
.obj-row { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; color: #d6c6ae; }
.obj-row.done { color: #a8c686; text-decoration: line-through; opacity: 0.75; }
.obj-row b { color: #f4e6cc; }

#item-strip { display: flex; flex-wrap: wrap; gap: 4px; }
.item-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(18, 14, 11, 0.92);
  border: 1px solid currentColor;
}

#ammo-type-row {
  margin-top: 8px;
  font-size: 9px;
  letter-spacing: 1px;
  color: #b4a084;
}
#ammo-type-row b { font-size: 10px; }

#toast-stack {
  position: fixed;
  top: 130px;
  right: 24px;
  width: 310px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  background: rgba(20, 15, 11, 0.96);
  border: 1px solid #6b5238;
  border-left: 4px solid #d89642;
  padding: 8px 12px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.85);
  animation: toastIn 0.25s ease-out;
}
.toast .t-title { font-size: 12px; font-weight: 900; letter-spacing: 1.5px; }
.toast .t-desc { font-size: 11px; color: #d8c8b0; margin-top: 2px; }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

#menu-records { font-size: 12px; letter-spacing: 2px; color: #b8a488; margin: 4px 0 8px; }
#menu-records b { color: #e6b868; }

/* Character / Chronicle screen */
.char-cols { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px; text-align: left; margin: 12px 0; }
.char-col h3 { font-size: 11px; letter-spacing: 3px; color: #e6b868; margin-bottom: 8px; }
.char-head { font-size: 13px; letter-spacing: 2px; color: #e0b870; margin: 6px 0 10px; }
.skill-branch { font-size: 10px; letter-spacing: 2px; color: #d47a48; margin: 8px 0 4px; font-weight: 800; }
.skill-row {
  pointer-events: auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  margin: 3px 0;
  font-size: 11px;
  background: rgba(24, 18, 14, 0.75);
  border: 1px solid #54402e;
  cursor: pointer;
}
.skill-row:hover { border-color: #e6b868; }
.skill-row.maxed { border-color: #a8c686; }
.skill-row small { color: #b09c82; display: block; font-size: 9px; }
.relic-row { font-size: 11px; margin: 4px 0; }
.relic-row small { color: #b8a488; display: block; }
.ach-row { font-size: 11px; margin: 3px 0; color: #786a58; }
.ach-row.got { color: #e6b868; }
.lore-row { font-size: 11px; color: #d8c8b0; margin: 6px 0; line-height: 1.45; font-style: italic; border-left: 2px solid #8c6a42; padding-left: 8px; }

#screen-boon .upgrade-card .rarity { font-size: 10px; font-weight: 900; letter-spacing: 2px; display: block; margin-bottom: 6px; }

/* Level Complete Screen (Arcade Action Progression) */
.level-clear-panel {
  max-width: 820px;
  background: linear-gradient(180deg, rgba(28, 20, 14, 0.98), rgba(14, 9, 6, 0.99));
  border: 2px solid #8c6a38;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.96), 0 0 40px rgba(216, 139, 50, 0.15);
  text-align: center;
  padding: 36px 48px;
}
.clear-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 5px;
  color: #f2cb78;
  padding: 5px 18px;
  background: rgba(184, 134, 56, 0.2);
  border: 1px solid #c89642;
  border-radius: 4px;
  margin-bottom: 14px;
}
#clear-level-title {
  font-size: 46px;
  letter-spacing: 7px;
  color: #fff;
  text-shadow: 0 0 25px rgba(216, 150, 50, 0.6);
  margin-bottom: 6px;
}
#clear-verse-title {
  font-size: 14px;
  letter-spacing: 3px;
  color: #e6b868;
  margin-bottom: 12px;
}
.clear-story-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: #d8c8b4;
  margin: 12px auto 24px;
  max-width: 680px;
  font-style: italic;
}
.clear-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 28px;
}
.stat-box {
  background: rgba(16, 11, 8, 0.85);
  border: 1px solid #54402e;
  padding: 14px 10px;
  border-radius: 4px;
}
.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #a8947c;
  margin-bottom: 6px;
}
.stat-val {
  font-size: 18px;
  font-weight: 900;
  color: #f2cb78;
}
.stat-val.green {
  color: #7ab864;
}
.level-clear-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
}
.btn-primary {
  background: linear-gradient(180deg, rgba(180, 110, 40, 0.55), rgba(110, 60, 20, 0.75)) !important;
  border-color: #d89b42 !important;
  color: #fff !important;
  font-size: 14px !important;
  padding: 12px 32px !important;
  box-shadow: 0 4px 20px rgba(216, 150, 50, 0.3) !important;
}
.btn-primary:hover {
  filter: brightness(1.18);
  transform: translateY(-2px);
}
.btn-secondary {
  background: rgba(30, 22, 16, 0.85) !important;
  border-color: #6e5438 !important;
  color: #c8b49c !important;
  font-size: 13px !important;
  padding: 12px 24px !important;
}

/* ==========================================================================
   WIDESCREEN 2.39:1 CINEMATIC CUTSCENE ENGINE
   ========================================================================== */
#cutscene-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  font-family: 'Cinzel', 'Georgia', serif;
}

#cutscene-bar-top,
#cutscene-bar-bottom {
  position: absolute;
  left: 0;
  right: 0;
  height: 12vh;
  background: #020202;
  z-index: 10001;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
#cutscene-bar-top {
  top: 0;
  border-bottom: 2px solid #362416;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.95);
}
#cutscene-bar-bottom {
  bottom: 0;
  border-top: 2px solid #362416;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.95);
}

#cutscene-art-wrap {
  position: absolute;
  inset: 0;
  z-index: 9998;
  overflow: hidden;
  background: #000;
}
#cutscene-art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.7) contrast(1.15) saturate(0.9);
  animation: kenBurns 26s ease-out infinite alternate;
}
@keyframes kenBurns {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.12) translate(-2%, -2%); }
}
.cutscene-art-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 30%, rgba(0, 0, 0, 0.88) 95%),
              linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.92) 100%);
}

.cutscene-speaker {
  position: absolute;
  bottom: 23vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10002;
  transition: transform 0.4s ease, filter 0.4s ease, opacity 0.4s ease;
}
.cutscene-speaker.left { left: 5vw; }
.cutscene-speaker.right { right: 5vw; }

.cutscene-portrait-frame {
  width: 220px;
  height: 270px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.95);
}
.cutscene-portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.cutscene-portrait-frame.rika-frame {
  border: 2px solid #c89642;
  background: #140d09;
}
.cutscene-portrait-frame.demon-frame {
  border: 2px solid #a82020;
  background: #180808;
}
.demon-blood-aura {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  box-shadow: inset 0 0 25px rgba(220, 30, 30, 0.65);
  pointer-events: none;
  animation: bloodPulse 2.8s infinite alternate;
}
@keyframes bloodPulse {
  0% { opacity: 0.4; }
  100% { opacity: 0.95; }
}

.cutscene-speaker.active-speaker {
  transform: scale(1.06);
  filter: brightness(1.12);
  opacity: 1;
}
.cutscene-speaker.dimmed-speaker {
  transform: scale(0.94);
  filter: brightness(0.42) grayscale(0.45);
  opacity: 0.55;
}

.speaker-nametag {
  margin-top: 10px;
  padding: 5px 14px;
  background: linear-gradient(180deg, rgba(28, 20, 15, 0.96), rgba(16, 11, 8, 0.98));
  border: 1px solid #785a3c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.85);
  text-align: center;
  border-radius: 4px;
}
.speaker-nametag span {
  display: block;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2.5px;
  color: #f0dfc8;
}
.speaker-nametag small {
  display: block;
  font-size: 9.5px;
  letter-spacing: 1.5px;
  color: #c8964c;
  margin-top: 2px;
}
.speaker-nametag.demon-nametag {
  border-color: #8c2424;
}
.speaker-nametag.demon-nametag span {
  color: #ff5555;
  text-shadow: 0 0 8px rgba(255, 30, 30, 0.5);
}
.speaker-nametag.demon-nametag small {
  color: #d86850;
}

#cutscene-box {
  position: absolute;
  bottom: 13vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(860px, 88vw);
  background: linear-gradient(180deg, rgba(22, 16, 12, 0.96), rgba(12, 8, 6, 0.98));
  border: 2px solid #6b4e34;
  border-radius: 6px;
  padding: 20px 28px;
  z-index: 10003;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.95), inset 0 0 24px rgba(0, 0, 0, 0.7);
}

.cutscene-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #4a3828;
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.scene-tag {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #c8964c;
}
#cutscene-counter {
  font-size: 11px;
  color: #8e7a64;
  font-weight: bold;
}

#cutscene-dialogue-text {
  font-size: 15.5px;
  line-height: 1.65;
  color: #ecdcc6;
  min-height: 52px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}
.speaker-pill {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 2px 8px;
  border-radius: 3px;
  margin-right: 8px;
}
.speaker-pill.rika {
  background: rgba(184, 134, 56, 0.22);
  border: 1px solid #c89642;
  color: #f2cb78;
}
.speaker-pill.boss {
  background: rgba(180, 24, 24, 0.25);
  border: 1px solid #a82020;
  color: #ff5555;
  text-shadow: 0 0 10px rgba(255, 40, 40, 0.6);
}

.cutscene-controls {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}
#cutscene-btn-skip {
  padding: 6px 14px;
  font-size: 11px;
  letter-spacing: 2px;
  background: rgba(30, 22, 17, 0.85);
  border: 1px solid #54402e;
  color: #a8947c;
}
#cutscene-btn-next {
  padding: 6px 20px;
  font-size: 12px;
  letter-spacing: 2px;
  background: linear-gradient(180deg, rgba(160, 100, 36, 0.45), rgba(90, 52, 20, 0.65));
  border: 1px solid #c89642;
  color: #f5eed8;
}

#cutscene-boss-splash {
  position: absolute;
  inset: 0;
  z-index: 10005;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(16, 4, 4, 0.88), rgba(4, 1, 1, 0.98));
  text-align: center;
  padding: 0 40px;
}
#cutscene-splash-tag {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #d84438;
  text-shadow: 0 0 16px rgba(200, 30, 20, 0.8);
  margin-bottom: 12px;
  animation: splashFadeIn 0.4s ease-out;
}
#cutscene-splash-title {
  font-size: 58px;
  letter-spacing: 8px;
  color: #fff;
  text-shadow: 0 0 35px #a81c1c, 0 4px 14px #000;
  text-transform: uppercase;
  margin: 0;
  animation: bossTitleSlam 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.25);
}
#cutscene-splash-sub {
  font-size: 16px;
  letter-spacing: 5px;
  color: #e6b868;
  margin-top: 14px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  animation: splashFadeIn 0.6s ease-out;
}
@keyframes bossTitleSlam {
  0% { transform: scale(1.6); opacity: 0; filter: blur(8px); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}
@keyframes splashFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-btn-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
}
.btn-prologue {
  background: linear-gradient(180deg, rgba(80, 52, 28, 0.45), rgba(40, 24, 12, 0.6)) !important;
  border-color: #8c6a3c !important;
  color: #dfcdb4 !important;
}
.btn-prologue:hover {
  border-color: #e6b868 !important;
  color: #fff !important;
}

/* Tip 90: Boss Bar Multi-Phase Segment Dividers */
#boss-phase-notches {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-evenly;
}
.boss-phase-notch {
  width: 2px;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  box-shadow: 1px 0 0 rgba(255, 215, 0, 0.4);
}

/* Tip 100: Live Developer Debug Overlay [F1] */
#debug-overlay {
  position: fixed;
  top: 60px;
  left: 14px;
  background: rgba(8, 6, 5, 0.92);
  border: 1px solid #7c6246;
  padding: 10px 14px;
  font-family: monospace;
  font-size: 11px;
  color: #64ff96;
  z-index: 99999;
  box-shadow: 0 4px 18px rgba(0,0,0,0.85);
  pointer-events: auto;
}
.debug-header {
  color: #ffd24a;
  font-weight: bold;
  margin-bottom: 6px;
  border-bottom: 1px solid #3d2f21;
  padding-bottom: 4px;
}
.debug-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.debug-actions button {
  background: #1f1712;
  border: 1px solid #6c5438;
  color: #f0dac2;
  font-size: 10px;
  padding: 3px 6px;
  cursor: pointer;
}
.debug-actions button:hover {
  background: #3a281c;
  border-color: #ffd24a;
}

/* Tip 81-85: Sanctuary Settings & Accessibility Grid */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
  text-align: left;
}
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  background: rgba(18, 13, 10, 0.6);
  padding: 10px;
  border: 1px solid #3d2d20;
}
.settings-group label {
  color: #dfcdb4;
}
.settings-group select, .settings-group input[type="range"] {
  accent-color: #d49a3c;
  background: #140f0c;
  border: 1px solid #5a422d;
  color: #f5eed8;
  padding: 4px;
}
.topbar-btn {
  background: #1f1610;
  border: 1px solid #5c4530;
  color: #d4a864;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 3px 8px;
  cursor: pointer;
  margin-left: 10px;
}
.topbar-btn:hover {
  background: #3d2918;
  border-color: #ffd24a;
  color: #fff;
}
.btn-rush {
  background: linear-gradient(180deg, rgba(160, 24, 40, 0.6), rgba(80, 10, 20, 0.75)) !important;
  border-color: #d42238 !important;
  color: #ffe6e8 !important;
}
.btn-rush:hover {
  border-color: #ff4d64 !important;
  box-shadow: 0 0 16px rgba(220, 30, 60, 0.5);
}

/* =====================================================================
   COMPACT HUD PASS — keeps the bottom third of the screen clear so
   Rika and the demons around her are never hidden behind panels.
   ===================================================================== */
#topbar { top: 10px; padding: 6px 16px; gap: 14px; }
#stage-badge { font-size: 12px; }
#progress-track { width: 180px; }
#score-box { margin-left: 44px; gap: 12px; font-size: 11px; }

#left-hud { top: 64px; left: 14px; width: 250px; gap: 8px; }
#objectives-panel { background: rgba(14, 10, 8, 0.72); font-size: 10.5px; padding: 6px 10px; }

#right-hud { top: 10px; right: 14px; gap: 8px; }
#minimap-wrap { background: rgba(14, 10, 8, 0.78); padding: 4px 6px; }
#minimap-canvas { width: 210px; height: auto; }

#vitals-panel {
  left: 14px;
  bottom: 14px;
  width: 340px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(20, 15, 12, 0.82), rgba(12, 9, 7, 0.86));
  border-width: 1px;
  border-left-width: 3px;
}
.char-header { margin-bottom: 4px; gap: 8px; }
.char-name { font-size: 11px; letter-spacing: 1.5px; }
.stat-row { margin: 3px 0; font-size: 10px; gap: 6px; }
.stat-row span { width: 54px; }
.stat-row b { width: 52px; font-size: 10px; }
.bar-wrap { height: 7px; }
#weapon-bar { margin-top: 6px; padding-top: 6px; gap: 3px; }
.wep { font-size: 9px; padding: 3px 4px; }
.ammo-box { font-size: 11px; }
#ammo-type-row { margin-top: 5px; font-size: 8.5px; }

#abilities-panel { right: 14px; bottom: 14px; gap: 5px; }
.ability { width: 62px; height: 56px; padding: 4px 3px; background: linear-gradient(180deg, rgba(20, 15, 12, 0.82), rgba(12, 9, 7, 0.86)); }
.ability .ab-desc { display: none; }
.ability .ab-name { font-size: 8px; letter-spacing: 0.4px; line-height: 1.15; }
.ability .key { font-size: 9px; padding: 1px 5px; }

#messages { top: 64px; font-size: 12px; padding: 5px 16px; }
#journey-ribbon { top: 58px; padding: 9px 20px; }
#journey-text { font-size: 13px; }
#interact-prompt { top: 56%; }

/* Short laptop screens: trim secondary detail */
@media (max-height: 760px) {
  #perk-list, #ammo-type-row, .minimap-label { display: none; }
  .ability { height: 46px; width: 56px; }
  .ability .ab-name { font-size: 7.5px; }
  #vitals-panel { width: 310px; }
  #objectives-panel { font-size: 10px; }
}
/* Narrow screens: abilities sit above the vitals instead of beside them */
@media (max-width: 1100px) {
  #abilities-panel { bottom: 14px; right: 14px; flex-wrap: wrap; max-width: 260px; justify-content: flex-end; }
}

/* Top bar must never run into the minimap on ~1000–1300px wide windows */
@media (max-width: 1400px) {
  #topbar { left: 280px; transform: none; right: auto; }
  .skull-icon { display: none; }
  #score-box { margin-left: 0; }
  #progress-track { width: 120px; }
}
@media (max-width: 1150px) {
  #topbar { padding: 5px 10px; gap: 10px; }
  #stage-badge { font-size: 10.5px; letter-spacing: 1px; max-width: 150px; }
  #progress-track { display: none; }
  #minimap-canvas { width: 170px; }
  #score-box { font-size: 10px; gap: 8px; }
  .topbar-btn { padding: 3px 6px; font-size: 9px; }
}

/* Boss bar owns the top-center slot; transient messages sit just beneath it */
#boss-hud { top: 56px; padding: 7px 16px; }
#boss-name { font-size: 14px; letter-spacing: 3px; }
#messages { top: 136px; }
#boss-hud { width: min(560px, 50vw); }

/* =====================================================================
   THEME — one palette and type scale shared by the title, menus and HUD
   ===================================================================== */
:root {
  --ink: #070405;
  --panel: rgba(12, 7, 7, 0.86);
  --panel-solid: #0e0808;
  --line: rgba(230, 168, 72, 0.28);
  --ember: #e6a848;
  --ember-hot: #ffcf7a;
  --blood: #c8322a;
  --bone: #efe2c4;
  --muted: #a8967c;
  --violet: #b06aff;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Cormorant Garamond', Georgia, 'Palatino Linotype', serif;
}

body { font-family: var(--body); }
h1, h2, h3, #stage-badge, .char-name, #boss-name, #banner-title, #boss-intro-title, .clear-badge, .tm-item span {
  font-family: var(--display);
}
#banner-title { font-size: clamp(22px, 3vw, 36px); letter-spacing: 6px; }
#boss-intro-title { font-size: clamp(26px, 4vw, 46px); }
.wep.relic { border-color: #8a6aa8; }
#weapon-bar { flex-wrap: wrap; }
.ammo-box { margin-left: auto; white-space: nowrap; }
.ability.sigil { border-color: var(--violet); }
.ability.sigil.active-sigil { box-shadow: 0 0 18px rgba(176, 106, 255, 0.7); }
.ability.sigil .key { color: #d8b8ff; border-color: rgba(176, 106, 255, 0.5); }

/* =====================================================================
   TITLE SCREEN
   ===================================================================== */
#screen-menu.title-screen {
  display: block;
  background: var(--ink);
  overflow: hidden;
}
#title-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.title-left {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(440px, 92vw);
  padding: clamp(24px, 6vh, 64px) 0 24px clamp(24px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  z-index: 2;
  background: linear-gradient(90deg, rgba(4, 2, 3, 0.82), rgba(4, 2, 3, 0.45) 70%, rgba(4, 2, 3, 0));
}
.title-kicker {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 6px;
  color: var(--ember);
  opacity: 0.85;
  animation: titleFade 1.4s ease-out both;
}
.title-main {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 5.6vw, 76px);
  line-height: 0.95;
  letter-spacing: 6px;
  margin: 10px 0 0;
  background: linear-gradient(180deg, #fff3da 0%, #e6c38a 45%, #9a5a2a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(200, 60, 30, 0.45));
  animation: titleFade 1.6s ease-out 0.15s both;
}
.title-rule {
  position: relative;
  height: 14px;
  margin: 14px 0 8px;
  width: 78%;
  animation: titleFade 1.6s ease-out 0.3s both;
}
.title-rule::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--ember), rgba(230, 168, 72, 0));
}
.title-rule span { position: relative; background: transparent; color: var(--ember); font-size: 12px; padding-right: 8px; }
.title-sub {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 4px;
  color: #d8c4a0;
  animation: titleFade 1.6s ease-out 0.4s both;
}
@keyframes titleFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: clamp(20px, 5vh, 48px);
  animation: titleFade 1.4s ease-out 0.6s both;
}
.tm-item {
  all: unset;
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 7px 0 7px 22px;
  transition: transform 0.18s ease, color 0.18s ease;
}
.tm-item.hidden { display: none; }
.tm-item span {
  font-size: clamp(15px, 1.5vw, 19px);
  font-weight: 700;
  letter-spacing: 4px;
  color: #d9c8aa;
  transition: color 0.18s ease;
}
.tm-item small {
  font-family: var(--body);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
  max-height: 0;
  transition: all 0.2s ease;
}
.tm-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%) rotate(45deg) scale(0);
  border: 1px solid var(--ember);
  background: rgba(230, 168, 72, 0.25);
  transition: transform 0.18s ease;
}
.tm-item:hover, .tm-item.current, .tm-item:focus-visible { transform: translateX(6px); }
.tm-item:hover span, .tm-item.current span, .tm-item:focus-visible span {
  color: var(--ember-hot);
  text-shadow: 0 0 18px rgba(255, 160, 60, 0.55);
}
.tm-item:hover small, .tm-item.current small, .tm-item:focus-visible small { opacity: 1; max-height: 20px; }
.tm-item:hover::before, .tm-item.current::before, .tm-item:focus-visible::before { transform: translateY(-50%) rotate(45deg) scale(1); }
#tm-continue span { color: var(--ember-hot); }
#tm-continue small { opacity: 0.9; max-height: 20px; }

.title-footer { margin-top: auto; padding-top: 18px; font-size: 13px; color: var(--muted); }
#menu-progress { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 6px; }
#menu-progress b, #menu-records b { color: var(--bone); font-weight: 600; }
#menu-records { font-family: var(--display); font-size: 10px; letter-spacing: 2px; }

/* Slide-in panels */
.title-panel {
  position: absolute;
  top: 50%;
  right: clamp(16px, 4vw, 56px);
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  transform: translate(40px, -50%);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  padding: 28px 30px 26px;
  background: linear-gradient(180deg, rgba(18, 10, 9, 0.94), rgba(8, 4, 5, 0.95));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 220, 160, 0.06);
  transition: transform 0.35s cubic-bezier(.2, .8, .2, 1), opacity 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: #5a4030 transparent;
}
.title-panel.wide { width: min(820px, calc(100vw - 32px)); }
.title-panel.open { transform: translate(0, -50%); opacity: 1; pointer-events: auto; }
.title-panel::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(230, 168, 72, 0.1);
  pointer-events: none;
}
.title-panel h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--bone);
  margin: 4px 0 14px;
}
.title-panel h3 { font-size: 13px; letter-spacing: 4px; color: var(--ember); margin: 18px 0 10px; }
.tp-kicker { font-family: var(--display); font-size: 10px; letter-spacing: 5px; color: var(--ember); }
.tp-close {
  all: unset;
  pointer-events: auto;
  position: absolute;
  top: 14px;
  right: 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 4px 8px;
}
.tp-close:hover { color: var(--ember-hot); }
.tp-story { font-size: 17px; line-height: 1.55; color: #ddd0b8; margin: 0 0 12px; }
.tp-story b { color: var(--ember-hot); font-weight: 600; }
.tp-hint { font-size: 15px; font-style: italic; color: var(--muted); margin: 0 0 14px; }
.tp-hint b { color: var(--bone); font-style: normal; }
.tp-label {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--ember);
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.tp-label small { color: var(--muted); letter-spacing: 1px; }
.tp-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }

.title-panel button.btn-primary, .title-panel button.btn-ghost, .diff-row button, .chapter-card, .swatch, .sigil-card {
  margin: 0;
  font-family: var(--display);
}
.title-panel .btn-primary {
  background: linear-gradient(180deg, #b8742a, #7a3c14);
  border: 1px solid #ffcf7a;
  color: #fff6e4;
  letter-spacing: 4px;
  padding: 12px 28px;
}
.title-panel .btn-primary:hover { box-shadow: 0 0 26px rgba(255, 160, 60, 0.55); }
.title-panel .btn-ghost { background: transparent; border: 1px solid rgba(230, 168, 72, 0.4); color: #d8c4a0; font-size: 12px; letter-spacing: 3px; }

.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.diff-row .diff-btn { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; letter-spacing: 2px; font-size: 13px; background: rgba(24, 14, 10, 0.8); border: 1px solid rgba(230, 168, 72, 0.25); }
.diff-row .diff-btn small { font-family: var(--body); font-style: italic; font-weight: 500; letter-spacing: 0; font-size: 13px; color: var(--muted); }
.diff-row .diff-btn.active { border-color: var(--ember-hot); background: rgba(140, 70, 20, 0.4); box-shadow: inset 0 0 18px rgba(255, 160, 60, 0.2); }

/* Chapters */
.chapter-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.chapter-card {
  text-align: left;
  padding: 14px 14px 12px;
  background: linear-gradient(160deg, rgba(30, 16, 12, 0.9), rgba(10, 6, 6, 0.95));
  border: 1px solid rgba(230, 168, 72, 0.22);
  border-top: 2px solid var(--accent);
  letter-spacing: 0;
  font-weight: 500;
}
.chapter-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.chapter-card.unvisited { opacity: 0.72; }
.ch-num { font-size: 10px; letter-spacing: 4px; color: var(--accent); }
.ch-name { font-size: 15px; letter-spacing: 1.5px; color: var(--bone); margin: 3px 0 2px; }
.ch-sub { font-family: var(--body); font-style: italic; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.ch-row { display: flex; justify-content: space-between; gap: 8px; font-family: var(--body); font-size: 13px; color: var(--muted); border-top: 1px solid rgba(255, 255, 255, 0.05); padding-top: 3px; margin-top: 3px; }
.ch-row b { color: #d8c8ac; font-weight: 600; text-align: right; }
.ch-row b.got { color: #b6e08a; }

/* Trials */
.trial-card { padding: 16px; margin-top: 12px; border: 1px solid var(--line); background: rgba(20, 10, 8, 0.6); }
.trial-card h3 { margin: 0 0 6px; }
.trial-card p { font-size: 16px; color: #d8c8ac; margin: 0 0 12px; }

/* Armory */
.armory-grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.armory-preview-wrap { text-align: center; background: radial-gradient(circle at 50% 70%, rgba(80, 30, 20, 0.5), rgba(0, 0, 0, 0)); border: 1px solid var(--line); }
#armory-preview { display: block; width: 260px; height: 300px; }
#armory-cloak-name { font-family: var(--display); font-size: 12px; letter-spacing: 3px; color: var(--ember-hot); padding: 8px 0 10px; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px 6px; background: rgba(20, 12, 10, 0.8); border: 1px solid rgba(230, 168, 72, 0.18); letter-spacing: 0; font-size: 9px; font-weight: 500; color: #cdbb9c; }
.swatch i { width: 30px; height: 30px; border-radius: 50%; background: var(--fill); border: 2px solid var(--edge); box-shadow: 0 0 12px var(--edge); }
.swatch span { line-height: 1.15; text-align: center; min-height: 20px; }
.swatch.on { border-color: var(--ember-hot); background: rgba(120, 60, 20, 0.35); }
.swatch.locked { opacity: 0.4; cursor: not-allowed; }
.swatch.locked i { background: #111; border-color: #333; box-shadow: none; }
.sigil-list { display: flex; flex-direction: column; gap: 6px; }
.sigil-card { display: flex; gap: 12px; align-items: center; text-align: left; padding: 8px 12px; background: rgba(20, 12, 10, 0.8); border: 1px solid rgba(255, 255, 255, 0.08); border-left: 3px solid var(--accent); letter-spacing: 0; font-weight: 500; }
.sigil-card.on { box-shadow: inset 0 0 22px color-mix(in srgb, var(--accent) 25%, transparent); border-color: var(--accent); }
.sigil-card.locked { opacity: 0.5; cursor: default; border-left-color: #444; }
.sg-icon { font-size: 22px; color: var(--accent); width: 26px; text-align: center; }
.sg-name { font-size: 13px; letter-spacing: 2px; color: var(--bone); }
.sg-desc { font-family: var(--body); font-size: 13px; color: var(--muted); }
.wep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.wep-card { display: flex; gap: 10px; padding: 8px 10px; background: rgba(20, 12, 10, 0.7); border: 1px solid rgba(255, 255, 255, 0.06); }
.wep-card > b { font-family: var(--display); color: var(--ember); font-size: 18px; width: 18px; }
.wep-card.relic { border-left: 3px solid var(--accent); }
.wep-card.relic > b { color: var(--accent); }
.wep-card.locked { opacity: 0.5; }
.wp-name { font-family: var(--display); font-size: 12px; letter-spacing: 2px; color: var(--bone); }
.wp-desc { font-size: 13px; color: var(--muted); line-height: 1.3; }
.wp-desc i { color: #c8b48c; }

/* Codex */
.codex-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.codex-card { background: rgba(16, 9, 8, 0.85); border: 1px solid rgba(230, 168, 72, 0.15); padding: 0 0 8px; text-align: center; }
.codex-card.secret { border-color: rgba(176, 106, 255, 0.3); }
.codex-card.lord { border-color: rgba(230, 120, 60, 0.35); }
.codex-card canvas { display: block; width: 100%; height: auto; }
.cx-name { font-family: var(--display); font-size: 11px; letter-spacing: 1.5px; color: var(--bone); padding: 0 6px; }
.cx-lore { font-size: 12.5px; line-height: 1.25; color: var(--muted); padding: 3px 8px 0; font-style: italic; }
.codex-card.unseen .cx-name { color: #6a5a4a; }

/* Controls panel reuses the old grid */
.title-panel .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 15px; color: #d8c8ac; margin: 6px 0 14px; }
.title-panel .controls b { font-family: var(--display); font-size: 11px; color: var(--ember-hot); letter-spacing: 1px; }

@media (max-width: 900px) {
  .title-screen.panel-open .title-left { opacity: 0.15; pointer-events: none; }
  .armory-grid { grid-template-columns: 1fr; }
  .armory-preview-wrap { max-width: 260px; margin: 0 auto; }
  .swatches { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .title-panel, .tm-item, .title-main, .title-kicker, .title-sub, .title-menu, .title-rule { transition: none; animation: none; }
}
.chapter-list { align-items: stretch; }
.chapter-card { display: flex; flex-direction: column; align-items: stretch; }
.ch-row:first-of-type { margin-top: auto; }
