/* ============================================================
   HollowLight — styles for additive-display ARPG
   - body background is pure #000 (transparent on the additive
     display so the real world shows through)
   - UI surfaces use dark grays so they read as opaque overlays
   - Saturated rim-light accents look great on the waveguide
   ============================================================ */

:root {
  --bg-page:       #000000;   /* transparent on glasses */
  --bg-card:       #14141f;
  --bg-card-hi:    #1c1c2e;
  --bg-strip:      #0a0a12;
  --bg-overlay:    rgba(8, 8, 16, 0.78);

  --text:          #ffffff;
  --text-dim:      #c2c2d4;
  --text-muted:    #9a9ab0;

  --gold:          #ffc857;
  --crimson:       #ff4d6d;
  --crystal:       #6df1ff;
  --emerald:       #51e6a4;
  --violet:        #c489ff;
  --amber:         #ff9f43;

  --rarity-common:    #cfcfcf;
  --rarity-magic:     #6db4ff;
  --rarity-rare:      #ffe066;
  --rarity-unique:    #ff8c42;
  --rarity-mythic:    #f062ff;

  --focus-ring:    var(--crystal);
  --focus-glow:    rgba(109, 241, 255, 0.45);

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
/* Center the fixed 600x600 stage in the viewport. On the glasses the viewport IS
   exactly 600x600, so the stage fills it with zero offset and fitDesktop() applies no
   transform — the on-device layout is byte-for-byte unchanged. On PC/large screens the
   stage sits centered with even letterboxing and is uniformly scaled to fit by
   fitDesktop(). The phone path (body.touch-layout) opts OUT of this flex centering — it
   positions #app absolutely to reserve a control band at the bottom. */
body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 600px;
  height: 600px;
  position: relative;
  transform-origin: center center;
}

/* --- screens --------------------------------------------- */
.screen {
  width: 600px;
  height: 600px;
  position: absolute;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  animation: screenFadeIn 0.2s ease-out;
}
@keyframes screenFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

/* --- header ---------------------------------------------- */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--bg-strip), rgba(10,10,18,0.95));
  border-bottom: 1px solid rgba(109, 241, 255, 0.12);
  flex-shrink: 0;
  position: relative;
}
.header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109, 241, 255, 0.2), transparent);
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex: 1;
}
.header-meta {
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  text-shadow: 0 0 6px rgba(255, 200, 87, 0.2);
}
.back-btn {
  background: transparent;
  border: 2px solid transparent;
  color: var(--text);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- content --------------------------------------------- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(109, 241, 255, 0.25) transparent;
}
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: rgba(109, 241, 255, 0.3); border-radius: 2px; }

/* --- focus ring (critical for D-pad nav) ----------------- */
.focusable {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  outline: none;
}

/* --- nav-item (menu rows) -------------------------------- */
.nav-item {
  display: block;
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  scroll-margin: 14px 0;
}
.nav-item:focus { background: var(--bg-card-hi); border-color: var(--focus-ring); box-shadow: 0 0 18px var(--focus-glow); transform: translateX(3px); }
.nav-item.danger { color: var(--crimson); }
.nav-item.danger:focus { border-color: var(--crimson); box-shadow: 0 0 18px rgba(255, 77, 109, 0.3); }

/* =========================================================
   TITLE SCREEN
   ========================================================= */
.title-frame {
  width: 600px;
  height: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(109, 241, 255, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(196, 137, 255, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 200, 87, 0.02) 0%, transparent 40%);
}
/* ----- Title emblem: an eclipse of hollow light ----- */
.title-emblem {
  position: relative;
  width: 132px;
  height: 132px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.title-beam {
  position: absolute;
  left: 50%;
  top: -34px;
  width: 6px;
  height: 200px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent 4%, rgba(109,241,255,0.45) 50%, transparent 96%);
  border-radius: 3px;
  animation: titleBeam 4.2s ease-in-out infinite;
}
.title-glyph {
  width: 116px;
  height: 116px;
  position: relative;
  border-radius: 50%;
  /* hollow dark core — the light is around the void */
  background: radial-gradient(circle at 50% 46%, #02030a 48%, rgba(2,3,10,0) 72%);
  animation: titleFloat 5.5s ease-in-out infinite;
}
/* rotating corona ring — conic gradient masked into a thin ring */
.title-glyph::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--crystal), var(--violet), var(--gold), var(--crimson), var(--crystal));
  -webkit-mask: radial-gradient(circle, transparent 49%, #000 52%, #000 62%, transparent 65%);
          mask: radial-gradient(circle, transparent 49%, #000 52%, #000 62%, transparent 65%);
  animation: titleSpin 16s linear infinite;
}
/* static glow ring under the spinning corona (cheap — doesn't animate) */
.title-glyph {
  box-shadow: 0 0 22px rgba(109,241,255,0.35), inset 0 0 14px rgba(109,241,255,0.12);
}
/* soft outer halo */
.title-glyph::after {
  content: '';
  position: absolute;
  inset: -32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(109,241,255,0.16) 0%, rgba(196,137,255,0.06) 42%, transparent 64%);
  animation: titlePulse 3.6s ease-in-out infinite;
  z-index: -1;
}
@keyframes titleFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes titleBeam  { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.85; } }
@keyframes titlePulse {
  0%, 100% { transform: scale(1);    opacity: 0.9; }
  50%      { transform: scale(1.12); opacity: 1; }
}
@keyframes titleSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
/* drifting embers rising through the scene */
.title-embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.ember {
  position: absolute;
  bottom: -12px;
  border-radius: 50%;
  opacity: 0;
  animation-name: emberRise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes emberRise {
  0%   { transform: translateY(0) scale(0.5);      opacity: 0; }
  12%  { opacity: 0.9; }
  85%  { opacity: 0.45; }
  100% { transform: translateY(-610px) scale(1.1); opacity: 0; }
}
/* atmosphere */
.title-vignette {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 28%, rgba(0,0,0,0.55) 88%);
}
.title-divider {
  position: relative; z-index: 2;
  width: 210px; height: 1px;
  margin: 2px 0 16px;
  background: linear-gradient(90deg, transparent, var(--crystal), transparent);
  box-shadow: 0 0 8px rgba(109,241,255,0.45);
  opacity: 0.6;
}
/* keep foreground content above the ember/vignette layers */
.title-emblem, .title-name, .title-tagline, .title-menu { position: relative; z-index: 2; }
.title-hint { z-index: 2; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.title-name {
  font-size: 35px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 8px;
  white-space: nowrap;
  background: linear-gradient(180deg, #ffffff 0%, var(--crystal) 60%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleTextGlow 4s ease-in-out infinite;
}
@keyframes titleTextGlow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(109, 241, 255, 0.4)); }
  50%      { filter: drop-shadow(0 0 24px rgba(109, 241, 255, 0.7)); }
}
.title-tagline {
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 1.5px;
  margin-bottom: 32px;
  text-transform: uppercase;
}
.title-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
}
.title-btn {
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hi) 100%);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.2px;
  border: 2px solid rgba(109, 241, 255, 0.18);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.title-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(109, 241, 255, 0.06), transparent);
  transition: left 0.5s ease;
}
.title-btn:focus::before {
  left: 100%;
}
.title-btn:focus {
  background: linear-gradient(135deg, var(--bg-card-hi) 0%, rgba(30,40,60,1) 100%);
  border-color: var(--focus-ring);
  box-shadow: 0 0 22px var(--focus-glow), inset 0 0 12px rgba(109, 241, 255, 0.05);
  transform: scale(1.02);
}
.title-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.title-hint {
  position: absolute;
  bottom: 20px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* =========================================================
   CLASS SELECT
   ========================================================= */
.class-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.class-card {
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-strip) 100%);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 2px solid rgba(255,255,255,0.06);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.class-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.class-card:focus::after { opacity: 0.5; }
.class-card:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 22px var(--focus-glow);
  transform: scale(1.02);
  background: var(--bg-card-hi);
}
.class-portrait {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg-strip);
  position: relative;
  overflow: hidden;
}
.class-portrait::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 70%, currentColor 0%, transparent 55%);
  opacity: 0.3;
  animation: portraitGlow 3s ease-in-out infinite alternate;
}
@keyframes portraitGlow {
  from { opacity: 0.2; }
  to   { opacity: 0.4; }
}
.class-portrait-warrior  { color: var(--crimson); }
.class-portrait-mage     { color: var(--crystal); }
.class-portrait-ranger   { color: var(--emerald); }
.class-portrait-summoner { color: var(--violet); }
.class-portrait-paladin  { color: #ffd45e; }

.class-portrait::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--portrait-art, none) center/contain no-repeat;
}
.class-portrait-warrior::before  { content: '⚔'; font-size: 46px; display: flex; align-items: center; justify-content: center; color: var(--crimson); text-shadow: 0 0 16px var(--crimson), 0 0 32px rgba(255,77,109,0.3); }
.class-portrait-mage::before     { content: '✦'; font-size: 46px; display: flex; align-items: center; justify-content: center; color: var(--crystal); text-shadow: 0 0 16px var(--crystal), 0 0 32px rgba(109,241,255,0.3); }
.class-portrait-ranger::before   { content: '➹'; font-size: 46px; display: flex; align-items: center; justify-content: center; color: var(--emerald); text-shadow: 0 0 16px var(--emerald), 0 0 32px rgba(81,230,164,0.3); }
.class-portrait-summoner::before { content: '☠'; font-size: 46px; display: flex; align-items: center; justify-content: center; color: var(--violet); text-shadow: 0 0 16px var(--violet), 0 0 32px rgba(196,137,255,0.3); }
.class-portrait-paladin::before  { content: '✝'; font-size: 46px; display: flex; align-items: center; justify-content: center; color: #ffd45e; text-shadow: 0 0 16px #ffd45e, 0 0 32px rgba(255,212,94,0.3); }

.class-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
}
.class-tag {
  font-size: 11px;
  color: var(--crystal);
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.class-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* =========================================================
   ABOUT
   ========================================================= */
.about-body { gap: 10px; }
.about-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-dim);
}
.kbd {
  display: inline-block;
  min-width: 64px;
  text-align: center;
  padding: 6px 8px;
  background: var(--bg-strip);
  border: 1px solid rgba(109, 241, 255, 0.25);
  border-radius: 6px;
  color: var(--crystal);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
}
.about-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.5px;
}
.about-section-title {
  margin-top: 18px;
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--crystal);
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(109, 241, 255, 0.2);
  padding-bottom: 6px;
}
.about-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}
.about-card p {
  margin: 0 0 8px 0;
}
.about-card p:last-child {
  margin-bottom: 0;
}
.about-card ul, .about-card ol {
  margin: 6px 0;
  padding-left: 18px;
}
.about-card li {
  margin-bottom: 5px;
}
.about-card strong {
  color: #fff;
}
.about-section-title.focusable:focus,
.about-card.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
}

/* =========================================================
   GAME CANVAS + HUD
   ========================================================= */
#game { position: relative; }
#game-canvas {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
/* 3D layer sits at the bottom of the stack; GPU-filtered (no pixelated). */
#game-canvas-gl {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  display: none;          /* shown only when the 3D renderer mounts */
}
/* crisp 2D overlay for floating combat text, above the canvases, below the HUD */
#game-overlay-2d {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  display: none;          /* shown only when the 3D renderer mounts */
  pointer-events: none;
}
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.hud-buffs {
  position: absolute;
  top: 50px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
.hud-buff {
  background: rgba(8,8,16,0.85);
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid currentColor;
  text-shadow: 0 0 6px currentColor;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.hud-zone {
  background: linear-gradient(135deg, rgba(8,8,16,0.85), rgba(20,20,40,0.8));
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--crystal);
  border: 1px solid rgba(109, 241, 255, 0.3);
  text-shadow: 0 0 8px rgba(109, 241, 255, 0.5);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.hud-auto {
  margin-top: 4px;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #ffd45e;
  background: rgba(40,30,10,0.7);
  border: 1px solid rgba(255,212,94,0.5);
  text-shadow: 0 0 8px rgba(255,212,94,0.6);
  animation: autopulse 1.4s ease-in-out infinite;
}
@keyframes autopulse { 0%,100% { opacity: 0.65; } 50% { opacity: 1; } }
.hud-rift {
  background: linear-gradient(135deg, rgba(20,8,30,0.9), rgba(40,20,60,0.85));
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #d9c2ff;
  border: 1px solid rgba(179, 136, 255, 0.5);
  text-shadow: 0 0 8px rgba(179, 136, 255, 0.7);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  margin-top: 6px;
}
.hud-rift.hidden { display: none; }
.hud-rift.low {
  color: #ff8095;
  border-color: rgba(255, 80, 110, 0.7);
  text-shadow: 0 0 10px rgba(255, 80, 110, 0.8);
  animation: riftPulse 0.8s ease-in-out infinite;
}
@keyframes riftPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.hud-hollow {
  background: linear-gradient(135deg, rgba(28,10,36,0.92), rgba(54,20,72,0.88));
  padding: 6px 14px; border-radius: 16px; font-size: 13px; font-weight: 800; letter-spacing: 0.5px;
  color: #d3a7ff; border: 1px solid rgba(176, 107, 255, 0.6);
  text-shadow: 0 0 8px rgba(176, 107, 255, 0.8); backdrop-filter: blur(4px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4); margin-top: 6px;
}
.hud-hollow.hidden { display: none; }
.hud-hollow.high {
  color: #ff7be0; border-color: rgba(255, 90, 200, 0.75);
  text-shadow: 0 0 10px rgba(255, 90, 200, 0.85); animation: riftPulse 1.1s ease-in-out infinite;
}
.rift-card {
  background: linear-gradient(135deg, rgba(30,16,46,0.95), rgba(20,10,32,0.9));
  border: 1px solid rgba(179, 136, 255, 0.35);
}
.hud-minimap {
  background: linear-gradient(135deg, rgba(8,8,16,0.9), rgba(15,15,30,0.85));
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(109, 241, 255, 0.3);
  box-shadow: 0 2px 16px rgba(0,0,0,0.5), inset 0 0 8px rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
}
#minimap {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  opacity: 0.9;
}

.hud-bottom {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.hud-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #1a1a2e 0%, #0a0a12 100%);
  border: 2px solid rgba(255,255,255,0.18);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 18px rgba(0,0,0,0.7), inset 0 0 12px rgba(0,0,0,0.5);
}
.hud-orb-hp { border-color: rgba(255, 77, 109, 0.55); box-shadow: 0 0 18px rgba(0,0,0,0.7), 0 0 8px rgba(255,77,109,0.2); }
.hud-orb-mp { border-color: rgba(109, 241, 255, 0.55); box-shadow: 0 0 18px rgba(0,0,0,0.7), 0 0 8px rgba(109,241,255,0.2); }
.hud-orb-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: radial-gradient(circle at 50% 20%, rgba(255,255,255,0.35), transparent 55%),
              linear-gradient(180deg, rgba(255,90,120,1), rgba(200,30,60,0.95), rgba(120,10,30,0.95));
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: orbLiquid 3s ease-in-out infinite;
}
@keyframes orbLiquid {
  0%, 100% { border-radius: 40% 40% 0 0; }
  50%      { border-radius: 45% 35% 0 0; }
}
.hud-orb-mp .hud-orb-fill {
  background: radial-gradient(circle at 50% 20%, rgba(255,255,255,0.35), transparent 55%),
              linear-gradient(180deg, rgba(130,250,255,1), rgba(60,180,220,0.95), rgba(20,80,140,0.95));
}
.hud-orb::after {
  content: '';
  position: absolute;
  top: 8px; left: 14px;
  width: 18px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  pointer-events: none;
}
.hud-orb-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,1), 0 0 8px rgba(0,0,0,0.8);
}

.hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px 6px;
}
.hud-name {
  font-size: 12px;
  text-align: center;
  color: var(--text-dim);
  text-shadow: 0 0 6px #000;
}
.hud-name span { color: #fff; font-weight: 600; }
.hud-xp {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(109, 241, 255, 0.15);
}
.hud-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crystal), var(--violet), var(--crystal));
  background-size: 200% 100%;
  animation: xpShimmer 3s linear infinite;
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px var(--crystal), inset 0 -1px 2px rgba(0,0,0,0.3);
  border-radius: 3px;
}
@keyframes xpShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.hud-skill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(8,8,16,0.85), rgba(20,20,40,0.85));
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,200,87,0.15);
  margin-top: 2px;
  backdrop-filter: blur(4px);
}
.hud-skill-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold);
  background: rgba(255,200,87,0.08);
  border-radius: 8px;
  border: 1px solid rgba(255,200,87,0.2);
}
.hud-skill-name {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  flex: 1;
}
.hud-skill-cd {
  font-size: 11px;
  color: var(--crimson);
  font-weight: 700;
  min-width: 24px;
  text-align: right;
}
.hud-skill-cd.ready { color: var(--emerald); text-shadow: 0 0 6px var(--emerald); }

/* Floating damage text */
.floating-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.float-text {
  position: absolute;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0 0 4px #000, 0 0 4px #000;
  animation: floatUp 0.9s ease-out forwards;
  white-space: nowrap;
}
.float-text.dmg     { color: #fff; }
.float-text.crit    { color: var(--gold); font-size: 18px; }
.float-text.heal    { color: var(--emerald); }
.float-text.xp      { color: var(--crystal); font-size: 12px; }
.float-text.loot    { color: var(--gold); font-size: 12px; }
@keyframes floatUp {
  0%   { transform: translateY(0)   scale(1);   opacity: 1; }
  100% { transform: translateY(-32px) scale(1); opacity: 0; }
}

.hud-toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px) scale(0.95);
  background: linear-gradient(135deg, rgba(8,8,20,0.92), rgba(20,20,45,0.9));
  border: 1px solid rgba(109, 241, 255, 0.5);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--crystal);
  letter-spacing: 1.2px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 12px rgba(109, 241, 255, 0.1);
  text-shadow: 0 0 8px rgba(109, 241, 255, 0.4);
}
.hud-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* =========================================================
   INVENTORY / EQUIPMENT
   ========================================================= */
.equipped-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.equip-slot {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
}
.equip-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.equip-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}
.inv-consumables {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  margin-bottom: 4px;
  background: var(--bg-strip);
  border: 1px solid rgba(109, 241, 255, 0.10);
  border-radius: var(--radius-md);
}
.consum-chip {
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 9px;
  background: var(--bg-card);
  border-radius: 999px;
  white-space: nowrap;
}
.consum-chip b { color: #fff; font-weight: 700; }
.inv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.inv-row:focus { background: var(--bg-card-hi); border-color: var(--focus-ring); box-shadow: 0 0 18px var(--focus-glow); }
.inv-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, var(--bg-card-hi), var(--bg-strip));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.06);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  overflow: hidden;
}
.inv-icon svg {
  width: 28px;
  height: 28px;
}
.inv-meta { flex: 1; min-width: 0; }
.inv-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-sub {
  font-size: 11px;
  color: var(--text-dim);
}
.inv-equipped {
  font-size: 11px;
  color: var(--emerald);
  font-weight: 700;
  letter-spacing: 1px;
}
.inv-row.disabled {
  opacity: 0.55;
}
.inv-row.disabled:focus {
  opacity: 0.75;
}
.sell-all-row {
  border-color: rgba(255, 200, 80, 0.35);
  background: linear-gradient(90deg, rgba(255, 200, 80, 0.08), transparent);
  margin-bottom: 8px;
}

/* rarity colors */
.rarity-common  { color: var(--rarity-common); }
.rarity-magic   { color: var(--rarity-magic); }
.rarity-rare    { color: var(--rarity-rare); }
.rarity-unique  { color: var(--rarity-unique); }
.rarity-mythic  { color: var(--rarity-mythic); text-shadow: 0 0 8px rgba(240, 98, 255, 0.6); }

/* item detail */
.item-card {
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.06);
}
.item-card .item-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.item-card .item-type {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.item-card .item-affix {
  font-size: 13px;
  color: var(--crystal);
  margin-top: 4px;
}
.item-card .item-flavor {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 10px;
}
.item-actions {
  display: flex;
  gap: 8px;
}
.item-actions .nav-item { flex: 1; }

/* =========================================================
   CHARACTER SHEET
   ========================================================= */
.char-portrait {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-md);
  background: radial-gradient(ellipse at 50% 70%, var(--bg-card-hi), var(--bg-strip));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 -20px 40px rgba(0,0,0,0.3);
}
.char-portrait::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 90%, rgba(109, 241, 255, 0.06), transparent 50%);
}
.char-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.stat-row .stat-label { color: var(--text-dim); }
.stat-row .stat-value { color: var(--text); font-weight: 700; text-align: right; }
.stat-sub { font-size: 10px; color: var(--text-dim); font-weight: 400; letter-spacing: 0.3px; }
.delta-up   { color: #51e6a4; }
.delta-down { color: #ff6677; }
.char-points-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.char-points-row .nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.char-points-row .pts {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 1px;
}

/* =========================================================
   SKILL SCREEN
   ========================================================= */
.skill-card {
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.06);
}
.skill-card .skill-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--gold);
}
.skill-card .skill-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}
.skill-card .skill-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  opacity: 0.7;
}
.skill-card.skill-active {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(255, 200, 87, 0.25);
}
.skill-card.disabled {
  opacity: 0.5;
}
.skill-card:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
}
.skill-card + .skill-card {
  margin-top: 10px;
}
.skill-header {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Skill runes */
.rune-badge {
  font-size: 12px;
  font-weight: 700;
  color: #b388ff;
  text-shadow: 0 0 6px rgba(179,136,255,0.6);
}
.rune-section { margin-top: 16px; }
.rune-chips { display: flex; flex-direction: column; gap: 8px; }
.rune-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid rgba(179, 136, 255, 0.18);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text);
}
.rune-chip:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 14px var(--focus-glow); }
.rune-chip.rune-on {
  border-color: #b388ff;
  box-shadow: 0 0 10px rgba(179, 136, 255, 0.35);
  background: linear-gradient(135deg, var(--bg-card), rgba(40, 24, 60, 0.6));
}
.rune-chip-name { font-size: 15px; font-weight: 700; color: #d9c2ff; }
.rune-chip-desc { font-size: 12px; color: var(--text-dim); }

/* Difficulty selector (Waystone) */
.diff-selector { margin-bottom: 14px; }
.diff-label { font-size: 12px; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 6px; }
.diff-chips { display: flex; gap: 8px; }
.diff-chip {
  flex: 1;
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.diff-chip:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 14px var(--focus-glow); }
.diff-chip.diff-on { border-color: var(--gold); background: rgba(255, 200, 87, 0.12); box-shadow: 0 0 12px rgba(255, 200, 87, 0.35); color: #fff; }
.diff-chip.locked { opacity: 0.4; cursor: default; font-size: 12px; }

/* Permanent upgrades (gold sink) */
.upgrade-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 200, 87, 0.15);
  margin-bottom: 10px;
}
.upgrade-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--gold);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, var(--bg-card-hi), var(--bg-strip));
  text-shadow: 0 0 8px rgba(255,200,87,0.5);
}
.upgrade-meta { flex: 1; min-width: 0; }
.upgrade-name { font-size: 16px; font-weight: 700; color: #fff; }
.upgrade-lvl { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.upgrade-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.up-pips { display: flex; gap: 4px; margin-top: 6px; }
.up-pip { width: 16px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.12); }
.up-pip.on { background: var(--gold); box-shadow: 0 0 6px rgba(255,200,87,0.6); }
.upgrade-buy {
  flex-shrink: 0;
  padding: 10px 14px;
  font-size: 14px; font-weight: 800;
  color: var(--gold);
  background: var(--bg-card-hi);
  border: 1px solid rgba(255,200,87,0.4);
  border-radius: 8px;
  cursor: pointer;
}
.upgrade-buy:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 14px var(--focus-glow); }
.upgrade-buy.disabled { opacity: 0.4; cursor: default; }
.upgrade-maxed {
  flex-shrink: 0; padding: 10px 14px;
  font-size: 13px; font-weight: 800; letter-spacing: 1px;
  color: #51e6a4;
}

/* =========================================================
   QUESTS
   ========================================================= */
.quest-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(20,20,35,1) 100%);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
}
.quest-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--crystal), var(--violet));
  border-radius: 2px;
}
.quest-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.quest-prog {
  font-size: 12px;
  color: var(--crystal);
  margin-bottom: 4px;
  font-weight: 600;
}
.quest-prog.done { color: var(--emerald); text-shadow: 0 0 6px rgba(81, 230, 164, 0.3); }
.quest-reward {
  font-size: 11px;
  color: var(--gold);
  text-shadow: 0 0 4px rgba(255, 200, 87, 0.2);
}
.quest-card.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 30px;
}

/* =========================================================
   DIALOG
   ========================================================= */
.dialog-portrait {
  width: 100%;
  height: 100px;
  background: radial-gradient(circle at 50% 60%, var(--bg-card-hi), var(--bg-strip));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
}
.dialog-portrait::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 80%, rgba(109, 241, 255, 0.05), transparent 60%);
}
.dialog-line {
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  border-left: 3px solid var(--crystal);
}
.dialog-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* =========================================================
   VENDOR / STASH
   ========================================================= */
.vendor-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.vendor-tab {
  flex: 1;
  padding: 10px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
}
.vendor-tab:focus {
  background: var(--bg-card-hi);
  border-color: var(--focus-ring);
  box-shadow: 0 0 14px var(--focus-glow);
}
.vendor-tab.active {
  border-color: var(--crystal);
  background: var(--bg-card-hi);
  box-shadow: inset 0 -2px 0 var(--crystal), 0 0 10px var(--focus-glow);
  color: #fff;
}

/* =========================================================
   WAYPOINT
   ========================================================= */
.waypoint-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: left;
}
.waypoint-card:focus { border-color: var(--focus-ring); box-shadow: 0 0 18px var(--focus-glow); }
.waypoint-card.locked { opacity: 0.45; cursor: default; }

/* ===== Abyss boon draft ===== */
.abyss-intro { color: #b9b9d0; font-size: 13px; margin: 8px 4px 14px; line-height: 1.4; }
.boon-card { display: block; width: 100%; text-align: left; background: rgba(20,16,32,0.62);
  border: 2px solid #555; border-radius: 10px; padding: 13px 16px; margin: 0 0 12px; cursor: pointer; }
.boon-card.focused, .boon-card:focus { outline: none; background: rgba(44,32,66,0.9); box-shadow: 0 0 18px var(--focus-glow); }
.boon-tag { font-size: 10px; letter-spacing: 2px; opacity: 0.85; margin-bottom: 3px; }
.boon-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.boon-desc { font-size: 13px; color: #c8c8d8; line-height: 1.35; }
.gamble-result { margin: 0 4px 14px; font-size: 15px; padding: 8px 12px; background: rgba(255,154,60,0.1); border-radius: 8px; }
/* The Journey */
.journey-records { font-size: 12px; color: #b9b9d0; margin: 4px 4px 14px; padding: 8px 12px; background: rgba(20,16,32,0.5); border-radius: 8px; line-height: 1.5; }
.journey-chapter { margin: 0 0 16px; padding: 12px 14px; background: rgba(20,16,32,0.45); border: 1px solid #333; border-radius: 10px; }
.journey-chapter h3 { margin: 0 0 8px; font-size: 15px; }
.journey-obj { font-size: 13px; color: #9a9ab0; padding: 3px 0; display: flex; align-items: center; gap: 7px; }
.journey-obj.done { color: #cfe3ff; }
.jo-check { color: #555; font-weight: 700; }
.journey-obj.done .jo-check { color: #7dffb0; }
.jo-prog { margin-left: auto; opacity: 0.7; font-size: 12px; }
.journey-reward { margin-top: 8px; font-size: 12px; color: #8a8aa0; }
.journey-claimed { margin-top: 8px; font-size: 13px; color: #7dffb0; font-weight: 600; }
.primal-tag { color: #ff9a3c; font-weight: 800; text-shadow: 0 0 8px rgba(255,154,60,0.7); letter-spacing: 1px; }
/* Factions */
.faction-card { margin: 0 0 16px; padding: 12px 14px; background: rgba(20,16,32,0.45); border: 1px solid #333; border-radius: 10px; }
.faction-card h3 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.faction-rank { font-size: 11px; font-weight: 700; color: #cfe3ff; background: rgba(255,255,255,0.08); padding: 2px 8px; border-radius: 10px; }
.faction-blurb { font-size: 12px; color: #9a9ab0; margin-bottom: 8px; line-height: 1.4; }
.faction-bar { height: 8px; background: rgba(0,0,0,0.4); border-radius: 5px; overflow: hidden; margin-bottom: 4px; }
.faction-bar-fill { height: 100%; border-radius: 5px; transition: width 0.3s; }
.faction-next { font-size: 11px; color: #8a8aa0; }
.faction-perk { margin-top: 8px; font-size: 12px; color: #6a6a80; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); }
.faction-perk.active { color: #ffd45e; font-weight: 600; }
/* Story interlude */
#story { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(28,18,44,0.96), rgba(6,4,12,0.99)); }
.story-inner { max-width: 560px; padding: 24px 28px; text-align: center; animation: storyFade 1s ease; }
.story-title { font-size: 22px; color: #e8d9ff; margin: 0 0 18px; letter-spacing: 0.5px; text-shadow: 0 0 16px rgba(176,107,255,0.5); }
.story-text { font-size: 15px; line-height: 1.7; color: #c3bcd6; margin: 0 0 26px; font-style: italic; }
.story-continue { background: linear-gradient(135deg, #7a4fd0, #4a2f8a); color: #fff; border: 1px solid rgba(176,107,255,0.6); padding: 11px 30px; border-radius: 22px; font-size: 15px; font-weight: 700; cursor: pointer; }
.story-continue:focus, .story-continue:hover { box-shadow: 0 0 0 3px rgba(176,107,255,0.5); outline: none; }
@keyframes storyFade { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
/* Chronicle */
.chronicle-act { margin: 0 0 16px; padding: 12px 16px; background: rgba(20,16,32,0.5); border-left: 3px solid #b06bff; border-radius: 8px; }
.chronicle-act h3 { margin: 0 0 6px; font-size: 15px; color: #e8d9ff; }
.chronicle-act p { margin: 0; font-size: 13px; line-height: 1.6; color: #b3acc6; font-style: italic; }
.chronicle-act.locked { border-left-color: #444; opacity: 0.6; }
.chronicle-act.locked h3 { color: #888; }
.chronicle-act.locked p { font-style: normal; color: #777; }
.reforge-modes { display: flex; gap: 8px; margin-top: 10px; }
.reforge-mode { flex: 1; padding: 7px 6px; font-size: 12px; border: 1px solid #555; border-radius: 7px; background: rgba(30,24,44,0.5); color: #c8c8d8; cursor: pointer; }
.reforge-mode.active { border-color: var(--gold); color: var(--gold); background: rgba(255,200,87,0.12); }
.reforge-mode:focus { outline: none; box-shadow: 0 0 12px var(--focus-glow); }
.stash-filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.stash-filter { padding: 5px 10px; font-size: 11px; border: 1px solid #555; border-radius: 12px; background: rgba(30,24,44,0.5); color: #c8c8d8; cursor: pointer; }
.stash-filter.active { border-color: var(--accent, #6df1ff); color: var(--accent, #6df1ff); }
.stash-filter:focus { outline: none; box-shadow: 0 0 10px var(--focus-glow); }
.waypoint-glyph {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: radial-gradient(circle at 50% 40%, var(--bg-card-hi), var(--bg-strip));
  flex-shrink: 0;
  border: 1px solid rgba(109, 241, 255, 0.12);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.waypoint-meta { flex: 1; min-width: 0; }
.waypoint-name { font-size: 23px; font-weight: 800; letter-spacing: 0.3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.waypoint-sub  { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

/* =========================================================
   BESTIARY
   ========================================================= */
.bestiary-section { margin-bottom: 18px; }
.bestiary-biome {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 4px 0 8px;
}
.bestiary-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(109, 241, 255, 0.08);
  margin-bottom: 8px;
}
.bestiary-entry.boss {
  border-color: rgba(255, 170, 0, 0.4);
  background: linear-gradient(135deg, var(--bg-card), rgba(40, 28, 10, 0.6));
}
.bestiary-entry.unknown { opacity: 0.6; }
.bestiary-glyph {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, var(--bg-card-hi), var(--bg-strip));
  border: 1px solid rgba(255,255,255,0.06);
}
.bestiary-meta { flex: 1; min-width: 0; }
.bestiary-name { font-size: 17px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.bestiary-boss-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffaa00;
  border: 1px solid rgba(255,170,0,0.5);
  border-radius: 4px;
  padding: 1px 5px;
}
.bestiary-lore { font-size: 12px; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.bestiary-kills {
  font-size: 16px;
  font-weight: 800;
  color: #ffc857;
  flex-shrink: 0;
  min-width: 38px;
  text-align: right;
}

/* =========================================================
   CRAFTING BENCH
   ========================================================= */
.craft-header {
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(109, 241, 255, 0.12);
}
.craft-header.hidden { display: none; }
.craft-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(109, 241, 255, 0.08);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.craft-info { display: flex; align-items: center; gap: 10px; }
.craft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.craft-btn {
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-card-hi);
  color: var(--text);
  border: 1px solid rgba(109, 241, 255, 0.25);
  cursor: pointer;
  white-space: nowrap;
}
.craft-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 14px var(--focus-glow);
  outline: none;
}
.craft-btn.danger { border-color: rgba(255, 100, 120, 0.4); color: #ff8095; }
.craft-btn.disabled { opacity: 0.4; cursor: default; }

/* =========================================================
   DEATH / LEVEL UP
   ========================================================= */
.death-frame, .levelup-frame {
  width: 600px;
  height: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px;
  position: relative;
}
.death-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(255,77,109,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.levelup-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(255,200,87,0.1) 0%, transparent 60%);
  pointer-events: none;
  animation: levelupBg 2s ease-in-out infinite;
}
@keyframes levelupBg {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}
.death-glyph {
  font-size: 80px;
  color: var(--crimson);
  text-shadow: 0 0 30px var(--crimson), 0 0 60px rgba(255,77,109,0.3);
  animation: deathShake 0.5s ease-out;
}
@keyframes deathShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(1deg); }
  60% { transform: translateX(-3px) rotate(-1deg); }
  80% { transform: translateX(2px); }
}
.levelup-glyph {
  font-size: 80px;
  color: var(--gold);
  text-shadow: 0 0 30px var(--gold), 0 0 60px rgba(255,200,87,0.4);
  animation: levelupGlyph 2s ease-in-out infinite;
}
@keyframes levelupGlyph {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.12) rotate(3deg); }
}
.death-title, .levelup-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.death-title { color: var(--crimson); }
.levelup-title { color: var(--gold); }
.death-sub, .levelup-sub { font-size: 13px; color: var(--text-dim); max-width: 360px; line-height: 1.5; }

/* ============================================================
   TOUCH CONTROLS — virtual D-pad + pinch button for phone play.
   Hidden by default; only shown when user enables in menu.
   Glasses keyboard input is completely unaffected.
   ============================================================ */
/* Body-level fixed overlay so the controls sit in the reserved band BELOW the scaled
   game on phones (and at the bottom of the 600x600 stage on desktop toggle / glasses). */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none; /* parent passes touches; children opt in */
  z-index: 1000;
}
.touch-dpad {
  position: absolute;
  left: 16px;
  bottom: 12px;
  width: 192px;
  height: 192px;
  pointer-events: none;
}

/* ---- Phone responsive layout (body.touch-layout, set only on touchscreens) ----
   Scale the 600x600 stage to fit the screen width, pinned top-centre, leaving the
   bottom band for the controls. Glasses/desktop never get this class, so their fixed
   600x600 viewport + layout is completely unchanged. The transform is set by fitApp(). */
html, body { height: 100%; }
body.touch-layout {
  display: block;        /* opt out of the flex centering; #app is positioned absolutely below */
  min-height: 100vh;
  background: #05060a;
  overflow: hidden;
}
body.touch-layout #app {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;   /* fitApp() sets explicit left/top; the scale grows from the corner */
}
.touch-btn {
  pointer-events: auto;
  background: rgba(8, 8, 16, 0.55);
  border: 1.5px solid rgba(109, 241, 255, 0.45);
  color: var(--crystal);
  font-size: 22px;
  font-weight: 700;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  touch-action: none; /* don't fight with the browser for gestures */
  transition: transform 60ms ease-out, background 60ms;
}
.touch-btn:active {
  background: rgba(20, 70, 100, 0.85);
  transform: scale(0.92);
}
.touch-dpad .touch-btn {
  position: absolute;
  width: 64px;
  height: 64px;
  font-size: 26px;
}
.touch-up    { left: 64px; top: 0;    }
.touch-left  { left: 0;    top: 64px; }
.touch-right { left: 128px; top: 64px; }
.touch-down  { left: 64px; top: 128px; }
.touch-pinch {
  position: absolute;
  right: 24px;
  bottom: 46px;
  width: 104px;
  height: 104px;
  font-size: 40px;
  border-color: rgba(255, 200, 87, 0.55);
  color: var(--gold);
}
/* Menu (pause/inventory) button — phone players reach the in-game menu here
   instead of the ↑↓↑↓ wiggle gesture they can't perform on a touchscreen. */
.touch-menu {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 78px;
  width: 84px;
  height: 48px;
  border-radius: 24px;
  font-size: 24px;
  pointer-events: auto;
  border-color: rgba(155, 208, 255, 0.5);
}
.touch-menu:active { transform: translateX(-50%) scale(0.92); }

/* ============================================================
   SAVE SYNC SCREEN
   ============================================================ */
.sync-help {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0 0 14px 0;
  padding: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}
.sync-section {
  background: var(--bg-card);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.sync-section h3 {
  font-size: 12px;
  margin: 0 0 8px 0;
  color: var(--crystal);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.sync-box {
  width: 100%;
  min-height: 90px;
  background: var(--bg-strip);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: monospace;
  font-size: 10px;
  padding: 8px;
  resize: vertical;
  margin: 8px 0;
  white-space: pre;
  word-break: break-all;
}
.sync-code {
  margin: 10px 0;
  padding: 14px;
  background: var(--bg-strip);
  border: 1px solid rgba(109, 241, 255, 0.35);
  border-radius: var(--radius-sm);
  color: var(--crystal);
  font-family: monospace;
  font-size: 22px;
  letter-spacing: 3px;
  text-align: center;
  font-weight: 700;
  min-height: 30px;
  user-select: all;
  -webkit-user-select: all;
}
.sync-code.muted {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 400;
}
.sync-short-input {
  width: 100%;
  background: var(--bg-strip);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: monospace;
  font-size: 18px;
  padding: 12px;
  margin: 8px 0;
  text-align: center;
  letter-spacing: 2px;
  text-transform: none;
  outline: none;
}
.sync-short-input:focus {
  border-color: var(--crystal);
  box-shadow: 0 0 6px rgba(109, 241, 255, 0.4);
}
.sync-fallback {
  margin-top: 14px;
}
.sync-fallback summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 11px;
  padding: 6px;
  list-style: none;
}
.sync-fallback summary::-webkit-details-marker { display: none; }
.sync-fallback summary::before { content: "▸ "; }
.sync-fallback[open] summary::before { content: "▾ "; }

/* ============================================================
   D-PAD CODE PICKER — CD-key-style text entry for glasses
   ============================================================ */
.picker-slots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 24px 0 12px 0;
  flex-wrap: wrap;
}
.picker-slot {
  width: 44px;
  height: 58px;
  border: 2px solid rgba(109, 241, 255, 0.25);
  border-radius: 6px;
  background: var(--bg-strip);
  color: var(--text);
  font-family: monospace;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 80ms, box-shadow 80ms, transform 80ms;
}
.picker-slot.active {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 200, 87, 0.45);
  color: var(--gold);
  transform: translateY(-3px);
}
.picker-help {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  margin: 0 0 8px 0;
  line-height: 1.5;
}
.picker-status {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 14px 0;
  min-height: 14px;
}
