:root {
  --bg1: #e8f1ff;
  --bg2: #b8d6ff;
  --bg3: #67a6ee;
  --text: #133665;
  --muted: #4f6f98;
  --tg-safe-top: env(safe-area-inset-top, 0px);
  --tg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tg-header-offset: 0px;
  --content-top-offset: calc(var(--tg-safe-top) + var(--tg-header-offset));
  --nav-offset-bottom: 26px;
}

html.tma {
  --tg-header-offset: 54px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% -20%, #fff 0%, var(--bg2) 45%, var(--bg3) 100%);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--content-top-offset)) 14px calc(120px + var(--tg-safe-bottom));
}

.screens {
  min-height: calc(100dvh - var(--content-top-offset) - 138px - var(--tg-safe-bottom));
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.hero-balance {
  text-align: center;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 800;
  margin-top: 6px;
}

.character-wrap {
  min-height: 60dvh;
  display: grid;
  place-items: center;
}

.character-image {
  max-height: 62dvh;
  width: auto;
  max-width: min(90vw, 440px);
  object-fit: contain;
}

.card {
  background: rgba(240, 246, 255, 0.82);
  border: 1px solid rgba(43, 95, 166, 0.15);
  border-radius: 22px;
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}

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

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

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.tile-grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.tile-grid.two {
  grid-template-columns: 1fr 1fr;
}

.tile-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tile {
  background: rgba(223, 235, 251, 0.72);
  border: 1px solid rgba(35, 93, 164, 0.16);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tile h3 {
  margin: 0 0 6px;
  font-size: 1.85rem;
}

.tile-grid.three .tile h3 {
  font-size: 1.15rem;
  line-height: 1.15;
  min-height: 2.6rem;
}

.tile p {
  margin: 4px 0;
  color: var(--muted);
}

.actions {
  margin-top: auto;
  padding-top: 8px;
  display: grid;
  gap: 8px;
}

.actions.two {
  grid-template-columns: 1fr 1fr;
}

.actions.one {
  grid-template-columns: 1fr;
}

.ozot {
  color: #2f74d8;
}

.wp {
  color: #d640a0;
}

.ty-parket {
  color: #b69200;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(223, 235, 251, 0.72);
  border: 1px solid rgba(35, 93, 164, 0.16);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #ffe17b, #f7bf20);
  color: #102f58;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.btn.secondary {
  background: linear-gradient(180deg, #84ddff, #43a1e7);
}

.btn:disabled {
  opacity: 0.65;
  filter: grayscale(0.7);
  cursor: not-allowed;
}

.row-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-text {
  margin: 0 0 12px;
  line-height: 1.35;
}

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-offset-bottom) + var(--tg-safe-bottom));
  width: min(560px, calc(100vw - 18px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: linear-gradient(180deg, rgba(191, 201, 218, 0.58), rgba(165, 177, 198, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 24px;
  padding: 9px;
  backdrop-filter: blur(12px);
}

.nav-item {
  border: none;
  border-radius: 14px;
  padding: 10px 4px;
  background: transparent;
  font-weight: 700;
  color: #345683;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.nav-item.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(230, 238, 248, 0.72));
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.leaderboard li {
  padding: 10px;
  border-radius: 12px;
  background: rgba(223, 235, 251, 0.72);
  border: 1px solid rgba(35, 93, 164, 0.16);
  display: flex;
  justify-content: space-between;
}

.modal {
  border: none;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(5, 17, 38, 0.62);
}

.modal-card {
  background: #eef4ff;
  min-width: min(92vw, 360px);
  border-radius: 22px;
  border: 1px solid rgba(48, 95, 160, 0.2);
  padding: 18px;
  text-align: center;
  touch-action: manipulation;
}

.modal-card input,
.modal-card select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(50, 98, 164, 0.24);
  margin-bottom: 8px;
  font-size: 1rem;
}

.coin-btn {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: radial-gradient(circle at 35% 30%, #fff3bf 0%, #ffd753 35%, #f7b800 73%, #d08a00 100%);
  font-size: 3rem;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.coin-btn:active {
  transform: scale(0.97);
}

@media (max-width: 740px) {
  .tile-grid.three,
  .tile-grid.two {
    grid-template-columns: 1fr;
  }

  .row-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
