@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --void: #0a0612;
  --void-2: #120a1f;
  --panel: #160f27;
  --panel-2: #1d1533;
  --border: #2f2350;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --teal: #22d3ee;
  --gold: #fbbf24;
  --crit: #f43f5e;
  --hp: #34d399;
  --hp-low: #f43f5e;
  --text: #ece7fb;
  --text-dim: #a99cd1;
  --common: #b9b3c9;
  --rare: #5ec2f0;
  --epic: #c77dff;
  --legendary: #ffb347;
  --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .titlefont {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.02em;
}

button {
  font-family: inherit;
  cursor: pointer;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- background rift portal ---------- */
.void-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(139, 92, 246, 0.25), transparent 55%),
    radial-gradient(ellipse at 90% 100%, rgba(34, 211, 238, 0.12), transparent 50%),
    var(--void);
}

.rift-portal {
  position: absolute;
  width: 46vmin;
  height: 46vmin;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg, var(--violet), var(--teal), var(--gold), var(--violet));
  filter: blur(48px) saturate(1.3);
  opacity: 0.35;
  animation: spin 18s linear infinite;
  z-index: -1;
  pointer-events: none;
}
.rift-portal.small { width: 22vmin; height: 22vmin; opacity: 0.3; }

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ---------- layout shell ---------- */
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  position: relative;
}

.brand {
  text-align: center;
  margin-bottom: 22px;
}
.brand h1 {
  font-size: clamp(28px, 6vw, 44px);
  margin: 0;
  background: linear-gradient(90deg, var(--violet-2), var(--teal), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: var(--shadow-glow);
}
.brand p { color: var(--text-dim); margin: 4px 0 0; font-size: 14px; }

.screen { display: none; }
.screen.active { display: block; animation: fadein 0.35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.panel h2 { margin: 0 0 12px; font-size: 18px; color: var(--violet-2); }

.btn {
  background: linear-gradient(135deg, var(--violet), #6d28d9);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 4px 14px rgba(139,92,246,0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 6px 18px rgba(139,92,246,0.5); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: transparent; border: 1px solid var(--border); box-shadow: none; color: var(--text-dim); }
.btn.gold { background: linear-gradient(135deg, var(--gold), #d97706); box-shadow: 0 4px 14px rgba(251,191,36,0.4); }
.btn.danger { background: linear-gradient(135deg, var(--crit), #9f1239); }
.btn.block { width: 100%; }

/* ---------- create screen ---------- */
.class-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0; }
@media (max-width: 520px) { .class-grid { grid-template-columns: 1fr; } }
.class-card {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  padding: 14px;
  text-align: left;
  color: var(--text);
  position: relative;
  overflow: hidden;
}
.class-card:hover { border-color: var(--violet); }
.class-card.selected { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal), 0 0 18px rgba(34,211,238,0.35); }
.class-card .icon { font-size: 26px; }
.class-card .name { font-weight: 700; margin: 6px 0 2px; }
.class-card .desc { font-size: 12px; color: var(--text-dim); }
.name-input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 10px;
}
.name-input:focus { outline: none; border-color: var(--violet); }

/* ---------- camp screen ---------- */
.hero-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hero-portrait {
  width: 58px; height: 58px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: radial-gradient(circle at 30% 30%, var(--violet-2), var(--violet) 60%, #4c1d95);
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}
.hero-meta { flex: 1; min-width: 180px; }
.hero-meta .name { font-size: 20px; font-weight: 700; }
.hero-meta .sub { color: var(--text-dim); font-size: 13px; }

.bar { position: relative; height: 12px; border-radius: 7px; background: rgba(0,0,0,0.4); overflow: hidden; border: 1px solid var(--border); }
.bar > .fill { height: 100%; border-radius: 7px; transition: width 0.35s ease; }
.bar.xp > .fill { background: linear-gradient(90deg, var(--teal), var(--violet-2)); }
.bar.hp > .fill { background: linear-gradient(90deg, var(--hp), #059669); }
.bar.hp.low > .fill { background: linear-gradient(90deg, var(--hp-low), #9f1239); }
.bar.boss > .fill { background: linear-gradient(90deg, #f43f5e, #fbbf24, var(--violet-2)); }
.bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin: 6px 0 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 14px; }
.stat-chip { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.stat-chip .v { font-size: 16px; font-weight: 700; color: var(--teal); }
.stat-chip .k { font-size: 11px; color: var(--text-dim); }

/* tier list */
.tier-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.02); margin-bottom: 8px;
}
.tier-row.locked { opacity: 0.45; }
.tier-row.cleared { border-color: rgba(52,211,153,0.4); }
.tier-row .tname { font-weight: 700; }
.tier-row .tsub { font-size: 12px; color: var(--text-dim); }
.tier-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); }
.tier-badge.cleared { color: var(--hp); border-color: var(--hp); }

/* inventory */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: rgba(255,255,255,0.02); }
.item-card .iname { font-weight: 700; font-size: 13px; }
.item-card .islot { font-size: 11px; color: var(--text-dim); }
.item-card .affix { font-size: 11px; color: var(--teal); margin-top: 4px; }
.item-card.equipped { border-color: var(--gold); box-shadow: 0 0 12px rgba(251,191,36,0.25); }
.rarity-common { color: var(--common); }
.rarity-rare { color: var(--rare); }
.rarity-epic { color: var(--epic); }
.rarity-legendary { color: var(--legendary); }

/* skill tree */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.skill-node { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: rgba(255,255,255,0.02); }
.skill-node .sname { font-weight: 700; font-size: 13px; }
.skill-node .sdesc { font-size: 11px; color: var(--text-dim); margin: 4px 0 8px; }
.skill-node .ranks { font-size: 11px; color: var(--teal); margin-bottom: 6px; }
.skill-node.locked { opacity: 0.5; }

/* ---------- queue screen ---------- */
.queue-wrap { text-align: center; padding: 60px 20px; }
.queue-spinner { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--teal); animation: spin2 1s linear infinite; }
@keyframes spin2 { to { transform: rotate(360deg); } }

/* ---------- rift screen ---------- */
.boss-panel { position: relative; overflow: hidden; }
.boss-name { font-size: 22px; font-weight: 700; }
.boss-title { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.boss-flags { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.flag { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); }
.flag.enrage { color: var(--crit); border-color: var(--crit); animation: pulse 1s infinite; }
.flag.phase-physical { color: var(--gold); border-color: var(--gold); }
.flag.phase-magic { color: var(--teal); border-color: var(--teal); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.float-text {
  position: absolute;
  transform: translate(-50%, 0) scale(0.6);
  font-weight: 700;
  font-size: 15px;
  color: var(--gold);
  opacity: 0;
  text-shadow: 0 0 8px rgba(0,0,0,0.6);
  transition: transform 0.9s cubic-bezier(.2,.8,.2,1), opacity 0.9s ease;
  white-space: nowrap;
}
.float-text.play { transform: translate(-50%, -60px) scale(1); opacity: 1; }
.float-text.crit { color: var(--crit); font-size: 22px; }
.float-text.heal { color: var(--hp); }
.float-text.boss_hit { color: #ff8fa3; }
.float-text.guarded { color: var(--teal); }

.telegraph-banner {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--crit);
  color: var(--crit);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: pulse 0.6s infinite;
}
.telegraph-ring {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--crit);
  border-top-color: transparent;
  animation: spin2 0.5s linear infinite;
}

.party-frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
.party-frame { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: rgba(255,255,255,0.02); position: relative; }
.party-frame.down { opacity: 0.4; }
.party-frame.you { border-color: var(--teal); }
.party-frame .pname { font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; }
.party-frame .pclass { color: var(--text-dim); font-size: 11px; margin-bottom: 6px; }
.guard-armed-badge { position: absolute; top: 8px; right: 8px; font-size: 14px; }

.ability-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.ability-btn {
  position: relative;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(139,92,246,0.18), rgba(0,0,0,0.2));
  border-radius: 12px;
  padding: 12px 6px 8px;
  color: var(--text);
  text-align: center;
  overflow: hidden;
}
.ability-btn .aname { font-size: 12px; font-weight: 700; }
.ability-btn .acd { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.ability-btn .cdsweep {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.65);
  height: 0%;
}
.ability-btn:disabled { cursor: not-allowed; }
.guard-btn {
  margin-top: 8px;
  border: 1px solid var(--teal);
  background: rgba(34,211,238,0.08);
  color: var(--teal);
}
.guard-btn.armed { background: rgba(34,211,238,0.3); box-shadow: 0 0 14px rgba(34,211,238,0.5); }

.combat-log { max-height: 140px; overflow-y: auto; margin-top: 14px; font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column-reverse; gap: 3px; }

/* ---------- modal / reward ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,2,12,0.75);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), var(--shadow-glow);
}
.modal h2 { margin-top: 0; }
.reward-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.reward-item { margin-top: 10px; padding: 10px; border-radius: 10px; border: 1px solid var(--border); }

/* leaderboard */
.lb-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.lb-rank { color: var(--text-dim); width: 22px; display: inline-block; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab-btn { background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: 999px; padding: 6px 14px; font-size: 12px; }
.tab-btn.active { color: var(--void); background: var(--teal); border-color: var(--teal); font-weight: 700; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(20,10,35,0.95); border: 1px solid var(--crit); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 80;
  opacity: 0; transition: opacity 0.25s ease;
}
.toast.show { opacity: 1; }

.footer-note { text-align: center; color: var(--text-dim); font-size: 11px; margin-top: 30px; }
