/* Tap to earn (/tap). One immersive screen: top row (player, level + progress, info button), a huge balance, the giant
   gold coin with layered light (idle breathing, press-squash, 3D tilt toward the touch, +N and sparks at the touch point),
   the energy bar, and one legal line. Levels, stats, the so'm card and the referral-energy note live in the info panel:
   a side column on desktop, a bottom sheet on phones and in the Telegram app. */
.tap-layout { display: grid; gap: 18px; align-items: start; }
.tap-stage {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 16px 12px; border-radius: 28px; isolation: isolate; overflow: hidden;
  background:
    radial-gradient(70% 45% at 50% 55%, rgba(139, 92, 255, 0.28), transparent 70%),
    linear-gradient(180deg, rgba(30, 22, 74, 0.85), rgba(14, 10, 38, 0.92));
  box-shadow: inset 0 0 0 1px rgba(177, 140, 255, 0.16), 0 30px 60px -30px rgba(0, 0, 0, 0.9);
}

/* ---- top row ---- */
.tap-top { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; }
.tap-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tap-ava .ava, .tap-ava > * { width: 34px; height: 34px; font-size: 0.95rem; }
.tap-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tap-lvl { display: grid; gap: 4px; justify-items: end; }
.tap-level {
  padding: 4px 10px; border-radius: 999px; font: 800 0.75rem/1 var(--display); letter-spacing: 0.02em; color: #fff;
  background: linear-gradient(180deg, #8b5cff, #6a3bf0); box-shadow: 0 6px 16px -6px rgba(139, 92, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.tap-level:empty { display: none; }
.tap-lvlbar { width: 88px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.tap-lvlfill { display: block; height: 100%; width: 100%; transform-origin: left center; transform: scaleX(var(--lvl, 0));
  background: linear-gradient(90deg, #b18cff, #ffc940); transition: transform 300ms var(--ease); }
.tap-info-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; font: 800 1rem/1 var(--display); color: var(--ink);
  background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.tap-info-btn:focus-visible, .tap-info-close:focus-visible { outline: 2px solid var(--violet-2); outline-offset: 2px; }

/* ---- balance ---- */
.tap-bal { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; }
.tap-bal-coin { width: clamp(34px, 9vw, 46px); height: clamp(34px, 9vw, 46px); filter: drop-shadow(0 4px 14px rgba(255, 201, 64, 0.55)); }
.tap-bal strong {
  font: 900 clamp(46px, 15vw, 72px)/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: #fff;
  text-shadow: 0 4px 30px rgba(255, 201, 64, 0.28);
}
.tap-bal strong.is-bump { animation: tap-bump 180ms var(--ease); }
@keyframes tap-bump { 50% { transform: scale(1.04); } }
.tap-power { margin: 0; font-weight: 800; font-size: var(--step--1); color: var(--gold); opacity: 0.9; }
.tap-power:empty { display: none; }

/* ---- the coin ---- */
.tap-coin-wrap {
  position: relative; width: min(70vw, 320px); aspect-ratio: 1; margin: 10px 0 8px;
  animation: tap-breathe 4.2s ease-in-out infinite;
}
.tap-glow {
  position: absolute; inset: -22%; border-radius: 50%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle, rgba(255, 214, 102, 0.5) 0%, rgba(245, 168, 0, 0.2) 36%, transparent 62%),
    radial-gradient(circle, rgba(139, 92, 255, 0.35) 30%, transparent 72%);
  filter: blur(6px); animation: tap-pulse 4.2s ease-in-out infinite;
}
.tap-coin {
  position: relative; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--s, 1));
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.4), filter var(--fast);
  filter: drop-shadow(0 22px 40px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 34px rgba(255, 201, 64, 0.35));
}
.tap-coin.is-press { --s: 0.93; transition-duration: 70ms; }
.tap-coin:focus-visible { outline: 3px solid var(--gold); outline-offset: 8px; }
.tap-coin.is-empty { filter: grayscale(0.8) brightness(0.6); cursor: not-allowed; }
.tap-face { display: block; width: 100%; height: 100%; pointer-events: none; }
@keyframes tap-breathe { 50% { transform: scale(1.018); } }
@keyframes tap-pulse { 50% { opacity: 0.75; transform: scale(0.97); } }

.tap-float {
  position: absolute; left: var(--x, 50%); top: var(--y, 40%); z-index: 3; pointer-events: none;
  font: 900 2rem/1 var(--display); color: #fff; text-shadow: 0 0 12px rgba(255, 201, 64, 0.9), 0 2px 6px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%); animation: tap-float 760ms var(--ease) forwards;
}
@keyframes tap-float { to { transform: translate(-50%, -190%) scale(1.1); opacity: 0; } }
.tap-spark {
  position: absolute; left: var(--x); top: var(--y); z-index: 2; width: 7px; height: 7px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff6d6, #ffc940 60%, transparent 70%);
  animation: tap-spark 560ms cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
@keyframes tap-spark { to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }

/* ---- energy ---- */
.tap-energy { width: min(100%, 420px); display: grid; gap: 6px; }
.tap-energy-head { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: baseline; gap: 6px; }
.tap-bolt { font-size: 1.1rem; filter: drop-shadow(0 0 6px rgba(255, 201, 64, 0.8)); }
.tap-energy-head strong { font: 900 1.15rem/1 var(--display); font-variant-numeric: tabular-nums; }
.tap-regen { justify-self: end; font-size: 0.78rem; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tap-bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); overflow: hidden; }
.tap-bar-fill {
  display: block; height: 100%; width: 100%; border-radius: inherit; transform-origin: left center; transform: scaleX(var(--fill, 1));
  background: linear-gradient(90deg, #ff9d00, #ffd75e 70%, #fff3c4); box-shadow: 0 0 14px rgba(255, 201, 64, 0.75); transition: transform 200ms linear;
}
.tap-login { display: grid; justify-items: center; gap: 10px; text-align: center; }
.tap-login p, .tap-off { margin: 0; font-weight: 700; text-align: center; }
.tap-legal { margin: 6px 0 0; font-size: 0.72rem; color: var(--dim); text-align: center; }

/* ---- info panel: bottom sheet (phones, app) / side column (desktop site) ---- */
.tap-info {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: min(84dvh, 720px); overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 12px; padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0; background: linear-gradient(180deg, #1d1648, #110c2e);
  box-shadow: 0 -1px 0 rgba(177, 140, 255, 0.25), 0 -30px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(105%); visibility: hidden; transition: transform 260ms var(--ease), visibility 0s linear 260ms;
}
.tap-info.is-open { transform: none; visibility: visible; transition: transform 260ms var(--ease); }
.tap-info-backdrop { position: fixed; inset: 0; z-index: 69; background: rgba(4, 3, 14, 0.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.tap-info-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.tap-info-head h2 { font-size: 1.1rem; line-height: 1.2; }
.tap-langs { width: max-content; margin: 2px 0 4px; }
.tap-info-close { width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; cursor: pointer; font-size: 1.3rem; color: var(--ink); background: rgba(255, 255, 255, 0.08); }
.tap-info p { margin: 0; }
.tap-virtual { padding: 10px 12px; border-radius: 16px; font-weight: 700; font-size: var(--step--1);
  background: rgba(255, 201, 64, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 201, 64, 0.28); }
.tap-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.tap-stats strong { font-size: 0.95rem; }
.tap-ref { display: grid; gap: 4px; width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; border: 0; padding: 14px 16px; border-radius: 20px; }
.tap-ref-title { font-weight: 800; color: var(--ink); }
.tap-levels h3 { margin: 0 0 4px; font-size: var(--step-0); }
.tap-levels ol { margin: 6px 0 10px; padding-left: 1.3em; display: grid; gap: 3px; font-size: var(--step--1); }
.tap-levels li.is-current { color: var(--gold); font-weight: 800; }
.tap-info .som { margin: 0; }

/* desktop website: the coin column + a static info column, no sheet */
@media (min-width: 1024px) {
  html:not(.app) .tap-layout { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
  html:not(.app) .tap-stage { padding: 22px 28px 18px; min-height: calc(100vh - var(--top-h, 64px) - 48px); justify-content: center; }
  html:not(.app) .tap-coin-wrap { width: min(36vw, 340px, calc(100vh - 420px)); min-width: 220px; }
  html:not(.app) .tap-info {
    position: static; transform: none; visibility: visible; max-height: none; overflow: visible; padding: 18px;
    border-radius: 24px; box-shadow: inset 0 0 0 1px rgba(177, 140, 255, 0.16);
  }
  html:not(.app) .tap-info-btn, html:not(.app) .tap-info-close, html:not(.app) .tap-info-backdrop { display: none; }
}

/* Telegram app: exactly one screen above the app nav */
html.app .tap-stage {
  min-height: calc(var(--app-h, 100dvh) - var(--app-nav-h, 64px) - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px) - 22px);
  justify-content: space-between; padding: 10px 14px 8px; background: none; box-shadow: none; overflow: visible;
}
html.app .tap-coin-wrap { width: min(70vw, 300px, calc(var(--app-h, 100dvh) - 410px)); min-width: 180px; }
html.app .tap-info { bottom: calc(var(--app-nav-h, 64px) + env(safe-area-inset-bottom, 0px)); max-height: calc(var(--app-h, 100dvh) - 120px); }

@media (prefers-reduced-motion: reduce) {
  .tap-coin-wrap, .tap-glow, .tap-bal strong.is-bump { animation: none; }
  .tap-coin { transition: none; }
  .tap-float, .tap-spark { display: none; }
}
