/* Terazm Clicker — polished mobile UI */
:root {
  --bg: #07060c;
  --bg2: #0e0b16;
  --surface: rgba(28, 22, 42, 0.92);
  --surface2: rgba(40, 30, 58, 0.88);
  --border: rgba(167, 139, 250, 0.18);
  --border2: rgba(244, 114, 182, 0.28);
  --text: #f5f0ff;
  --muted: #a89bb8;
  --accent: #c4b5fd;
  --accent2: #f472b6;
  --gold: #fbbf24;
  --cyan: #67e8f9;
  --ok: #34d399;
  --danger: #fb7185;
  --radius: 16px;
  --radius-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tg-bottom: 0px; /* Telegram bottom bar inset (set from JS) */
  --header-h: 52px;
  --tabs-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding: 0;
  margin: 0;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }

#app {
  height: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 0;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(124, 58, 237, 0.22), transparent 55%),
    radial-gradient(ellipse 80% 40% at 100% 50%, rgba(244, 114, 182, 0.08), transparent 50%),
    var(--bg);
}

/* ===== Header ===== */
.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 12px 8px;
  min-height: var(--header-h);
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 14, 0.75);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
  box-shadow: 0 0 0 2px rgba(196, 181, 253, 0.35);
  overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-text { min-width: 0; }
.username {
  font-weight: 700; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 140px;
}
.level-line { font-size: 11px; color: var(--muted); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.crystal-badge, .prestige-badge {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-weight: 700; font-size: 13px;
}
.prestige-badge { border-color: rgba(251, 191, 36, 0.35); color: var(--gold); }

/* ===== Balance ===== */
.balance-section {
  flex-shrink: 0;
  text-align: center;
  padding: 10px 16px 6px;
}
.coins-display {
  font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  text-shadow: 0 2px 16px rgba(251, 191, 36, 0.25);
}
.coin-icon { font-size: 24px; }
.income-line {
  margin-top: 4px; font-size: 12px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap;
}
.income-line #passiveIncome { color: var(--ok); font-weight: 600; }
.income-line #clickPower { color: var(--cyan); font-weight: 600; }
.income-line #multDisplay { color: var(--accent); font-weight: 700; }
.sep { opacity: 0.4; margin: 0 2px; }

.combo-bar-wrap { margin-top: 8px; padding: 0 8px; }
.combo-bar {
  height: 6px; border-radius: 99px; background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.combo-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #f472b6, #fbbf24, #f472b6);
  background-size: 200% 100%;
  border-radius: 99px;
  transition: width 0.12s linear;
  animation: comboShine 2s linear infinite;
}
@keyframes comboShine {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
.combo-text {
  font-size: 11px; color: var(--accent2); margin-top: 3px; font-weight: 600;
  min-height: 14px;
}

.exp-bar {
  margin: 8px 8px 0; height: 5px; border-radius: 99px;
  background: rgba(255,255,255,0.06); overflow: hidden;
}
.exp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 99px; transition: width 0.25s ease;
}
.exp-text { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ===== Click area / character ===== */
.click-area {
  flex-shrink: 0;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 2px 12px 4px;
  min-height: 0;
}
.prestige-bg {
  position: absolute; inset: 4px 12px; z-index: 0; pointer-events: none;
  border-radius: 20px; opacity: 0.4; transition: background 0.6s;
}
.prestige-bg.p0 { background: radial-gradient(ellipse at 50% 80%, #2a1840, transparent 70%); }
.prestige-bg.p1 { background: radial-gradient(ellipse at 50% 70%, #1a3a2a, #1a1040 80%); }
.prestige-bg.p3 { background: radial-gradient(ellipse at 50% 60%, #0a2a4a, #1a1040 80%); }
.prestige-bg.p5 { background: radial-gradient(ellipse at 50% 50%, #3a2a0a, #2a1040 80%); }
.prestige-bg.p10 { background: radial-gradient(ellipse at 50% 40%, #2a0a3a, #050218 80%); }

.night-badge {
  position: absolute; top: 8px; right: 16px; z-index: 6;
  background: rgba(30, 40, 90, 0.92); color: #c7d2fe; font-size: 11px;
  padding: 4px 10px; border-radius: 10px; border: 1px solid #6366f1;
  font-weight: 600;
}
.night-badge.hidden { display: none; }

.fox-bubble {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  background: rgba(30, 20, 45, 0.95); border: 1px solid #c4b5fd;
  color: #fce7f3; padding: 6px 12px; border-radius: 14px 14px 14px 4px;
  font-size: 12px; z-index: 25; max-width: 85%; text-align: center;
  animation: bubbleIn .25s ease;
}
.fox-bubble.hidden { display: none; }
@keyframes bubbleIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.char-stage-label {
  position: relative; z-index: 5;
  font-size: 12px; font-weight: 700; color: var(--accent);
  letter-spacing: 0.04em; text-transform: uppercase;
  margin-bottom: 4px;
  text-shadow: 0 0 12px rgba(196, 181, 253, 0.5);
}

.click-btn {
  position: relative; z-index: 4;
  width: min(68vw, 240px); aspect-ratio: 3/4;
  max-height: min(280px, 36vh);
  border-radius: 20px;
  padding: 0; overflow: hidden;
  background: transparent;
  border: 2px solid rgba(196, 181, 253, 0.25);
  box-shadow:
    0 8px 32px rgba(124, 58, 237, 0.25),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  transition: transform 0.08s ease, box-shadow 0.15s;
  touch-action: manipulation;
}
.click-btn:active, .click-btn.pressed {
  transform: scale(0.96);
  box-shadow: 0 4px 16px rgba(244, 114, 182, 0.35);
}
.btn-inner {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  background: linear-gradient(180deg, #1a1228 0%, #0c0a14 100%);
}
.btn-glow {
  position: absolute; inset: -20%;
  background: radial-gradient(circle at 50% 70%, rgba(244, 114, 182, 0.2), transparent 55%);
  pointer-events: none; z-index: 1;
}
.char-sprite {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  animation: foxIdle 3.2s ease-in-out infinite;
  will-change: transform;
  pointer-events: none;
}
.char-sprite.reacting { animation: none; }
@keyframes foxIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.skin-frame {
  position: absolute; inset: 0; border-radius: 18px; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 0 2px rgba(167, 139, 250, 0.35);
}
.skin-frame.legend {
  box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.7), 0 0 20px rgba(251, 191, 36, 0.25);
}
.skin-frame.sexy {
  box-shadow: inset 0 0 0 2px rgba(244, 114, 182, 0.65), 0 0 18px rgba(244, 114, 182, 0.3);
}

.char-next {
  position: relative; z-index: 5;
  font-size: 11px; color: var(--muted); margin-top: 6px;
  min-height: 14px;
}

#floatingNumbers {
  position: absolute; inset: 0; pointer-events: none; z-index: 15; overflow: hidden;
}
.float-num {
  position: absolute; left: 50%; bottom: 40%;
  font-weight: 800; font-size: 16px; color: #fef3c7;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  animation: floatUp 0.85s ease-out forwards;
  will-change: transform, opacity; pointer-events: none;
}
.float-num.crit {
  color: #f9a8d4; font-size: 20px;
  text-shadow: 0 0 12px rgba(244, 114, 182, 0.8);
}
@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1.15); }
}

.event-banner {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 12; white-space: nowrap;
  background: linear-gradient(90deg, #7c3aed, #db2777);
  color: #fff; font-weight: 700; font-size: 12px;
  padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  animation: pulse 1.2s ease infinite;
}
.event-banner.hidden { display: none; }
@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}

/* ===== Quick actions under character ===== */
.quick-row {
  display: flex; gap: 8px; justify-content: center;
  padding: 0 12px 6px; flex-shrink: 0;
}
.quick-btn {
  flex: 1; max-width: 110px;
  padding: 8px 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.quick-btn:active { background: var(--surface2); border-color: var(--accent); }

/* ===== Tabs ===== */
.tabs {
  flex-shrink: 0;
  display: flex; gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-b) + var(--tg-bottom));
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-top: 1px solid var(--border);
  background: rgba(8, 6, 14, 0.96);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 30;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 8px 12px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
  transition: all 0.15s;
}
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.55), rgba(219, 39, 119, 0.4));
  border: 1px solid rgba(196, 181, 253, 0.35);
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.25);
}

/* ===== Panels ===== */
main.panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.panel {
  display: none;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 10px 12px 16px;
}
.panel.active { display: block; }

.section-title {
  font-size: 13px; font-weight: 700; color: var(--accent);
  margin: 12px 0 8px; letter-spacing: 0.02em;
}
.section-title:first-child { margin-top: 0; }

.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.subtabs {
  display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.subtabs button, [data-filter], [data-lb] {
  padding: 6px 12px; border-radius: 8px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: rgba(255,255,255,0.04); border: 1px solid transparent;
}
.subtabs button.active, [data-filter].active, [data-lb].active {
  color: #fff; border-color: var(--border);
  background: rgba(124, 58, 237, 0.35);
}

.row, .row-between {
  display: flex; align-items: center; gap: 8px;
}
.row-between { justify-content: space-between; }

.hint, .muted { font-size: 11px; color: var(--muted); line-height: 1.4; }
.ok { color: var(--ok); font-size: 12px; font-weight: 600; }

/* Upgrade cards */
.upgrade-card, .ach-card, .mission-card, .skin-card, .case-card, .title-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.upgrade-card:active { border-color: var(--accent); }
.upgrade-icon, .ach-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  background: rgba(124, 58, 237, 0.2);
}
.upgrade-info, .ach-info { flex: 1; min-width: 0; }
.upgrade-name, .ach-name { font-weight: 700; font-size: 13px; }
.upgrade-desc, .ach-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.upgrade-buy, .primary-btn {
  padding: 8px 14px; border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: #fff; font-weight: 700; font-size: 12px;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
  transition: transform 0.1s, filter 0.15s;
}
.upgrade-buy:active, .primary-btn:active { transform: scale(0.97); }
.upgrade-buy:disabled, .primary-btn:disabled {
  opacity: 0.4; filter: grayscale(0.4); box-shadow: none;
}
.secondary-btn {
  padding: 8px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 12px;
}
.secondary-btn:active { background: var(--surface2); }
.secondary-btn:disabled { opacity: 0.4; }

/* Skins grid */
.skins-grid, .codex-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.skin-card {
  flex-direction: column; padding: 8px; text-align: center;
  margin: 0; position: relative; overflow: hidden;
}
.skin-card img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  border-radius: 10px; margin-bottom: 6px;
}
.skin-card.locked { opacity: 0.45; filter: grayscale(0.6); }
.skin-card.equipped {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px rgba(244, 114, 182, 0.4), 0 4px 16px rgba(244, 114, 182, 0.2);
}
.skin-card .skin-name { font-size: 11px; font-weight: 700; }

.codex-cell {
  aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); background: #15101f; position: relative;
}
.codex-cell img { width: 100%; height: 100%; object-fit: cover; }
.codex-cell.locked { filter: grayscale(1) brightness(0.35); }
.codex-cell .cx {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* Cases */
.cases-grid {
  display: grid; grid-template-columns: 1fr; gap: 8px;
}
.case-card {
  justify-content: space-between;
}
.case-card .case-left { display: flex; align-items: center; gap: 10px; }
.case-card.rare { border-color: rgba(96, 165, 250, 0.4); }
.case-card.legendary { border-color: rgba(251, 191, 36, 0.45); }

/* Stats */
.stat {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.stat b { font-weight: 700; color: var(--accent); }

.toggle-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.toggle-row input { width: 18px; height: 18px; accent-color: #7c3aed; }

/* Story */
.story-chapters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.story-ch {
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.03);
  font-size: 12px;
}
.story-ch.locked { opacity: 0.45; }
.story-ch b { display: block; margin-bottom: 3px; color: var(--accent); }

/* Pet */
.pet-zone {
  margin-top: 8px; height: 90px; border-radius: 14px;
  border: 2px dashed #f9a8d4; background: rgba(244, 114, 182, 0.12);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fbcfe8; touch-action: manipulation;
}
.pet-zone.hidden { display: none; }
.pet-zone.active { background: rgba(244, 114, 182, 0.28); transform: scale(1.02); }

.gift-btn { flex: 1 1 40%; font-size: 12px; }

.fox-dialogue {
  min-height: 48px; padding: 10px 12px; border-radius: 12px;
  background: rgba(167, 139, 250, 0.12); border: 1px solid rgba(167, 139, 250, 0.3);
  font-size: 13px; line-height: 1.4; color: #e9d5ff;
}

/* Leaderboard */
.lb-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 6px;
  background: var(--surface2); border-radius: 10px;
  border: 1px solid var(--border); font-size: 12px;
}
.lb-rank { width: 24px; font-weight: 800; color: var(--gold); }

/* Modals */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-content {
  width: 100%; max-width: 340px;
  background: linear-gradient(180deg, #1a1428, #0e0b16);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-content h3 { font-size: 18px; margin-bottom: 8px; }
.offline-coins {
  font-size: 28px; font-weight: 800; color: var(--gold);
  margin: 12px 0 16px;
}
.primary-btn { width: 100%; padding: 12px; font-size: 14px; margin-top: 4px; }
.secondary-btn { width: 100%; padding: 10px; }

.evo-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.evo-choices button {
  padding: 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-weight: 600; text-align: left;
}
.evo-choices button:active { border-color: var(--accent); }

/* Toast / tips / react */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 200; max-width: 90%;
  background: rgba(30, 20, 50, 0.95);
  border: 1px solid var(--border2);
  color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tip-banner {
  position: fixed; top: calc(8px + var(--safe-t)); left: 50%;
  transform: translateX(-50%); z-index: 90;
  background: rgba(124, 58, 237, 0.9); color: #fff;
  padding: 8px 14px; border-radius: 10px; font-size: 12px;
  max-width: 90%; text-align: center;
}
.tip-banner.hidden { display: none; }

.char-react {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  z-index: 80; font-size: 28px; pointer-events: none;
  opacity: 0; transition: opacity 0.2s;
}
.char-react.show { opacity: 1; animation: reactPop 0.6s ease; }
@keyframes reactPop {
  0% { transform: translate(-50%, -50%) scale(0.5); }
  40% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}

.evolve-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 0, 15, 0.72); pointer-events: none;
}
.evolve-overlay.hidden { display: none; }
.evolve-flash {
  position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255, 200, 255, 0.55), transparent 55%);
  animation: evoFlash 1.4s ease forwards;
}
.evolve-name {
  position: relative; z-index: 2; font-size: 22px; font-weight: 800;
  color: #fff; text-shadow: 0 0 20px #e879f9;
  animation: evoName 1.6s ease forwards;
}
@keyframes evoFlash {
  0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; }
}
@keyframes evoName {
  0% { opacity: 0; transform: scale(0.6); }
  30% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1) translateY(-20px); }
}

/* Quiet mode */
body.quiet .char-sprite { animation: none !important; }
body.quiet .float-num { display: none !important; }
body.quiet .char-react { display: none !important; }
body.quiet .btn-glow { display: none !important; }
body.quiet .combo-fill { animation: none !important; }

/* Scrollbar subtle */
.panel::-webkit-scrollbar { width: 3px; }
.panel::-webkit-scrollbar-thumb { background: rgba(167, 139, 250, 0.3); border-radius: 3px; }

/* Save status */
.save-status {
  text-align: center; font-size: 11px; color: var(--ok);
  min-height: 16px; margin-top: 8px;
}

/* Landscape / very small */
@media (max-height: 600px) {
  .click-btn { max-height: 180px; }
  .coins-display { font-size: 22px; }
}
@media (min-width: 480px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.tab-admin { color: #fbbf24 !important; }
.tab-admin.active {
  background: linear-gradient(135deg, rgba(251,191,36,0.35), rgba(124,58,237,0.4)) !important;
  border-color: rgba(251,191,36,0.45) !important;
}
.adm-input {
  flex: 1; min-width: 0;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(0,0,0,0.35); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; outline: none;
}
.adm-input:focus { border-color: var(--accent); }
select.adm-input { appearance: none; }
.adm-out {
  white-space: pre-wrap; word-break: break-word;
  font-size: 11px; line-height: 1.4; color: #e9d5ff;
  max-height: 280px; overflow-y: auto;
  background: rgba(0,0,0,0.25); padding: 10px; border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.adm-user-card {
  padding: 8px; border-radius: 10px;
  background: rgba(124,58,237,0.12); border: 1px solid var(--border);
  font-size: 12px; line-height: 1.45;
}
.hidden { display: none !important; }

/* ===== Generated cards polish ===== */
.upgrade-level { font-size: 10px; color: var(--accent); margin-top: 2px; font-weight: 600; }
.upgrade-buy:disabled { opacity: 0.45; }

.ach-card.unlocked {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}
.ach-check {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--ok);
  background: rgba(52, 211, 153, 0.15);
  flex-shrink: 0;
}
.ach-reward { font-size: 10px; color: var(--gold); margin-top: 2px; }

.mission-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mission-card.ready { border-color: rgba(52, 211, 153, 0.45); }
.mission-card.done { opacity: 0.55; }
.mission-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; background: rgba(124, 58, 237, 0.2); flex-shrink: 0;
}
.mission-info { flex: 1; min-width: 0; }
.mission-name { font-weight: 700; font-size: 13px; }
.mission-bar {
  height: 5px; border-radius: 99px; background: rgba(255,255,255,0.06);
  margin-top: 6px; overflow: hidden;
}
.mission-bar > div {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #7c3aed, #f472b6);
  transition: width 0.3s ease;
}
.mission-btn {
  padding: 7px 12px; border-radius: 10px; font-size: 11px; font-weight: 700;
  background: linear-gradient(135deg, #7c3aed, #db2777); color: #fff;
}
.mission-btn:disabled { opacity: 0.35; filter: grayscale(0.3); }

.case-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: rgba(124, 58, 237, 0.2); flex-shrink: 0;
}
.case-name { font-weight: 700; font-size: 14px; }
.case-cost { font-size: 12px; color: var(--cyan); margin-top: 2px; font-weight: 600; }
.case-open {
  padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 12px;
  background: linear-gradient(135deg, #7c3aed, #db2777); color: #fff;
}
.case-open:disabled { opacity: 0.4; }

.title-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; margin: 0 6px 6px 0; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.title-chip.have { color: var(--text); border-color: rgba(167,139,250,0.35); }
.title-chip.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124,58,237,0.6), rgba(219,39,119,0.45));
  border-color: rgba(244,114,182,0.5);
  box-shadow: 0 2px 12px rgba(124,58,237,0.3);
}
.title-chip:disabled { opacity: 0.35; }

.skin-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,0.65); color: var(--gold); z-index: 2;
}
.skin-req { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.2; }

/* Leaders */
#leadersList, .leaders-list { display: flex; flex-direction: column; gap: 6px; }

/* Season / weekly bars */
.season-bar, .weekly-bar {
  height: 8px; border-radius: 99px; background: rgba(255,255,255,0.06);
  overflow: hidden; margin: 8px 0;
}
.season-bar > div, .weekly-bar > div {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
}

/* Coins pulse on gain */
.coins-display.pulse {
  animation: coinPulse 0.35s ease;
}
@keyframes coinPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Tabs bottom-ish feel: sticky strip */
.tabs {
  box-shadow: 0 -8px 24px rgba(0,0,0,0.25);
}

/* Click area depth */
.click-btn::after {
  content: '';
  position: absolute; inset: 0; border-radius: 18px; pointer-events: none; z-index: 5;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 28%, transparent 70%, rgba(0,0,0,0.25) 100%);
}

/* Loading skeleton optional */
#app.booting .click-btn { opacity: 0.5; }

/* Panel empty */
.panel > :first-child { margin-top: 0; }

/* Better focus for accessibility */
button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Prestige button highlight */
#prestigeBtn, .prestige-do {
  background: linear-gradient(135deg, #b45309, #f59e0b) !important;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35) !important;
}

/* Admin inputs full width on small */
@media (max-width: 380px) {
  .skins-grid, .codex-grid { grid-template-columns: repeat(2, 1fr); }
  .coins-display { font-size: 24px; }
  .tab { padding: 7px 10px; font-size: 10px; }
}
.danger-btn {
  padding: 10px 14px; border-radius: 10px; width: 100%;
  background: linear-gradient(135deg, #b45309, #f59e0b);
  color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}
.danger-btn:disabled { opacity: 0.4; box-shadow: none; }

/* === Layout fix iPhone Telegram === */
#app {
  height: var(--app-h, 100dvh) !important;
  max-height: var(--app-h, 100dvh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Only the panel list scrolls */
main.panels {
  flex: 1 1 auto;
  min-height: 0;
}
main.panels .panel.active {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
