* {
  box-sizing: border-box;
}

body {
  background: 
    radial-gradient(
      circle at top center,
      rgba(255, 255, 255, 0.15),
      transparent 60%
    ),
    radial-gradient(
      circle at bottom left,
      #d83b0b 0%,
      transparent 60%
    ),
    #342685;
  margin: 0;
  font-family: system-ui, sans-serif;
  color: white;
}

html, body {
  width: 100%;
  height: 100%;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- TOP ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Выравнивание сверху */
  padding: 10px;
}

.top-left {
  text-align: center;
}

.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
}

.nickname {
  margin-top: 5px;
  font-weight: bold;
  color: #ec810685;
}

.top-right {
  text-align: right;
}

.token-balance {
  display: flex;
  align-items: center;      /* Выравнивание по вертикали */
  margin-bottom: 5px;        /* Отступ снизу */
}

.token-icon {
  width: 20px;             /* Размер логотипа */
  height: 20px;
  margin-right: 8px;       /* Отступ между иконкой и текстом */
  object-fit: contain;     /* Сохранение пропорций */
}

.balance {
  font-size: 18px;
  font-weight: bold;
  color: #acf108;
}

.coins {
  margin-top: 3px;
  font-size: 16px;
  color: #f39c12;
}

/* ---------- CENTER ---------- */
.center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===== ХОМЯК ===== */

.game-btn {
  display: block;
  width: 200px;
  padding: 15px;
  margin: 10px auto;
  background: #2980b9;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

.game-btn:hover {
  background: #3498db;
}
#hamster {
  width: min(70vw, 320px);
  aspect-ratio: 1;
  object-fit: contain;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.12s ease;
}

#hamster:active {
  transform: scale(0.92);
}

/* ---------- +1 ---------- */
.plus {
  position: absolute;
  z-index: 999;
  font-size: 24px;
  color: gold;
  animation: floatUp 0.8s ease-out forwards;
  pointer-events: none;
}

@keyframes floatUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-60px);
  }
}

/* ---------- BOTTOM ---------- */
.bottom {
  padding: 12px 16px;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.stat-label {
  width: 60px;
  text-align: left;
  opacity: 0.9;
}

.stat-bar {
  position: relative;
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.stat-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  max-width: 100%; /* Защита от переполнения */
  transition: width 0.2s ease;
}

.xp-fill {
  background: linear-gradient(90deg, #ffd54f, #ff9800);
}

.energy-fill {
  background: linear-gradient(90deg, #4caf50, #8bc34a);
}

.stat-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(10px, 3vw, 12px);
  font-weight: 600;
  color: #000;
  pointer-events: none;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.3); /* Улучшенная читаемость */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Эффект при наведении */
.stat-bar:hover .stat-fill {
  filter: brightness(1.1);
}

/* Индикатор низкой энергии */
.energy-fill[data-low="true"] {
  background: linear-gradient(90deg, #f44336, #e57373);
}


/* ===== NAV ===== */
.nav {
  display: flex;
  justify-content: space-around;
  margin-top: 6px;
}

.nav button {
  background: #222;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav button:hover {
  background: #444;
}