:root {
  --bg-1: #081322;
  --bg-2: #140b2f;
  --bg-3: #1d4f7a;
  --card: rgba(13, 22, 34, 0.78);
  --card-border: rgba(255, 255, 255, 0.14);
  --text-main: #f8fbff;
  --text-soft: #b5cae5;
  --accent: #ffcf4b;
  --accent-2: #00d7ff;
  --danger: #ff5b6f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  height: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
  background:
    radial-gradient(1200px 800px at 90% -10%, rgba(0, 215, 255, 0.25), transparent 60%),
    radial-gradient(900px 800px at -20% 10%, rgba(255, 80, 140, 0.24), transparent 60%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
  color: var(--text-main);
  font-family: 'Segoe UI', 'Tahoma', sans-serif;
  overflow-x: hidden;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: radial-gradient(circle, #ffffff 1px, transparent 1px);
  background-size: 4px 4px;
}

.app-shell {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding-top: calc(100px + env(safe-area-inset-top, 0px));
  padding-right: 12px;
  padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px));
  padding-left: 12px;
}

.app-topbar {
  position: fixed;
  z-index: 12;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: calc(72px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: linear-gradient(180deg, rgba(5, 10, 16, 0.92), rgba(5, 10, 16, 0));
}

.app-topbar-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.86);
}

.bonus-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #eaf3ff;
  font-size: 12px;
  font-weight: 700;
}

body.profile-mode .app-topbar {
  display: none;
}

body.profile-mode .app-shell {
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-detail {
  padding-bottom: 14px;
}

.wheel-zone,
.giveaways-card,
.media-card,
.donate-card,
.donations-card,
.participants-card,
.profile-card {
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--card);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.giveaways-card,
.media-card,
.donate-card,
.donations-card,
.participants-card,
.profile-card {
  padding: 12px;
}

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

.card-head h2 {
  margin: 0;
  font-size: 17px;
}

.card-head span {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
  font-size: 12px;
}

.giveaway-filters {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.giveaway-filters select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  padding: 8px 9px;
  font-size: 12px;
}

.giveaways-list {
  margin-top: 10px;
  display: grid;
  gap: 7px;
  max-height: min(56vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.giveaway-item {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px 11px;
  cursor: pointer;
  color: var(--text-main);
  text-align: left;
  width: 100%;
}

.giveaway-item.active {
  border-color: rgba(255, 207, 75, 0.62);
  background: rgba(255, 207, 75, 0.14);
}

.giveaway-item-title {
  font-size: 16px;
  font-weight: 800;
}

.giveaway-item-meta {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.35;
}

.back-to-main {
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.wheel-zone {
  padding: 14px;
  min-width: 0;
}

.wheel-head h1 {
  margin: 6px 0 6px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.08;
}

.wheel-head p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.round-kicker {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #ffe88e);
  color: #2a1e00;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.round-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wheel-stage {
  position: relative;
  margin-top: 12px;
  width: min(100%, 840px);
  aspect-ratio: 1 / 1;
  margin-inline: auto;
  border-radius: 50%;
  border: 10px solid rgba(255, 214, 109, 0.96);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.25), transparent 42%),
    radial-gradient(circle at 80% 75%, rgba(0, 215, 255, 0.25), transparent 40%),
    rgba(8, 12, 18, 0.66);
  box-shadow:
    0 20px 36px rgba(0, 0, 0, 0.46),
    0 0 28px rgba(255, 208, 79, 0.36);
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 24px solid transparent;
  border-right: 24px solid transparent;
  border-top: 48px solid #ff8f46;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
  z-index: 4;
}

body.is-spinning .pointer {
  animation: pulse 700ms ease-in-out infinite;
}

.round-timer {
  margin-top: 10px;
  text-align: center;
  color: #ffe7aa;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.wheel-metrics {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
}

.metric-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
}

.metric-card span {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
}

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

.metric-card strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.metric-card.full {
  grid-column: 1 / -1;
}

.metric-card.winner {
  border-color: rgba(255, 207, 75, 0.45);
  background: rgba(255, 207, 75, 0.12);
}

.media-card,
.donate-card,
.donations-card,
.participants-card {
  margin-top: 12px;
}

.media-wrap {
  margin-top: 10px;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}

.media-wrap img,
.media-wrap video {
  width: 100%;
  height: 100%;
  display: block;
}

.media-wrap img {
  object-fit: cover;
}

.media-wrap video {
  object-fit: contain;
  background: #04080f;
}

.media-wrap.portrait {
  aspect-ratio: 9 / 16;
  max-height: min(62vh, 620px);
}

.media-placeholder {
  color: var(--text-soft);
  font-size: 14px;
  text-align: center;
  padding: 0 10px;
}

.media-open-link {
  margin-top: 10px;
  color: #d9ecff;
  text-decoration: underline;
  font-size: 13px;
}

.input-label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 13px;
}

.donate-hint {
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.35;
}

.info-pill {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.pay-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.inline-input input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  padding: 10px;
  font-size: 15px;
}

.action-btn {
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #091018;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn.stars {
  background: linear-gradient(90deg, #ffcf4b, #ffe798);
}

.action-btn.bonus {
  background: linear-gradient(90deg, #9fd3ff, #d5ecff);
}

.action-btn.ton {
  background: linear-gradient(90deg, #00d7ff, #80e9ff);
}

.action-btn.rub {
  width: 100%;
  background: linear-gradient(90deg, #6fffa7, #baf7d3);
}

.action-btn.donate-open {
  width: 100%;
  background: linear-gradient(90deg, #ffcf4b, #ff9e4b);
}

.ton-connect-button {
  margin-top: 8px;
  min-height: 40px;
}

.ton-connect-button [data-tc-connect-button='true'],
.ton-connect-button [data-tc-dropdown-button='true'] {
  width: 100%;
}

body [data-tc-dropdown-container='true'] {
  right: 12px !important;
  left: auto !important;
  inset-inline-start: auto !important;
  inset-inline-end: 12px !important;
  max-width: calc(100vw - 24px) !important;
  z-index: 50 !important;
}

body [data-tc-dropdown='true'] {
  right: 0 !important;
  left: auto !important;
  transform: none !important;
  max-width: calc(100vw - 24px) !important;
}

.pay-status {
  margin-top: 10px;
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.35;
}

.participants-list {
  margin-top: 10px;
  display: grid;
  gap: 7px;
  max-height: min(36vh, 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  padding-bottom: 6px;
}

.donations-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  max-height: min(32vh, 280px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.donation-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
}

.donation-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.donation-avatar-fallback {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff8d4;
  font-weight: 700;
  font-size: 13px;
}

.donation-main {
  min-width: 0;
}

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

.donation-name {
  font-size: 14px;
  font-weight: 700;
}

.donation-amount {
  font-size: 13px;
  color: #ffe59d;
}

.donation-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-soft);
}

.donation-comment {
  margin-top: 5px;
  font-size: 12px;
  color: #dbe8fa;
  word-break: break-word;
}

.participant-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.participant-item strong {
  font-size: 14px;
}

.participant-empty {
  color: var(--text-soft);
  font-size: 14px;
}

.profile-card {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 360px;
}

.profile-avatar-wrap {
  position: relative;
  width: 88px;
  height: 88px;
}

.profile-avatar,
.profile-avatar-fallback {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.profile-avatar {
  object-fit: cover;
  display: none;
}

.profile-avatar-fallback {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 28px;
  font-weight: 800;
}

#profileName {
  margin: 14px 0 4px;
  font-size: 22px;
}

#profileUsername {
  margin: 0;
  color: var(--text-soft);
}

.profile-balance {
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.legal-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 2px 2px;
}

.legal-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 20, 34, 0.66);
  color: #dbeaff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.legal-link-btn:hover,
.legal-link-btn:focus-visible {
  background: rgba(255, 207, 75, 0.15);
  border-color: rgba(255, 207, 75, 0.48);
  transform: translateY(-1px);
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  width: min(360px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border-radius: 999px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(5, 12, 20, 0.88);
  backdrop-filter: blur(10px);
}

.bottom-nav-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 8px;
  background: transparent;
  color: #dbeaff;
  font-weight: 700;
  cursor: pointer;
}

.bottom-nav-btn.active {
  color: #201200;
  background: linear-gradient(90deg, #ffcf4b, #ffb965);
}

.pay-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(4, 8, 14, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pay-modal-layer.active {
  display: flex;
}

.pay-modal {
  position: relative;
  width: min(520px, 100%);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(120% 130% at 90% -10%, rgba(0, 215, 255, 0.2), transparent 45%),
    radial-gradient(120% 130% at -10% 120%, rgba(255, 132, 80, 0.2), transparent 45%),
    rgba(8, 14, 23, 0.97);
  padding: 14px;
}

.pay-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  cursor: pointer;
}

.pay-step {
  display: none;
}

.pay-step.active {
  display: block;
}

.pay-step h3 {
  margin: 2px 0 10px;
}

.pay-methods {
  display: grid;
  gap: 8px;
}

.pay-method-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  color: #0c121a;
  font-weight: 700;
}

.pay-method-btn.stars {
  background: linear-gradient(90deg, #ffcf4b, #ffe798);
}

.pay-method-btn.bonus {
  background: linear-gradient(90deg, #9fd3ff, #d5ecff);
}

.pay-method-btn.ton {
  background: linear-gradient(90deg, #00d7ff, #80e9ff);
}

.pay-method-btn.rub {
  background: linear-gradient(90deg, #6fffa7, #baf7d3);
}

.pay-method-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pay-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pay-back-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  padding: 6px 9px;
}

.comment-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  padding: 10px;
  font-size: 14px;
  min-height: 80px;
  resize: vertical;
}

.pay-convert,
.pay-method-note {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.35;
}

.celebration-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 250ms ease;
  z-index: 20;
}

.celebration-layer.active {
  opacity: 1;
  visibility: visible;
}

.celebration-card {
  width: min(640px, 92vw);
  border-radius: 20px;
  border: 1px solid rgba(255, 207, 75, 0.4);
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 207, 75, 0.24), transparent 46%),
    radial-gradient(circle at 80% 75%, rgba(0, 215, 255, 0.22), transparent 42%),
    rgba(7, 11, 18, 0.88);
  text-align: center;
  padding: 24px 20px;
}

.celebration-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffe59a;
  font-size: 12px;
}

.celebration-name {
  margin-top: 12px;
  font-size: clamp(30px, 6vw, 66px);
  font-weight: 900;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.08);
  }
}

@media (max-width: 760px) {
  .wheel-metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .wheel-stage {
    width: min(100%, 560px);
  }

  .participants-list {
    max-height: min(30vh, 220px);
  }

  .donations-list {
    max-height: min(28vh, 200px);
  }

  .giveaways-list {
    max-height: min(58vh, 520px);
  }
}
