* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body {
  background: radial-gradient(ellipse at top, #1a1f3a 0%, #0a0e1f 60%, #000 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 18px;
  touch-action: manipulation;
  padding-top: env(safe-area-inset-top, 14px);
  padding-bottom: env(safe-area-inset-bottom, 18px);
}
.top { width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.header { display: flex; width: 100%; align-items: center; gap: 10px; margin-bottom: 4px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #4a5577, #2a3550);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-info { flex: 1; min-width: 0; }
.header-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-level { font-size: 11px; color: #94a0bd; }
.header-daily {
  background: linear-gradient(135deg, #ffd54f, #f0a020);
  color: #3d2500; border: none; padding: 6px 12px;
  border-radius: 20px; font-size: 12px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
}
.header-daily.unavailable { background: rgba(255,255,255,0.06); color: #6a728a; cursor: default; }
.progress { width: 100%; height: 5px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #ffb74d, #ffd54f); width: 0%; transition: width 0.4s ease; border-radius: 4px; }
.balance { display: flex; align-items: center; gap: 8px; font-size: 36px; font-weight: 700; letter-spacing: -0.5px; margin-top: 2px; }
.coin-mini {
  width: 32px; height: 32px; border-radius: 50%;
  background-image: url('/coin.png'); background-size: 105%; background-position: center;
  box-shadow: 0 0 10px rgba(255, 201, 53, 0.5);
}
.stats { display: flex; gap: 16px; color: #94a0bd; font-size: 12px; }
.stats b { color: #fff; }
.center { position: relative; flex: 1; width: 100%; max-width: 460px; display: flex; align-items: center; justify-content: center; min-height: 0; }
.coin {
  width: 260px; height: 260px; border-radius: 50%; overflow: hidden;
  background: #1a1f3a;
  box-shadow: 0 0 60px rgba(255, 193, 7, 0.45), 0 0 0 4px rgba(255,255,255,0.06), 0 0 0 10px rgba(255,255,255,0.03);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.06s ease; position: relative;
}
.coin:active { transform: scale(0.96); }
.coin.disabled { filter: grayscale(0.7) brightness(0.6); cursor: not-allowed; }
.coin-img { width: 104%; height: 104%; object-fit: cover; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.float {
  position: absolute; color: #ffd54f; font-size: 30px; font-weight: 800;
  pointer-events: none; text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  animation: floatUp 0.9s ease-out forwards; z-index: 10;
}
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(0.8); } 100% { opacity: 0; transform: translateY(-100px) scale(1.2); } }
.energy-row { width: 100%; max-width: 460px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-top: 6px; }
.energy-row .energy-label { display: flex; align-items: center; gap: 6px; color: #ffd54f; font-weight: 600; }
.energy-bar { width: 100%; height: 8px; background: rgba(255,255,255,0.08); border-radius: 6px; overflow: hidden; margin-top: 4px; }
.energy-fill { height: 100%; background: linear-gradient(90deg, #ffd54f, #ffeb3b); width: 100%; border-radius: 6px; transition: width 0.2s ease; }
.bottom { width: 100%; max-width: 460px; }
.bottom-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 8px; margin-top: 10px;
}
.nav-btn {
  background: transparent; border: none; color: #c4cce0;
  padding: 8px 4px; border-radius: 10px; font-size: 11px; font-weight: 600;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background 0.15s;
}
.nav-btn:active { background: rgba(255,255,255,0.08); }
.nav-btn .ico { font-size: 20px; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: linear-gradient(180deg, #1d2440, #0e1326);
  width: 100%; max-width: 480px; border-radius: 24px 24px 0 0;
  padding: 18px 16px 24px; max-height: 85vh; overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.modal-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: #94a0bd; margin-bottom: 14px; }
.modal-close {
  float: right; background: rgba(255,255,255,0.08); color: #fff; border: none;
  width: 28px; height: 28px; border-radius: 50%; font-size: 14px; cursor: pointer;
}
.upgrade, .lb-row, .ref-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  padding: 10px; border-radius: 12px; margin-bottom: 8px;
}
.upgrade .ico-box {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, #ffd54f, #f0a020);
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0;
}
.upgrade .info { flex: 1; min-width: 0; }
.upgrade .name { font-size: 13px; font-weight: 600; }
.upgrade .desc { font-size: 11px; color: #8a93b0; margin-top: 2px; }
.upgrade .price { font-size: 12px; font-weight: 700; color: #ffd54f; margin-top: 3px; }
.upgrade .lvl { font-size: 11px; color: #94a0bd; }
.upgrade button {
  background: linear-gradient(135deg, #ffd54f, #f0a020);
  color: #3d2500; border: none; padding: 7px 12px; border-radius: 9px;
  font-size: 12px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.upgrade button:disabled { background: rgba(255,255,255,0.08); color: #6a728a; cursor: not-allowed; }
.task {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  padding: 11px 13px; border-radius: 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.task.done { opacity: 0.5; }
.task .reward { color: #ffd54f; font-weight: 700; font-size: 12px; }
.lb-row .rank { width: 26px; text-align: center; font-weight: 800; color: #94a0bd; font-size: 14px; flex-shrink: 0; }
.lb-row .rank.gold { color: #ffd54f; }
.lb-row .rank.silver { color: #d0d8e8; }
.lb-row .rank.bronze { color: #d49060; }
.lb-row .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #4a5577, #2a3550);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.lb-row .av img { width: 100%; height: 100%; object-fit: cover; }
.lb-row .name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row .bal { color: #ffd54f; font-weight: 700; font-size: 13px; }
.lb-row.me { background: rgba(255,213,79,0.1); border-color: rgba(255,213,79,0.3); }
.ref-cta {
  background: linear-gradient(135deg, #4a5fff, #6c4aff); border: none; color: #fff;
  padding: 14px; border-radius: 14px; font-size: 14px; font-weight: 700;
  width: 100%; cursor: pointer; margin-bottom: 14px; box-shadow: 0 6px 20px rgba(74, 95, 255, 0.4);
}
.ref-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ref-stats .box { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); padding: 12px; border-radius: 12px; text-align: center; }
.ref-stats .num { font-size: 20px; font-weight: 800; color: #ffd54f; }
.ref-stats .label { font-size: 11px; color: #94a0bd; margin-top: 2px; }
.loader {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #0a0e1f; z-index: 999; gap: 14px;
}
.loader .spin {
  width: 40px; height: 40px; border: 3px solid rgba(255,213,79,0.2);
  border-top-color: #ffd54f; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader .msg { color: #94a0bd; font-size: 13px; }
.toast {
  position: fixed; top: 20%; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd54f, #f0a020); color: #3d2500;
  padding: 12px 20px; border-radius: 14px; font-weight: 700; z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4); animation: floatUp 2.4s ease-out forwards; pointer-events: none;
}
