:root {
  color-scheme: light dark;
}

html,
body {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: radial-gradient(120% 80% at 50% 0%, #132b8f 0%, #070c3d 45%, #060a2d 100%);
  color: #f8fafc;
}

.app {
  --wheel-size: min(330px, calc(100vw - 34px));
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(32px, 8.5vw, 42px);
  line-height: 1.1;
  font-weight: 800;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hero-sub {
  margin: 4px 0 10px;
  color: #d9ddf8;
  font-size: clamp(16px, 4.4vw, 19px);
  font-weight: 700;
}

.wheel-wrap {
  position: relative;
  width: var(--wheel-size);
  height: var(--wheel-size);
  margin: 0 auto 10px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
}

.wheel-pointer-slot {
  position: absolute;
  left: 50%;
  width: 100%;
  top: -2px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  pointer-events: none;
}

.wheel-stack {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 50%;
  border: 9px solid #f1f5ff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transition: transform 5s cubic-bezier(0.12, 0.8, 0.2, 1);
  background: #102352;
  transform-origin: 50% 50%;
}

.wheel-svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  vertical-align: top;
}

.wheel-labels {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.winner-line {
  width: min(100%, var(--wheel-size));
  font-size: clamp(18px, 5.4vw, 22px);
  font-weight: 700;
  color: #ffd56a;
  margin: 0 0 12px;
  min-height: 1.3em;
  text-align: center;
}

.pointer {
  width: 34px;
  height: 26px;
  flex-shrink: 0;
  line-height: 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
}

.wheel-center-cap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(90px, 28vw, 106px);
  height: clamp(90px, 28vw, 106px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 4px solid #d7d9e4;
  background: radial-gradient(circle at 32% 30%, #ffffff 0%, #efeff5 62%, #d8dbe6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e2759;
  font-weight: 900;
  font-size: clamp(18px, 5.2vw, 22px);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 8px 18px rgba(0, 0, 0, 0.35), inset 0 -6px 10px rgba(0, 0, 0, 0.09);
  z-index: 4;
}

.stats-card {
  width: min(100%, var(--wheel-size));
  border-radius: 14px;
  border: 1px solid rgba(137, 154, 255, 0.22);
  background: rgba(10, 19, 66, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  padding: 12px 12px;
  margin: 6px 0 10px;
}

.stats-title {
  color: #d6dcff;
  font-size: 14px;
  margin-bottom: 3px;
}

.stats-count {
  color: #ffffff;
  font-size: clamp(36px, 10vw, 46px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 6px;
}

.stats-subtitle {
  color: #bfc7f3;
  font-size: 13px;
  margin-bottom: 6px;
}

.stats-winners {
  min-height: 18px;
  color: #f0f3ff;
  font-size: 14px;
  opacity: 0.96;
}

.spin-btn {
  width: min(100%, var(--wheel-size));
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font-size: clamp(28px, 9vw, 35px);
  font-weight: 800;
  background: linear-gradient(180deg, #ff5f52 0%, #ff2f21 100%);
  color: #fff7f6;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(255, 54, 40, 0.34);
}

.spin-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.result {
  width: min(100%, var(--wheel-size));
  min-height: 24px;
  margin-top: 8px;
  font-size: 15px;
  text-align: center;
  color: #e6ebff;
}

.prize-line {
  width: min(100%, var(--wheel-size));
  color: #edf1ff;
  font-size: clamp(18px, 5.5vw, 22px);
  font-weight: 700;
  margin: 2px 0 6px;
  min-height: 1.2em;
}

.hint {
  width: min(100%, var(--wheel-size));
  font-size: 13px;
  color: #b9c3f3;
  margin: 8px 0 16px;
  text-align: center;
}

/* По запросу: скрыть статусный блок под карточкой участников. */
.result,
.hint {
  display: none;
}

.refresh-btn {
  width: min(100%, var(--wheel-size));
  margin-top: 8px;
  border: 1px solid rgba(177, 188, 255, 0.35);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 15px;
  background: rgba(8, 17, 55, 0.55);
  color: #e9eeff;
  cursor: pointer;
}

.refresh-btn:active {
  opacity: 0.85;
}

@media (max-width: 360px) {
  h1 {
    margin-top: 2px;
  }
}

/* Стандартное мобильное окно Telegram Web App (iOS/Android) */
@media (max-width: 520px) {
  .app {
    --wheel-size: min(332px, calc(100vw - 28px));
    max-width: 400px;
    padding-top: 12px;
  }
  .stats-card {
    margin-top: 8px;
  }
}

/* Стандартное десктопное окно Telegram Web App (popup/side pane) */
@media (min-width: 521px) {
  .app {
    --wheel-size: min(360px, calc(100vw - 56px));
    max-width: 460px;
    padding-top: 16px;
    padding-left: 18px;
    padding-right: 18px;
  }
  h1 {
    font-size: clamp(34px, 4.4vw, 44px);
  }
}
