:root {
  --bg-obsidian: #0a090d;
  --panel-bg: rgba(13, 11, 18, 0.88);
  --panel-bg-solid: #110e17;
  --panel-border: #3a3047;
  --panel-border-hi: #6d587f;
  --gold: #e8b959;
  --gold-dim: #9e7a35;
  --ember: #e85d2a;
  --crimson: #b8293d;
  --crimson-hi: #e84558;
  --mana: #3875c9;
  --mana-hi: #63a4ff;
  --stamina: #3d9957;
  --stamina-hi: #68cf82;
  --xp: #9b5de5;
  --text-main: #e6dfd5;
  --text-muted: #9b8fa6;
  --font-title: 'Cinzel', Georgia, serif;
  --font-pixel: 'Silkscreen', 'Courier New', monospace;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--bg-obsidian);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
  -webkit-tap-highlight-color: transparent;
}

#gl-canvas,
#overlay-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#gl-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

#overlay-canvas {
  pointer-events: none;
}

#ui-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.ui-interactive {
  pointer-events: auto;
}

/* Dark Fantasy Wrought-Iron & Tarnished-Gold Panel Styling (AAA Tier-2 Materiality!) */
.df-panel {
  position: relative;
  background: linear-gradient(168deg, rgba(22, 17, 29, 0.93), rgba(9, 7, 14, 0.95));
  border: 1px solid #59462f;
  box-shadow:
    inset 0 1px 0 rgba(248, 212, 128, 0.24),
    inset 0 0 0 1px rgba(212, 162, 74, 0.14),
    0 14px 36px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  border-radius: 3px;
}

.df-panel::before,
.df-panel::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  pointer-events: none;
  border-color: #d4a64c;
  border-style: solid;
  opacity: 0.72;
}

.df-panel::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}

.df-panel::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}

.svg-ico {
  width: 23px;
  height: 23px;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.85));
}

.svg-ico.sm {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.svg-ico.xs {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: -2px;
}

.df-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(212, 166, 76, 0.32);
  background: linear-gradient(90deg, rgba(232, 185, 89, 0.16), rgba(20, 15, 28, 0.45) 70%);
}

.df-title {
  font-family: var(--font-title);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #f3d185;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
}

.df-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(180deg, #292130, #16111c);
  color: #ebe2d4;
  border: 1px solid #594a3c;
  box-shadow: inset 0 1px 0 rgba(255, 224, 150, 0.14), 0 3px 8px rgba(0, 0, 0, 0.55);
  padding: 5px 10px;
  font-family: var(--font-title);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.12s ease;
}

.df-btn:hover {
  border-color: var(--gold);
  color: #fff8e6;
  background: linear-gradient(180deg, #3c2f42, #22192b);
  box-shadow: 0 0 10px rgba(232, 185, 89, 0.25), inset 0 1px 0 rgba(255, 232, 168, 0.28);
}

.df-btn.active {
  border-color: #f2ca70;
  background: linear-gradient(180deg, #5c4016, #332109);
  color: #ffe299;
  box-shadow: 0 0 12px rgba(232, 185, 89, 0.35), inset 0 1px 0 rgba(255, 236, 178, 0.35);
}

.df-btn.danger {
  border-color: #7c2432;
  background: linear-gradient(180deg, #3d141c, #240c11);
  color: #ff99a6;
}

.df-btn.danger:hover {
  border-color: var(--crimson-hi);
  color: #fff;
}

/* Commercial AAA Asymmetric Title Screen (live 3D world breathes on the right!) */
.title-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: max(24px, env(safe-area-inset-top)) clamp(24px, 6.5vw, 92px) max(24px, env(safe-area-inset-bottom));
  background:
    linear-gradient(102deg, rgba(6, 5, 11, 0.92) 0%, rgba(10, 8, 16, 0.76) 36%, rgba(10, 8, 16, 0.16) 72%, rgba(6, 5, 11, 0.42) 100%),
    radial-gradient(circle at 72% 48%, rgba(232, 130, 52, 0.08), transparent 58%);
  z-index: 100;
  pointer-events: auto;
  transition: opacity 0.48s ease;
}

.title-screen.hidden,
.title-screen.hidden * {
  opacity: 0;
  pointer-events: none !important;
  visibility: hidden;
}

/* Pure unobstructed live 3D village backdrop while on the Home Screen! */
#title-screen:not(.hidden) ~ .hud-vitals,
#title-screen:not(.hidden) ~ .zone-banner,
#title-screen:not(.hidden) ~ .boss-bar-wrap,
#title-screen:not(.hidden) ~ .hud-top-right,
#title-screen:not(.hidden) ~ .hud-bottom {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.title-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 420px;
  width: 100%;
}

.title-crest {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: #e6b35c;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.title-crest::before,
.title-crest::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d4a64c);
}

.title-crest::after {
  background: linear-gradient(90deg, #d4a64c, transparent);
}

.title-logo {
  font-family: var(--font-title);
  font-size: clamp(44px, 6.5vw, 76px);
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.0;
  background: linear-gradient(180deg, #fff1c2 0%, #f0c365 55%, #b87c24 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 #1f1108) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.92)) drop-shadow(0 0 24px rgba(232, 120, 42, 0.38));
  margin-bottom: 12px;
}

.title-divider {
  width: 220px;
  height: 1px;
  background: linear-gradient(90deg, #d9a74a, rgba(217, 167, 74, 0.12));
  margin-bottom: 14px;
}

.title-sub {
  font-family: var(--font-title);
  font-size: 13.5px;
  color: #d6cadc;
  letter-spacing: 0.04em;
  margin-bottom: 26px;
  text-align: left;
  max-width: 390px;
  line-height: 1.55;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  max-width: 316px;
}

.title-play-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 13px 22px;
  color: #160d06;
  background: linear-gradient(180deg, #f6d584 0%, #c88f30 100%);
  border: 1px solid #ffe8ae;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(232, 165, 60, 0.36), 0 8px 20px rgba(0, 0, 0, 0.72);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.15s ease;
}

.title-play-btn small {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #3a230b;
}

.title-play-btn:hover {
  transform: translateX(4px);
  filter: brightness(1.08);
  box-shadow: 0 0 34px rgba(242, 185, 72, 0.55), 0 8px 22px rgba(0, 0, 0, 0.8);
}

.title-nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 11px 18px;
  color: #e8decb;
  background: linear-gradient(90deg, rgba(28, 21, 36, 0.88), rgba(14, 10, 20, 0.72));
  border: 1px solid rgba(212, 166, 76, 0.32);
  border-left: 3px solid rgba(212, 166, 76, 0.58);
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.title-nav-btn:hover {
  transform: translateX(5px);
  border-color: #f0c975;
  border-left-color: #ffe28a;
  background: linear-gradient(90deg, rgba(64, 44, 22, 0.92), rgba(22, 16, 30, 0.85));
  color: #fff3d1;
}

.title-nav-btn small {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: #b7a9c4;
}

.title-footer {
  margin-top: 22px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: rgba(206, 194, 218, 0.62);
}

.df-btn.locked {
  opacity: 0.54;
  border-color: #3c3447;
  background: linear-gradient(180deg, #1b1722, #110e17);
  color: #8f849e;
}

.df-btn.locked:hover {
  opacity: 0.85;
  border-color: #6b5878;
  color: #cbbdd9;
}

/* Guided Opening Onboarding Whisper Card (top-center, non-blocking) */
.onboarding-card {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  z-index: 22;
  max-width: 480px;
  border-color: #d9a74a;
  box-shadow: 0 0 22px rgba(232, 180, 74, 0.28), 0 8px 24px rgba(0, 0, 0, 0.85);
}

.onboarding-card.visible {
  display: flex;
}

/* Boss Posture / Stagger Break Bar beneath Boss HP */
.boss-posture-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.boss-posture-lbl {
  font-family: var(--font-pixel);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  color: #ffd978;
  white-space: nowrap;
}

.bar-posture {
  background: linear-gradient(90deg, #c9861f, #ffd966);
  box-shadow: 0 0 10px rgba(255, 212, 92, 0.55);
}

.bar-posture.broken {
  background: linear-gradient(90deg, #fff2a8, #ffae2b);
  animation: lowHpPulse 0.45s ease-in-out infinite;
}

/* Gameplay Trailer Recorder Live Indicator Pill */
.rec-pill {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: rgba(96, 14, 24, 0.92);
  border: 1px solid #ff5e73;
  border-radius: 16px;
  color: #ffe2e6;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.1em;
  cursor: pointer;
  z-index: 55;
  pointer-events: auto;
  box-shadow: 0 0 16px rgba(255, 58, 84, 0.55);
}

.rec-pill.active {
  display: inline-flex;
}

.controls-strip.quiet {
  opacity: 0.28;
  transition: opacity 0.35s ease;
}

.controls-strip.quiet:hover {
  opacity: 0.95;
}

/* HUD Top-Left Vital Bars (Commercial AAA Minimalist Medallion + Filigree Bars) */
.hud-vitals {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 286px;
  padding: 9px 11px;
}

.hud-vitals.low-hp {
  border-color: #e83b50;
  box-shadow: 0 0 22px rgba(232, 48, 72, 0.55), inset 0 0 14px rgba(232, 48, 72, 0.25);
  animation: lowHpPulse 1.1s ease-in-out infinite;
}

@keyframes lowHpPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(232, 48, 72, 0.35), inset 0 0 8px rgba(232, 48, 72, 0.18); }
  50% { box-shadow: 0 0 26px rgba(232, 48, 72, 0.72), inset 0 0 16px rgba(232, 48, 72, 0.35); }
}

.vitals-layout {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hero-portrait-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  box-shadow: 0 0 14px rgba(232, 185, 89, 0.32), inset 0 0 8px rgba(0, 0, 0, 0.8);
  overflow: visible;
  flex-shrink: 0;
  background: #100c18;
}

.hero-portrait-wrap canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
}

.hero-lvl-pill {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-pixel);
  font-size: 8.5px;
  padding: 1px 6px;
  background: #1b1329;
  border: 1px solid var(--gold);
  color: #ffe28a;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

.vital-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.char-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.char-lvl {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(155, 93, 229, 0.25);
  border: 1px solid rgba(155, 93, 229, 0.55);
  color: #d9b8ff;
  border-radius: 3px;
}

.bar-row {
  margin-bottom: 5px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.bar-track {
  height: 10px;
  background: linear-gradient(180deg, #060409, #120e18);
  border: 1px solid #4a3a2a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.9);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.bar-track.thin {
  height: 5px;
}

.bar-fill {
  height: 100%;
  position: relative;
  transition: width 0.12s ease-out;
}

.bar-fill::after {
  content: '';
  position: absolute;
  inset: 0 0 55% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent);
}

.bar-hp {
  background: linear-gradient(90deg, #8f1a2c, #e63950);
}

.bar-mp {
  background: linear-gradient(90deg, #214f9e, #5ca4ff);
}

.bar-st {
  background: linear-gradient(90deg, #2a7843, #66d986);
}

.bar-xp {
  background: linear-gradient(90deg, #6936b3, #c48cff);
}

.vital-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10.5px;
}

/* HUD Top-Center Boss Bar & Zone Banner */
.zone-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 40vw;
  text-align: center;
  pointer-events: none;
}

.zone-name {
  font-family: var(--font-title);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #efe1c4;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}

.zone-meta {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-shadow: 0 1px 4px #000;
}

.boss-bar-wrap {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  width: min(490px, 64vw);
  padding: 9px 16px;
  border-color: #9e6b36;
  display: none;
}

.boss-bar-wrap .bar-track::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 224, 130, 0.72);
  pointer-events: none;
}

.boss-bar-wrap.visible {
  display: block;
}

.boss-name {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #ff9c78;
  text-align: center;
  margin-bottom: 5px;
}

/* HUD Top-Right Toolbar & Minimap */
.hud-top-right {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.toolbar-row {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  max-width: 248px;
  justify-content: end;
}

.toolbar-row .df-btn {
  padding: 4px 7px;
  font-size: 10px;
  white-space: nowrap;
}

/* Circular Engraved Astrolabe Minimap (Diablo / Witcher 3 style!) */
.minimap-wrap {
  position: relative;
  padding: 8px;
  border-radius: 50%;
  border: 2px solid #b88b3d;
  box-shadow:
    inset 0 0 14px rgba(0, 0, 0, 0.88),
    0 0 0 2px #1a131f,
    0 0 0 3px rgba(212, 166, 76, 0.45),
    0 10px 26px rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0a14;
}

.minimap-wrap::before,
.minimap-wrap::after {
  display: none;
}

#minimap-canvas {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  border: 1px solid #4a3a2c;
  background: #0c0a12;
  image-rendering: pixelated;
  display: block;
}

.compass-pip {
  position: absolute;
  font-family: var(--font-title);
  font-size: 9px;
  font-weight: 800;
  color: #f5d482;
  background: #140f1c;
  border: 1px solid #9c7432;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.compass-pip.n { top: -6px; left: 50%; transform: translateX(-50%); color: #ffbe66; border-color: #f2c86b; }
.compass-pip.s { bottom: -6px; left: 50%; transform: translateX(-50%); opacity: 0.78; }
.compass-pip.e { right: -6px; top: 50%; transform: translateY(-50%); opacity: 0.78; }
.compass-pip.w { left: -6px; top: 50%; transform: translateY(-50%); opacity: 0.78; }

.quest-tracker {
  width: 242px;
  max-height: 215px;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  padding: 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: #826133 #100c18;
}

/* Custom Dark-Fantasy Engraved Scrollbars (Zero bright OS chrome!) */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: rgba(10, 8, 16, 0.85);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #9c7538, #594120);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #d4a64c;
}

.quest-tracker-title {
  font-family: var(--font-title);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 5px;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  cursor: pointer;
}

.quest-tracker.collapsed .quest-tracker-body {
  display: none;
}

.quest-tracker.collapsed .quest-tracker-title {
  margin-bottom: 0;
}

.quest-step {
  font-size: 11px;
  color: #d6cddf;
  margin-bottom: 3px;
  line-height: 1.35;
}

.quest-step.done {
  color: #77b887;
  text-decoration: line-through;
  opacity: 0.78;
}

/* HUD Bottom Action Hotbar */
.hud-bottom {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.interact-prompt {
  padding: 5px 12px;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--gold);
  background: rgba(15, 11, 20, 0.92);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  display: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.75);
}

.interact-prompt.visible {
  display: block;
}

.hotbar {
  display: flex;
  gap: 6px;
  padding: 7px 10px;
  border-color: #7d5d33;
}

.slot-btn {
  width: 56px;
  height: 56px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, #261f33, #0e0a14 82%);
  border: 1px solid #5c4936;
  box-shadow: inset 0 1px 0 rgba(255, 224, 148, 0.16), 0 4px 10px rgba(0, 0, 0, 0.75);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-main);
  overflow: hidden;
  transition: border-color 0.12s, transform 0.08s;
}

.slot-btn:hover {
  border-color: #f5cd70;
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(232, 185, 89, 0.35), inset 0 1px 0 rgba(255, 232, 168, 0.3);
}

.slot-btn.mounted {
  border-color: #ffcf66;
  background: radial-gradient(circle at 50% 35%, #4d3514, #1b1107 84%);
  box-shadow: 0 0 14px rgba(242, 185, 72, 0.52), inset 0 1px 0 rgba(255, 236, 178, 0.4);
}

.slot-key {
  position: absolute;
  top: 2px;
  left: 3px;
  padding: 0 3px;
  background: rgba(12, 9, 18, 0.85);
  border: 1px solid rgba(212, 166, 76, 0.45);
  border-radius: 2px;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: #f3ce78;
}

.slot-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  margin-top: 4px;
}

.slot-label {
  font-family: var(--font-title);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #cfc4d8;
  margin-top: 2px;
}

.slot-cd {
  position: absolute;
  inset: 0;
  background: rgba(7, 5, 11, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: #ffd599;
}

.controls-strip {
  font-size: 9.5px;
  white-space: nowrap;
  max-width: 96vw;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #9e91ac;
  background: rgba(10, 8, 14, 0.72);
  padding: 3px 10px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Modal Panels (Inventory / Skills / Dialogue / Quests) */
.modal-overlay {
  position: fixed;
  inset: 0;
  padding: 52px 16px 16px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 5, 10, 0.76);
  z-index: 40;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  width: min(760px, 92vw);
  max-height: calc(100vh - 76px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
}

.inv-grid-layout {
  grid-template-columns: 260px 1fr;
}

.equip-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #30273d;
  border-radius: 3px;
  margin-bottom: 6px;
}

.equip-slot-type {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.equip-slot-name {
  font-size: 12px;
  font-weight: 600;
}

.item-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 8px;
  align-content: start;
}

.item-card {
  padding: 9px;
  background: rgba(24, 19, 34, 0.85);
  border: 1px solid #382e47;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-card.equipped {
  border-color: var(--gold);
  box-shadow: inset 0 0 12px rgba(232, 185, 89, 0.14);
}

.rarity-common { color: #d6d0dc; }
.rarity-uncommon { color: #75d98a; }
.rarity-rare { color: #6bb4ff; }
.rarity-epic { color: #c785ff; }
.rarity-legendary { color: #ffbe55; }

/* Dialogue Box */
.dialogue-box {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 90vw);
  z-index: 45;
  display: none;
}

.dialogue-box.open {
  display: block;
}

.dialogue-content {
  padding: 12px 14px;
  display: flex;
  gap: 12px;
}

.dialogue-portrait {
  width: 96px;
  height: 96px;
  border: 2px solid var(--gold);
  box-shadow: 0 0 16px rgba(232, 185, 89, 0.25);
  border-radius: 4px;
  background: #130f1c;
  flex-shrink: 0;
}

.dialogue-text {
  font-size: 12px;
  line-height: 1.55;
  color: #ebe3d8;
  margin-bottom: 10px;
}

.dialogue-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Editor Side Dock (Skeleton Studio & World Editor) */
.editor-dock {
  position: fixed;
  top: 56px;
  left: 14px;
  width: 316px;
  max-height: calc(100vh - 150px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 35;
}

.editor-dock.open {
  display: flex;
}

.editor-scroll {
  padding: 10px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-section {
  border: 1px solid #2e253b;
  background: rgba(16, 13, 24, 0.72);
  border-radius: 3px;
  padding: 8px;
}

.editor-section h4 {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.editor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}

.editor-row input[type='range'] {
  flex: 1;
  accent-color: var(--gold);
}

.editor-row select {
  background: #171221;
  color: var(--text-main);
  border: 1px solid #443757;
  padding: 3px 6px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.toast-stack {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: min(460px, 60vw);
  z-index: 60;
  pointer-events: none;
}

body.patch-shot-mode #ui-root,
body.patch-shot-mode #overlay-canvas {
  display: none !important;
}

.title-play-btn.gp-focus,
.title-nav-btn.gp-focus {
  outline: 2px solid #ffe082;
  outline-offset: 2px;
}

@media (max-width: 1080px) {
  .toolbar-row {
    grid-template-columns: repeat(2, auto);
    max-width: 196px;
  }
  .zone-name {
    font-size: 13px;
    letter-spacing: 0.1em;
  }
  .zone-meta {
    font-size: 9px;
  }
}

@media (max-width: 960px) {
  .hud-vitals {
    width: 214px;
    padding: 8px 10px;
  }
  .boss-bar-wrap {
    width: 256px;
    top: 52px;
    padding: 6px 9px;
  }
  .editor-dock {
    width: 256px;
  }
  .quest-tracker {
    width: 196px;
  }
  .controls-strip {
    display: none;
  }
}

.toast-msg {
  padding: 6px 14px;
  background: rgba(16, 12, 22, 0.92);
  border: 1px solid var(--gold-dim);
  color: #f4dfae;
  font-family: var(--font-pixel);
  font-size: 11px;
  border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  animation: toastIn 0.18s ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.skill-branches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.skill-card {
  padding: 9px;
  border: 1px solid #352b44;
  background: rgba(20, 16, 30, 0.9);
  border-radius: 3px;
  margin-bottom: 8px;
}

.skill-card.unlocked {
  border-color: var(--gold-dim);
  background: rgba(38, 28, 16, 0.42);
}

/* ==================== MOBILE TOUCH CONTROLS (iOS / ANDROID / PWA) ==================== */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 25;
}

.touch-controls.active {
  display: block;
}

body.touch-ui-active .hud-bottom {
  display: none;
}

.touch-stick-zone {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.touch-stick-base {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(28, 22, 40, 0.45), rgba(10, 8, 16, 0.72));
  border: 2px solid rgba(232, 185, 89, 0.45);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.65), 0 4px 18px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-stick-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f5d88c, #b5802b);
  border: 2px solid #fff2c4;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
  transition: transform 0.03s linear;
}

.touch-action-pad {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 220px;
  height: 220px;
  touch-action: none;
}

.touch-btn {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(232, 185, 89, 0.55);
  background: radial-gradient(circle at 35% 30%, rgba(44, 34, 62, 0.9), rgba(14, 11, 22, 0.92));
  color: #f4ead6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
}

.touch-btn.pressed {
  transform: scale(0.92);
  border-color: #fff2c2;
  filter: brightness(1.25);
}

.touch-atk {
  width: 76px;
  height: 76px;
  font-size: 28px;
  border-color: var(--gold);
  background: radial-gradient(circle at 35% 30%, rgba(168, 86, 36, 0.92), rgba(68, 22, 18, 0.95));
  box-shadow: 0 0 18px rgba(232, 125, 42, 0.45), 0 4px 16px rgba(0, 0, 0, 0.7);
}
.t-pos-atk { right: 8px; bottom: 8px; }

.touch-med {
  width: 54px;
  height: 54px;
  font-size: 16px;
}
.touch-med span { font-size: 8px; color: #d6c8e0; margin-top: 1px; }
.t-pos-roll { right: 94px; bottom: 10px; }
.t-pos-parry { right: 88px; bottom: 72px; }

.touch-sm {
  width: 46px;
  height: 46px;
  font-size: 16px;
}
.touch-sm small { font-size: 9px; color: #ffd980; line-height: 1; }
.t-pos-ember { right: 16px; bottom: 96px; }
.t-pos-frost { right: 70px; bottom: 132px; }
.t-pos-shadow { right: 132px; bottom: 118px; }
.t-pos-flask { right: 152px; bottom: 48px; }
.t-pos-mount { right: 186px; bottom: 108px; }
.t-pos-swap { right: 132px; bottom: 172px; }
.touch-btn.mounted {
  border-color: #ffdc73;
  background: radial-gradient(circle at 35% 30%, rgba(164, 108, 32, 0.94), rgba(56, 34, 10, 0.95));
  box-shadow: 0 0 16px rgba(245, 194, 78, 0.55);
}

.df-btn.gp-focus {
  outline: 2px solid #ffe488;
  box-shadow: 0 0 16px rgba(255, 224, 120, 0.65);
  border-color: #ffe488;
}

@media (max-width: 780px), (max-height: 520px) {
  .hud-vitals { width: 224px; padding: 6px 8px; }
  .hero-portrait-wrap { width: 42px; height: 42px; }
  .minimap-wrap { padding: 4px; }
  #minimap-canvas { width: 96px; height: 96px; }
  .quest-tracker { display: none; }
  .toolbar-row { max-width: 196px; }
  .toolbar-row .df-btn { padding: 3px 5px; font-size: 9px; }
  .zone-name { font-size: 11px; }
}

.touch-interact {
  width: auto;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  right: 8px;
  bottom: 160px;
  font-size: 10px;
  color: #191008;
  background: linear-gradient(180deg, #f3ce74, #c98f32);
  border-color: #ffe9ad;
  white-space: nowrap;
}

/* Settings & Tabs UI */
.tab-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
}

.ach-banner {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: linear-gradient(90deg, rgba(46, 30, 12, 0.96), rgba(22, 16, 32, 0.96));
  border: 1px solid var(--gold);
  box-shadow: 0 0 24px rgba(232, 185, 89, 0.35), 0 8px 24px rgba(0, 0, 0, 0.85);
  border-radius: 4px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  animation: toastIn 0.25s ease-out;
}

.riposte-badge {
  padding: 3px 10px;
  background: rgba(88, 56, 12, 0.92);
  border: 1px solid #ffdf70;
  color: #ffe885;
  font-family: var(--font-pixel);
  font-size: 10px;
  border-radius: 3px;
  display: none;
}
.riposte-badge.visible { display: block; }

/* ==================== STORY MODE CUTSCENE & CHAPTER BANNERS ==================== */
.buff-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.buff-pill {
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(255, 200, 96, 0.55);
  background: rgba(52, 30, 14, 0.85);
  color: #ffd87a;
}

.buff-pill.iron {
  border-color: rgba(110, 200, 255, 0.55);
  background: rgba(16, 36, 56, 0.85);
  color: #9ae0ff;
}

.cutscene-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: auto;
}

.cutscene-overlay.active {
  display: flex;
}

.cutscene-bar {
  height: clamp(46px, 9vh, 84px);
  background: linear-gradient(180deg, #050408, rgba(5, 4, 8, 0.94));
  border-bottom: 1px solid rgba(232, 185, 89, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.cutscene-bar.bottom {
  height: auto;
  min-height: clamp(118px, 19vh, 178px);
  border-bottom: none;
  border-top: 1px solid rgba(232, 185, 89, 0.35);
  background: linear-gradient(180deg, rgba(8, 6, 14, 0.92), #050408);
  padding: 16px 24px 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.cutscene-chapter {
  font-family: var(--font-title);
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
}

.cutscene-progress {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--text-muted);
}

.cutscene-card {
  width: min(760px, 92vw);
  text-align: center;
}

.cutscene-speaker {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #ffd984;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.cutscene-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: #f0e8dc;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
}

.cutscene-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.chapter-banner {
  position: fixed;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 88;
  pointer-events: none;
  text-align: center;
  padding: 20px 44px;
  background: radial-gradient(ellipse at center, rgba(16, 12, 24, 0.92) 0%, rgba(10, 8, 16, 0.65) 70%, transparent 100%);
  border-top: 1px solid rgba(232, 185, 89, 0.55);
  border-bottom: 1px solid rgba(232, 185, 89, 0.55);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.chapter-banner.visible {
  opacity: 1;
}

.chapter-banner-title {
  font-family: var(--font-title);
  font-size: clamp(22px, 3.6vw, 38px);
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #f5d484;
  text-shadow: 0 0 22px rgba(232, 125, 42, 0.55), 0 4px 12px #000;
}

.chapter-banner-sub {
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #dcd1e6;
  margin-top: 6px;
}

.map-node-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.map-node-card {
  padding: 12px;
  background: rgba(20, 16, 30, 0.9);
  border: 1px solid #3f3352;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-node-card.current {
  border-color: var(--gold);
  box-shadow: inset 0 0 16px rgba(232, 185, 89, 0.15);
}

.elixir-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.parchment-map-wrap {
  position: relative;
  width: 100%;
  border: 2px solid var(--gold-dim);
  border-radius: 4px;
  overflow: hidden;
  background: #1b1410;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.65);
}

.parchment-map-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
}

.map-pin-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 3px 8px;
  font-family: var(--font-pixel);
  font-size: 9.5px;
  background: rgba(20, 14, 24, 0.92);
  border: 1px solid var(--gold);
  color: #fce29f;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.85);
  transition: transform 0.12s ease, background 0.12s ease;
}

.map-pin-btn:hover {
  transform: translate(-50%, -56%) scale(1.06);
  background: rgba(68, 44, 16, 0.96);
  color: #fff;
}

.map-pin-btn.current {
  border-color: #78f2a2;
  color: #9effbe;
  box-shadow: 0 0 14px rgba(105, 240, 150, 0.5);
}

/* Mobile Portrait / Narrow Phone Optimizations */
@media (max-width: 620px) {
  .map-node-grid { grid-template-columns: 1fr; }
  .elixir-bar { grid-template-columns: 1fr; }
  .hud-vitals {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: 172px;
    padding: 6px 8px;
  }
  .char-name { font-size: 10px; }
  .hud-top-right {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
  }
  .minimap-wrap { padding: 4px; }
  #minimap-canvas { width: 96px; height: 96px; }
  .quest-tracker { display: none; }
  .zone-banner {
    top: 112px;
  }
  .inv-grid-layout {
    grid-template-columns: 1fr;
  }
  .skill-branches {
    grid-template-columns: 1fr;
  }
  .modal-box {
    width: 96vw;
    max-height: 88vh;
  }
  .dialogue-box {
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 95vw;
  }
}

/* Safe-Area Insets for Modern Notched Phones (iOS / Android) */
.hud-bottom {
  bottom: max(12px, env(safe-area-inset-bottom));
}

.touch-controls {
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Reduced-Motion Accessibility Mode (OhMyGame UI Standard + OS prefers-reduced-motion) */
@media (prefers-reduced-motion: reduce) {
  .df-btn,
  .slot-btn,
  .map-pin-btn,
  .hud-vitals.low-hp,
  .riposte-badge,
  .chapter-banner {
    animation: none !important;
    transition: none !important;
  }
}

body.reduced-motion .df-btn,
body.reduced-motion .slot-btn,
body.reduced-motion .map-pin-btn,
body.reduced-motion .hud-vitals.low-hp,
body.reduced-motion .riposte-badge,
body.reduced-motion .chapter-banner {
  animation: none !important;
  transition: none !important;
}
