* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overflow: hidden; height: 100%; background: #05070f; font-family: 'Segoe UI', Verdana, sans-serif; touch-action: none; }
canvas#game-canvas { display: block; }

:root {
  --gold: #ffd782;
  --panel: rgba(10, 14, 26, 0.78);
  --panel-border: rgba(255, 215, 130, 0.4);
  --blue: #5ec8ff;
}

#hud { position: fixed; inset: 0; pointer-events: none; color: #eef1f7; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
/* No HUD over the login/character-select cinematic - only the world shows
   through those screens, like a real MMO title screen. */
#hud.hidden { display: none; }

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 8px; height: 8px;
  margin: -4px 0 0 -4px; border: 2px solid rgba(255,255,255,0.85); border-radius: 50%;
}

/* --- unit frames (player + target) --- */
#unitframe {
  position: absolute; top: 14px; left: 14px; width: 250px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 9px 11px; backdrop-filter: blur(3px);
}
#unitframe .name-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; margin-bottom: 5px; color: var(--gold); font-weight: 600; }
#player-class-text { font-size: 11px; opacity: 0.85; font-weight: 500; }
.bar { position: relative; height: 15px; border-radius: 5px; background: rgba(0,0,0,0.55); margin-bottom: 5px; overflow: hidden; border: 1px solid rgba(255,255,255,0.15); }
.bar.xp { height: 7px; }
.bar .fill { position: absolute; inset: 0; width: 0%; transition: width 0.15s ease; }
#health-fill { background: linear-gradient(180deg, #e4534a, #a5241b); }
#mana-fill { background: linear-gradient(180deg, #4d8ff0, #1c4fa8); }
#xp-fill { background: linear-gradient(180deg, #d8b23a, #92721a); }
.bar .label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; }
.meta-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 2px; }
#biome-text { font-size: 11px; opacity: 0.75; }
#gold-text { font-size: 12px; color: var(--gold); font-weight: 700; }

#target-frame {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 210px;
  background: var(--panel); border: 1px solid rgba(228, 72, 63, 0.55);
  border-radius: 10px; padding: 7px 10px; display: none;
}
#target-frame.visible { display: block; }
#target-frame .name-row { font-size: 12px; color: #ffb4af; font-weight: 600; margin-bottom: 4px; }
#target-health-fill { background: linear-gradient(180deg, #e4534a, #a5241b); }

/* --- party frames + invite prompt --- */
#party-frames { position: absolute; top: 122px; left: 14px; width: 250px; display: flex; flex-direction: column; gap: 5px; }
.party-frame {
  background: var(--panel); border: 1px solid rgba(94, 200, 255, 0.35);
  border-radius: 8px; padding: 5px 9px; font-size: 11px;
}
.party-frame .name-row { display: flex; justify-content: space-between; margin-bottom: 3px; color: var(--blue); font-weight: 600; }
.party-frame .bar { height: 9px; margin-bottom: 0; }

#party-invite-prompt {
  position: absolute; top: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 40, 70, 0.9); border: 1px solid var(--blue); border-radius: 8px;
  padding: 8px 14px; font-size: 13px; color: #dff0ff; display: flex; align-items: center; gap: 10px;
  pointer-events: auto; z-index: 30;
}
#party-invite-prompt.hidden { display: none; }

/* Duel challenge prompt - same placement rules as the party invite (explicit
   z-index:30 so touch-look-area taps can never eat the Accept button). */
#duel-prompt {
  position: absolute; top: 160px; left: 50%; transform: translateX(-50%);
  background: rgba(70, 25, 25, 0.92); border: 1px solid #ff8a7a; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; color: #ffe3df; display: flex; align-items: center; gap: 10px;
  pointer-events: auto; z-index: 30;
}
#duel-prompt.hidden { display: none; }

#crafting-list { max-height: 50vh; overflow-y: auto; text-align: left; touch-action: pan-y; }

#minimap-wrap { position: absolute; top: 14px; right: 14px; text-align: center; }
#minimap { border-radius: 50%; border: 2px solid rgba(255, 215, 130, 0.5); background: #0a0e18; }
#clock-text { font-size: 11px; margin-top: 4px; opacity: 0.85; }

#quest-panel {
  position: absolute; top: 175px; right: 14px; width: 220px;
  background: var(--panel); border: 1px solid rgba(120, 170, 255, 0.35);
  border-radius: 10px; padding: 8px 10px;
}
#quest-panel h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.06em; color: #9fd4ff; text-transform: uppercase; }
#quest-list { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.5; }
/* L toggles this closed, WoW-style - collapses to just the title bar */
#quest-panel.collapsed { padding-bottom: 0; }
#quest-panel.collapsed h3::after { content: ' (L to open)'; opacity: 0.6; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 10px; }
#quest-panel.collapsed #quest-list { display: none; }

/* --- Today's Tasks (dailies + login streak) --- */
#daily-panel {
  position: absolute; top: 360px; right: 14px; width: 220px;
  background: var(--panel); border: 1px solid rgba(255, 196, 92, 0.42);
  border-radius: 10px; padding: 8px 10px;
}
#daily-panel h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.05em; color: #ffcf7a; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
#daily-streak { color: #ff8a3d; font-weight: 700; text-transform: none; letter-spacing: 0; }
#daily-list { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.5; }
#daily-list .daily-done { color: #7fe07f; }
#daily-list .daily-clear { color: #9fd4ff; font-style: italic; margin-top: 3px; }

/* --- action bar (class abilities) --- */
/* z-index matters here: #action-bar lives in #hud, which comes before
   #touch-ui in the DOM, so #touch-look-area (the full-height drag-to-look
   zone covering the right 55% of the screen) would otherwise win every tap
   that lands on the right side of the bar and silently eat it as a look-drag
   instead of an ability cast. */
#action-bar { position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; z-index: 20; }
.ability-slot {
  position: relative; width: 58px; height: 58px; border-radius: 9px; cursor: pointer;
  background: rgba(10, 14, 26, 0.85); border: 2px solid rgba(255,255,255,0.3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 22px; user-select: none; overflow: hidden;
}
.ability-slot .ability-key { position: absolute; top: 2px; left: 5px; font-size: 10px; color: var(--gold); font-weight: 700; }
.ability-slot .ability-cost { position: absolute; bottom: 2px; right: 5px; font-size: 9px; color: #9fc5ff; }
.ability-slot .cooldown-sweep {
  position: absolute; inset: 0; background: rgba(0,0,0,0.72);
  transform-origin: bottom; transform: scaleY(0); pointer-events: none;
}
.ability-slot.on-cooldown { border-color: rgba(255,255,255,0.15); }
.ability-slot.no-mana .ability-cost { color: #ff8f8f; }
.ability-slot:active { border-color: var(--gold); }

/* same reasoning as #action-bar above - must outrank #touch-look-area */
#hotbar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; pointer-events: auto; z-index: 20; }
.hotbar-slot {
  position: relative; width: 52px; height: 52px; background: rgba(10, 14, 26, 0.75); border: 2px solid rgba(255,255,255,0.25);
  border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; cursor: pointer;
}
.hotbar-slot.active { border-color: var(--gold); box-shadow: 0 0 8px rgba(255, 215, 130, 0.65); }
.slot-key { position: absolute; top: 2px; left: 4px; font-size: 9px; opacity: 0.7; }
.slot-label { font-size: 10px; }

#toasts { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; align-items: center; }
.toast { background: rgba(10, 14, 26, 0.85); border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; padding: 4px 10px; font-size: 13px; transition: opacity 0.2s; }

#storm-banner {
  position: absolute; top: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(90, 20, 130, 0.85); border: 1px solid #c76bff; border-radius: 6px;
  padding: 6px 16px; font-size: 13px; opacity: 0; transition: opacity 0.3s; font-weight: 600;
}
#storm-banner.visible { opacity: 1; }

#vendor-prompt {
  position: absolute; bottom: 200px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 60, 30, 0.88); border: 1px solid #7cf59a; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; color: #d9ffe3; cursor: pointer; pointer-events: auto;
  font-family: inherit;
  z-index: 30; /* above the touch look-area, or phone taps never reach it */
}
#vendor-prompt.hidden { display: none; }
#vendor-prompt kbd {
  background: rgba(255,255,255,0.16); border-radius: 4px; padding: 1px 7px;
  font-family: 'Consolas', monospace; font-size: 12px; margin-left: 4px;
}

#quest-prompt {
  position: absolute; bottom: 250px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 40, 60, 0.88); border: 1px solid #ffd94a; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; color: #ffeecb; cursor: pointer; pointer-events: auto;
  font-family: inherit; z-index: 30;
}
#quest-prompt.hidden { display: none; }
#quest-prompt kbd {
  background: rgba(255,255,255,0.16); border-radius: 4px; padding: 1px 7px;
  font-family: 'Consolas', monospace; font-size: 12px; margin-left: 4px;
}

/* --- quest-giver dialogue --- */
#dialogue-list { max-height: 50vh; overflow-y: auto; text-align: left; touch-action: pan-y; }
.dialogue-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.65; margin: 10px 0 4px; }
.dialogue-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 13px;
}
.dialogue-row .dialogue-name { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.dialogue-row .dialogue-name small { opacity: 0.65; font-size: 11px; }
.dialogue-row.ready .dialogue-name { color: #ffd94a; }
/* main-story chapters read as special: gold left edge + the giver's words */
.dialogue-row.story { border-left: 3px solid var(--gold); padding-left: 8px; background: rgba(255,215,130,0.05); }
.dialogue-story-text {
  font-size: 12.5px; font-style: italic; line-height: 1.5; opacity: 0.85;
  margin: 6px 4px 12px; padding: 8px 10px; border-left: 2px solid rgba(255,215,130,0.4);
  background: rgba(255,255,255,0.03); border-radius: 0 6px 6px 0;
}
.dialogue-story-text.outro { border-left-color: #7cf59a; background: rgba(124,245,154,0.06); }

/* --- story journal (J) --- */
#journal-list { max-height: 56vh; overflow-y: auto; text-align: left; touch-action: pan-y; }
.journal-chapter { padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.journal-chapter-head { font-size: 13.5px; font-weight: 600; }
.journal-chapter-head small { opacity: 0.65; font-weight: 400; }
.journal-chapter .journal-glyph { display: inline-block; width: 18px; }
.journal-chapter.done .journal-chapter-head { color: var(--gold); }
.journal-chapter.active .journal-chapter-head { color: #9ecbff; }
.journal-chapter.locked { opacity: 0.45; }
.journal-chapter-text { font-size: 12px; font-style: italic; line-height: 1.5; opacity: 0.8; margin: 5px 0 0 18px; }
.journal-chapter.epilogue-line { text-align: center; font-size: 13px; padding: 12px 6px; border-bottom: none; }
.quest-story { color: var(--gold); }

/* --- story epilogue overlay --- */
#epilogue-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(3,5,12,0.88); z-index: 60; /* above every menu (40) and prompt (30) */
  pointer-events: all;
}
#epilogue-overlay.hidden { display: none; }
.settings-box.epilogue-box { width: min(520px, 92vw); text-align: center; }
#epilogue-text h3 { color: var(--gold); font-size: 20px; margin: 10px 0; letter-spacing: 0.04em; }
#epilogue-text p { font-size: 13.5px; line-height: 1.6; opacity: 0.9; margin: 10px 0; }
#epilogue-text .epilogue-sign { font-style: italic; color: #9ecbff; margin-top: 16px; }

/* --- vendor shop --- */
#shop-gold-row { font-size: 14px; margin-bottom: 12px; }
#shop-gold-text { color: var(--gold); font-weight: 700; }
#shop-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
#shop-list { max-height: 46vh; overflow-y: auto; text-align: left; touch-action: pan-y; }
.shop-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 13px;
}
.shop-row .shop-icon { font-size: 20px; width: 28px; text-align: center; }
.shop-row .shop-name { flex: 1; }
.shop-row .shop-name small { display: block; opacity: 0.65; font-size: 11px; }
.shop-row .shop-price { color: var(--gold); font-weight: 600; white-space: nowrap; }
.shop-row .shop-owned { font-size: 11px; opacity: 0.75; white-space: nowrap; }
.shop-btn {
  padding: 6px 12px; border-radius: 7px; font-size: 12px; cursor: pointer; color: #eef1f7;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3); white-space: nowrap;
}
.shop-btn:hover { background: rgba(255, 215, 130, 0.2); border-color: var(--gold); }
.shop-btn:disabled { opacity: 0.35; cursor: default; }
.shop-row.owned-upgrade .shop-price { color: #7cf59a; }

#hint-bar {
  position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%);
  font-size: 11px; opacity: 0.55; white-space: nowrap;
}

#perf-badge {
  position: absolute; top: 44px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; font-size: 11px; opacity: 0.6; font-family: 'Consolas', monospace;
}

#chat-box { position: absolute; bottom: 84px; left: 14px; width: 280px; }
#chat-log {
  max-height: 110px; overflow: hidden; display: flex; flex-direction: column-reverse;
  margin-bottom: 4px; font-size: 12px;
}
#chat-log div {
  background: rgba(10, 14, 26, 0.6); border-radius: 4px; padding: 2px 8px; margin-top: 3px; width: fit-content; max-width: 100%;
}
#chat-log .chat-name { color: var(--gold); font-weight: 600; margin-right: 4px; }
#chat-input {
  width: 100%; padding: 6px 8px; font-size: 12px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); border-radius: 4px; color: #eef1f7;
  opacity: 0.55; pointer-events: none;
}
#chat-input.active { opacity: 1; pointer-events: all; }

/* --- overlay menus --- */
.overlay-menu, #settings-menu {
  position: absolute; inset: 0; background: rgba(2, 3, 8, 0.82);
  display: none; align-items: center; justify-content: center; pointer-events: none;
}
/* z-index must outrank #hotbar/#action-bar (both explicitly 20, so they can
   win over #touch-look-area) - without this, a tall overlay (e.g. the world
   map) whose buttons land in the hotbar's screen region silently loses
   every click to the hotbar sitting underneath instead of the menu on top. */
.overlay-menu.visible, #settings-menu.visible { display: flex; pointer-events: all; z-index: 40; }
.settings-box {
  background: linear-gradient(160deg, rgba(16, 20, 36, 0.97), rgba(9, 11, 22, 0.97));
  border: 1px solid var(--panel-border); box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  border-radius: 14px; padding: 24px 28px; width: 400px; max-width: 92vw; max-height: 88vh; overflow-y: auto; text-align: center;

  /* html/body set touch-action:none (blocks pinch-zoom/pull-to-refresh over the
     3D canvas); that also disables touch panning inside any scrollable child
     unless explicitly re-enabled here - without this, the vendor shop list and
     other overlay menus can't be scrolled by touch on phones. */
  touch-action: pan-y;
}
.settings-box.wide { width: 460px; }
.settings-box.huge { width: 640px; }
#world-map-canvas { width: 100%; max-width: 600px; aspect-ratio: 1 / 1; border-radius: 10px; border: 2px solid rgba(255, 215, 130, 0.5); background: #0a0e18; }
#world-map-legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-size: 12px; margin: 10px 0 14px; opacity: 0.85; }
#world-map-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-village { background: #ffd782; }
.legend-vendor { background: #7cf59a; }
.legend-mob { background: #e4483f; }
.legend-player { background: #5ec8ff; }
.settings-box h2 { margin: 0 0 14px; color: var(--gold); font-size: 19px; letter-spacing: 0.02em; }
#settings-detected { font-size: 12px; opacity: 0.8; margin-bottom: 12px; line-height: 1.6; white-space: pre-line; }
.settings-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.65; text-align: left; margin: 6px 0; }
#settings-quality-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.quality-btn {
  flex: 1; padding: 10px 6px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; color: #eef1f7; font-size: 13px; cursor: pointer;
}
.quality-btn:hover { background: rgba(255,255,255,0.16); }
.quality-btn.active { border-color: var(--gold); background: rgba(255, 215, 130, 0.18); color: var(--gold); }
.quality-btn.full-width { width: 100%; margin-bottom: 12px; }
.quality-btn.big { padding: 12px; font-size: 15px; font-weight: 600; }
.quality-btn.hidden { display: none; }
.settings-hint { font-size: 11px; opacity: 0.6; line-height: 1.5; margin: 0 0 14px; }
#settings-close, .settings-close-generic {
  padding: 9px 22px; background: rgba(255, 215, 130, 0.15); border: 1px solid rgba(255, 215, 130, 0.5);
  border-radius: 8px; color: var(--gold); font-size: 13px; cursor: pointer;
}
#settings-close:hover, .settings-close-generic:hover { background: rgba(255, 215, 130, 0.28); }

.settings-slider-row { text-align: left; margin-bottom: 10px; }
.settings-slider-row label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; opacity: 0.9; }
.settings-slider-row input[type="range"] { width: 100%; accent-color: var(--gold); }
.settings-toggle-row { display: flex; gap: 18px; justify-content: flex-start; margin: 4px 0 12px; flex-wrap: wrap; }
.settings-toggle-row label { font-size: 12px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.settings-toggle-row input { accent-color: var(--gold); }

.menu-text { font-size: 13px; opacity: 0.9; margin-bottom: 16px; }
.menu-list { text-align: left; font-size: 13px; list-style: none; padding: 0; margin: 0 0 16px; }
.menu-list li { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.07); }
.menu-label { display: block; text-align: left; font-size: 11px; opacity: 0.7; margin: 10px 0 5px; }
.menu-input {
  width: 100%; padding: 9px 10px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.3); border-radius: 8px; color: #eef1f7; font-size: 13px;
}
#character-color-row { display: flex; gap: 8px; justify-content: center; margin: 4px 0 16px; flex-wrap: wrap; }
.color-swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25); cursor: pointer; }
.color-swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 215, 130, 0.4); }
#character-class-row { display: flex; gap: 8px; margin: 4px 0 6px; }
.class-chip {
  flex: 1; padding: 8px 4px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05); cursor: pointer; font-size: 12px; color: #eef1f7; text-align: center;
}
.class-chip.active { border-color: var(--gold); background: rgba(255, 215, 130, 0.14); }
#character-save-btn { margin-top: 14px; }

/* --- console --- */
#console {
  position: absolute; bottom: 0; left: 0; right: 0; height: 42%;
  background: rgba(5, 7, 15, 0.92); border-top: 1px solid rgba(255,255,255,0.2);
  display: flex; flex-direction: column; padding: 8px 10px; pointer-events: none;
  transform: translateY(100%); transition: transform 0.15s ease;
}
#console.visible { transform: translateY(0); pointer-events: all; }
#console-log { flex: 1; overflow-y: auto; font-family: 'Consolas', monospace; font-size: 12px; margin-bottom: 6px; }
#console-log div { padding: 1px 0; opacity: 0.9; }
#console-input {
  font-family: 'Consolas', monospace; font-size: 13px; padding: 6px 8px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; color: #eef1f7;
}

/* --- full-screen states: login, character select, class select, game menu --- */
#blocker, #login-screen, #class-select, #char-select {
  position: fixed; inset: 0; color: #eef1f7;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 42, 80, 0.9), rgba(2, 3, 8, 0.96) 70%);
  display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center;
  transition: opacity 0.25s ease; padding: 16px;
}
#blocker.hidden, #login-screen.hidden, #class-select.hidden, #char-select.hidden { opacity: 0; pointer-events: none; }

/* Cinematic screens (login + character select) sit over the live 3D world -
   the camera slowly orbits Joschiheim behind them (see main.js), so the
   backdrop is a readability vignette, not an opaque wall. */
#login-screen.cinematic, #char-select.cinematic {
  background:
    linear-gradient(180deg, rgba(2, 3, 8, 0.72) 0%, rgba(2, 3, 8, 0.18) 30%, rgba(2, 3, 8, 0.18) 62%, rgba(2, 3, 8, 0.82) 100%),
    radial-gradient(ellipse at 50% 45%, rgba(2, 3, 8, 0) 35%, rgba(2, 3, 8, 0.55) 100%);
}

.game-logo { font-size: 34px; font-weight: 800; letter-spacing: 0.04em; margin-bottom: 10px; color: #eef1f7; text-shadow: 0 3px 14px rgba(0,0,0,0.8); }
.game-logo span { color: var(--gold); }
.game-logo.small { font-size: 24px; }
.game-logo.epic {
  font-size: 46px; letter-spacing: 0.06em; margin-bottom: 4px;
  background: linear-gradient(180deg, #fff3d0 20%, var(--gold) 55%, #b8862e 90%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 26px rgba(255, 215, 130, 0.28));
}
.game-logo.epic span { -webkit-text-fill-color: transparent; }
.login-tagline { font-size: 13px; opacity: 0.8; margin-bottom: 22px; text-shadow: 0 2px 6px rgba(0,0,0,0.9); }

/* --- character select (WoW/D3-style) --- */
#char-select-main { display: flex; flex-direction: column; align-items: center; max-width: 100%; }
#char-select-main.hidden { display: none; }
#char-select-layout { display: flex; gap: 26px; align-items: stretch; justify-content: center; flex-wrap: wrap; max-width: 96vw; }
#char-list-pane {
  width: 300px; max-width: 92vw; display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(160deg, rgba(16, 20, 36, 0.92), rgba(9, 11, 22, 0.92));
  border: 1px solid var(--panel-border); border-radius: 14px; padding: 14px;
  max-height: 62vh;
}
#char-roster-header { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); display: flex; justify-content: space-between; }
#char-roster-count { opacity: 0.7; text-transform: none; letter-spacing: 0; }
#char-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; touch-action: pan-y; min-height: 120px; }
.char-card {
  --class-color: rgba(255,255,255,0.35);
  display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.14);
  text-align: left; transition: border-color 0.12s ease, transform 0.12s ease;
}
.char-card:hover { transform: translateX(3px); border-color: var(--class-color); }
.char-card.selected { border-color: var(--class-color); background: rgba(255, 215, 130, 0.1); box-shadow: 0 0 14px rgba(255, 215, 130, 0.18), inset 0 0 10px rgba(255,255,255,0.03); }
.char-card-icon { font-size: 24px; width: 32px; text-align: center; }
.char-card-main { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.char-card-name { font-weight: 700; font-size: 14px; color: #f4e9cf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-card-sub { font-size: 11px; opacity: 0.75; }
.char-card-gold { font-size: 11px; color: var(--gold); white-space: nowrap; }

#char-preview-pane {
  width: 330px; max-width: 92vw; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: linear-gradient(160deg, rgba(16, 20, 36, 0.85), rgba(9, 11, 22, 0.9));
  border: 1px solid var(--panel-border); border-radius: 14px; padding: 14px;
}
#char-preview-canvas { width: 100%; height: 300px; display: block; border-radius: 10px; background: radial-gradient(ellipse at 50% 80%, rgba(60, 52, 24, 0.5), rgba(5, 7, 15, 0.2) 70%); }
#char-preview-name { font-size: 22px; font-weight: 800; color: #f4e9cf; text-shadow: 0 2px 8px rgba(0,0,0,0.8); }
#char-preview-class { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
#char-preview-stats { display: flex; flex-direction: column; gap: 2px; font-size: 12px; opacity: 0.85; margin-bottom: 10px; }
#char-select-actions { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.char-actions-row { display: flex; gap: 8px; justify-content: center; }
.char-actions-row .menu-btn { flex: 1; }
.menu-btn.danger { border-color: rgba(228, 72, 63, 0.5); color: #ffb4af; }
.menu-btn.danger:hover { background: rgba(228, 72, 63, 0.18); }
.shop-btn.danger { border-color: rgba(228, 72, 63, 0.6); color: #ffb4af; }

#char-delete-confirm {
  margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  background: rgba(60, 8, 14, 0.9); border: 1px solid rgba(228, 72, 63, 0.6); border-radius: 10px;
  padding: 10px 16px; font-size: 13px;
}
#char-delete-confirm.hidden { display: none; }

#char-create-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 96vw; }
#char-create-panel.hidden { display: none; }
#char-create-name { width: 300px; max-width: 90vw; }
#char-create-classes { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 900px; }
.class-card.compact { width: 165px; padding: 12px 10px; }
.class-card.compact .class-icon { font-size: 32px; }
.class-card.active { border-color: var(--gold); box-shadow: 0 0 16px rgba(255, 215, 130, 0.35); transform: translateY(-4px); }
#char-create-colors { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#char-create-hair { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.hair-swatch {
  padding: 6px 14px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.05); cursor: pointer; font-size: 12px; color: #eef1f7;
}
.hair-swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 215, 130, 0.4); }
#char-create-error { color: #ffb4af; font-size: 13px; font-weight: 600; min-height: 18px; }
.settings-section-label.centered { text-align: center; }
#blocker p { opacity: 0.85; max-width: 460px; line-height: 1.5; font-size: 14px; }
#blocker .keys { margin-top: 20px; font-size: 11px; opacity: 0.6; max-width: 520px; line-height: 1.7; display: flex; flex-direction: column; gap: 2px; text-align: center; }
#menu-buttons { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; width: 250px; }
.menu-btn {
  padding: 12px; font-size: 14px; border-radius: 10px; cursor: pointer; color: #eef1f7;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.22); text-align: center;
}
.menu-btn:hover { background: rgba(255,255,255,0.14); }
.menu-btn.primary { background: rgba(255, 215, 130, 0.18); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.menu-btn.primary:hover { background: rgba(255, 215, 130, 0.3); }

.login-box { width: 380px; }
.login-hint { text-align: left; }
.login-input { text-align: center; font-size: 14px; margin: 10px 0 12px; }
#login-error {
  color: #ffb4af; background: rgba(228,72,63,0.18); border: 1px solid rgba(228,72,63,0.4);
  border-radius: 6px; font-size: 13px; font-weight: 600; min-height: 18px; padding: 6px 8px; margin-bottom: 10px; display: none;
}

#class-cards { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.class-card {
  width: 190px; padding: 18px 14px; border-radius: 14px; cursor: pointer; text-align: center;
  background: linear-gradient(160deg, rgba(16, 20, 36, 0.95), rgba(9, 11, 22, 0.95));
  border: 2px solid rgba(255,255,255,0.18); transition: transform 0.12s ease, border-color 0.12s ease;
}
.class-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.class-card .class-icon { font-size: 40px; margin-bottom: 6px; }
.class-card h3 { margin: 0 0 4px; font-size: 17px; }
.class-card .class-tagline { font-size: 11px; opacity: 0.7; margin-bottom: 10px; min-height: 28px; }
.class-card ul { list-style: none; margin: 0; padding: 0; font-size: 11px; text-align: left; opacity: 0.85; }
.class-card li { padding: 2px 0; }

/* --- touch controls --- */
#touch-ui { display: none; }
#touch-ui.visible { display: block; }
#touch-look-area { position: absolute; top: 0; right: 0; width: 55%; height: 100%; pointer-events: auto; }
#touch-joystick {
  position: absolute; bottom: 90px; left: 26px; width: 128px; height: 128px; border-radius: 50%;
  background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.25); pointer-events: auto;
}
#touch-joystick-knob {
  position: absolute; top: 50%; left: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(255,255,255,0.3); border: 2px solid rgba(255,255,255,0.5);
}
#touch-buttons { position: absolute; bottom: 96px; right: 20px; display: flex; flex-direction: column; gap: 12px; pointer-events: auto; }
#touch-top-buttons { position: absolute; top: 160px; right: 14px; display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
.touch-btn {
  width: 62px; height: 62px; border-radius: 50%; font-size: 24px;
  background: rgba(10, 14, 26, 0.7); border: 2px solid rgba(255,255,255,0.35); color: #eef1f7;
}
.touch-btn.small { width: 44px; height: 44px; font-size: 18px; }
.touch-btn:active { background: rgba(255, 215, 130, 0.3); border-color: var(--gold); }

/* --- phone/tablet layout --- */
@media (max-width: 900px), (max-height: 560px) {
  #unitframe { width: 190px; padding: 6px 8px; transform: scale(0.92); transform-origin: top left; }
  #quest-panel { display: none; }
  #hint-bar { display: none; }
  #minimap { width: 96px; height: 96px; }
  #chat-box { width: 200px; bottom: 230px; }
  #chat-log { max-height: 72px; font-size: 11px; }
  .hotbar-slot { width: 40px; height: 40px; }
  .ability-slot { width: 50px; height: 50px; font-size: 19px; }
  #action-bar { bottom: 72px; }
  #hotbar { bottom: 14px; }
  /* target frame sits under the unit frame instead of colliding with it */
  #target-frame { width: 170px; top: 104px; left: 10px; transform: none; }
  #toasts { top: 56px; }
  body.touch-mode #chat-input:not(.active) { display: none; }
  .game-logo { font-size: 26px; }
  #perf-badge { display: none; }
  body.touch-mode #hotbar { left: 12px; transform: none; }
  /* Abilities move to the right, stacked above the attack/jump/place column,
     instead of sitting under the movement joystick (bottom:90-218px, left:26-154px) -
     they used to overlap it, and since the joystick markup comes later in the
     DOM it silently won the touch, swallowing every ability tap while moving. */
  body.touch-mode #action-bar {
    left: auto; right: 16px; bottom: 300px; transform: none; gap: 6px;
  }
  body.touch-mode .ability-slot { width: 44px; height: 44px; font-size: 17px; }

  /* character select on phones: stack panes, shrink the pedestal */
  .game-logo.epic { font-size: 30px; }
  #char-select { overflow-y: auto; justify-content: flex-start; padding-top: 26px; }
  #char-select-layout { gap: 12px; }
  #char-list-pane { max-height: 34vh; }
  #char-preview-canvas { height: 190px; }
  .class-card.compact { width: 140px; padding: 9px 8px; }
  .class-card.compact ul { display: none; }
}

/* --- v4: world events, low-HP vignette, Diablo-style equipment --- */
#event-banner {
  position: absolute; top: 116px; left: 50%; transform: translateX(-50%);
  padding: 10px 22px; border-radius: 10px; font-size: 17px; font-weight: 800;
  color: #ffd9d0; background: rgba(60, 8, 14, 0.82); border: 1px solid rgba(255, 90, 70, 0.55);
  text-shadow: 0 2px 8px rgba(0,0,0,0.8); box-shadow: 0 0 24px rgba(200, 30, 30, 0.35);
  opacity: 0; transition: opacity 0.4s ease; pointer-events: none; text-align: center; max-width: 80vw;
}
#event-banner.visible { opacity: 1; }

#vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s ease;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(160, 10, 10, 0.55) 100%);
}

#equipment-list { max-height: 220px; overflow-y: auto; margin: 4px 0 8px; text-align: left; }
.gear-slot-header {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.65;
  margin: 8px 0 3px; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 2px;
}
.gear-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px;
  background: rgba(255,255,255,0.04); margin-bottom: 3px; font-size: 13px;
}
.gear-row.equipped { background: rgba(255, 215, 130, 0.12); border: 1px solid rgba(255, 215, 130, 0.4); }
.gear-row.empty { opacity: 0.5; font-size: 12px; }
.gear-name { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.gear-name small { color: #cfd6e4; font-size: 11px; }
.menu-text.small { font-size: 12px; margin-bottom: 6px; }

/* --- character menu tabs (Equipment / Talents) --- */
#character-tabs { display: flex; gap: 8px; margin: 10px 0 6px; }
#character-tabs .quality-btn { padding: 7px 6px; font-size: 12px; }
.pane-hidden { display: none; }

/* --- paperdoll (equipped-slot squares) + stat breakdown --- */
#paperdoll-row { display: flex; gap: 10px; justify-content: center; margin: 6px 0 12px; }
.paperdoll-slot {
  width: 68px; height: 68px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.25);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; transition: transform 0.1s ease;
}
.paperdoll-slot:hover { transform: translateY(-2px); }
.paperdoll-slot.selected { background: rgba(255, 215, 130, 0.12); }
.paperdoll-slot.empty { opacity: 0.55; border-style: dashed; }
.paperdoll-icon { font-size: 26px; line-height: 1; }
.paperdoll-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.75; }
#stat-breakdown-list { margin: 0 0 10px; text-align: left; }
.stat-breakdown-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 2px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.stat-breakdown-row span:first-child { opacity: 0.75; }
.stat-breakdown-row span:last-child { color: var(--gold); font-weight: 600; }
#talent-list { max-height: 220px; overflow-y: auto; margin: 4px 0 8px; text-align: left; }
.talent-row .gear-name { flex: 1; }
.talent-rank { font-size: 12px; color: var(--gold); font-weight: 600; white-space: nowrap; margin-right: 4px; }

/* --- inventory / bags (I key) --- */
#inventory-gold-row { text-align: left; font-size: 13px; color: var(--gold); font-weight: 600; margin-bottom: 8px; }
#inventory-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px;
  max-height: 55vh; overflow-y: auto; touch-action: pan-y;
}
.bag-slot {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 10px 6px 8px; position: relative; text-align: center;
}
.bag-icon { font-size: 26px; line-height: 1; }
.bag-count { position: absolute; top: 4px; right: 7px; font-size: 11px; font-weight: 700; color: var(--gold); text-shadow: 0 1px 2px rgba(0,0,0,0.9); }
.bag-name { font-size: 10.5px; opacity: 0.8; line-height: 1.2; }
.bag-use-btn { margin-top: 4px; padding: 3px 10px; font-size: 11px; }
#inventory-grid .gear-row.empty { grid-column: 1 / -1; }

/* --- admin player roster panel --- */
#admin-summary { text-align: left; margin-bottom: 10px; }
#admin-players { max-height: 60vh; overflow-y: auto; text-align: left; touch-action: pan-y; }
.admin-account { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.14); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.admin-account-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--gold); flex-wrap: wrap; }
.admin-account-meta { font-size: 11px; opacity: 0.7; margin: 2px 0 6px; }
.admin-char-row { display: flex; gap: 10px; font-size: 12px; padding: 3px 0; border-top: 1px solid rgba(255,255,255,0.08); flex-wrap: wrap; }
.admin-char-row span:first-child { min-width: 110px; font-weight: 600; }
#admin-players .gear-row.empty { text-align: center; }
