:root {
  --bg: #071012;
  --panel: rgba(13, 22, 28, 0.86);
  --panel-strong: rgba(16, 28, 36, 0.94);
  --text: #f7fbff;
  --muted: #9fb0bb;
  --line: rgba(137, 220, 196, 0.22);
  --mint: #51e6b1;
  --cyan: #39c7ff;
  --gold: #ffd36a;
  --rose: #ff6b9a;
  --violet: #9d80ff;
  --shadow: rgba(0, 0, 0, 0.52);
  --app-safe-top: max(18px, env(safe-area-inset-top));
  --app-safe-bottom: max(76px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, Arial, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 18% 10%, rgba(81, 230, 177, 0.16), transparent 29%),
    radial-gradient(circle at 86% 18%, rgba(255, 211, 106, 0.14), transparent 24%),
    linear-gradient(180deg, #071012 0%, #0c1720 48%, #080d12 100%);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--app-safe-top) 16px var(--app-safe-bottom);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, rgba(8, 16, 20, 0.96), rgba(6, 12, 16, 0.98));
  background-size: 32px 32px, 32px 32px, auto;
}

body.telegram-mode .app-shell {
  --app-safe-top: max(10px, env(safe-area-inset-top));
}

body.telegram-mode .topbar {
  display: none;
}

body.telegram-mode .hero {
  margin-top: 2px;
}

body.telegram-mode .hero h1 {
  font-size: clamp(22px, 6vw, 26px);
}

body.telegram-mode .lead {
  max-width: 250px;
  margin-top: 6px;
  line-height: 1.32;
}

body:not([data-current-page="room"]) .room-card,
body:not([data-current-page="room"]) .stats,
body:not([data-current-page="room"]) .game-library {
  display: none;
}

body:not([data-current-page="room"]) .hero {
  display: block;
}

body:not([data-current-page="room"]) .hero h1 {
  font-size: clamp(20px, 5.5vw, 24px);
}

body:not([data-current-page="room"]) .lead,
body:not([data-current-page="room"]) .daily-chip {
  display: none;
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 48px;
}

.icon-btn {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.icon-btn span {
  font-weight: 900;
}

.icon-btn:first-child span {
  font-size: 28px;
  line-height: 1;
}

.icon-btn:last-child span {
  color: var(--mint);
  font-size: 12px;
}

.brand {
  text-align: center;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.1;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(24px, 6.5vw, 28px);
  line-height: 1.05;
}

.lead {
  max-width: 310px;
  margin: 8px 0 0;
  color: #d8e2e6;
  font-size: clamp(13px, 3.6vw, 14px);
  line-height: 1.45;
}

.daily-chip {
  display: grid;
  min-width: 104px;
  min-height: 38px;
  place-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(81, 230, 177, 0.46);
  border-radius: 999px;
  color: var(--mint);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  background: rgba(81, 230, 177, 0.08);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}

.room-card {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 72px;
  margin-top: 16px;
  padding: 11px;
  border: 1px solid rgba(81, 230, 177, 0.28);
  border-radius: 8px;
  background:
    radial-gradient(circle at 0 50%, rgba(81, 230, 177, 0.12), transparent 38%),
    linear-gradient(145deg, rgba(17, 32, 39, 0.94), rgba(11, 20, 26, 0.88));
  box-shadow: 0 16px 38px var(--shadow);
}

.room-avatar {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 211, 106, 0.52);
  border-radius: 50%;
  color: var(--gold);
  font-size: 15px;
  font-weight: 900;
  background: linear-gradient(145deg, rgba(255, 211, 106, 0.16), rgba(57, 199, 255, 0.12));
}

.room-card span,
.room-card strong,
.room-card b {
  display: block;
}

.room-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.room-card strong {
  margin-top: 3px;
  font-size: 18px;
}

.room-card b {
  min-width: 94px;
  padding: 9px 10px;
  border-radius: 999px;
  color: var(--gold);
  font-size: 11px;
  text-align: center;
  background: rgba(255, 211, 106, 0.09);
}

.stats article,
.result-panel,
.prizes,
.game-stage,
.history {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--panel-strong), var(--panel));
  box-shadow: 0 16px 38px var(--shadow);
}

.stats article {
  min-height: clamp(66px, 18vw, 78px);
  padding: 12px 9px;
  text-align: center;
}

.stats span {
  display: block;
  min-height: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.stats strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(20px, 6vw, 24px);
  line-height: 1;
}

.game-library {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}

.game-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  min-height: clamp(64px, 18vw, 76px);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 8px;
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
}

.game-card.active {
  border-color: rgba(81, 230, 177, 0.58);
  background:
    radial-gradient(circle at 0 0, rgba(81, 230, 177, 0.18), transparent 46%),
    rgba(255, 255, 255, 0.06);
}

.game-card span {
  grid-row: 1 / 3;
  font-size: 25px;
}

.game-card b {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-card small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-stage {
  margin-top: 14px;
  padding: 14px;
}

.game-stage[data-page-view="room"] {
  display: none;
}

.game-stage[data-page-view="room"].active {
  display: none;
}

.app-page {
  display: none;
}

.app-page.active {
  display: block;
}

.room-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.room-tabs button {
  min-height: 38px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  background: transparent;
}

.room-tabs button.active {
  color: #071012;
  background: linear-gradient(135deg, var(--mint), var(--gold));
}

.stage-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.stage-title .eyebrow {
  margin-bottom: 4px;
}

.stage-title h2 {
  margin: 0;
  font-size: clamp(18px, 5.6vw, 22px);
}

.page-note {
  margin: 12px 0 0;
  color: #dce7ea;
  font-size: 13px;
  line-height: 1.45;
}

.wheel-zone {
  position: relative;
  display: grid;
  width: min(100%, 318px, 70dvh);
  aspect-ratio: 1;
  place-items: center;
  margin: 16px auto 0;
}

.wheel-zone::before,
.wheel-zone::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.wheel-zone::before {
  inset: 7px;
  background: radial-gradient(circle, rgba(81, 230, 177, 0.18), rgba(57, 199, 255, 0.06) 56%, transparent 70%);
  filter: blur(18px);
}

.wheel-zone::after {
  inset: 14px;
  border: 1px solid rgba(255, 211, 106, 0.32);
  box-shadow:
    0 0 0 5px rgba(255, 255, 255, 0.025),
    0 0 34px rgba(81, 230, 177, 0.16);
}

#wheelCanvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.56));
  transition: transform 4.4s cubic-bezier(0.12, 0.74, 0.12, 1);
}

.pointer {
  position: absolute;
  top: -2px;
  z-index: 4;
  width: 34px;
  height: 50px;
  background: linear-gradient(180deg, #fff8d2, var(--gold));
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 6px 11px rgba(0, 0, 0, 0.45));
}

.spin-core {
  position: absolute;
  z-index: 3;
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  padding: 18px 10px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.65), transparent 18%),
    linear-gradient(145deg, #ffdc78, #ff7b73 45%, #8a71ff);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.42),
    0 0 28px rgba(255, 211, 106, 0.32);
}

.spin-core b,
.spin-core span {
  display: block;
}

.spin-core b {
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
}

.spin-core span {
  color: rgba(255, 255, 255, 0.86);
  font-size: 10px;
  font-weight: 800;
}

.spin-core:disabled {
  cursor: default;
  filter: grayscale(0.45) brightness(0.78);
}

.result-panel {
  margin-top: 12px;
  padding: 12px;
}

.result-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.result-panel h2 {
  margin: 7px 0 0;
  font-size: 19px;
}

.result-panel p:last-child {
  margin: 6px 0 0;
  color: #dce7ea;
  font-size: 13px;
  line-height: 1.4;
}

.coming-game {
  display: grid;
  justify-items: center;
  min-height: min(372px, 58dvh);
  margin-top: 16px;
  padding: 28px 16px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 8px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0, rgba(157, 128, 255, 0.22), transparent 38%),
    rgba(255, 255, 255, 0.04);
}

.coming-icon {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  font-size: 46px;
  background: rgba(255, 255, 255, 0.06);
}

.coming-game h2 {
  margin: 18px 0 0;
  font-size: 25px;
}

.coming-game p {
  max-width: 280px;
  margin: 10px 0 0;
  color: #dce7ea;
  font-size: 13px;
  line-height: 1.45;
}

.preview-btn {
  min-height: 42px;
  margin-top: 18px;
  padding: 0 18px;
  border: 1px solid rgba(81, 230, 177, 0.48);
  border-radius: 999px;
  color: var(--mint);
  font-size: 13px;
  font-weight: 900;
  background: rgba(81, 230, 177, 0.08);
}

.coming-game blockquote {
  width: 100%;
  max-width: 300px;
  margin: 16px 0 0;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.18);
}

.prizes,
.history {
  margin-top: 12px;
  padding: 14px;
}

.prizes h2,
.history h2 {
  margin: 0 0 11px;
  font-size: 16px;
}

.prize-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.prize-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: #eaf4f3;
  background: rgba(255, 255, 255, 0.045);
}

.prize-pill span {
  font-size: 19px;
  flex: 0 0 auto;
}

.prize-pill b {
  display: block;
  font-size: 12px;
}

.prize-pill small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
}

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

.history li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #dce7ea;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.history time {
  color: var(--muted);
}

.spin-core:active,
.icon-btn:active,
.game-card:active,
.preview-btn:active {
  transform: scale(0.97);
}

@media (min-width: 520px) {
  body {
    display: grid;
    place-items: center;
    padding: 22px;
  }

  .app-shell {
    min-height: 880px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 34px;
    box-shadow:
      0 0 0 8px #070b0f,
      0 24px 90px rgba(0, 0, 0, 0.65);
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .hero {
    grid-template-columns: 1fr;
    margin-top: 12px;
  }

  .daily-chip {
    justify-self: start;
  }

  .topbar {
    grid-template-columns: 38px 1fr 38px;
    min-height: 42px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .wheel-zone {
    width: min(100%, 292px);
  }

  .game-library {
    grid-template-columns: 1fr;
  }

  .spin-core {
    width: 96px;
    height: 96px;
  }
}

@media (max-height: 720px) {
  :root {
    --app-safe-top: 12px;
    --app-safe-bottom: 14px;
  }

  .topbar {
    min-height: 40px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .hero,
  .room-card,
  .stats,
  .game-library,
  .room-tabs,
  .game-stage,
  .prizes,
  .history {
    margin-top: 10px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .lead {
    margin-top: 8px;
    line-height: 1.32;
  }

  .room-card {
    min-height: 62px;
    padding: 9px;
  }

  .room-avatar {
    width: 42px;
    height: 42px;
  }

  .stats article {
    min-height: 62px;
    padding: 9px 7px;
  }

  .stats span {
    min-height: 18px;
  }

  .game-card {
    min-height: 60px;
    padding: 8px;
  }

  .game-stage {
    padding: 11px;
  }

  .wheel-zone {
    width: min(100%, 278px, 58dvh);
    margin-top: 10px;
  }

  .result-panel {
    padding: 10px;
  }
}

@media (min-width: 390px) and (min-height: 820px) {
  .wheel-zone {
    width: min(100%, 340px, 62dvh);
  }
}
