@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&family=Noto+Sans+JP:wght@300;400;500&display=swap');

:root {
  --bg-primary: #060608;
  --bg-secondary: #0d0d10;
  --bg-card: #111115;
  --bg-glass: rgba(14,14,18,0.85);
  --text-primary: #dde1e7;
  --text-secondary: #555566;
  --text-muted: #333340;
  --accent: #9b59b6;
  --accent-hover: #8e44ad;
  --accent-dim: rgba(155,89,182,0.12);
  --border: #1c1c24;
  --border-subtle: #161620;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --copper: #cd7f32;
  --silver: #9ea3ad;
  --gold: #f1c40f;

  --font-main: 'Space Grotesk', 'Noto Sans JP', sans-serif;
  --font-mono: 'Space Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --bar-height: 3px;
  --stat-bar-height: 4px;
  --border-width: 1px;

  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
  --spring: 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: 72px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 2px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; opacity: 0.3; }

/* ===== FILM GRAIN ===== */
.film-grain-overlay::after {
  content: "";
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
}

/* ===== PAGE TITLES ===== */
.page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.neon-text {
  text-shadow: 0 0 8px var(--accent), 0 0 24px rgba(155,89,182,0.3);
}

/* ===== GLASS ===== */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
}

/* ===== PAGE PADDING ===== */
.tab-content { padding: 16px; }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes barFill {
  from { width: 0%; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes shimmer {
  from { background-position: -200% center; }
  to   { background-position: 200% center; }
}
@keyframes glitch {
  0%, 100% { clip-path: inset(0 0 98% 0); transform: translate(-4px,0); }
  25%       { clip-path: inset(30% 0 50% 0); transform: translate(4px,0); }
  50%       { clip-path: inset(70% 0 10% 0); transform: translate(-2px,0); }
  75%       { clip-path: inset(10% 0 80% 0); transform: translate(2px,0); }
}
@keyframes levelUp {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 var(--accent); }
  30%  { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(155,89,182,0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(155,89,182,0); }
}
@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes levelUpModal {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes confetti {
  0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(200px) rotate(720deg); opacity: 0; }
}

/* ===== REGISTER SCREEN ===== */
.register-screen {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn 0.4s ease;
}

.register-box {
  background: var(--bg-secondary);
  padding: 40px 28px;
  border-radius: var(--radius-xl);
  max-width: 400px; width: 100%;
  border: var(--border-width) solid var(--border);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: scaleIn 0.4s var(--spring);
}

.register-box h1 {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.register-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.register-avatar {
  display: flex; flex-direction: column; align-items: center; margin-bottom: 24px;
}
.register-avatar-preview {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--bg-primary);
  border: var(--border-width) solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; margin-bottom: 10px; overflow: hidden;
  box-shadow: 0 0 20px rgba(155,89,182,0.2);
  transition: box-shadow var(--transition);
}
.register-avatar-preview:hover { box-shadow: 0 0 30px rgba(155,89,182,0.4); }
.register-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.register-avatar-btn {
  background: transparent;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: var(--border-width) solid var(--border);
  transition: var(--transition);
  color: var(--text-secondary);
  font-family: var(--font-main);
}
.register-avatar-btn:hover { border-color: var(--accent); color: var(--text-primary); }

.register-field { margin-bottom: 14px; }
.register-field label {
  display: block; font-size: 11px; color: var(--text-secondary);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1.5px;
  font-family: var(--font-mono);
}
.register-field input,
.register-field textarea {
  width: 100%; padding: 10px 14px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary); color: var(--text-primary);
  font-family: var(--font-main); font-size: 14px;
  transition: border-color var(--transition);
}
.register-field input:focus,
.register-field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155,89,182,0.08);
}
.register-field textarea { resize: none; min-height: 70px; }

.btn-large { width: 100%; padding: 14px; font-size: 15px; margin-top: 10px; }

/* ===== GLITCH BUTTON ===== */
.glitch-btn { position: relative; overflow: hidden; }
.glitch-btn::before {
  content: attr(data-text);
  position: absolute; inset: 0;
  color: var(--accent);
  opacity: 0;
  animation: glitch 3s infinite;
  pointer-events: none;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(6,6,8,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: var(--border-width) solid var(--border);
  padding: 6px 0 10px;
  z-index: 100;
  max-width: 480px; margin: 0 auto;
}
.nav-btn {
  flex: 1; background: none; border: none;
  color: var(--text-secondary); font-size: 10px;
  padding: 5px 0; cursor: pointer;
  transition: color var(--transition);
  font-family: var(--font-main);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative;
}
.nav-btn .nav-icon { font-size: 18px; line-height: 1; }
.nav-btn .nav-label { font-size: 9px; letter-spacing: 0.5px; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 1px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}
.nav-btn:hover { color: var(--text-primary); }

/* ===== TABS ===== */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp 0.3s ease; }

/* ===== PROFILE HEADER ===== */
.profile-header {
  position: relative; min-height: 240px;
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  background: linear-gradient(135deg, #0d0d12, #141420);
  background-size: cover; background-position: center;
  overflow: hidden;
  border: var(--border-width) solid var(--border);
}
.profile-header-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,6,8,0.1) 0%, rgba(6,6,8,0.75) 70%, rgba(6,6,8,0.95) 100%);
  z-index: 1;
}
.profile-bg-gif {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}
.profile-header-content {
  position: relative; z-index: 1;
  text-align: center; padding: 28px 20px 20px;
  animation: fadeUp 0.4s ease 0.1s both;
}

.avatar-container {
  position: relative; display: inline-block;
  margin-bottom: 10px;
}
#avatar {
  width: 76px; height: 76px; border-radius: 50%;
  border: var(--border-width) solid var(--accent);
  object-fit: cover; background: var(--bg-primary);
  box-shadow: 0 0 20px rgba(155,89,182,0.25), 0 4px 16px rgba(0,0,0,0.5);
  transition: box-shadow var(--transition);
  display: block;
}
#avatar:hover { box-shadow: 0 0 30px rgba(155,89,182,0.5); }
.edit-avatar-btn {
  position: absolute; bottom: 2px; right: 2px;
  background: var(--bg-card);
  border: var(--border-width) solid var(--border);
  border-radius: 50%; width: 24px; height: 24px;
  color: var(--text-secondary); cursor: pointer; font-size: 11px;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.edit-avatar-btn:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.1); }

#nickname {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.5px;
  text-shadow: 0 0 12px rgba(155,89,182,0.4);
  margin-bottom: 3px;
}
.title {
  color: var(--accent); font-size: 12px;
  letter-spacing: 2px; text-transform: uppercase;
  font-family: var(--font-mono);
  opacity: 0.9;
}
.level-display {
  font-size: 13px; margin-top: 6px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.level-display span { color: var(--text-primary); font-weight: 600; }
.arc-display {
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* Profile description */
.profile-description {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 8px; line-height: 1.5;
  font-style: italic;
  max-width: 260px; margin-left: auto; margin-right: auto;
  padding: 6px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--border-subtle);
}

/* ===== PROFILE STATS SECTION ===== */
.profile-stats { padding: 0; }

/* XP Block */
.stat-block {
  background: var(--bg-secondary);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: var(--border-width) solid var(--border-subtle);
  animation: fadeUp 0.4s ease 0.15s both;
}
.stat-label {
  font-size: 10px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.xp-bar-container {
  position: relative;
  background: var(--bg-card);
  border-radius: 2px; height: var(--bar-height);
  overflow: visible; margin-bottom: 6px;
}
.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), rgba(155,89,182,0.6));
  border-radius: 2px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}
.xp-bar::after {
  content: '';
  position: absolute; right: -1px; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
}
.xp-text {
  font-size: 11px; color: var(--text-secondary);
  font-family: var(--font-mono);
}
.reserve-bar-container { margin-top: 10px; }
.reserve-bar {
  background: linear-gradient(90deg, var(--warning), rgba(243,156,18,0.5));
}
.reserve-bar::after { background: var(--warning); box-shadow: 0 0 8px var(--warning); }

/* ===== STATS SECTION — С КРАСИВЫМИ БАРАМИ ===== */
.stats-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: var(--border-width) solid var(--border-subtle);
  animation: fadeUp 0.4s ease 0.2s both;
}
.stats-section-title {
  font-size: 10px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 14px;
  font-family: var(--font-mono);
}

.stat-row {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 12px;
}
.stat-row:last-child { margin-bottom: 0; }

.stat-icon {
  font-size: 14px; width: 20px; text-align: center; flex-shrink: 0;
}
.stat-name {
  font-size: 12px; color: var(--text-secondary);
  width: 80px; flex-shrink: 0;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}
.stat-bar-wrap {
  flex: 1; background: var(--bg-card);
  border-radius: 2px; height: var(--stat-bar-height);
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), rgba(155,89,182,0.5));
  border-radius: 2px;
  transition: width 0.9s cubic-bezier(0.4,0,0.2,1);
  animation: barFill 0.9s ease both;
}
.stat-val {
  font-size: 12px; color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 600; width: 28px; text-align: right;
  flex-shrink: 0;
}

/* ===== CURRENCY WIDGET ===== */
.currency-widget {
  position: fixed;
  top: 10px;
  right: 12px;
  left: auto;
  transform: none;
  z-index: 90;
  width: auto;
  max-width: none;
  display: flex;
  justify-content: flex-end;
  animation: fadeDownRight 0.3s ease;
}
@keyframes fadeDownRight {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.currency-widget-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 5px 8px;
  gap: 0;
  width: auto;
}
.currency-widget-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px 6px;
}
.currency-widget-icon { font-size: 12px; line-height: 1; }
.currency-widget-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.currency-widget-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  flex-shrink: 0;
}

/* ===== CURRENCY (inline) ===== */
.currency-display {
  display: flex; gap: 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: var(--border-width) solid var(--border-subtle);
  overflow: hidden;
  animation: fadeUp 0.4s ease 0.25s both;
}
.currency-item {
  flex: 1; text-align: center; padding: 10px 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  border-right: var(--border-width) solid var(--border-subtle);
}
.currency-item:last-child { border-right: none; }
.currency-item-icon { font-size: 16px; display: block; margin-bottom: 2px; }
.currency-item-val { font-weight: 700; font-size: 14px; }
.currency-item-label { font-size: 9px; color: var(--text-secondary); letter-spacing: 1px; text-transform: uppercase; margin-top: 1px; }
.copper-val { color: var(--copper); }
.silver-val { color: var(--silver); }
.gold-val   { color: var(--gold); }
.gacha-val  { color: var(--accent); }

/* ===== DEBUFFS ===== */
.debuff-container {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: var(--border-width) solid var(--border-subtle);
  animation: fadeUp 0.4s ease 0.3s both;
  min-height: 40px; align-items: center;
}
.debuff-tag {
  background: rgba(231,76,60,0.1);
  color: var(--danger);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  border: var(--border-width) solid rgba(231,76,60,0.2);
  font-family: var(--font-mono);
}
.no-debuffs {
  color: var(--text-muted); font-size: 12px; font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

/* ===== BLOCK ===== */
.block-container {
  background: rgba(231,76,60,0.06);
  border: var(--border-width) solid rgba(231,76,60,0.3);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  animation: fadeUp 0.3s ease;
}
.block-warning {
  color: var(--danger); font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

/* ===== INVENTORY ===== */
.inventory-section {
  margin-top: 14px;
  animation: fadeUp 0.4s ease 0.35s both;
}
.section-title {
  font-size: 10px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 2px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: var(--border-width) solid var(--border-subtle);
  font-family: var(--font-mono);
}

.equipment-slots {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.eq-slot {
  flex: 1; height: 56px;
  background: var(--bg-card);
  border: var(--border-width) dashed var(--border);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer; flex-direction: column; gap: 2px;
  font-family: var(--font-mono);
}
.eq-slot:not(.empty) {
  border-color: rgba(155,89,182,0.4);
  border-style: solid;
  color: var(--accent);
  background: rgba(155,89,182,0.06);
}
.eq-slot:not(.empty):hover { border-color: var(--accent); }

.inventory-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.inv-item {
  background: var(--bg-card);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 4px; text-align: center;
  cursor: pointer; position: relative;
  transition: all var(--transition);
}
.inv-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.inv-item:active { transform: scale(0.96); }
.inv-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent); color: #fff;
  font-size: 9px; padding: 1px 5px;
  border-radius: 8px; font-family: var(--font-mono);
}

.btn-export {
  width: 100%; margin-top: 10px;
  color: var(--text-secondary);
}

/* ===== QUESTS ===== */
.quest-controls {
  display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
}

.quest-filters {
  display: flex; gap: 4px; margin-bottom: 14px;
  overflow-x: auto; padding-bottom: 2px;
}
.quest-filters::-webkit-scrollbar { display: none; }

.filter-btn {
  background: transparent;
  border: var(--border-width) solid var(--border);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer; font-size: 11px;
  transition: all var(--transition);
  font-family: var(--font-main);
  white-space: nowrap; flex-shrink: 0;
}
.filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.filter-btn:hover:not(.active) { border-color: var(--text-secondary); color: var(--text-primary); }

/* Quest sections */
.quest-section { margin-bottom: 20px; }
.quest-section-title {
  font-size: 10px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 2px;
  padding: 6px 0; margin-bottom: 8px;
  border-bottom: var(--border-width) solid var(--border-subtle);
  font-family: var(--font-mono);
  display: flex; align-items: center; gap: 8px;
}
.quest-section-count {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 9px; padding: 1px 7px;
  border-radius: 10px;
}

.quest-list { display: flex; flex-direction: column; gap: 6px; }

.quest-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-subtle);
  overflow: hidden;
  transition: all var(--transition);
  animation: fadeUp 0.3s ease both;
  cursor: pointer;
}
.quest-item:hover { border-color: var(--border); }
.quest-item.quest-daily   { border-left: 2px solid #3498db; }
.quest-item.quest-story   { border-left: 2px solid var(--accent); }
.quest-item.quest-side    { border-left: 2px solid var(--success); }
.quest-item.quest-legendary { border-left: 2px solid var(--gold); }

.quest-item-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; gap: 8px;
}
.quest-item-left { flex: 1; min-width: 0; }
.quest-title {
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quest-reward {
  font-size: 11px; color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-top: 3px;
}
.quest-reward .xp-badge { color: var(--accent); }
.quest-reward .copper-badge { color: var(--copper); }

.quest-type-badge {
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.badge-daily    { background: rgba(52,152,219,0.1); color: #3498db; border: 1px solid rgba(52,152,219,0.2); }
.badge-story    { background: rgba(155,89,182,0.1); color: var(--accent); border: 1px solid rgba(155,89,182,0.2); }
.badge-side     { background: rgba(46,204,113,0.1); color: var(--success); border: 1px solid rgba(46,204,113,0.2); }
.badge-legendary{ background: rgba(241,196,15,0.1); color: var(--gold); border: 1px solid rgba(241,196,15,0.2); }

/* Quest expanded body */
.quest-body {
  display: none; padding: 0 14px 14px;
  border-top: var(--border-width) solid var(--border-subtle);
  animation: slideDown 0.2s ease;
}
.quest-body.expanded { display: block; }
.quest-desc-text {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5; margin-top: 10px; margin-bottom: 10px;
}
.quest-body-actions { display: flex; gap: 6px; margin-top: 8px; }
.btn-complete {
  flex: 1; background: rgba(46,204,113,0.1);
  border: var(--border-width) solid rgba(46,204,113,0.3);
  color: var(--success); padding: 7px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12px; font-family: var(--font-main);
  transition: all var(--transition);
}
.btn-complete:hover { background: rgba(46,204,113,0.2); }

.quest-lock-icon { color: var(--danger); font-size: 12px; }

/* ===== QUEST MODAL ===== */
.quest-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: flex-end;
  animation: fadeIn 0.2s ease;
}
.quest-modal {
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-height: 85vh;
  overflow-y: auto; padding: 24px;
  animation: modalSlideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  transform: translateY(0);
}
.quest-modal-handle {
  width: 36px; height: 3px;
  background: var(--border);
  border-radius: 2px; margin: 0 auto 20px;
}
.quest-modal h3 {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.3px; margin-bottom: 6px;
}
.quest-modal-meta {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.quest-modal-desc {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.6; margin-bottom: 16px;
}
.quest-modal-rewards {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px; margin-bottom: 16px;
  display: flex; gap: 16px;
}
.reward-item {
  text-align: center; flex: 1;
  font-family: var(--font-mono);
}
.reward-val { font-size: 18px; font-weight: 700; }
.reward-lbl { font-size: 10px; color: var(--text-secondary); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }
.quest-modal-actions { display: flex; gap: 8px; }

/* ===== ADD QUEST MODAL ===== */
.add-quest-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 600;
  display: flex; align-items: flex-end;
  animation: fadeIn 0.2s ease;
}
.add-quest-modal {
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-height: 90vh;
  overflow-y: auto; padding: 24px;
  animation: modalSlideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  transform: translateY(0);
}
.add-quest-modal h3 {
  font-size: 17px; font-weight: 700; margin-bottom: 18px;
  letter-spacing: -0.3px;
}
.form-field { margin-bottom: 14px; }
.form-field label {
  display: block; font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 6px; font-family: var(--font-mono);
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%; padding: 10px 14px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary); color: var(--text-primary);
  font-family: var(--font-main); font-size: 14px;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none; border-color: var(--accent);
}
.form-field textarea { resize: none; min-height: 80px; }
.form-field select { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.quest-type-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.quest-type-btn {
  flex: 1; min-width: 70px; padding: 8px 4px;
  background: transparent;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 11px;
  cursor: pointer; transition: all var(--transition);
  font-family: var(--font-main); text-align: center;
}
.quest-type-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.modal-actions { display: flex; gap: 8px; margin-top: 18px; }

/* Gen settings panel */
.gen-settings {
  background: var(--bg-card);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  display: none;
}
.gen-settings.open { display: block; animation: slideDown 0.2s ease; }
.gen-settings-title {
  font-size: 11px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1.5px;
  font-family: var(--font-mono);
  margin-bottom: 12px;
}
.gen-settings .form-row { margin-bottom: 10px; }

/* ===== SHOP ===== */
#shop-tab .page-title { margin-bottom: 14px; }

.shop-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--bg-card);
  padding: 3px; border-radius: var(--radius-md);
}
.shop-tab-btn {
  flex: 1; padding: 7px; background: transparent;
  border: none; color: var(--text-secondary);
  font-size: 11px; cursor: pointer;
  font-family: var(--font-main);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  letter-spacing: 0.3px;
}
.shop-tab-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.shop-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.shop-card {
  background: var(--bg-card);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition);
  animation: scaleIn 0.3s ease both;
}
.shop-card:hover { border-color: var(--border); transform: translateY(-1px); }

.shop-card-img {
  height: 72px; background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  border-bottom: var(--border-width) solid var(--border-subtle);
}
.shop-card-info { padding: 10px; }
.shop-card-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.shop-card-desc { font-size: 10px; color: var(--text-secondary); margin-bottom: 6px; line-height: 1.4; }
.shop-card-price {
  font-size: 12px; margin-bottom: 8px;
  font-family: var(--font-mono); font-weight: 600;
}
.price-copper { color: var(--copper); }
.price-silver { color: var(--silver); }
.price-gold   { color: var(--gold); }

.btn-buy {
  width: 100%; background: transparent;
  border: var(--border-width) solid var(--accent);
  color: var(--accent);
  padding: 6px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  font-size: 11px; font-family: var(--font-main);
  letter-spacing: 0.5px;
}
.btn-buy:hover { background: var(--accent); color: #fff; }

.btn-remove-shop-item {
  width: 100%; margin-top: 4px;
  background: transparent; border: none;
  color: var(--text-muted); font-size: 10px;
  cursor: pointer; font-family: var(--font-mono);
  padding: 2px 0;
}
.btn-remove-shop-item:hover { color: var(--danger); }

/* Shop manage */
.shop-manage-bar {
  display: flex; gap: 8px; margin-bottom: 12px;
  flex-wrap: wrap; align-items: center;
}
.shop-item-count {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
}

.shop-catalog-panel {
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  animation: slideDown 0.2s ease;
}
.shop-catalog-header {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 12px;
}
.shop-catalog-header span:first-child {
  font-size: 11px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1.5px;
  font-family: var(--font-mono);
}
.shop-catalog-hint {
  font-size: 11px; color: var(--text-muted);
}
.shop-catalog-filters {
  display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap;
}
.catalog-filter-btn {
  background: transparent;
  border: var(--border-width) solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px; border-radius: 16px;
  font-size: 10px; cursor: pointer;
  font-family: var(--font-main);
  transition: all var(--transition);
}
.catalog-filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.shop-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.catalog-item {
  background: var(--bg-card);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.catalog-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.catalog-item.in-shop { border-color: rgba(46,204,113,0.4); background: rgba(46,204,113,0.04); }
.catalog-item-icon { font-size: 24px; margin-bottom: 4px; }
.catalog-item-name {
  font-size: 9px; line-height: 1.2;
  color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.catalog-item-badge {
  position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.catalog-item.rarity-common { border-bottom: 2px solid var(--text-muted); }
.catalog-item.rarity-uncommon { border-bottom: 2px solid var(--success); }
.catalog-item.rarity-rare { border-bottom: 2px solid #3498db; }
.catalog-item.rarity-legendary { border-bottom: 2px solid var(--gold); }

.rarity-badge {
  display: inline-block;
  font-size: 9px; padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rarity-badge-common { background: rgba(85,85,102,0.15); color: var(--text-secondary); }
.rarity-badge-uncommon { background: rgba(46,204,113,0.12); color: var(--success); }
.rarity-badge-rare { background: rgba(52,152,219,0.12); color: #3498db; }
.rarity-badge-legendary { background: rgba(241,196,15,0.12); color: var(--gold); }

.shop-card { cursor: pointer; }
.shop-card-rarity {
  font-size: 9px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.item-detail-modal .item-detail-icon { font-size: 48px; text-align: center; margin: 8px 0; }
.item-detail-modal .item-detail-effect {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.5; margin-bottom: 14px;
  border: var(--border-width) solid var(--border-subtle);
}
.item-detail-modal .item-detail-price {
  font-family: var(--font-mono);
  font-size: 16px; font-weight: 700;
  text-align: center; margin-bottom: 14px;
}

/* Rarity badges */
.rarity-common    { color: var(--text-secondary); }
.rarity-uncommon  { color: var(--success); }
.rarity-rare      { color: #3498db; }
.rarity-legendary { color: var(--gold); }

#profile-tab { position: relative; }

#profile-tab .profile-settings-btn {
  top: 50px;
}

.profile-settings-btn {
  position: absolute;
  right: 12px;
  z-index: 20;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: var(--border-width) solid var(--border);
  background: rgba(6,6,8,0.75);
  backdrop-filter: blur(8px);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.profile-settings-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(45deg);
}

/* ===== GACHA FAB & MODAL ===== */
.gacha-fab {
  position: fixed;
  bottom: 88px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: linear-gradient(135deg, var(--accent), #4a00e0);
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 95;
  box-shadow: 0 4px 20px rgba(155,89,182,0.4);
  transition: all var(--transition);
  display: none;
}
.gacha-fab.visible { display: flex; align-items: center; justify-content: center; }
.gacha-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(155,89,182,0.55); }
.gacha-fab.locked {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-muted);
  box-shadow: none;
  filter: grayscale(0.6);
}

.gacha-modal {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.gacha-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
}
.gacha-modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 20px 16px 24px;
  animation: scaleIn 0.3s var(--spring);
}
.gacha-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}
.gacha-modal-title { text-align: center; font-size: 17px; margin-bottom: 6px; }
.gacha-tier-info {
  text-align: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--gold);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}
.gacha-meta-row {
  display: flex;
  justify-content: space-around;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.gacha-meta-row strong { color: var(--text-primary); }

.gacha-roulette-wrap {
  position: relative;
  margin: 16px 0;
}
.gacha-roulette-pointer {
  text-align: center;
  color: var(--gold);
  font-size: 18px;
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 0 8px var(--gold);
}
.gacha-roulette-viewport {
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  height: 88px;
  position: relative;
}
.gacha-roulette-viewport::before,
.gacha-roulette-viewport::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 40px;
  z-index: 2;
  pointer-events: none;
}
.gacha-roulette-viewport::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg-primary), transparent);
}
.gacha-roulette-viewport::after {
  right: 0;
  background: linear-gradient(-90deg, var(--bg-primary), transparent);
}
.gacha-roulette-strip {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 0s;
}
.gacha-roulette-strip.spinning {
  transition: transform 4s cubic-bezier(0.15, 0.85, 0.25, 1);
}
.gacha-roulette-item {
  flex: 0 0 72px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border-subtle);
  padding: 4px;
}
.gacha-roulette-item-icon { font-size: 28px; }
.gacha-roulette-item-name {
  font-size: 8px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
  line-height: 1.1;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gacha-roulette-item.rarity-uncommon { background: rgba(46,204,113,0.05); }
.gacha-roulette-item.rarity-rare { background: rgba(52,152,219,0.05); }
.gacha-roulette-item.rarity-legendary { background: rgba(241,196,15,0.08); }

.gacha-spin-result {
  min-height: 48px;
  text-align: center;
  margin-bottom: 12px;
  font-size: 14px;
}
.gacha-lock-msg {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-mono);
  margin-top: 10px;
}

/* ===== STORY MAP ===== */
.story-tab-title { margin-bottom: 6px; }
.story-tab-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}
.story-map-scroll {
  max-height: calc(100dvh - 180px);
  overflow-y: auto;
  padding: 8px 4px 40px;
}
.story-map-track {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0;
  padding-bottom: 20px;
}
.story-node {
  position: relative;
  width: 100%;
  max-width: 320px;
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
  animation: fadeUp 0.3s ease both;
}
.story-node:hover { border-color: var(--accent); }
.story-node.completed {
  border-color: rgba(46,204,113,0.4);
  background: rgba(46,204,113,0.04);
}
.story-node.active {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(155,89,182,0.2);
}
.story-node.locked {
  opacity: 0.45;
  cursor: default;
}
.story-node-level {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.story-node-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.story-node-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.story-node-status {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 16px;
}
.story-connector {
  width: 2px;
  height: 28px;
  background: linear-gradient(180deg, var(--border), var(--accent-dim));
  flex-shrink: 0;
}
.story-connector.completed { background: linear-gradient(180deg, var(--success), rgba(46,204,113,0.3)); }

.shop-card.locked-item { opacity: 0.5; }
.shop-level-lock {
  font-size: 9px;
  color: var(--warning);
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* ===== GACHA ===== */
.gacha-pity-bar-wrap {
  background: var(--bg-card);
  border-radius: 2px; height: 2px; margin-bottom: 14px;
}
.gacha-pity-bar {
  height: 100%; background: var(--gold);
  border-radius: 2px; transition: width 0.6s ease;
}
.btn-gacha {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #4a00e0);
  border: none; padding: 14px;
  color: white; font-weight: 700;
  letter-spacing: 3px; cursor: pointer;
  border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 12px;
  transition: opacity var(--transition);
  position: relative; overflow: hidden;
}
.btn-gacha::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  background-size: 200% 100%;
  animation: shimmer 2.5s infinite;
}
.btn-gacha:hover { opacity: 0.9; }
.btn-gacha:active { transform: scale(0.98); }

.gacha-result {
  margin-top: 12px; padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  min-height: 56px; font-size: 14px;
  border: var(--border-width) solid var(--border);
  animation: scaleIn 0.3s ease;
}
.gacha-result .legendary { color: var(--gold); font-weight: 700; }
.gacha-result .rare { color: #3498db; font-weight: 700; }
.gacha-result .uncommon { color: var(--success); font-weight: 700; }

.gacha-history {
  margin-top: 10px; display: flex; flex-wrap: wrap;
  gap: 4px; justify-content: center;
}
.gacha-history-item {
  font-size: 10px; padding: 2px 8px;
  border-radius: 10px; font-family: var(--font-mono);
  background: var(--bg-card); border: var(--border-width) solid var(--border);
}

/* ===== CHATS (MESSENGER) ===== */
#chats-tab.tab-chats-fullheight {
  display: none;
  flex-direction: column;
  height: calc(100dvh - 72px);
  padding: 12px 16px 0;
  overflow: hidden;
}
#chats-tab.tab-chats-fullheight.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.chat-list-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.chat-contacts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}
.chat-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
  font-family: var(--font-main);
  color: var(--text-primary);
  animation: fadeUp 0.25s ease both;
}
.chat-contact-item:hover { border-color: var(--border); background: var(--bg-card); }
.chat-contact-item:active { transform: scale(0.98); }
.chat-contact-avatar,
.chat-room-avatar,
.chat-msg-avatar {
  object-fit: cover;
  object-position: center;
  background: var(--bg-card);
  display: block;
  flex-shrink: 0;
}
.chat-contact-avatar { width: 48px; height: 48px; min-width: 48px; min-height: 48px; border-radius: 50%; }
.chat-room-avatar { width: 36px; height: 36px; min-width: 36px; min-height: 36px; border-radius: 50%; }
.chat-msg-avatar { width: 28px; height: 28px; min-width: 28px; min-height: 28px; border-radius: 50%; }

.ui-icon, .nav-icon, .stat-icon-svg { display: inline-flex; align-items: center; justify-content: center; color: var(--accent); }
.ui-icon svg, .nav-icon svg, .stat-icon-svg svg { width: 1.15em; height: 1.15em; }
.nav-icon svg { width: 18px; height: 18px; }
.stat-icon-svg svg { width: 16px; height: 16px; }
.ui-icon-xs svg { width: 12px; height: 12px; }
.ui-icon-sm svg { width: 14px; height: 14px; }
.nav-icon-slot { display: flex; margin-bottom: 2px; }
.currency-widget-icon svg { width: 12px; height: 12px; }
.ui-icon-empty svg { width: 36px; height: 36px; opacity: 0.35; }
.page-title-icon-svg svg, .section-title-icon-svg svg { width: 1.1em; height: 1.1em; margin-right: 6px; vertical-align: -2px; }
.settings-cat-icon svg { width: 22px; height: 22px; color: var(--accent); }
.gacha-fab-icon svg { width: 24px; height: 24px; }
.price-row { display: inline-flex; align-items: center; gap: 4px; }
.price-icon svg { width: 12px; height: 12px; }
.story-status-icon svg { width: 14px; height: 14px; }
.story-progress-bar { height: 4px; background: var(--bg-card); border-radius: 2px; margin-bottom: 16px; overflow: hidden; }
.story-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width 0.6s ease; }
.story-node-deadline, .story-node-penalty { font-size: 10px; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 4px; }
.story-node-deadline.urgent { color: var(--danger); }
.section-title { display: flex; align-items: center; gap: 6px; }
.page-title { display: flex; align-items: center; gap: 8px; }
.settings-section-title { display: flex; align-items: center; gap: 8px; }
.settings-title { display: flex; align-items: center; gap: 8px; }
.gacha-modal-title { display: flex; align-items: center; justify-content: center; gap: 8px; }
.gacha-fab { display: flex; align-items: center; justify-content: center; }
.register-avatar-preview [data-icon] { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.register-avatar-preview svg { width: 48px; height: 48px; opacity: 0.4; }
.register-avatar-btn { display: inline-flex; align-items: center; gap: 6px; }

.item-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.item-icon, .item-icon-img, .inv-item-icon img, .shop-card-img img, .catalog-item-icon img, .item-detail-icon img {
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.item-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.item-icon-svg svg {
  width: 100%;
  height: 100%;
}
.inv-item-icon { margin-bottom: 4px; display: flex; justify-content: center; }

.stat-tier {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 72px;
  text-align: right;
}

.quest-deadline { font-size: 10px; color: var(--warning); font-family: var(--font-mono); display: inline-flex; align-items: center; gap: 3px; }
.quest-deadline.urgent { color: var(--danger); }
.quest-deadline.expired { color: var(--danger); opacity: 0.7; }
.quest-block-note { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); margin-bottom: 8px; }
.btn-abandon {
  background: transparent;
  border: 1px solid rgba(231,76,60,0.35);
  color: var(--danger);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
}
.quest-done-label { font-size: 12px; color: var(--success); font-family: var(--font-mono); }

.level-up-modal-v2 { position: relative; overflow: hidden; }
.level-up-ring {
  width: 120px; height: 120px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 40px rgba(155,89,182,0.45), inset 0 0 30px rgba(155,89,182,0.15);
  animation: levelRingPulse 2s ease-in-out infinite;
}
.level-up-badge {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--font-mono); font-weight: 700; font-size: 28px; margin-bottom: 8px;
}
.level-up-from { color: var(--text-secondary); }
.level-up-to { color: var(--gold); text-shadow: 0 0 20px rgba(241,196,15,0.5); }
.level-up-arrow { color: var(--accent); font-size: 20px; }
.level-up-title { font-size: 14px; letter-spacing: 4px; color: var(--accent); margin-bottom: 6px; }
.level-up-glow-bar {
  height: 3px; margin: 16px auto 20px; max-width: 200px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--gold), transparent);
  animation: shimmer 2s infinite;
}
.level-up-btn { min-width: 160px; }
.level-particle {
  position: absolute; top: -10px; width: 4px; height: 14px; border-radius: 2px;
  animation: confetti linear forwards; opacity: 0.8;
}
@keyframes levelRingPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}

.profile-settings-btn span { display: flex; }
.edit-avatar-btn span { display: flex; }
.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name {
  font-size: 14px; font-weight: 600;
  margin-bottom: 3px;
}
.chat-contact-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.chat-contact-time {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.chat-unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: var(--font-mono);
}

.chat-room-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.chat-room-view.active { display: flex; }

.chat-room-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: var(--border-width) solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.chat-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}
.chat-room-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: var(--border-width) solid var(--border);
}
.chat-room-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}
.chat-room-status {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  animation: messageIn 0.25s ease;
}
.chat-message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-message-row.assistant { align-self: flex-start; }
.chat-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: var(--border-width) solid var(--border-subtle);
}
.chat-message {
  padding: 9px 13px;
  border-radius: 14px;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.5;
}
.chat-message-row.user .chat-message {
  background: var(--accent-dim);
  border: var(--border-width) solid rgba(155,89,182,0.2);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}
.chat-message-row.assistant .chat-message {
  background: var(--bg-card);
  border: var(--border-width) solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.message-time {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
  font-family: var(--font-mono);
}

.chat-input {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: var(--border-width) solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: var(--border-width) solid var(--border);
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  transition: border-color var(--transition);
}
.chat-input input:focus { outline: none; border-color: var(--accent); }

.chat-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.chat-typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: pulse 1s infinite;
}
.chat-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

.chat-message.typing .typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: pulse 0.8s infinite;
}

.chat-quest-proposal {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
}

.chat-list-view { display: flex; }

/* ===== SETTINGS ===== */
#settings-tab h2.settings-title {
  font-size: 17px; font-weight: 700;
  margin-bottom: 16px; letter-spacing: -0.3px;
}

.settings-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--font-main);
  color: var(--text-primary);
}
.settings-category-card:hover {
  border-color: var(--border);
  background: var(--bg-card);
}
.settings-category-card:active { transform: scale(0.98); }

.settings-category-icon {
  font-size: 22px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.settings-category-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-category-name {
  font-size: 14px;
  font-weight: 600;
}
.settings-category-desc {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.settings-category-arrow {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.settings-section {
  display: none;
  animation: fadeUp 0.25s ease;
}
.settings-section.active { display: block; }

.settings-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-family: var(--font-main);
  cursor: pointer;
  padding: 0 0 12px;
  margin-bottom: 4px;
  transition: opacity var(--transition);
}
.settings-back-btn:hover { opacity: 0.75; }

.settings-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: -0.2px;
}

.settings-group { margin-bottom: 16px; }
.settings-group label {
  display: block; font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 6px; font-family: var(--font-mono);
}
.settings-group input,
.settings-group textarea,
.settings-group select {
  width: 100%; padding: 10px 14px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card); color: var(--text-primary);
  font-family: var(--font-main); font-size: 14px;
  transition: border-color var(--transition);
}
.settings-group textarea { resize: none; min-height: 80px; }
.settings-group select { cursor: pointer; -webkit-appearance: none; }
.settings-group input:focus,
.settings-group textarea:focus,
.settings-group select:focus { outline: none; border-color: var(--accent); }
.settings-group input:disabled { opacity: 0.4; }

.bg-upload-container { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bg-preview {
  width: 100%; height: 90px; border-radius: var(--radius-md);
  background-size: cover; background-position: center;
  border: var(--border-width) solid var(--border);
  cursor: pointer; transition: border-color var(--transition);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
}
.bg-preview:hover { border-color: var(--accent); }

.color-options { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.color-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: var(--border-width) solid transparent;
  cursor: pointer; transition: all var(--transition);
}
.color-btn:hover { transform: scale(1.12); }
.color-btn.active {
  border-color: white;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
  transform: scale(1.08);
}

.settings-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.settings-actions .btn { flex: 1; min-width: 120px; }

/* ===== DEV MODE ===== */
.dev-panel {
  background: rgba(155,89,182,0.06);
  border: var(--border-width) solid rgba(155,89,182,0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 16px 0;
}
.dev-panel-title {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 2px;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.dev-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.dev-btn {
  padding: 6px 14px;
  background: rgba(155,89,182,0.1);
  border: var(--border-width) solid rgba(155,89,182,0.2);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-mono);
}
.dev-btn:hover { background: rgba(155,89,182,0.2); }

/* ===== LEVEL UP MODAL ===== */
.level-up-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.3s ease;
}
.level-up-modal {
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--accent);
  border-radius: var(--radius-xl);
  padding: 40px 32px 32px;
  max-width: 380px; width: 90%;
  text-align: center;
  animation: levelUpModal 0.5s var(--spring);
  box-shadow: 0 0 60px rgba(155,89,182,0.3);
}
.level-up-emoji {
  font-size: 72px; display: block; margin-bottom: 8px;
}
.level-up-modal h2 {
  font-size: 32px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.level-up-modal .sub {
  font-size: 14px; color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-bottom: 16px;
}
.level-up-modal .stats-gain {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border: var(--border-width) solid var(--border);
}
.level-up-modal .stats-gain span {
  font-size: 12px; color: var(--text-secondary);
  font-family: var(--font-mono);
}
.level-up-modal .stats-gain .highlight {
  color: var(--gold);
  font-weight: 700;
}
.level-up-modal .btn {
  min-width: 140px;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 9px 18px;
  border: none; border-radius: var(--radius-md);
  cursor: pointer; font-size: 13px;
  transition: all var(--transition);
  font-family: var(--font-main);
  font-weight: 500; letter-spacing: 0.3px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: var(--border-width) solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.btn-ghost {
  background: transparent; color: var(--text-secondary); border: none;
}
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(231,76,60,0.3); }
.btn-danger:hover { background: rgba(231,76,60,0.1); }
.btn-small { padding: 5px 12px; font-size: 11px; }

.settings-danger-zone {
  margin-top: 28px;
  padding: 16px;
  border: 1px solid rgba(231, 76, 60, 0.35);
  border-radius: 12px;
  background: rgba(231, 76, 60, 0.06);
}
.settings-danger-title {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 15px;
}
.settings-danger-desc {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}
.settings-danger-zone label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.settings-danger-zone input {
  width: 100%;
  margin-bottom: 12px;
}

body.telegram-webapp {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
body.telegram-webapp .bottom-nav {
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
body.telegram-webapp .toast {
  bottom: calc(82px + env(safe-area-inset-bottom));
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 82px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; z-index: 9000;
  animation: slideUp 0.25s ease;
  max-width: 88%; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast-success { border-color: rgba(46,204,113,0.4); }
.toast-error   { border-color: rgba(231,76,60,0.4); }
.toast-info    { border-color: rgba(52,152,219,0.3); }

/* ===== LOADING SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-secondary) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 13px;
  font-family: var(--font-mono); letter-spacing: 0.5px;
}
.empty-state-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.4; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .nav-btn { font-size: 9px; }
  .quest-modal, .add-quest-modal { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  #chats-tab.tab-chats-fullheight { height: calc(100dvh - 68px); }
  .currency-widget { top: 8px; right: 8px; }
  .currency-widget-value { font-size: 10px; }
  .currency-widget-icon { font-size: 11px; }
}

/* ===== STAGGER ANIMATION ===== */
.quest-item:nth-child(1) { animation-delay: 0.02s; }
.quest-item:nth-child(2) { animation-delay: 0.04s; }
.quest-item:nth-child(3) { animation-delay: 0.06s; }
.quest-item:nth-child(4) { animation-delay: 0.08s; }
.quest-item:nth-child(5) { animation-delay: 0.10s; }
.quest-item:nth-child(6) { animation-delay: 0.12s; }
.shop-card:nth-child(1) { animation-delay: 0.02s; }
.shop-card:nth-child(2) { animation-delay: 0.05s; }
.shop-card:nth-child(3) { animation-delay: 0.08s; }
.shop-card:nth-child(4) { animation-delay: 0.11s; }