/* ============================================================
   EIDOLON'S REALM — DM SCREEN
   Design system (HUD operativo) — fedele al sito marketing
   Mobile-first. Tab bar bottom. Dark cyberpunk noir.
   ============================================================ */

:root {
  /* Core palette (dal sito) */
  --bg-void: #050508;
  --bg-deep: #0a0a12;
  --bg-card: #101018;
  --bg-elevated: #181826;
  --bg-input: #0d0d16;
  --cyan: #00e5cc;
  --cyan-dim: rgba(0, 229, 204, 0.15);
  --cyan-glow: rgba(0, 229, 204, 0.40);
  --violet: #7c3aed;
  --violet-dim: rgba(124, 58, 237, 0.15);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.15);
  --green: #16a34a;
  --amber: #d97706;
  --white: #f0f0f8;
  --grey: #8b8ba0;
  --grey-dim: #2a2a3a;
  --line: rgba(0, 229, 204, 0.14);
  --line-soft: rgba(255, 255, 255, 0.07);

  /* Shard colors */
  --azurith: #00aaff;
  --oblivara: #9333ea;
  --miravex: #10b981;
  --solith: #f59e0b;
  --zerathel: #ec4899;
  --eidolon: #dc2626;

  /* Fonts */
  --f-display: 'Orbitron', system-ui, sans-serif;
  --f-head: 'Rajdhani', system-ui, sans-serif;
  --f-body: 'Inter', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Layout */
  --header-h: 52px;
  --tabbar-h: 64px;
  --radius: 10px;
  --radius-sm: 7px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: var(--radius-sm); }
.input:focus-visible { outline: none; }

body {
  font-family: var(--f-body);
  background: var(--bg-void);
  color: var(--white);
  line-height: 1.5;
  overflow: hidden;               /* lo scroll vive in <main> */
  overscroll-behavior: none;
  position: relative;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Ambient cyberpunk background (fisso, dietro tutto) */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 12%, rgba(0,229,204,0.08) 0%, transparent 58%),
    radial-gradient(ellipse 60% 60% at 88% 85%, rgba(124,58,237,0.09) 0%, transparent 55%),
    radial-gradient(circle, rgba(0,229,204,0.05) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 38px 38px;
  pointer-events: none;
  z-index: 0;
}
/* Scanlines overlay. Promote to its own GPU layer (translateZ) so that
   canvases updating beneath it (WebGL dice, dashboard particles) are simply
   composited — NOT re-painted full-screen every frame. No mix-blend-mode:
   blending forced a costly per-frame recomposite over the canvas. */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,229,204,0.018) 2px, rgba(0,229,204,0.018) 4px);
  pointer-events: none;
  z-index: 9999;
  transform: translateZ(0);
}

img { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
::selection { background: var(--cyan-dim); color: var(--white); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--grey-dim); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Typography helpers ===== */
.t-display { font-family: var(--f-display); font-weight: 900; letter-spacing: -0.01em; }
.t-head    { font-family: var(--f-head); font-weight: 700; letter-spacing: 0.01em; }
.t-mono    { font-family: var(--f-mono); }
.t-label   { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); }
.glow      { text-shadow: 0 0 14px var(--cyan-glow), 0 0 28px rgba(0,229,204,0.18); animation: glowPulse 3.6s ease-in-out infinite; }
@keyframes glowPulse { 0%,100% { text-shadow: 0 0 14px var(--cyan-glow), 0 0 28px rgba(0,229,204,0.18); } 50% { text-shadow: 0 0 22px rgba(0,229,204,0.55), 0 0 38px rgba(0,229,204,0.28); } }
.muted     { color: var(--grey); }

/* ============================================================
   APP SHELL
   ============================================================ */
#app { position: relative; z-index: 1; height: 100dvh; display: flex; flex-direction: column; }

/* Header */
.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 14px 0;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(10,10,18,0.97), rgba(10,10,18,0.82));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0; position: relative; z-index: 5;
}
.app-header .logo {
  font-family: var(--f-display); font-weight: 900; font-size: 0.95rem;
  letter-spacing: 0.02em; color: var(--white); display: flex; align-items: center; gap: 7px;
}
.app-header .logo b { color: var(--cyan); }
.app-header .logo .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.45;transform:scale(.8)} }
.app-header .view-title { margin-left: auto; font-family: var(--f-head); font-weight: 700; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--grey); }

/* Main scroll area */
.app-main {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  scroll-behavior: smooth;
}

/* Views */
.view { display: none; animation: viewIn 0.32s var(--ease); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 14px; }
.view-head h1 { font-family: var(--f-display); font-weight: 900; font-size: 1.5rem; line-height: 1.1; }
.view-head p { color: var(--grey); font-size: 0.85rem; margin-top: 3px; }

/* ============================================================
   BOTTOM TAB BAR
   ============================================================ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch;
  background: linear-gradient(0deg, rgba(8,8,14,0.99), rgba(12,12,20,0.95));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 26px rgba(0,0,0,0.5);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--grey); font-size: 0.6rem; font-family: var(--f-head); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; position: relative;
  transition: color 0.2s var(--ease); padding: 6px 2px;
}
.tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; transition: transform 0.25s var(--ease); }
.tabbar button.active { color: var(--cyan); }
.tabbar button.active svg { transform: translateY(-1px); filter: drop-shadow(0 0 7px var(--cyan-glow)); }
.tabbar button.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 2px; background: var(--cyan); border-radius: 2px; box-shadow: 0 0 8px var(--cyan);
}
.tabbar button:active { transform: scale(0.92); }

/* ============================================================
   COMPONENTS
   ============================================================ */
/* Card / panel */
.card {
  background: linear-gradient(160deg, var(--bg-card), var(--bg-deep));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; position: relative; overflow: hidden;
}
.card.glowable:active { border-color: var(--line); box-shadow: 0 0 18px rgba(0,229,204,0.18); }
.card .corner { position: absolute; top: 0; right: 0; width: 26px; height: 26px; border-top: 2px solid var(--cyan); border-right: 2px solid var(--cyan); opacity: 0.5; border-top-right-radius: var(--radius); }

.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius-sm); font-family: var(--f-head);
  font-weight: 700; font-size: 0.9rem; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--bg-elevated); color: var(--white); border: 1px solid var(--line-soft);
  transition: all 0.18s var(--ease); -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: linear-gradient(135deg, var(--cyan), #00b8a4); color: #04161a; border: none; box-shadow: 0 0 18px rgba(0,229,204,0.32); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--cyan); }
.btn-danger { background: var(--red-dim); border: 1px solid rgba(220,38,38,0.4); color: #ff6b6b; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.78rem; }
.btn-icon { padding: 10px; width: 42px; height: 42px; }

/* Inputs */
.input, textarea.input, select.input {
  width: 100%; padding: 11px 13px; background: var(--bg-input);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  color: var(--white); font-size: 0.95rem; transition: border-color 0.18s var(--ease);
}
.input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.6; }
.field-label { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--grey); margin-bottom: 5px; display: block; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-family: var(--f-mono); font-size: 0.68rem; font-weight: 500; letter-spacing: 0.04em; background: var(--bg-elevated); border: 1px solid var(--line-soft); }
.badge-cr { background: var(--cyan-dim); border-color: var(--line); color: var(--cyan); font-weight: 700; }
.badge-danger { background: var(--red-dim); border-color: rgba(220,38,38,0.4); color: #ff7a7a; }
.chip { display: inline-flex; padding: 5px 11px; border-radius: 8px; background: var(--bg-elevated); border: 1px solid var(--line-soft); font-size: 0.78rem; font-family: var(--f-head); font-weight: 600; white-space: nowrap; }
.chip.active { background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan); }

/* Search */
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar input { padding-left: 38px; }
.searchbar svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; stroke: var(--grey); fill: none; stroke-width: 2; }

/* Horizontal scroll filter row */
.filter-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }

/* Section label */
.section-label { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); margin: 18px 0 9px; display: flex; align-items: center; gap: 8px; }
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

/* Empty / placeholder */
.placeholder { text-align: center; padding: 40px 18px; color: var(--grey); }
.placeholder .ph-icon { font-size: 2.4rem; margin-bottom: 10px; opacity: 0.5; }
.placeholder h3 { font-family: var(--f-head); font-weight: 700; color: var(--white); margin-bottom: 6px; }
.placeholder p { font-size: 0.85rem; line-height: 1.6; max-width: 320px; margin: 0 auto; }

/* Modal / widget sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(2,2,6,0.74); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 0.28s var(--ease); }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101; max-height: 88dvh;
  background: var(--bg-deep); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
  transform: translateY(100%); transition: transform 0.34s var(--ease);
  display: flex; flex-direction: column; padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--grey-dim); border-radius: 4px; margin: 9px auto 4px; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px 12px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }
.sheet-head h2 { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; flex: 1; }
.sheet-body { overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.sheet-close { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-elevated); display: grid; place-items: center; color: var(--grey); font-size: 1.2rem; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); transform: translateX(-50%) translateY(20px); z-index: 200; background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 10px; padding: 11px 18px; font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.3s var(--ease); box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Stat grid (statblock ability scores) */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0; }
.stat-cell { background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 7px; padding: 7px 3px; text-align: center; }
.stat-cell .ab { font-family: var(--f-mono); font-size: 0.6rem; letter-spacing: 0.1em; color: var(--grey); }
.stat-cell .val { font-family: var(--f-mono); font-weight: 700; font-size: 0.95rem; color: var(--white); }
.stat-cell .mod { font-family: var(--f-mono); font-size: 0.68rem; color: var(--cyan); }

/* Vitals row (AC / HP / Speed) */
.vitals { display: flex; gap: 8px; margin: 10px 0; }
.vital { flex: 1; background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 8px; padding: 9px; text-align: center; }
.vital .lbl { font-family: var(--f-mono); font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grey); }
.vital .num { font-family: var(--f-mono); font-weight: 700; font-size: 1.35rem; color: var(--cyan); line-height: 1.2; }

/* Utility */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; } .mt-lg { margin-top: 20px; }
.hidden { display: none !important; }
.text-c { text-align: center; }
.spinner { width: 26px; height: 26px; border: 2px solid var(--grey-dim); border-top-color: var(--cyan); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 640px) {
  .app-main { padding-left: max(14px, calc((100% - 760px) / 2)); padding-right: max(14px, calc((100% - 760px) / 2)); }
  .tabbar button { font-size: 0.66rem; }
}
/* ===== Boot screen ===== */
#boot { position: fixed; inset: 0; z-index: 10000; background: radial-gradient(ellipse at 50% 45%, #0a1418, #050508 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity .7s var(--ease), visibility .7s; }
#boot.done { opacity: 0; visibility: hidden; }
#boot::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,229,204,.03) 3px, rgba(0,229,204,.03) 4px); pointer-events: none; }
.boot-core { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.boot-ring { position: absolute; inset: 0; border: 2px solid var(--cyan); border-right-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; box-shadow: 0 0 22px var(--cyan-glow); }
.boot-diamond { width: 32px; height: 32px; background: var(--cyan); transform: rotate(45deg); box-shadow: 0 0 26px var(--cyan-glow); animation: pulse 1.4s var(--ease) infinite; }
.boot-title { font-family: var(--f-display); font-weight: 900; font-size: 1.5rem; letter-spacing: .06em; color: #fff; text-shadow: 0 0 18px var(--cyan-glow); }
.boot-status { font-family: var(--f-mono); font-size: .66rem; letter-spacing: .2em; color: var(--cyan); text-transform: uppercase; animation: pulse 1.6s infinite; }
.boot-bar { width: 160px; height: 3px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: bootbar 1.5s var(--ease) forwards; }
@keyframes bootbar { to { width: 100%; } }

/* ===== Screen flash + shake ===== */
.screen-flash { position: fixed; inset: 0; z-index: 9000; pointer-events: none; opacity: 0; }
.screen-flash.go.crit { animation: flashCrit .66s ease-out; }
.screen-flash.go.fail { animation: flashFail .66s ease-out; }
@keyframes flashCrit { 0% { opacity: 0; } 25% { opacity: 1; box-shadow: inset 0 0 100px rgba(0,229,204,.55), inset 0 0 260px rgba(0,229,204,.28); } 100% { opacity: 0; } }
@keyframes flashFail { 0% { opacity: 0; } 15% { opacity: 1; box-shadow: inset 0 0 100px rgba(220,38,38,.6); } 30% { opacity: .5; } 45% { opacity: 1; } 100% { opacity: 0; } }
.shake { animation: shake .45s var(--ease); }
@keyframes shake { 10%,90% { transform: translateX(-1px); } 20%,80% { transform: translateX(2px); } 30%,50%,70% { transform: translateX(-4px); } 40%,60% { transform: translateX(4px); } }

/* ===== Ripple ===== */
.ripple { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(0,229,204,.4), transparent 70%); transform: scale(0); animation: ripple .6s ease-out; pointer-events: none; z-index: 1; }
@keyframes ripple { to { transform: scale(2.4); opacity: 0; } }

/* ===== Glitch logo ===== */
.logo.glitch { animation: glitchShift 7s steps(1) infinite; }
@keyframes glitchShift { 0%,96%,100% { text-shadow: none; } 97% { text-shadow: -2px 0 var(--red), 2px 0 var(--cyan); } 98% { text-shadow: 2px 0 var(--violet), -2px 0 var(--cyan); } 99% { text-shadow: -1px 0 var(--cyan), 1px 0 var(--red); } }

/* ===== Soundboard FX ===== */
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 15px; }
.eq i { width: 3px; background: var(--cyan); border-radius: 2px; box-shadow: 0 0 6px var(--cyan-glow); animation: eqb .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .15s; } .eq i:nth-child(3) { animation-delay: .3s; } .eq i:nth-child(4) { animation-delay: .45s; } .eq i:nth-child(5) { animation-delay: .1s; }
@keyframes eqb { 0%,100% { height: 4px; } 50% { height: 15px; } }
.card.playing { border-color: var(--violet) !important; box-shadow: 0 0 18px rgba(124,58,237,.4); }
.card.shot-hit { animation: shotHit .4s var(--ease); }
@keyframes shotHit { 0% { box-shadow: 0 0 0 rgba(0,229,204,0); } 30% { box-shadow: 0 0 22px rgba(0,229,204,.55); } 100% { box-shadow: 0 0 0 rgba(0,229,204,0); } }
.content-list { content-visibility: auto; contain-intrinsic-size: auto 600px; }

/* ===== Dashboard background ===== */
#view-dashboard { position: relative; min-height: calc(100dvh - 160px); }
.dash-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#view-dashboard > *:not(.dash-bg) { position: relative; z-index: 1; }

/* ============================================================
   PREMIUM ANIMATED BACKGROUND (all pages)
   ============================================================ */
.fx-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.fx-aurora {
  position: absolute; inset: -30%;
  background:
    radial-gradient(36% 30% at 18% 14%, rgba(0,229,204,.22), transparent 60%),
    radial-gradient(34% 30% at 84% 20%, rgba(124,58,237,.24), transparent 60%),
    radial-gradient(42% 34% at 74% 86%, rgba(0,170,255,.16), transparent 62%),
    radial-gradient(30% 28% at 24% 90%, rgba(236,72,153,.13), transparent 60%);
  animation: auroraDrift 26s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
@keyframes auroraDrift {
  0%   { transform: translate3d(0,0,0) scale(1);     opacity: .82; }
  50%  { transform: translate3d(3%,-2%,0) scale(1.09); opacity: 1; }
  100% { transform: translate3d(-3%,2%,0) scale(1.05); opacity: .78; }
}
.fx-floor {
  position: absolute; left: -50%; right: -50%; bottom: -2%; height: 46%;
  background-image:
    linear-gradient(rgba(0,229,204,.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,204,.16) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: perspective(440px) rotateX(65deg); transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, #000, transparent 82%);
  mask-image: linear-gradient(to top, #000, transparent 82%);
  opacity: .13; animation: floorScroll 6.5s linear infinite; will-change: background-position;
}
@keyframes floorScroll { to { background-position: 0 46px, 46px 0; } }
.fx-bg::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(125% 95% at 50% 28%, transparent 52%, rgba(2,2,6,.72) 100%);
}

/* ===== Home hero ===== */
.dash-hero { padding-top: 4px; }
.dash-hero .eyebrow { font-family: var(--f-mono); font-size: .66rem; letter-spacing: .24em; color: var(--grey); margin-bottom: 8px; text-transform: uppercase; }
.dash-hero .eyebrow i { color: var(--grey-dim); font-style: normal; }
.dash-hero .eyebrow span { color: var(--cyan); text-shadow: 0 0 12px var(--cyan-glow); animation: pulse 2.6s ease-in-out infinite; }
.dash-hero h1 { font-size: clamp(1.8rem, 9vw, 2.6rem); line-height: 1.04; }

@media (max-width: 767px) { .fx-aurora { animation-duration: 34s; } }
@media (prefers-reduced-motion: reduce) { .fx-aurora, .fx-floor { animation: none; } }

/* ============================================================
   PREMIUM POLISH PASS (craft + depth)
   ============================================================ */
.fx-aurora { opacity: 1; }
/* Card depth + top highlight + richer active */
.card { background: linear-gradient(158deg, rgba(21,21,34,.94), rgba(11,11,20,.94)); }
.card.glowable { transition: transform .18s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease); }
.card.glowable:active { transform: translateY(1px) scale(.994); border-color: var(--line); box-shadow: 0 0 24px rgba(0,229,204,.22), inset 0 1px 0 rgba(255,255,255,.05); }
.card::before { content: ''; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: linear-gradient(90deg, transparent, rgba(0,229,204,.4), transparent); opacity: .55; pointer-events: none; }
/* Tab bar active glow */
.tabbar button.active svg { filter: drop-shadow(0 0 9px var(--cyan)); }
.tabbar button.active span { text-shadow: 0 0 8px var(--cyan-glow); }
/* Primary button sheen */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after { content: ''; position: absolute; top: 0; left: -65%; width: 42%; height: 100%; background: linear-gradient(105deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-18deg); animation: sheen 5.5s ease-in-out infinite; pointer-events: none; }
@keyframes sheen { 0%, 72% { left: -65%; } 90%, 100% { left: 135%; } }
/* Badge / label accents */
.badge-cr { box-shadow: 0 0 10px rgba(0,229,204,.18); }
.section-label::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); flex: 0 0 auto; }
/* Inputs focus premium */
.input:focus { box-shadow: 0 0 0 3px var(--cyan-dim), 0 0 18px rgba(0,229,204,.12); }
/* Sheet head accent line */
.sheet-head { background: linear-gradient(180deg, rgba(0,229,204,.05), transparent); }
@media (prefers-reduced-motion: reduce) { .btn-primary::after { animation: none; display: none; } }

/* ===== Live signal LED (header dot) — radar ping ===== */
.app-header .logo .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan); position: relative; flex: 0 0 auto;
  box-shadow: 0 0 7px var(--cyan), 0 0 14px var(--cyan-glow);
  animation: dotPulse 1.7s ease-in-out infinite;
}
.app-header .logo .dot::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px;
  margin: -4px 0 0 -4px; border-radius: 50%; border: 1.5px solid var(--cyan);
  animation: dotPing 1.7s cubic-bezier(0.22,1,0.36,1) infinite;
}
@keyframes dotPulse { 0%,100% { box-shadow: 0 0 6px var(--cyan), 0 0 12px var(--cyan-glow); } 50% { box-shadow: 0 0 12px var(--cyan), 0 0 24px var(--cyan-glow); transform: scale(1.12); } }
@keyframes dotPing { 0% { transform: scale(.5); opacity: .9; } 80%, 100% { transform: scale(3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .app-header .logo .dot::after { animation: none; opacity: 0; } }

/* Soundboard favorite star */
.pad-star { position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; display: grid; place-items: center; font-size: 1rem; line-height: 1; color: var(--grey); background: none; border-radius: 6px; transition: color .15s var(--ease), transform .15s var(--ease); }
.pad-star.on { color: var(--amber); text-shadow: 0 0 9px rgba(245,158,11,.65); }
.pad-star:active { transform: scale(.8); }
#view-dashboard::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,229,204,0.018) 3px, rgba(0,229,204,0.018) 4px);
  mix-blend-mode: screen;
}

/* ===== Entity portrait (statblock) ===== */
.portrait-wrap {
  width: 100%; margin-bottom: 14px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(180deg, #0e1620, #060a10);
  border: 1px solid var(--line);
  position: relative;
}
/* Subtle fade so the art melts into the sheet at the bottom edge */
.portrait-wrap::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 38%;
  background: linear-gradient(180deg, transparent, rgba(6,10,16,.85));
  pointer-events: none;
}
.entity-portrait {
  width: 100%; max-height: 300px; object-fit: cover; object-position: center top;
  display: block;
  filter: contrast(1.04) saturate(1.05);
}
.portrait-zoom {
  position: absolute; right: 9px; bottom: 9px; z-index: 2;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff;
  background: rgba(8,12,18,.7); border: 1px solid var(--line);
  backdrop-filter: blur(4px); pointer-events: none;
}

/* Fullscreen image lightbox */
.img-lightbox {
  position: fixed; inset: 0; z-index: 13000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(2,3,6,.93);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .24s var(--ease); cursor: zoom-out;
}
.img-lightbox.show { opacity: 1; }
.img-lightbox img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 10px; box-shadow: 0 0 50px rgba(0,0,0,.85);
  transform: scale(.95); transition: transform .24s var(--ease);
}
.img-lightbox.show img { transform: scale(1); }
.img-lightbox-close {
  position: fixed; top: calc(var(--safe-top) + 12px); right: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; line-height: 1; color: #fff;
  background: rgba(255,255,255,.08); border: 1px solid var(--line);
}

/* Vital sub-label (AC note / HP formula) */
.vital-note {
  font-family: var(--f-mono); font-size: .58rem; color: var(--grey);
  letter-spacing: .04em; margin-top: 2px; line-height: 1.3;
}

/* Combat in-progress pulse */
@keyframes combatPulse { 0%,100% { box-shadow: 0 0 0 rgba(220,38,38,0); border-color: var(--line); } 50% { box-shadow: 0 0 18px rgba(220,38,38,.25); border-color: rgba(220,38,38,.4); } }
.combat-live { animation: combatPulse 3.2s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  #boot { display: none; }
}

/* ============================================================
   MOBILE / TOUCH OPTIMIZATION
   ============================================================ */
/* Kill the 300ms tap delay and double-tap-zoom on all interactive targets. */
button, a, label, input[type="range"],
.card, .chip, .badge, .tabbar button, .pad-star, .lock-pad button {
  touch-action: manipulation;
}
/* No iOS long-press callout / accidental text selection on tappable UI + art. */
img, .card.glowable, .chip, .tabbar button, .lock-pad button, .btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
}
/* Keep momentum scrolling contained so pull-past-edge doesn't bounce the page. */
.app-main, .sheet-body, .dice-history, .filter-row {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Long sound/codex lists: skip painting off-screen cards (cheaper scroll). */
.content-list { content-visibility: auto; contain-intrinsic-size: auto 600px; }

/* Pause the always-on animated background off the dashboard. .fx-floor animates
   background-position (a per-frame CPU repaint) on every view — freezing it
   while another view is active frees the frame budget (e.g. the WebGL dice). */
body[data-view]:not([data-view="dashboard"]) .fx-aurora,
body[data-view]:not([data-view="dashboard"]) .fx-floor {
  animation-play-state: paused;
}

/* ============================================================
   ACCESS LOCK — PIN gate + numeric keypad
   ============================================================ */
html.unlocked #lock { display: none !important; }
#lock {
  position: fixed; inset: 0; z-index: 12000;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 20px);
  background: radial-gradient(ellipse at 50% 32%, #0a1620, #04060a 72%);
  transition: opacity .5s var(--ease), visibility .5s;
}
#lock.open { opacity: 0; visibility: hidden; pointer-events: none; }
#lock .lock-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(rgba(0,229,204,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,204,.05) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000, transparent 78%);
  mask-image: radial-gradient(ellipse at 50% 40%, #000, transparent 78%);
}
.lock-box {
  position: relative; z-index: 1; width: 100%; max-width: 320px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
}
.lock-logo {
  font-family: var(--f-display); font-weight: 900; font-size: 1.15rem;
  letter-spacing: .04em; color: var(--white);
  display: flex; align-items: center; gap: 8px;
}
.lock-logo b { color: var(--cyan); }
.lock-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); animation: pulse 2.4s var(--ease) infinite; }
.lock-sub {
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--grey); transition: color .2s var(--ease);
}
.lock-sub.err { color: var(--red); text-shadow: 0 0 10px rgba(220,38,38,.5); }
.lock-dots { display: flex; gap: 16px; margin: 2px 0 4px; }
.lock-dots i {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--grey); background: transparent;
  transition: all .18s var(--ease);
}
.lock-dots i.on {
  background: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow); transform: scale(1.12);
}
.lock-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  width: 100%; max-width: 280px;
}
.lock-pad button {
  aspect-ratio: 1 / 1; border-radius: 50%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  color: var(--white); font-family: var(--f-head); font-weight: 700;
  font-size: 1.5rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.lock-pad button:hover { background: rgba(0,229,204,.08); border-color: rgba(0,229,204,.4); }
.lock-pad button:active { transform: scale(.9); background: rgba(0,229,204,.16); }
.lock-pad .lock-del { font-size: 1.15rem; color: var(--grey); }
.lock-shake { animation: shake .45s var(--ease); }

/* ============================================================
   DESKTOP / PC LAYOUT — bottom tab bar becomes a left side rail,
   header + content shift right, content column widens.
   Purely CSS: nav clicks are delegated so JS is unaffected.
   ============================================================ */
@media (min-width: 1024px) {
  :root { --rail-w: 96px; }

  /* Bottom tab bar → vertical sidebar on the left */
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto;
    width: var(--rail-w); height: 100dvh;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: 4px; padding: 16px 0;
    border-top: none; border-right: 1px solid var(--line);
    box-shadow: 6px 0 28px rgba(0,0,0,0.45);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .tabbar::-webkit-scrollbar { width: 0; }
  .tabbar button {
    flex: 0 0 auto; height: 58px;
    margin: 0 10px; padding: 8px 2px; border-radius: 12px;
    font-size: 0.6rem;
    transition: color .18s var(--ease), background .18s var(--ease), transform .12s var(--ease);
  }
  .tabbar button:hover { color: var(--white); background: rgba(255,255,255,.045); }
  .tabbar button:active { transform: scale(.96); }
  .tabbar button.active { background: rgba(0,229,204,.08); }
  /* Active indicator: left edge bar instead of top edge */
  .tabbar button.active::before {
    top: 50%; left: -10px; transform: translateY(-50%);
    width: 3px; height: 24px;
  }

  /* Shift header + main to the right of the rail */
  .app-header { margin-left: var(--rail-w); padding-left: 28px; padding-right: 28px; }
  .app-main {
    margin-left: var(--rail-w);
    padding-top: 22px; padding-bottom: 44px;
    padding-left: max(28px, calc((100% - var(--rail-w) - 940px) / 2));
    padding-right: max(28px, calc((100% - var(--rail-w) - 940px) / 2));
  }

  /* Pointer affordances */
  .card.glowable { transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease); }
  .card.glowable:hover { transform: translateY(-2px); }
  .btn { cursor: pointer; }

  /* Toast clears the rail and centers over the content column */
  .toast { left: calc(50% + var(--rail-w) / 2); bottom: 28px; }

  /* Bigger headings benefit from the wider canvas */
  .view-head h1 { font-size: 1.8rem; }
  .dash-hero h1 { font-size: clamp(2.4rem, 4vw, 3.2rem); }

  /* Statblock portrait can breathe a bit more */
  .entity-portrait { max-height: 320px; }
}

/* ============================================================
   PARTY — player photo avatar + inventory chips
   ============================================================ */
.player-avatar {
  width: 52px; height: 52px; flex: none; border-radius: 50%;
  background: var(--bg-input); border: 1px solid var(--line-soft);
  display: grid; place-items: center; overflow: hidden;
  box-shadow: inset 0 0 14px rgba(0,229,204,0.12);
}
.player-avatar.sm { width: 38px; height: 38px; }
.player-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-avatar-ph { font-size: 1.3rem; opacity: .5; }
.player-avatar.sm .player-avatar-ph { font-size: 1rem; }

.inv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.inv-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 9px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--line-soft);
  font-family: var(--f-mono); font-size: .76rem; color: var(--white); line-height: 1.2;
}
.inv-chip .inv-x {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 1rem; line-height: 1;
  color: var(--grey); background: transparent;
}
.inv-chip .inv-x:active { background: var(--red-dim); color: #ff7a7a; }
