:root {
  --bg: var(--tg-theme-bg-color, #eef8ff);
  --text: var(--tg-theme-text-color, #202b35);
  --muted: var(--tg-theme-hint-color, #60717f);
  --button: var(--tg-theme-button-color, #25a7e0);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --panel: #ffffff;
  --line: #d7eef8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #d5f3ff 0, var(--bg) 46%, #ffffff 100%);
}
.shell {
  width: min(430px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}
.topline { text-align: center; }
h1 {
  margin: 12px 0 8px;
  font-size: clamp(27px, 9vw, 34px);
  line-height: 1.06;
  letter-spacing: 0;
}
.badge {
  display: inline-flex;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  color: #216d8e;
  font-size: 13px;
  font-weight: 800;
}
.status {
  min-height: 42px;
  margin: 0 auto;
  max-width: 330px;
  color: var(--muted);
  line-height: 1.4;
}
.wheel-card,
.control-card {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(31, 41, 51, .12);
}
.wheel-card {
  padding: 18px 12px 22px;
  display: grid;
  place-items: center;
}
.spin-wheel {
  position: relative;
  width: min(86vw, 360px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  border: 10px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 24px 55px rgba(31,41,51,.18), inset 0 0 0 1px rgba(31,41,51,.08);
}
.bulb-ring {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.bulb {
  --angle: calc(var(--i) * 12.857deg);
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0, #bfefff 54%, #39bdf2 100%);
  box-shadow: 0 0 10px rgba(37,167,224,.55);
  transform: rotate(var(--angle)) translate(calc(min(86vw, 360px) / 2 - 6px));
  animation: bulbPulse 1.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -45ms);
}
@keyframes bulbPulse {
  0%, 100% { opacity: 1; transform: rotate(var(--angle)) translate(calc(min(86vw, 360px) / 2 - 6px)) scale(1); }
  50% { opacity: .66; transform: rotate(var(--angle)) translate(calc(min(86vw, 360px) / 2 - 6px)) scale(.82); }
}
.wheel-pointer {
  position: absolute;
  top: -3px;
  left: 50%;
  z-index: 5;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 32px solid #202b35;
  filter: drop-shadow(0 5px 6px rgba(31,41,51,.22));
}
.wheel-button-core {
  position: absolute;
  z-index: 4;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff, #dff7ff);
  border: 1px solid rgba(31,41,51,.1);
  color: #16435a;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(31,41,51,.18), inset 0 0 0 8px rgba(255,255,255,.62);
}
.control-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}
.availability {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}
.availability strong {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8f8ff;
  color: #176a8e;
}
.primary {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(37,167,224,.28);
}
.primary:disabled { opacity: .56; box-shadow: none; }
.result {
  min-height: 46px;
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}
@media (max-width: 340px) {
  body { padding-left: 10px; padding-right: 10px; }
  .wheel-card { padding-left: 8px; padding-right: 8px; }
  .wheel-button-core { font-size: 13px; }
}
