/* ==========================================================================
   MOON WATCH WEB — DARK SOULS TRANSLUCENT EDITION
   Unified responsive UI for PC (1280x720+), iPad/Tablet, and Portrait-Only Phones
   (iPhone 13 Pro 390x844 & Samsung S22 360x780). Zero cyan/green neon, Jura + Inter.
   ========================================================================== */

:root {
  --ink: #edece8;
  --ink-soft: #ccc7bc;
  --ash: #a59f94;
  --gold: #d4bd91;
  --gold-bright: #f0dfb8;
  --bronze: #766b57;
  --bronze-dim: rgba(118, 107, 87, 0.48);
  --bronze-line: rgba(139, 124, 99, 0.62);

  --veil-light: rgba(10, 9, 9, 0.48);
  --veil-mid: rgba(11, 10, 10, 0.64);
  --veil-panel: rgba(12, 11, 11, 0.84);
  --veil-card: rgba(18, 16, 15, 0.78);

  --rule: linear-gradient(90deg, transparent, #8b7c63 18%, #8b7c63 82%, transparent);
  --rule-soft: linear-gradient(90deg, transparent, rgba(139, 124, 99, 0.55) 20%, rgba(139, 124, 99, 0.55) 80%, transparent);
  --selection: linear-gradient(90deg, transparent, rgba(148, 115, 66, 0.52) 50%, transparent);

  --hp-fill: linear-gradient(180deg, #b84b44 0%, #8e2d2d 100%);
  --boss-fill: linear-gradient(180deg, #b6363c 0%, #781c22 100%);
  --xp-fill: linear-gradient(180deg, #cbb787 0%, #9b8557 100%);
  --dash-fill: linear-gradient(180deg, #d8d3c8 0%, #9e9688 100%);
  --evo-accent: #c59ee8;
  --relic-accent: #c8a97e;

  /* Exact 16 equal segments (15 dividers) — matches Roblox HudWidgets 1-to-1 */
  --bar-ticks: repeating-linear-gradient(
    to right,
    transparent 0 calc(6.25% - 1px),
    rgba(12, 10, 8, 0.58) calc(6.25% - 1px) 6.25%
  );

  --font-display: "Jura", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #08080a;
  color: var(--ink);
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  touch-action: none;
}

#game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transform-origin: center center;
}

/* Desktop Device Preview Stage (testing iPhone 13 Pro / Samsung S22 / iPad from PC) */
body.device-emulated {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 46px 16px 14px;
  background: radial-gradient(circle at 50% 48%, #171513 0%, #070606 72%);
}

#game-shell.emulated-frame {
  flex-shrink: 0;
  border: 2px solid rgba(139, 124, 99, 0.62);
  border-radius: 10px;
  box-shadow:
    0 24px 68px rgba(0, 0, 0, 0.88),
    0 0 0 6px rgba(17, 15, 13, 0.94),
    inset 0 0 0 1px rgba(240, 223, 184, 0.14);
}
#game-shell.emulated-frame[data-device="phone"] { border-radius: 30px; }
#game-shell.emulated-frame[data-device="tablet"] { border-radius: 18px; }

.device-preview-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 14px;
  background: rgba(11, 10, 9, 0.92);
  border-bottom: 1px solid var(--bronze-dim);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}

.dp-meta {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
  white-space: nowrap;
}

/* Compact Device Switcher Pills (Menu, Pause, F2 Drawer, Top Preview Bar) */
.device-switch-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.device-switch-lbl {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
}

.device-switch-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.device-switch-row.compact {
  flex-wrap: nowrap;
  gap: 4px;
}

.dev-pill {
  height: 26px;
  padding: 0 9px;
  border-radius: 4px;
  border: 1px solid rgba(118, 107, 87, 0.48);
  background: rgba(18, 16, 15, 0.78);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.dev-pill:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(66, 52, 34, 0.45);
}

.dev-pill.active {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(154, 118, 66, 0.72), rgba(96, 69, 36, 0.82));
  color: #fff8e6;
  box-shadow: inset 0 1px 0 rgba(255, 244, 214, 0.25);
}

.debug-panel .dev-pill {
  height: 26px;
  padding: 0 7px;
  font-size: 10.5px;
  font-family: var(--font-display);
}
.debug-panel .dev-pill.active {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(154, 118, 66, 0.78), rgba(96, 69, 36, 0.88));
  color: #fff8e6;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden {
  display: none !important;
}

/* Soft Dark Souls Edge Gradients */
.ds-top-fade,
.ds-bottom-fade {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 4;
}

.ds-top-fade {
  top: 0;
  height: 155px;
  background: linear-gradient(180deg, rgba(6, 5, 5, 0.80) 0%, rgba(6, 5, 5, 0.40) 56%, transparent 100%);
}

.ds-bottom-fade {
  bottom: 0;
  height: 130px;
  background: linear-gradient(0deg, rgba(6, 5, 5, 0.84) 0%, rgba(6, 5, 5, 0.38) 54%, transparent 100%);
}

[data-device="phone"] .ds-bottom-fade { height: 195px; }
[data-device="tablet"] .ds-bottom-fade { height: 165px; }

.ds-rule {
  height: 1px;
  width: 100%;
  background: var(--rule);
  flex-shrink: 0;
}
.ds-rule.soft { background: var(--rule-soft); }

.ds-text-shadow {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.92), 0 0 10px rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   HUD LAYER (Safe-Area Aware)
   ========================================================================== */

#hud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    calc(24px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(24px + env(safe-area-inset-left, 0px));
}

[data-device="tablet"] #hud-layer {
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    calc(18px + env(safe-area-inset-right, 0px))
    calc(14px + env(safe-area-inset-bottom, 0px))
    calc(18px + env(safe-area-inset-left, 0px));
}

[data-device="phone"] #hud-layer {
  padding:
    calc(8px + env(safe-area-inset-top, 0px))
    calc(10px + env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px))
    calc(10px + env(safe-area-inset-left, 0px));
}

/* Segmented 16-div Dark Souls Bars */
.ds-meter-track {
  position: relative;
  width: 100%;
  background: var(--bar-ticks), rgba(22, 18, 16, 0.84);
  border: 1px solid #8b7c63;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.ds-meter-fill {
  height: 100%;
  width: 0%;
  position: relative;
  transition: width 0.08s linear;
}
.ds-meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bar-ticks);
  pointer-events: none;
}

.ds-meter-fill.hp { background: var(--hp-fill); }
.ds-meter-fill.xp { background: var(--xp-fill); }
.ds-meter-fill.boss { background: var(--boss-fill); }
.ds-meter-fill.dash { background: linear-gradient(180deg, #867f73, #5a544c); }
.ds-meter-fill.dash.ready { background: var(--dash-fill); }

/* Action Buttons & Custom Pixel Icons */
.ds-icon-btn {
  pointer-events: auto;
  background: rgba(12, 11, 10, 0.64);
  border: 1px solid var(--bronze-dim);
  border-radius: 6px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  height: 36px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.ds-icon-btn:hover {
  background: var(--selection);
  border-color: var(--gold);
  color: var(--gold-bright);
}

.ds-icon-btn img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  display: block;
}

.ds-icon-btn.sm-dbg {
  padding: 0 9px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.ds-kbd {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(20, 18, 16, 0.88);
  border: 1px solid rgba(139, 124, 99, 0.48);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ==========================================================================
   TOP HUD — SYMMETRIC PC / TABLET / PHONE ADAPTATION
   ========================================================================== */

.hud-top {
  display: grid;
  grid-template-columns: minmax(290px, 340px) minmax(240px, 1fr) minmax(290px, 340px);
  align-items: start;
  gap: 18px;
}

.hud-center {
  min-width: 0;
}

[data-device="tablet"] .hud-top {
  grid-template-columns: 280px 1fr 250px;
  gap: 12px;
}

[data-device="phone"] .hud-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ph-top-row { display: none; }

[data-device="phone"] .ph-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}
[data-device="phone"] .hud-hero,
[data-device="phone"] .hud-right,
[data-device="phone"] .pc-mission,
[data-device="phone"] .pc-only,
[data-device="tablet"] .pc-only {
  display: none !important;
}

/* PC / Tablet Hero Block */
.hud-hero {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.hero-avatar {
  width: 64px;
  height: 72px;
  flex-shrink: 0;
  border: 1.5px solid #8b7c63;
  border-radius: 4px;
  background: rgba(12, 10, 10, 0.72);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65);
}

[data-device="tablet"] .hero-avatar { width: 54px; height: 60px; }
.hero-avatar img { width: 54px; height: auto; image-rendering: pixelated; }
[data-device="tablet"] .hero-avatar img { width: 44px; }

.hero-meters {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-row { display: flex; flex-direction: column; gap: 3px; }
.meter-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--ink-soft);
}
.meter-meta.sm { font-size: 11.5px; }
.meter-meta b { font-family: var(--font-display); font-size: 15px; color: var(--ink); }

.lvl-pill {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
}

.hp-track { height: 15px; }
.xp-track { height: 8px; }

.buff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.buff-tag {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  background: rgba(12, 11, 10, 0.72);
  border: 1px solid rgba(212, 189, 145, 0.48);
  color: var(--gold-bright);
  border-radius: 4px;
}
.buff-tag.blood { border-color: rgba(196, 86, 94, 0.65); color: #f0a8ae; }

/* Center Mission + Boss Bar + Banner */
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.pc-mission { text-align: center; }

.pc-stage-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.pc-timer {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  margin-top: 2px;
}

/* Smoked Dark Souls Boss Bar (Guaranteed High Contrast even on Ruins Mosaic) */
.ds-boss-wrap {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ds-boss-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(10, 9, 8, 0.74) 0%, rgba(10, 9, 8, 0.78) 80%, rgba(10, 9, 8, 0.62) 100%);
  border-left: 2px solid #b6363c;
}

.ds-boss-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 2px 5px #000;
}

.ds-boss-hp {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-bright);
}

.boss-track { height: 14px; }

[data-device="phone"] .ds-boss-name { font-size: 12.5px; letter-spacing: 0.1em; }
[data-device="phone"] .ds-boss-hp { font-size: 12px; }
[data-device="phone"] .boss-track { height: 11px; }

.hud-banner {
  background: rgba(12, 11, 10, 0.86);
  border-top: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
  padding: 6px 20px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  animation: bannerPop 0.22s ease-out;
}
[data-device="phone"] .hud-banner { font-size: 12.5px; padding: 5px 12px; }

@keyframes bannerPop {
  from { transform: translateY(-6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* PC / Tablet Right */
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.pc-scores {
  display: flex;
  gap: 20px;
  text-align: right;
}

.pc-score-item small {
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ash);
}

.pc-score-item b {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--gold-bright);
  display: inline-block;
  transition: transform 0.1s ease;
}

.pc-score-item b.pulse { transform: scale(1.14); color: #fff; }

.hud-actions { display: flex; gap: 5px; flex-wrap: nowrap; }
[data-device="tablet"] .hud-actions .ds-icon-btn { width: 48px; height: 48px; padding: 0; }

/* Phone Top Strip */
.ph-stage-box {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  background: rgba(10, 9, 8, 0.62);
  border-left: 2px solid var(--gold);
  border-radius: 3px;
}

.ph-stage-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ph-stage-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.threat-chip {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: var(--gold-bright);
  background: rgba(139, 98, 46, 0.45);
  border: 1px solid rgba(212, 189, 145, 0.55);
  padding: 0 5px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ph-stage-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ph-score-box {
  text-align: right;
  padding: 4px 8px;
  background: rgba(10, 9, 8, 0.58);
  border-radius: 4px;
  flex-shrink: 0;
}

.ph-score-box small {
  display: block;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--ash);
}

.ph-score-box b {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--gold-bright);
  line-height: 1.05;
}

.ph-btn-pair { display: flex; gap: 5px; flex-shrink: 0; }
.ph-btn-pair .ds-icon-btn { width: 44px; height: 44px; padding: 0; }

/* ==========================================================================
   BOTTOM HUD — TACTILE SLOT DOCK + TOUCH CONTROLS
   ========================================================================== */

.hud-bottom-zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ph-buffs { display: none; justify-content: center; }
[data-device="phone"] .ph-buffs { display: flex; }

/* Touch Row: hidden on desktop, shown on phone & tablet */
.touch-row {
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 2px 4px;
}

[data-device="phone"] .touch-row,
[data-device="tablet"] .touch-row {
  display: flex;
}

.ds-joystick {
  pointer-events: auto;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 189, 145, 0.42);
  background: rgba(10, 9, 8, 0.34);
  display: grid;
  place-items: center;
  position: relative;
}

.ds-joystick.floating {
  position: fixed;
  margin-left: -48px;
  margin-top: -48px;
  z-index: 25;
}

[data-device="tablet"] .ds-joystick { width: 110px; height: 110px; }
[data-device="tablet"] .ds-joystick.floating { margin-left: -55px; margin-top: -55px; }

.ds-joystick-knob {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(237, 232, 220, 0.78), rgba(145, 134, 114, 0.65));
  border: 1.5px solid rgba(240, 223, 184, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.ds-dash-orb {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(54, 46, 38, 0.82), rgba(14, 12, 11, 0.86));
  border: 2px solid var(--bronze);
  box-shadow: inset 0 1px 0 rgba(240, 223, 184, 0.25), 0 4px 0 rgba(5, 4, 4, 0.88);
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1.05;
  opacity: 0.74;
}

.ds-dash-orb.ready {
  border-color: var(--gold);
  color: var(--gold-bright);
  opacity: 1;
  box-shadow: inset 0 1px 0 rgba(240, 223, 184, 0.35), 0 4px 0 rgba(5, 4, 4, 0.88), 0 0 16px rgba(212, 189, 145, 0.24);
}

[data-device="tablet"] .ds-dash-orb { width: 78px; height: 78px; }

.dash-orb-cd {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 5, 0.62);
  transform-origin: bottom;
  transform: scaleY(0);
  pointer-events: none;
}

.ds-dash-orb img {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}
[data-device="tablet"] .ds-dash-orb img { width: 32px; height: 32px; }

.ds-dash-orb span {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Bottom Row: PC Dash + Center Slot Dock + PC Foot Hint */
.hud-bottom-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

[data-device="tablet"] .hud-bottom-row { justify-content: center; }
[data-device="phone"] .hud-bottom-row { display: block; }

.pc-dash-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(10, 9, 8, 0.62);
  border: 1px solid var(--bronze-dim);
  border-radius: 8px;
}

.pc-dash-card img { width: 28px; height: 28px; image-rendering: pixelated; }
.pc-dash-meta { width: 124px; }
.pc-dash-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 4px;
}
.dash-track { height: 8px; }

.pc-foot-hint {
  min-width: 205px;
  text-align: right;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.pc-threat {
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
}

[data-device="tablet"] .pc-dash-card,
[data-device="tablet"] .pc-foot-hint,
[data-device="phone"] .pc-dash-card,
[data-device="phone"] .pc-foot-hint {
  display: none;
}

/* Tablet Landscape: pull Joystick + Slot Dock + Dash into one symmetrical bottom row! */
[data-device="tablet"][data-orient="landscape"] .hud-bottom-zone {
  position: relative;
}
[data-device="tablet"][data-orient="landscape"] .hud-bottom-row {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
}

/* Center Deck & Phone Vitals */
.ph-vitals { display: none; }
[data-device="phone"] .center-deck {
  background: rgba(10, 9, 8, 0.70);
  border: 1px solid var(--bronze-dim);
  border-radius: 8px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
[data-device="phone"] .center-deck::before {
  content: "";
  position: absolute;
  top: -1px; left: 10px; right: 10px; height: 1px;
  background: var(--rule);
}
[data-device="phone"] .ph-vitals {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ph-hp-row { display: flex; align-items: center; gap: 7px; }
.ph-lvl {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  padding: 2px 7px;
  border: 1px solid var(--bronze);
  background: rgba(24, 20, 17, 0.84);
  border-radius: 4px;
  white-space: nowrap;
}
.ph-hp-track { flex: 1; height: 16px; }
.ph-xp-track { height: 5px; }
.ph-bar-txt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

/* Tactile Weapon + Relic Dock */
.slot-dock {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(9, 8, 8, 0.66);
  border: 1px solid var(--bronze-dim);
  border-radius: 10px;
  padding: 7px 10px;
  position: relative;
}
.slot-dock::before {
  content: "";
  position: absolute;
  top: -1px; left: 12px; right: 12px; height: 1px;
  background: var(--rule);
}

[data-device="phone"] .slot-dock {
  pointer-events: none; /* Read-only on phone so thumbs never misfire Armory mid-fight */
  background: transparent;
  border: 0;
  padding: 2px 0 0;
  gap: 6px;
  width: 100%;
  justify-content: space-between;
}
[data-device="phone"] .slot-dock::before { display: none; }

.slot-group { display: flex; gap: 7px; }
[data-device="phone"] .slot-group { gap: 4px; }

.slot-divider {
  width: 1px;
  height: 36px;
  background: linear-gradient(180deg, transparent, #8b7c63, transparent);
}
[data-device="phone"] .slot-divider { height: 28px; }

.slot-box {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: rgba(14, 13, 12, 0.72);
  border: 1.5px solid rgba(118, 107, 87, 0.42);
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: inset 0 1px 0 rgba(237, 236, 232, 0.08), 0 3px 0 rgba(4, 3, 3, 0.85);
}

.slot-box.relic-slot { width: 52px; height: 52px; }
[data-device="tablet"] .slot-box { width: 50px; height: 50px; }
[data-device="tablet"] .slot-box.relic-slot { width: 46px; height: 46px; }
[data-device="phone"] .slot-box,
[data-device="phone"] .slot-box.relic-slot { width: 36px; height: 36px; border-radius: 6px; }

.slot-box.filled {
  cursor: pointer;
  background: rgba(24, 21, 19, 0.84);
  border-color: #8b7c63;
  transition: transform 0.1s, border-color 0.15s;
}
.slot-box.filled:hover { transform: translateY(-2px); border-color: var(--gold-bright); }

.slot-box.milestone { border-color: var(--gold); }
.slot-box.evolved {
  background: linear-gradient(160deg, rgba(66, 38, 86, 0.88), rgba(24, 16, 34, 0.90));
  border-color: var(--evo-accent);
  box-shadow: inset 0 1px 0 rgba(240, 220, 255, 0.22), 0 0 14px rgba(175, 120, 220, 0.30), 0 3px 0 rgba(6, 4, 10, 0.9);
}
.slot-box.relic { border-color: #9e8259; }

.slot-box.empty::after {
  content: "";
  width: 8px;
  height: 1px;
  background: rgba(165, 159, 148, 0.35);
}

.slot-box img { width: 34px; height: 34px; image-rendering: pixelated; }
.slot-box.relic-slot img { width: 28px; height: 28px; }
[data-device="tablet"] .slot-box img { width: 28px; height: 28px; }
[data-device="phone"] .slot-box img,
[data-device="phone"] .slot-box.relic-slot img { width: 21px; height: 21px; }

.slot-rank {
  position: absolute;
  right: 3px;
  bottom: 2px;
  background: rgba(8, 7, 7, 0.94);
  border: 1px solid rgba(212, 189, 145, 0.35);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 4px;
  line-height: 1.25;
}
[data-device="phone"] .slot-rank { font-size: 9.5px; padding: 0 3px; }

/* ==========================================================================
   MODAL LAYER — DARK SOULS TRANSLUCENT CODEX
   ========================================================================== */

#modal-layer {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(14px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
  background: rgba(5, 4, 4, 0.66);
}

.panel {
  position: relative;
  width: min(920px, 100%);
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bronze) transparent;
  background: var(--veil-panel);
  border: 1px solid var(--bronze-line);
  border-radius: 8px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.82);
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}
.panel::before { top: -1px; }
.panel::after { bottom: -1px; }

.compact-panel { width: min(440px, 100%); }
.menu-panel { width: min(580px, 100%); }
.records-panel { width: min(640px, 100%); }
.armory-panel { width: min(820px, 100%); }
.finish-panel { width: min(720px, 100%); }

[data-device="phone"] .panel {
  padding: 13px 12px;
  gap: 9px;
}

.m-eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-transform: uppercase;
}

.m-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  line-height: 1.1;
}
[data-device="phone"] .m-title { font-size: 17px; }

/* Dark Souls Engraved Buttons */
.btn {
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 5px;
  border: 1px solid var(--bronze);
  background: rgba(24, 21, 18, 0.80);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.12s;
}
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn:hover:not(:disabled) {
  background: var(--selection);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}
.btn img { width: 18px; height: 18px; image-rendering: pixelated; display: block; }

.btn.primary {
  background: linear-gradient(180deg, rgba(168, 130, 74, 0.88), rgba(114, 82, 42, 0.90));
  border-color: var(--gold-bright);
  color: #fff8e6;
  box-shadow: inset 0 1px 0 rgba(255, 244, 214, 0.35), 0 3px 0 rgba(10, 7, 4, 0.85);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn.danger {
  background: rgba(120, 32, 38, 0.38);
  border-color: rgba(212, 107, 115, 0.65);
  color: #f4b2b8;
}
.btn.danger:hover:not(:disabled) { background: rgba(154, 42, 48, 0.56); border-color: #f4a4ac; }

/* Menu */
.menu-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.menu-hero-top {
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
}
[data-device="phone"] .menu-hero-top { flex-direction: column; text-align: center; gap: 10px; }

.menu-portrait {
  width: 86px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.75));
}

.menu-wordmark {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
  line-height: 1.05;
}
[data-device="phone"] .menu-wordmark { font-size: 26px; letter-spacing: 0.1em; }

.menu-sub { font-size: 14px; color: var(--ink-soft); margin-top: 6px; line-height: 1.45; }

.menu-input {
  width: 100%;
  max-width: 340px;
  min-height: 44px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--bronze);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  text-align: center;
  padding: 6px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.menu-input:focus { border-bottom-color: var(--gold-bright); }

.menu-actions-col {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.controls-note { font-size: 12.5px; color: var(--ash); }

/* Upgrade Modal */
.upgrade-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}
.upgrade-meta {
  display: flex;
  gap: 14px;
  padding: 7px 14px;
  background: rgba(10, 9, 8, 0.56);
  border: 1px solid var(--bronze-dim);
  border-radius: 5px;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gold-bright);
}
[data-device="phone"] .upgrade-meta { display: none; }

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
[data-device="phone"] .upgrade-grid,
[data-device="tablet"][data-orient="portrait"] .upgrade-grid {
  grid-template-columns: 1fr;
  gap: 9px;
}

.upgrade-card {
  background: var(--veil-card);
  border: 1px solid var(--bronze-dim);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}
.upgrade-card:hover { transform: translateY(-2px); border-color: var(--gold-bright); }
[data-device="phone"] .upgrade-card { padding: 10px 11px; gap: 7px; }

.upgrade-card.rarity-evolution {
  border-left-color: var(--evo-accent);
  background: linear-gradient(155deg, rgba(50, 30, 66, 0.78), rgba(16, 13, 20, 0.84));
}
.upgrade-card.rarity-milestone { border-left-color: var(--gold-bright); }
.upgrade-card.rarity-relic { border-left-color: var(--relic-accent); }
.upgrade-card.rarity-new { border-left-color: #cfc6b2; }

.card-top { display: flex; align-items: center; gap: 11px; }
.card-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 7px;
  background: rgba(10, 9, 8, 0.80);
  border: 1px solid var(--bronze);
  display: grid;
  place-items: center;
}
[data-device="phone"] .card-icon { width: 42px; height: 42px; }
.card-icon img { width: 32px; height: 32px; image-rendering: pixelated; }
[data-device="phone"] .card-icon img { width: 26px; height: 26px; }

.card-badge {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.rarity-evolution .card-badge { color: #e2c2ff; }
.rarity-relic .card-badge { color: #d8be98; }

.card-head { flex: 1; min-width: 0; }
.card-head h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}
[data-device="phone"] .card-head h3 { font-size: 15px; }

.card-desc { font-size: 14px; line-height: 1.4; color: var(--ink-soft); flex: 1; }
[data-device="phone"] .card-desc { font-size: 12.5px; line-height: 1.3; }

.card-synergy {
  font-size: 12px;
  color: #e4cff8;
  background: rgba(98, 62, 130, 0.24);
  border: 1px solid rgba(197, 158, 232, 0.34);
  border-radius: 4px;
  padding: 5px 9px;
}
[data-device="phone"] .card-synergy { display: none; }

.card-footer { display: flex; gap: 8px; align-items: center; }
.card-footer .btn.primary { flex: 1; }
.card-footer .btn.danger { width: 44px; padding: 0; flex-shrink: 0; }

.upgrade-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.banish-counter { font-size: 13px; color: var(--ash); }
.banish-counter b { color: var(--gold-bright); }

/* Armory & DPS */
.armory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tab-row { display: flex; gap: 8px; }
.tab-btn {
  flex: 1;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 5px;
  border: 1px solid var(--bronze-dim);
  background: rgba(14, 13, 12, 0.68);
  color: var(--ash);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--selection);
  border-color: var(--gold);
  color: var(--gold-bright);
}

.armory-split { display: grid; grid-template-columns: 245px 1fr; gap: 14px; }
[data-device="phone"] .armory-split { grid-template-columns: 1fr; gap: 10px; }

.armory-list { display: flex; flex-direction: column; gap: 7px; }
[data-device="phone"] .armory-list { display: grid; grid-template-columns: repeat(2, 1fr); }

.armory-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  min-height: 48px;
  border-radius: 6px;
  background: rgba(14, 13, 12, 0.66);
  border: 1px solid rgba(118, 107, 87, 0.36);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.armory-item.active { background: var(--selection); border-color: var(--gold); }
.armory-item img { width: 28px; height: 28px; image-rendering: pixelated; }
.armory-item b { font-family: var(--font-display); font-size: 13.5px; display: block; }
.armory-item span { font-size: 11px; color: var(--ash); }

.armory-detail {
  background: rgba(10, 9, 8, 0.58);
  border: 1px solid rgba(118, 107, 87, 0.32);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.armory-detail-head { display: flex; align-items: center; gap: 12px; }
.armory-detail-head img { width: 40px; height: 40px; image-rendering: pixelated; }
.armory-detail-head h3 { font-family: var(--font-display); font-size: 18px; color: var(--gold-bright); }
.armory-desc { font-size: 14px; line-height: 1.45; color: var(--ink-soft); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(118, 107, 87, 0.25);
}
[data-device="phone"] .stat-row { font-size: 12.5px; }
.stat-row span { color: var(--ash); }
.stat-row b { font-family: var(--font-display); color: var(--gold-bright); }

.relic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
[data-device="phone"] .relic-grid { grid-template-columns: 1fr; }
.relic-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14, 13, 12, 0.68);
  border: 1px solid rgba(158, 130, 89, 0.42);
  border-radius: 6px;
  padding: 12px;
}
.relic-card img { width: 32px; height: 32px; image-rendering: pixelated; }
.relic-card h4 { font-family: var(--font-display); font-size: 15px; }
.relic-card p { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

.dps-list { display: flex; flex-direction: column; gap: 9px; }
.dps-row { display: flex; align-items: center; gap: 10px; }
.dps-row img { width: 26px; height: 26px; image-rendering: pixelated; }
.dps-info { flex: 1; }
.dps-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.dps-top b { font-family: var(--font-display); }
.dps-bar-track {
  height: 9px;
  background: rgba(24, 20, 17, 0.84);
  border: 1px solid rgba(118, 107, 87, 0.45);
  border-radius: 2px;
  overflow: hidden;
}
.dps-bar-fill { height: 100%; }
.dps-total { text-align: right; font-size: 13px; color: var(--gold); margin-top: 4px; }

.empty-note, .muted { color: var(--ash); font-size: 13px; }

/* Pause, Records, Finish */
.pause-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.finish-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
[data-device="phone"] .finish-stats { grid-template-columns: repeat(3, 1fr); }

.pause-stats div, .fstat {
  background: rgba(12, 11, 10, 0.68);
  border: 1px solid rgba(118, 107, 87, 0.4);
  border-radius: 5px;
  padding: 9px 8px;
  text-align: center;
}
.pause-stats span, .fstat span {
  display: block;
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ash);
  text-transform: uppercase;
}
.pause-stats b, .fstat b {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--gold-bright);
}

.stack-actions { display: flex; flex-direction: column; gap: 8px; }
.finish-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
[data-device="phone"] .finish-actions { grid-template-columns: 1fr; }

.records-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.records-table th, .records-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(118, 107, 87, 0.25);
}
.records-table th {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 11.5px;
  text-transform: uppercase;
}

/* Portrait-Only Guard Overlay for Sideways Phones */
#rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 55;
  background: rgba(8, 7, 7, 0.94);
  display: grid;
  place-items: center;
  padding: 24px;
}

.rotate-card {
  max-width: 420px;
  text-align: center;
  background: var(--veil-panel);
  border: 1px solid var(--bronze-line);
  border-radius: 8px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rotate-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.45; }

/* ==========================================================================
   F2 BALANCE & TESTING DRAWER (Dark Souls Charcoal + Antique Gold)
   ========================================================================== */

.debug-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(310px, 90vw);
  height: 100vh;
  height: 100dvh;
  z-index: 70;
  background: rgba(14, 13, 12, 0.96);
  border-left: 1px solid var(--bronze-line);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.72);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.debug-panel.open { transform: translateX(0); }

.dbg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bronze-dim);
  font-family: var(--font-display);
  color: var(--gold-bright);
  font-weight: 700;
  font-size: 13px;
}
.dbg-x { background: transparent; border: none; color: var(--ash); font-size: 16px; cursor: pointer; }
.dbg-scroll { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.dbg-section { background: rgba(22, 20, 18, 0.85); border: 1px solid rgba(118, 107, 87, 0.28); border-radius: 6px; padding: 9px; }
.dbg-title { font-family: var(--font-display); font-size: 11px; font-weight: 700; color: var(--gold); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.06em; }
.dbg-btn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.dbg-btn-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.debug-panel button {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 6px;
  border-radius: 5px;
  border: 1px solid rgba(118, 107, 87, 0.42);
  background: rgba(28, 25, 22, 0.9);
  color: var(--ink);
  cursor: pointer;
}
.debug-panel button:hover { border-color: var(--gold); background: rgba(68, 54, 36, 0.55); }
.debug-panel button.accent { border-color: rgba(196, 86, 94, 0.65); color: #f0a8ae; }
.dbg-toggles { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.dbg-toggles label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.dbg-slider { margin-bottom: 6px; }
.dbg-slider label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 2px; }
.dbg-slider input[type="range"] { width: 100%; accent-color: var(--gold); }
.dbg-weapon-rows { display: flex; flex-direction: column; gap: 4px; }
.dbg-wrow { display: flex; justify-content: space-between; align-items: center; font-size: 11px; padding: 2px 0; }
.dbg-wrow div { display: flex; gap: 3px; }
.dbg-wrow button { padding: 2px 6px; font-size: 10px; }

/* Boot Loader */
#loader-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #08080a;
  display: grid;
  place-items: center;
}
.loader-card {
  width: min(320px, 88vw);
  text-align: center;
  background: var(--veil-panel);
  border: 1px solid var(--bronze-line);
  border-radius: 8px;
  padding: 22px;
}
