/* =========================================================
   艾泽拉斯征途 · Premium ARPG UI
   ========================================================= */
:root {
  --bg-deep: #070a12;
  --bg-panel: rgba(10, 14, 26, 0.92);
  --gold: #f0c75e;
  --gold-dim: #b8943a;
  --gold-bright: #ffe9a0;
  --hp: #c0392b;
  --hp-bright: #ff5a4e;
  --mana: #2e86de;
  --rage: #e74c3c;
  --energy: #f1c40f;
  --xp: #8e44ad;
  --xp-bright: #c39bd3;
  --green: #2ecc71;
  --blue: #5dade2;
  --purple: #9b59b6;
  --orange: #e67e22;
  --red: #e74c3c;
  --white: #f5f7ff;
  --muted: #9aa3b8;
  --border: rgba(240, 199, 94, 0.35);
  --shadow: 0 20px 60px rgba(0,0,0,.55);
  --radius: 14px;
  --font-ui: "Noto Sans SC", system-ui, sans-serif;
  --font-display: "Cinzel", "Noto Sans SC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--white);
  font-family: var(--font-ui);
  user-select: none;
}
button, input { font-family: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

#app { width: 100%; height: 100%; position: relative; }
.screen {
  position: absolute; inset: 0;
  opacity: 0; pointer-events: none;
  transition: opacity .45s ease;
}
.screen.active { opacity: 1; pointer-events: auto; }

/* ---------- BOOT ---------- */
#screen-boot {
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(120,70,20,.35), transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(40,20,80,.4), transparent 50%),
    linear-gradient(180deg, #0a0f1d 0%, #05070e 100%);
  overflow: hidden;
}
.boot-bg {
  position: absolute; inset: -10%;
  background:
    radial-gradient(circle at 20% 30%, rgba(240,199,94,.08), transparent 25%),
    radial-gradient(circle at 80% 70%, rgba(142,68,173,.12), transparent 30%),
    repeating-linear-gradient(115deg, transparent 0 40px, rgba(255,255,255,.015) 40px 41px);
  animation: bootDrift 18s linear infinite;
}
@keyframes bootDrift {
  from { transform: translate3d(0,0,0) rotate(0deg); }
  to { transform: translate3d(-2%, 1%, 0) rotate(1deg); }
}
.boot-particles {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 10% 20%, rgba(255,230,160,.7), transparent),
    radial-gradient(1.5px 1.5px at 30% 70%, rgba(255,255,255,.5), transparent),
    radial-gradient(2px 2px at 70% 40%, rgba(180,220,255,.55), transparent),
    radial-gradient(1px 1px at 85% 15%, rgba(255,200,100,.8), transparent),
    radial-gradient(1.5px 1.5px at 50% 85%, rgba(255,255,255,.4), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }

.boot-content {
  position: relative; z-index: 2;
  text-align: center;
  padding: 40px 28px;
  animation: riseIn .9s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(28px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.logo-mark {
  font-size: 56px;
  filter: drop-shadow(0 0 18px rgba(240,199,94,.65));
  animation: pulseGlow 2.4s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%,100% { transform: scale(1); filter: drop-shadow(0 0 12px rgba(240,199,94,.5)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 28px rgba(240,199,94,.95)); }
}
.game-title {
  margin: 12px 0 8px;
  font-family: var(--font-display);
  letter-spacing: .12em;
}
.game-title .title-glow {
  display: block;
  font-size: clamp(36px, 6vw, 72px);
  font-weight: 900;
  background: linear-gradient(180deg, #fff7d6 0%, #f0c75e 45%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(240,199,94,.35);
}
.game-title small {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  letter-spacing: .35em;
  color: var(--gold-dim);
}
.tagline {
  color: var(--muted);
  margin: 10px 0 28px;
  letter-spacing: .18em;
  font-size: 14px;
}
.boot-actions {
  display: inline-grid;
  justify-items: center;
  gap: 10px;
}
.boot-hint {
  margin-top: 22px;
  color: rgba(255,255,255,.45);
  font-size: 12px;
  letter-spacing: .06em;
}

.btn-epic {
  position: relative;
  min-width: 220px;
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: .12em;
  color: #1a1205;
  background: linear-gradient(180deg, #ffe9a0, #f0c75e 40%, #b8860b);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.25) inset,
    0 8px 24px rgba(240,199,94,.35),
    0 0 40px rgba(240,199,94,.2);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
  overflow: hidden;
}
.btn-epic::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform .55s ease;
}
.btn-epic:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.05);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.35) inset,
    0 12px 32px rgba(240,199,94,.5),
    0 0 50px rgba(240,199,94,.35);
}
.btn-epic:hover::before { transform: translateX(120%); }
.btn-epic:disabled {
  opacity: .4; cursor: not-allowed; transform: none; filter: grayscale(.4);
}
.btn-ghost {
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  color: var(--white);
  background: rgba(255,255,255,.04);
  transition: .2s ease;
}
.btn-ghost:hover {
  border-color: var(--gold);
  background: rgba(240,199,94,.08);
  color: var(--gold-bright);
}
.btn-ghost.danger {
  border-color: rgba(231,76,60,.32);
  color: #ffb4ad;
}
.btn-ghost.danger:hover {
  border-color: rgba(231,76,60,.72);
  background: rgba(231,76,60,.1);
  color: #ffd2cd;
}
.btn-sm {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(240,199,94,.1);
  color: var(--gold);
  font-size: 12px;
}
.btn-sm:hover { background: rgba(240,199,94,.2); }

/* ---------- CREATE ---------- */
#screen-create {
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at center, rgba(30,40,70,.5), transparent 60%),
    linear-gradient(160deg, #0b1020, #05070f 70%);
  padding: 20px;
}
.create-frame {
  width: min(980px, 96vw);
  background: linear-gradient(180deg, rgba(18,24,42,.95), rgba(8,11,20,.97));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.03) inset;
  overflow: hidden;
}
.panel-header, .panel-head {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(240,199,94,.15);
  background: linear-gradient(90deg, rgba(240,199,94,.08), transparent 60%);
}
.panel-header h2, .panel-head h3 {
  font-family: var(--font-display);
  color: var(--gold-bright);
  letter-spacing: .12em;
}
.panel-header p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.create-body { padding: 22px; display: grid; gap: 18px; }
.name-row {
  display: flex; align-items: center; gap: 14px;
}
.name-row label { color: var(--gold); min-width: 72px; }
.name-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35);
  color: white;
  outline: none;
  font-size: 16px;
}
.name-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,199,94,.15);
}
.class-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.class-card {
  position: relative;
  padding: 16px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.2));
  text-align: center;
  transition: .2s ease;
  overflow: hidden;
}
.class-card::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--c, #f0c75e) 25%, transparent), transparent 65%);
  opacity: 0; transition: .25s ease;
}
.class-card:hover, .class-card.selected {
  border-color: var(--c, var(--gold));
  transform: translateY(-3px);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--c, #f0c75e) 25%, transparent);
}
.class-card.selected::after, .class-card:hover::after { opacity: 1; }
.class-card .icon { font-size: 34px; position: relative; z-index: 1; }
.class-card .label {
  margin-top: 8px; font-weight: 700; position: relative; z-index: 1;
  color: var(--c, var(--gold));
}
.class-detail {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.25);
}
.class-preview {
  width: 140px; height: 140px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 64px;
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--c, #f0c75e) 40%, transparent), transparent 60%),
    linear-gradient(160deg, #1a2238, #0b0f1a);
  border: 1px solid color-mix(in srgb, var(--c, #f0c75e) 50%, transparent);
  box-shadow: 0 0 30px color-mix(in srgb, var(--c, #f0c75e) 20%, transparent);
}
.class-info h3 {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--c, var(--gold));
}
.class-info p { color: var(--muted); margin: 8px 0 14px; line-height: 1.6; font-size: 14px; }
.stat-bars { display: grid; gap: 8px; }
.stat-row { display: grid; grid-template-columns: 56px 1fr 28px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.stat-track {
  height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden;
}
.stat-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c, #f0c75e) 70%, #fff), var(--c, #f0c75e));
  box-shadow: 0 0 10px color-mix(in srgb, var(--c, #f0c75e) 50%, transparent);
  transition: width .35s ease;
}
.create-actions {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 0 22px 22px;
}

/* ---------- GAME ---------- */
#screen-game { background: #000; }
#game-canvas, #fx-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#fx-canvas { pointer-events: none; z-index: 2; }
#game-canvas { z-index: 1; cursor: crosshair; }

#hud-top {
  position: absolute; top: 14px; left: 14px; right: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
  pointer-events: none;
}
.player-frame {
  display: flex; gap: 12px; align-items: center;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(12,16,28,.88), rgba(8,10,18,.82));
  border: 1px solid rgba(240,199,94,.25);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  pointer-events: auto;
}
.portrait {
  width: 58px; height: 58px; border-radius: 14px;
  display: grid; place-items: center; font-size: 28px;
  background: radial-gradient(circle at 40% 30%, rgba(255,255,255,.15), transparent 50%), #1a2238;
  border: 2px solid var(--gold);
  box-shadow: 0 0 16px rgba(240,199,94,.3);
}
.bars { flex: 1; min-width: 0; }
.name-line {
  display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px;
  font-size: 13px;
}
#hud-name { font-weight: 800; color: var(--gold-bright); }
#hud-level {
  background: linear-gradient(180deg, #f0c75e, #b8860b);
  color: #1a1205; font-weight: 900; font-size: 11px;
  padding: 1px 7px; border-radius: 99px;
}
#hud-class { color: var(--muted); font-size: 12px; }
.bar {
  position: relative;
  height: 14px;
  border-radius: 99px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
  margin-bottom: 4px;
}
.bar .fill {
  height: 100%; width: 100%;
  border-radius: inherit;
  transition: width .12s linear;
  position: relative;
}
.bar .fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.25), transparent 55%);
}
.bar.hp .fill { background: linear-gradient(90deg, #7a1f18, var(--hp-bright)); box-shadow: 0 0 12px rgba(255,90,78,.35); }
.bar.resource .fill { background: linear-gradient(90deg, #1b4f9c, #5dade2); }
.bar.resource.rage .fill { background: linear-gradient(90deg, #7a1a12, #ff5a4e); }
.bar.resource.energy .fill { background: linear-gradient(90deg, #8a6d0d, #f7dc6f); }
.bar.xp { height: 8px; }
.bar.xp .fill { background: linear-gradient(90deg, #4a235a, var(--xp-bright)); }
.bar span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  text-shadow: 0 1px 2px #000;
  color: white;
}

.zone-badge {
  justify-self: center;
  text-align: center;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(8,10,18,.75);
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
  min-width: 180px;
}
#zone-name {
  font-family: var(--font-display);
  letter-spacing: .12em;
  color: var(--gold-bright);
  font-size: 15px;
}
#zone-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }

.top-stats {
  justify-self: end;
  display: flex; gap: 8px;
  pointer-events: auto;
}
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(8,10,18,.8);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 13px;
}
.chip span { font-weight: 900; color: var(--gold); }
.chip b { color: var(--gold-bright); }

#target-frame {
  position: absolute; top: 92px; left: 50%; transform: translateX(-50%);
  z-index: 10;
  min-width: 240px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(20,8,8,.85);
  border: 1px solid rgba(231,76,60,.45);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  text-align: center;
}
#target-frame .t-name { font-weight: 800; margin-bottom: 6px; color: #ffb4ad; }
#target-frame .t-level { margin-top: 4px; font-size: 11px; color: var(--muted); }

#quest-tracker {
  position: absolute; top: 110px; right: 16px;
  z-index: 10;
  width: 250px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(8,12,22,.78);
  border: 1px solid rgba(240,199,94,.18);
  backdrop-filter: blur(8px);
}
.qt-title {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: .1em;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(240,199,94,.15);
  padding-bottom: 6px;
}
.quest-item { margin-bottom: 10px; font-size: 12px; line-height: 1.45; }
.quest-item .q-title { color: #ffe9a0; font-weight: 700; }
.quest-item .q-obj { color: #cfd6e6; margin-top: 2px; }
.quest-item .q-obj.done { color: var(--green); }
.quest-item .q-obj.done::before { content: "✓ "; }

#skill-bar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 10;
  display: flex; gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(14,18,30,.88), rgba(8,10,18,.92));
  border: 1px solid rgba(240,199,94,.28);
  box-shadow: 0 16px 40px rgba(0,0,0,.45), 0 0 30px rgba(240,199,94,.08);
}
.skill-slot {
  position: relative;
  width: 62px; height: 62px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 40% 30%, rgba(255,255,255,.12), transparent 50%),
    linear-gradient(160deg, #1d2740, #0d121f);
  border: 1px solid rgba(255,255,255,.12);
  display: grid; place-items: center;
  box-shadow: inset 0 0 12px rgba(0,0,0,.35);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.skill-slot:hover { transform: translateY(-2px); border-color: var(--gold); }
.skill-slot.ready-flash {
  box-shadow: 0 0 18px rgba(240,199,94,.55), inset 0 0 12px rgba(240,199,94,.15);
  border-color: var(--gold-bright);
}
.skill-slot .sk-icon { font-size: 22px; font-weight: 900; color: #fff; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.skill-slot .key {
  position: absolute; top: 3px; left: 5px;
  font-size: 9px; color: rgba(255,255,255,.65); font-weight: 700;
}
.skill-slot .sk-name {
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  font-size: 10px; white-space: nowrap; color: var(--muted);
}
.skill-slot .sk-cd {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: conic-gradient(rgba(0,0,0,.72) var(--p, 0%), transparent 0);
  display: none;
}
.skill-slot .sk-cd.active { display: block; }
.skill-slot.dash { border-color: rgba(93,173,226,.35); }

#minimap-wrap {
  position: absolute; right: 16px; bottom: 22px;
  z-index: 10;
  width: 180px; height: 180px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(240,199,94,.4);
  box-shadow: 0 12px 30px rgba(0,0,0,.45), 0 0 20px rgba(240,199,94,.1);
  background: #0a1020;
}
#minimap { width: 100%; height: 100%; display: block; }
.mm-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  text-align: center;
  font-size: 10px; letter-spacing: .12em;
  padding: 4px;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  color: var(--gold);
}

#buff-bar {
  position: absolute; left: 16px; bottom: 110px;
  z-index: 10;
  display: flex; gap: 6px; flex-wrap: wrap;
  max-width: 280px;
}
.buff {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px;
  background: rgba(10,14,24,.85);
  border: 1px solid rgba(255,255,255,.15);
  position: relative;
}
.buff .timer {
  position: absolute; bottom: 1px; right: 2px;
  font-size: 9px; color: var(--gold-bright); font-weight: 700;
}

#side-btns {
  position: absolute; left: 16px; bottom: 22px;
  z-index: 10;
  display: flex; gap: 8px;
}
.side-btn {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: rgba(12,16,28,.88);
  border: 1px solid rgba(240,199,94,.25);
  font-size: 18px;
  font-weight: 900;
  color: var(--gold-bright);
  transition: .15s ease;
}
.side-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 8px 20px rgba(240,199,94,.2);
}

#combat-log {
  position: absolute; left: 16px; top: 120px;
  z-index: 9;
  width: 280px;
  max-height: 160px;
  overflow: hidden;
  font-size: 12px;
  pointer-events: none;
  display: flex; flex-direction: column; gap: 3px;
}
.log-line {
  color: rgba(220,230,255,.75);
  text-shadow: 0 1px 2px #000;
  animation: logIn .25s ease both;
}
.log-line.dmg { color: #ff8a80; }
.log-line.heal { color: #7dcea0; }
.log-line.loot { color: #f7dc6f; }
.log-line.sys { color: #85c1e9; }
@keyframes logIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

#toast-stack {
  position: absolute; top: 28%; left: 50%; transform: translateX(-50%);
  z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(8,10,18,.88);
  border: 1px solid rgba(240,199,94,.4);
  color: var(--gold-bright);
  font-weight: 700;
  letter-spacing: .06em;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toastIn .35s cubic-bezier(.2,.8,.2,1) both;
}
.toast.epic {
  border-color: #9b59b6;
  color: #d7bde2;
  box-shadow: 0 0 24px rgba(155,89,182,.35);
}
.toast.rare {
  border-color: #3498db;
  color: #85c1e9;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to { opacity: 1; transform: none; }
}

#levelup-fx {
  position: absolute; inset: 0;
  z-index: 40;
  display: grid; place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(240,199,94,.18), transparent 55%);
}
#levelup-fx .lu-ring {
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  border: 3px solid rgba(255,230,150,.8);
  box-shadow: 0 0 40px rgba(240,199,94,.7), inset 0 0 30px rgba(240,199,94,.35);
  animation: luRing 1.2s ease-out both;
}
#levelup-fx .lu-text {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 900;
  letter-spacing: .2em;
  background: linear-gradient(180deg, #fff, #f0c75e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 30px rgba(240,199,94,.5);
  animation: luText 1.2s ease both;
}
#levelup-fx .lu-sub {
  position: absolute;
  margin-top: 90px;
  color: var(--gold-bright);
  letter-spacing: .18em;
  animation: luText 1.2s ease both;
}
@keyframes luRing {
  from { transform: scale(.2); opacity: 0; }
  40% { opacity: 1; }
  to { transform: scale(1.8); opacity: 0; }
}
@keyframes luText {
  from { opacity: 0; transform: scale(.6) translateY(10px); }
  30% { opacity: 1; transform: scale(1.08); }
  80% { opacity: 1; }
  to { opacity: 0; transform: scale(1) translateY(-10px); }
}

.overlay {
  position: absolute; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(6px);
}
.death-panel, .pause-panel {
  width: min(420px, 92vw);
  padding: 28px;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(30,12,12,.95), rgba(10,8,14,.96));
  border: 1px solid rgba(231,76,60,.4);
  box-shadow: var(--shadow);
}
.pause-panel {
  background: linear-gradient(180deg, rgba(16,20,34,.96), rgba(8,10,18,.97));
  border-color: var(--border);
  display: grid; gap: 12px;
}
.death-panel h2, .pause-panel h2 {
  font-family: var(--font-display);
  color: #ffb4ad;
  margin-bottom: 10px;
  letter-spacing: .12em;
}
.pause-panel h2 { color: var(--gold-bright); }
.death-panel p { color: var(--muted); margin-bottom: 20px; }

.panel {
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 45;
  width: min(460px, 94vw);
  max-height: min(70vh, 640px);
  overflow: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.panel.dragging {
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.08) inset;
}
.panel.wide { width: min(720px, 94vw); }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 1;
  cursor: move;
  touch-action: none;
}
.panel-head h3 { pointer-events: none; }
.close-x {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
  color: var(--muted);
  cursor: pointer;
}
.close-x:hover { color: white; border-color: var(--gold); }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 16px;
}
.inv-slot {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.35);
  display: grid; place-items: center;
  position: relative;
  cursor: pointer;
  transition: .12s ease;
}
.inv-slot:hover { border-color: var(--gold); transform: translateY(-1px); }
.inv-slot .ico { font-size: 22px; }
.inv-slot .qty {
  position: absolute; right: 4px; bottom: 2px;
  font-size: 10px; font-weight: 800; color: white;
  text-shadow: 0 1px 2px #000;
}
.inv-slot.r-common { border-color: #bdc3c7; }
.inv-slot.r-uncommon { border-color: #2ecc71; box-shadow: 0 0 10px rgba(46,204,113,.2); }
.inv-slot.r-rare { border-color: #3498db; box-shadow: 0 0 12px rgba(52,152,219,.25); }
.inv-slot.r-epic { border-color: #9b59b6; box-shadow: 0 0 14px rgba(155,89,182,.3); }
.inv-slot.r-legendary { border-color: #e67e22; box-shadow: 0 0 16px rgba(230,126,34,.35); }
.inv-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  color: var(--muted);
}
.inv-footer b { color: var(--gold); }

.char-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}
.equip-slots { display: grid; gap: 8px; }
.equip-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.06);
}
.equip-row .slot-ico {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 18px;
}
.equip-row .slot-name { font-size: 11px; color: var(--muted); }
.equip-row .item-name { font-size: 13px; font-weight: 700; }
.char-stats {
  display: grid; gap: 8px; align-content: start;
  font-size: 13px;
}
.stat-line {
  display: flex; justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
}
.stat-line b { color: var(--gold-bright); }

#quest-log-body { padding: 16px; display: grid; gap: 12px; }
.qlog-card {
  padding: 12px;
  border-radius: 12px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.08);
}
.qlog-card h4 { color: var(--gold-bright); margin-bottom: 6px; }
.qlog-card p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.qlog-card .objs { margin-top: 8px; font-size: 12px; color: #d5dbe8; }
.qlog-card .reward { margin-top: 8px; color: #f7dc6f; font-size: 12px; }

.map-zones {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}
.zone-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(0,0,0,.2));
  text-align: left;
  transition: .15s ease;
}
.zone-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
}
.zone-card.locked { opacity: .45; filter: grayscale(.4); }
.zone-card h4 { color: var(--gold-bright); margin-bottom: 4px; }
.zone-card p { color: var(--muted); font-size: 12px; line-height: 1.45; }
.zone-card .lvl { margin-top: 8px; font-size: 11px; color: #85c1e9; }

.cloud-account {
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: grid;
  gap: 10px;
}

.cloud-account-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.cloud-account-top strong {
  color: var(--gold-bright);
  font-size: 13px;
  max-width: 52%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 8px;
}

.cloud-form input {
  min-width: 0;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(2,6,12,.62);
  color: var(--text);
  padding: 0 10px;
  outline: none;
  font-weight: 700;
}

.cloud-form input:focus {
  border-color: rgba(240,199,94,.75);
  box-shadow: 0 0 0 2px rgba(240,199,94,.12);
}

.cloud-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.cloud-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #d9a928;
}

.cloud-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.cloud-tools #cloud-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

#leaderboard-body {
  padding: 14px 16px 18px;
  display: grid;
  gap: 8px;
}

.leader-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015)),
    rgba(0,0,0,.24);
  border: 1px solid rgba(255,255,255,.08);
}

.leader-rank {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #1a1205;
  background: linear-gradient(180deg, #ffe9a0, #b8860b);
  font-weight: 900;
  font-size: 12px;
}

.leader-name {
  min-width: 0;
  color: var(--gold-bright);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.leader-score {
  color: #f7dc6f;
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.leader-empty {
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

#tooltip {
  position: absolute;
  z-index: 60;
  min-width: 200px;
  max-width: 280px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(8,10,18,.96);
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.45;
}
#tooltip .tt-name { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
#tooltip .tt-slot { color: var(--muted); margin-bottom: 6px; }
#tooltip .tt-stat { color: #d5dbe8; }
#tooltip .tt-desc { color: #aab3c5; margin-top: 6px; font-style: italic; }
.rarity-common { color: #ecf0f1; }
.rarity-uncommon { color: #2ecc71; }
.rarity-rare { color: #3498db; }
.rarity-epic { color: #9b59b6; }
.rarity-legendary { color: #e67e22; }

/* floating damage numbers via canvas mainly, but CSS helper exists */
@media (max-width: 900px) {
  .class-grid { grid-template-columns: repeat(2, 1fr); }
  #quest-tracker { display: none; }
  #minimap-wrap { width: 120px; height: 120px; }
  .skill-slot { width: 52px; height: 52px; }
  .skill-slot .sk-name { display: none; }
  .char-body { grid-template-columns: 1fr; }
  .map-zones { grid-template-columns: 1fr; }
}


/* ---------- Item glyphs (emoji-free, system-font safe) ---------- */
.item-glyph {
  --r: #bdc3c7;
  display: inline-grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 8px;
  font-weight: 900;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,.28), transparent 45%),
    linear-gradient(160deg, color-mix(in srgb, var(--r) 70%, #1a1f2e), color-mix(in srgb, var(--r) 35%, #0b1020));
  border: 1px solid color-mix(in srgb, var(--r) 80%, #fff);
  box-shadow: 0 0 12px color-mix(in srgb, var(--r) 35%, transparent), inset 0 0 8px rgba(0,0,0,.25);
  text-shadow: 0 1px 2px rgba(0,0,0,.55);
  flex: 0 0 auto;
}
.item-glyph.inv { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.item-glyph.equip { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
.item-glyph.tt-ico { width: 22px; height: 22px; font-size: 12px; border-radius: 6px; vertical-align: -4px; margin-right: 4px; }
.item-glyph.tt-ico.sm { width: 18px; height: 18px; font-size: 11px; vertical-align: -3px; }
.item-glyph.empty {
  background: rgba(255,255,255,.04);
  border: 1px dashed rgba(255,255,255,.15);
  box-shadow: none;
  color: rgba(255,255,255,.35);
  font-weight: 700;
}
.inv-slot .item-glyph { margin: 0 auto; }
.slot-ico { display: grid; place-items: center; }

/* Tooltip compare */
#tooltip {
  min-width: 230px;
  max-width: 300px;
  backdrop-filter: blur(10px);
}
#tooltip .tt-name {
  display: flex;
  align-items: center;
  gap: 6px;
}
#tooltip .tt-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}
#tooltip .tt-stat b { color: #eef3ff; font-variant-numeric: tabular-nums; }
#tooltip .tt-stat.compare b { min-width: 52px; text-align: right; }
#tooltip .tt-delta {
  min-width: 48px;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#tooltip .tt-delta.up { color: #2ecc71; }
#tooltip .tt-delta.down { color: #ff6b6b; }
#tooltip .tt-delta.same { color: #8b93a7; }
#tooltip .tt-compare-title {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: #f0c75e;
  font-size: 11px;
  letter-spacing: .08em;
}
#tooltip .tt-compare-title.empty-slot { color: #8b93a7; }
#tooltip .tt-equipped {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
#tooltip .tt-equipped-stats {
  margin-top: 2px;
  color: #aab3c5;
  font-size: 11px;
}
#tooltip .tt-slot.foot {
  margin-top: 8px;
  color: #9aa3b8;
}
#tooltip .tt-desc {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ---------- Visual polish pass ---------- */
:root {
  --bg-panel: rgba(8, 12, 22, 0.94);
  --border: rgba(244, 209, 124, 0.32);
  --shadow: 0 26px 80px rgba(0,0,0,.62), 0 0 36px rgba(21,38,30,.18);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(244,209,124,.42) rgba(6,9,16,.64);
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track {
  background: rgba(6,9,16,.66);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg, rgba(255,236,174,.75), rgba(184,142,52,.55));
  border: 2px solid rgba(6,9,16,.8);
  border-radius: 999px;
}

#screen-game::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: .16;
  background:
    linear-gradient(115deg, rgba(255,255,255,.05), transparent 26%, rgba(0,0,0,.08) 64%, transparent),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}

.player-frame,
.zone-badge,
.chip,
#quest-tracker,
#skill-bar,
#minimap-wrap,
#side-btns {
  backdrop-filter: blur(14px) saturate(1.18);
}

.player-frame,
.zone-badge,
#quest-tracker,
#skill-bar,
#minimap-wrap {
  background:
    linear-gradient(180deg, rgba(23,30,47,.86), rgba(7,10,18,.9)),
    radial-gradient(circle at 12% 0%, rgba(244,209,124,.12), transparent 40%);
  border-color: rgba(244,209,124,.26);
  box-shadow:
    0 16px 48px rgba(0,0,0,.44),
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 -1px 0 rgba(0,0,0,.32);
}

.portrait {
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,.5), transparent 18%),
    radial-gradient(circle at 50% 58%, rgba(240,199,94,.28), transparent 58%),
    linear-gradient(145deg, #202b45, #090d18);
  border-color: rgba(255,232,160,.72);
}

.bar {
  height: 15px;
  background:
    linear-gradient(180deg, rgba(0,0,0,.76), rgba(255,255,255,.04)),
    rgba(0,0,0,.5);
  border-color: rgba(255,255,255,.12);
}

.bar.xp { height: 8px; }
.bar .fill { box-shadow: inset 0 1px 0 rgba(255,255,255,.24); }

.chip {
  background:
    linear-gradient(180deg, rgba(25,31,48,.86), rgba(7,10,18,.9));
  border-color: rgba(255,255,255,.12);
  box-shadow: 0 10px 28px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.08);
}

#skill-bar {
  gap: 12px;
  padding: 13px 16px 15px;
  border-radius: 16px;
}

.skill-slot {
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 42%),
    radial-gradient(circle at 50% 24%, rgba(255,255,255,.14), transparent 44%),
    linear-gradient(145deg, #202942, #090d19 72%);
  border-color: rgba(255,255,255,.16);
  box-shadow:
    0 8px 20px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.12),
    inset 0 -10px 18px rgba(0,0,0,.28);
}

.skill-slot::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.05);
  pointer-events: none;
}

.skill-slot:hover {
  transform: translateY(-3px);
  box-shadow:
    0 12px 26px rgba(0,0,0,.36),
    0 0 24px rgba(240,199,94,.18),
    inset 0 1px 0 rgba(255,255,255,.16);
}

.skill-slot .sk-icon {
  font-size: 24px;
  text-shadow: 0 2px 10px rgba(0,0,0,.55);
}

.skill-slot .key {
  top: 5px;
  left: 7px;
  color: rgba(255,232,160,.72);
}

.skill-slot .sk-cd {
  background:
    conic-gradient(rgba(0,0,0,.78) var(--p, 0%), rgba(0,0,0,.05) 0),
    radial-gradient(circle, transparent 48%, rgba(0,0,0,.35) 49%);
}

#side-btns {
  padding: 6px;
  border-radius: 16px;
  background: rgba(8,12,22,.7);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 14px 34px rgba(0,0,0,.38);
}

.side-btn {
  border-radius: 10px;
  background:
    radial-gradient(circle at 36% 20%, rgba(255,255,255,.18), transparent 34%),
    linear-gradient(150deg, rgba(30,39,62,.96), rgba(8,12,22,.96));
  border-color: rgba(244,209,124,.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), inset 0 -8px 16px rgba(0,0,0,.28);
}

.panel {
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(18,23,36,.96), rgba(7,10,18,.97)),
    radial-gradient(circle at 10% -8%, rgba(244,209,124,.2), transparent 34%),
    radial-gradient(circle at 105% 12%, rgba(93,173,226,.14), transparent 34%);
  border-color: rgba(244,209,124,.34);
  border-radius: 16px;
  box-shadow:
    0 30px 90px rgba(0,0,0,.66),
    0 0 0 1px rgba(255,255,255,.04),
    inset 0 1px 0 rgba(255,255,255,.08);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 16%),
    linear-gradient(90deg, rgba(244,209,124,.12), transparent 18%, transparent 82%, rgba(93,173,226,.08));
}

.panel-head {
  padding: 18px 20px 16px;
  background:
    linear-gradient(180deg, rgba(24,31,48,.98), rgba(11,15,26,.94)),
    linear-gradient(90deg, rgba(244,209,124,.16), transparent 62%);
  border-bottom-color: rgba(244,209,124,.18);
}

.panel-head::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 36px;
  height: 3px;
  border-radius: 999px;
  background: rgba(244,209,124,.26);
  transform: translateX(-50%);
}

.panel-head h3 {
  font-size: 20px;
  letter-spacing: .08em;
  text-shadow: 0 2px 16px rgba(240,199,94,.18);
}

.close-x {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.12));
  border-color: rgba(255,255,255,.12);
  font-size: 17px;
}

.close-x:hover {
  background: rgba(244,209,124,.1);
  box-shadow: 0 0 18px rgba(240,199,94,.16);
}

.inv-grid {
  gap: 10px;
  padding: 18px 20px 16px;
}

.inv-slot,
.equip-row,
.stat-line,
.qlog-card,
.zone-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.012)),
    rgba(0,0,0,.24);
  border-color: rgba(255,255,255,.085);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), inset 0 -10px 18px rgba(0,0,0,.14);
}

.inv-slot {
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,.065), transparent 50%),
    linear-gradient(145deg, rgba(18,23,34,.78), rgba(2,5,10,.88));
}

.inv-slot::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.04);
  pointer-events: none;
}

.inv-slot:hover {
  transform: translateY(-2px);
  border-color: rgba(255,232,160,.68);
  box-shadow:
    0 12px 24px rgba(0,0,0,.28),
    0 0 18px rgba(240,199,94,.16),
    inset 0 1px 0 rgba(255,255,255,.08);
}

.inv-footer {
  padding: 14px 20px 18px;
  background: rgba(0,0,0,.16);
  border-top-color: rgba(255,255,255,.07);
}

.equip-row {
  grid-template-columns: 48px 1fr;
  padding: 10px;
  border-radius: 12px;
}

.equip-row .slot-ico {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 32%, rgba(255,255,255,.08), transparent 52%),
    rgba(0,0,0,.2);
}

.stat-line {
  padding: 10px 12px;
  border-radius: 12px;
}

.btn-sm {
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,232,160,.16), rgba(184,142,52,.1));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09);
}

#tooltip {
  padding: 14px 15px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(17,22,34,.98), rgba(5,8,15,.98));
  border-color: rgba(255,255,255,.16);
  box-shadow:
    0 22px 58px rgba(0,0,0,.58),
    0 0 0 1px rgba(244,209,124,.1),
    inset 0 1px 0 rgba(255,255,255,.06);
}

#tooltip .tt-name {
  font-size: 15px;
  margin-bottom: 7px;
}

#tooltip .tt-stat {
  padding: 3px 0;
}

.item-glyph {
  border-radius: 7px;
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,.58), transparent 24%),
    linear-gradient(145deg, color-mix(in srgb, var(--r) 82%, #f8fbff), color-mix(in srgb, var(--r) 44%, #080b13) 72%);
  box-shadow:
    0 0 16px color-mix(in srgb, var(--r) 42%, transparent),
    inset 0 1px 0 rgba(255,255,255,.28),
    inset 0 -8px 14px rgba(0,0,0,.24);
}

.item-glyph.inv,
.item-glyph.equip {
  width: 36px;
  height: 36px;
}

/* ---------- Mobile play layout ---------- */
#mobile-controls {
  display: none;
}

@media (max-width: 700px), (pointer: coarse) {
  html,
  body,
  #screen-game,
  #game-canvas {
    touch-action: none;
  }

  #hud-top {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 8px;
    right: 8px;
    grid-template-columns: minmax(132px, 38vw) minmax(132px, 1fr);
    gap: 6px;
    align-items: start;
  }

  .player-frame {
    width: min(38vw, 168px);
    min-width: 132px;
    max-width: none;
    gap: 7px;
    padding: 7px;
    border-radius: 14px;
  }

  .portrait {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    font-size: 22px;
    flex: 0 0 auto;
  }

  .name-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    align-items: center;
    margin-bottom: 4px;
    font-size: 11px;
  }

  #hud-name,
  #hud-class {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #hud-class {
    display: none;
  }

  #hud-level {
    padding: 0 6px;
    font-size: 10px;
  }

  .bar {
    height: 10px;
    margin-bottom: 3px;
  }

  .bar.xp {
    height: 5px;
  }

  .bar span {
    font-size: 9px;
  }

  .zone-badge {
    min-width: 0;
    width: min(44vw, 190px);
    padding: 8px 10px;
    border-radius: 13px;
  }

  #zone-name {
    font-size: 14px;
    letter-spacing: .06em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #zone-sub {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-stats {
    display: none;
  }

  .chip {
    padding: 7px 10px;
    font-size: 12px;
  }

  #quest-tracker,
  #combat-log {
    display: none !important;
  }

  #target-frame {
    top: calc(env(safe-area-inset-top, 0px) + 74px);
    min-width: 180px;
    max-width: 62vw;
    padding: 8px 10px;
    border-radius: 12px;
  }

  #target-frame .t-name {
    margin-bottom: 4px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #minimap-wrap {
    top: calc(env(safe-area-inset-top, 0px) + 132px);
    right: 8px;
    bottom: auto;
    width: 92px;
    height: 92px;
    border-radius: 13px;
    opacity: .88;
  }

  .mm-label {
    font-size: 9px;
    padding: 3px;
  }

  #side-btns {
    left: auto;
    right: 8px;
    top: calc(env(safe-area-inset-top, 0px) + 76px);
    bottom: auto;
    display: grid;
    grid-template-columns: repeat(5, 36px);
    gap: 5px;
    padding: 5px;
    border-radius: 13px;
  }

  .side-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 16px;
  }

  #skill-bar {
    left: auto;
    right: calc(env(safe-area-inset-right, 0px) + 10px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    transform: none;
    display: grid;
    grid-template-columns: repeat(3, 46px);
    gap: 7px;
    padding: 8px;
    border-radius: 15px;
  }

  .skill-slot {
    width: 46px;
    height: 46px;
    border-radius: 11px;
  }

  .skill-slot:hover {
    transform: none;
  }

  .skill-slot .sk-icon {
    font-size: 20px;
  }

  .skill-slot .key {
    top: 3px;
    left: 5px;
    font-size: 8px;
  }

  .skill-slot .sk-name {
    display: none;
  }

  #buff-bar {
    left: calc(env(safe-area-inset-left, 0px) + 16px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 136px);
    max-width: 120px;
  }

  #toast-stack {
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 136px);
    left: 50%;
    width: min(82vw, 360px);
  }

  .toast {
    max-width: 100%;
    border-radius: 18px;
    padding: 9px 14px;
    text-align: center;
    white-space: normal;
    line-height: 1.35;
    letter-spacing: 0;
  }

  #mobile-controls {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 12;
    pointer-events: none;
  }

  .mobile-stick {
    position: absolute;
    left: calc(env(safe-area-inset-left, 0px) + 16px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    width: 112px;
    height: 112px;
    pointer-events: auto;
  }

  .stick-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 50%, rgba(255,232,160,.1), rgba(8,12,22,.58) 62%, rgba(8,12,22,.78)),
      linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.16));
    border: 1px solid rgba(244,209,124,.28);
    box-shadow: 0 18px 40px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08);
  }

  .stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background:
      radial-gradient(circle at 34% 24%, rgba(255,255,255,.45), transparent 26%),
      linear-gradient(145deg, rgba(255,232,160,.9), rgba(184,142,52,.76));
    border: 1px solid rgba(255,255,255,.32);
    box-shadow: 0 10px 24px rgba(0,0,0,.36), 0 0 22px rgba(240,199,94,.24);
  }

  .mobile-actions {
    display: none;
  }

  .panel {
    width: calc(100vw - 20px);
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 28px);
    border-radius: 14px;
  }

  .panel.wide {
    width: calc(100vw - 20px);
  }

  .panel-head {
    padding: 14px 16px 12px;
  }

  .panel-head h3 {
    font-size: 18px;
  }

  .close-x {
    width: 36px;
    height: 36px;
  }

  .inv-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 14px;
  }

  .char-body,
  .map-zones {
    grid-template-columns: 1fr;
  }

  .cloud-account {
    padding: 12px 14px;
  }

  .cloud-account-top {
    align-items: flex-start;
  }

  .cloud-account-top strong {
    max-width: 58%;
  }

  .cloud-form {
    grid-template-columns: 1fr 1fr;
  }

  .cloud-form input,
  .cloud-form .btn-sm {
    width: 100%;
  }

  .cloud-tools {
    align-items: stretch;
  }

  .cloud-tools .btn-sm {
    flex: 1 1 92px;
  }

  .cloud-tools #cloud-status {
    flex: 1 0 100%;
    margin-left: 0;
  }

  .leader-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .leader-score {
    grid-column: 2;
    text-align: left;
  }

  #tooltip {
    display: none !important;
  }
}

@media (max-width: 380px), (pointer: coarse) and (max-width: 380px) {
  #hud-top {
    grid-template-columns: 128px 1fr;
  }

  .top-stats {
    display: none;
  }

  .zone-badge {
    width: auto;
  }

  #side-btns {
    grid-template-columns: repeat(3, 36px);
  }

  #minimap-wrap {
    top: calc(env(safe-area-inset-top, 0px) + 132px);
  }

  #skill-bar {
    grid-template-columns: repeat(3, 43px);
    gap: 6px;
  }

  .skill-slot {
    width: 43px;
    height: 43px;
  }

  .mobile-stick {
    width: 104px;
    height: 104px;
    left: calc(env(safe-area-inset-left, 0px) + 12px);
  }
}
