:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-deep: #0a0f15;
  --accent: #ffd700;
  --text: #e8edf2;
  --text-dim: #8b9bb0;
  --win: #4ade80;
  --neutral: #fbbf24;
  --loss: #f87171;
  --border: #2a3a52;
  --cyan: #38bdf8;
  --violet: #a78bfa;
  --primary: linear-gradient(135deg, #ff6b35, #f72585);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(circle at top left, rgba(167, 139, 250, 0.12), transparent 22rem), var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 2px 0 4px;
}
.page-header::after {
  content: "";
  width: 58px;
}
.page-title { text-align: center; font-size: 16px; font-weight: 900; }
.nav-btn {
  min-width: 58px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.nav-btn:active { transform: scale(0.97); }
.nav-btn.ghost { color: var(--text-dim); cursor: default; }

.identity-card {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(56, 189, 248, 0.06)), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.identity-avatar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  display: grid;
  place-items: center;
  font-size: 28px;
  flex: 0 0 auto;
  color: white;
  box-shadow: 0 12px 24px rgba(56, 189, 248, 0.18);
}
.identity-meta { flex: 1; min-width: 0; }
.identity-name {
  font-size: clamp(13px, 3.4vw, 16px);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.08;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.identity-uid {
  display: inline-block;
  vertical-align: baseline;
  font-size: 1.12em;
  font-weight: 1000;
}
.identity-login-id {
  display: inline-block;
  max-width: min(130px, 44vw);
  margin-left: 6px;
  color: #b7c9ee;
  font-size: 0.62em;
  font-weight: 850;
  vertical-align: baseline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-summary {
  margin-top: 7px;
  color: #a7c7ff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xp-track {
  width: min(220px, 100%);
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(10, 15, 21, 0.72);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(43, 60, 83, 0.8);
}
.xp-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  transition: width 0.25s ease;
}
.identity-pill {
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: var(--accent);
  background: rgba(10, 15, 21, 0.34);
  border-radius: 14px;
  padding: 8px 11px;
  font-size: 18px;
  line-height: 1;
  font-weight: 950;
  min-width: 68px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(167, 139, 250, 0.12);
}

.telegram-uid-banner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid rgba(34, 158, 217, 0.42);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(34, 158, 217, 0.16), rgba(34, 197, 94, 0.07)), var(--bg-card);
}
.telegram-uid-banner strong {
  display: block;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 950;
  margin-bottom: 4px;
}
.telegram-uid-banner p {
  margin: 0;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.45;
  font-weight: 700;
}
.telegram-uid-banner a {
  min-width: 72px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #229ed9;
  color: white;
  text-decoration: none;
  font-size: 12px;
  font-weight: 950;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 2px 0;
  margin-top: 4px;
}
.section-title .sub { font-size: 10px; letter-spacing: 0; text-transform: none; opacity: 0.75; font-weight: 700; }

.asset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.asset-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 800;
}
.asset-value {
  font-size: 22px;
  font-weight: 900;
  margin-top: 4px;
  line-height: 1;
}
.asset-value.gold { color: var(--accent); }
.asset-value.cyan { color: var(--cyan); }
.asset-value.fire { color: #ff6b35; }
.asset-value.violet { color: var(--violet); }

.slot-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 8px;
}
.slot-row {
  display: grid;
  grid-template-columns: 24px 60px 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.slot-row:last-child { border-bottom: none; }
.slot-icon { font-size: 18px; text-align: center; }
.slot-name { color: var(--text-dim); font-weight: 700; }
.slot-lv {
  font-weight: 900;
  color: var(--accent);
  text-align: right;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
.slot-bar {
  height: 6px;
  background: var(--bg-deep);
  border-radius: 999px;
  overflow: hidden;
}
.slot-bar-fill { height: 100%; transition: width 0.3s ease; }
.slot-bar-fill.weapon { background: linear-gradient(90deg, #ff6b35, #f72585); }
.slot-bar-fill.armor { background: linear-gradient(90deg, var(--win), var(--cyan)); }
.slot-bar-fill.accessory { background: linear-gradient(90deg, var(--violet), var(--cyan)); }
.slot-power {
  text-align: right;
  font-size: 11px;
  color: #ff6b35;
  font-weight: 800;
  font-family: ui-monospace, monospace;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 10px;
  text-align: center;
}
.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 800;
}
.stat-value {
  font-size: 18px;
  font-weight: 900;
  margin-top: 4px;
  color: var(--text);
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.action-btn {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.action-btn:active { transform: scale(0.99); }
.action-btn.danger { border-color: rgba(248, 113, 113, 0.4); }
.action-btn.danger:active { background: rgba(248, 113, 113, 0.05); }

.action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-deep);
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--cyan);
}
.action-btn.danger .action-icon { color: var(--loss); }
.action-text { font-weight: 800; line-height: 1.3; }
.action-text small { display: block; font-weight: 600; color: var(--text-dim); font-size: 10px; margin-top: 3px; }
.action-tag {
  font-size: 10px;
  font-weight: 900;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(145, 163, 184, 0.10);
  color: var(--text-dim);
}
.action-tag.soon { color: var(--neutral); background: rgba(251, 191, 36, 0.10); }
.action-tag.local { color: var(--win); background: rgba(74, 222, 128, 0.10); }

.profile-foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  opacity: 0.65;
  margin-top: 6px;
  line-height: 1.5;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.18s ease;
}
.overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 318px;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px 20px 22px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}
.profile-icon { font-size: 48px; line-height: 1; }
.profile-icon.exchange-icon {
  font-size: 42px;
  color: var(--text);
  margin: 2px 0 4px;
}
.profile-icon.danger { color: var(--loss); }
.soon-title { font-size: 20px; font-weight: 900; margin: 12px 0 8px; }
.soon-sub {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 18px;
}
.soon-sub b { color: var(--text); }

.exchange-box {
  display: grid;
  gap: 9px;
  margin: 16px 0 15px;
  text-align: left;
}
.exchange-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.exchange-label {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}
.exchange-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-deep);
  color: var(--accent);
  padding: 0 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  font-weight: 900;
  outline: none;
}
.exchange-input:focus {
  border-color: rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.08);
}
.exchange-balance {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.exchange-balance b {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.exchange-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(10, 15, 21, 0.54);
  padding: 8px 11px;
}
.exchange-preview-label {
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.45;
  font-weight: 800;
}
.exchange-preview b {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  white-space: nowrap;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.close-btn {
  width: 100%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  min-height: 50px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.close-btn:active { transform: scale(0.98); }
.close-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.close-btn.ghost {
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
}
.close-btn.danger {
  background: var(--loss);
  color: white;
}
