* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-1: #050816;
  --bg-2: #0a1230;
  --text: #f4f7ff;
  --muted: #a9b4d0;
  --accent-1: #6f6bff;
  --accent-2: #9b63ff;
  --shadow-1: 0 30px 80px rgba(0, 0, 0, 0.38);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --shell-padding: 14px;
  --panel-width: 420px;
  --wheel-max-size: min(760px, calc(100svh - 210px), calc(100vw - var(--panel-width) - 110px));
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(109, 81, 255, 0.22), transparent 32%),
    radial-gradient(circle at bottom right, rgba(44, 89, 255, 0.18), transparent 28%),
    linear-gradient(180deg, var(--bg-1) 0%, #050a1b 35%, var(--bg-2) 100%);
  color: var(--text);
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input {
  color: var(--text);
}

.app-shell {
  position: relative;
  min-height: 100svh;
  padding: var(--safe-top) var(--shell-padding) var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.5;
}

.bg-glow-1 {
  width: 340px;
  height: 340px;
  left: -80px;
  top: 40px;
  background: rgba(131, 91, 255, 0.18);
}

.bg-glow-2 {
  width: 380px;
  height: 380px;
  right: -120px;
  bottom: 30px;
  background: rgba(69, 109, 255, 0.14);
}

.app-card {
  position: relative;
  z-index: 1;
  width: min(1500px, 100%);
  height: min(940px, calc(100svh - var(--safe-top) - var(--safe-bottom)));
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-width);
  overflow: hidden;
  border: 1px solid rgba(152, 170, 255, 0.14);
  border-radius: 36px;
  background:
    linear-gradient(90deg, rgba(41, 43, 80, 0.9) 0%, rgba(14, 27, 61, 0.94) 38%, rgba(7, 21, 49, 0.98) 100%);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(18px);
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%),
    radial-gradient(circle at 22% 84%, rgba(255, 126, 201, 0.08), transparent 18%),
    radial-gradient(circle at 80% 20%, rgba(124, 105, 255, 0.1), transparent 18%);
}

.wheel-area {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 22px 24px 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.wheel-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-badge {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.2vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 6px;
  color: #b39cff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.desktop-only {
  display: inline-flex;
}

.icon-button {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--text);
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(182, 196, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.16s ease, background 0.16s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

.wheel-stage {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wheel-frame {
  position: relative;
  width: max(260px, var(--wheel-max-size));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.wheel-frame::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(144, 120, 255, 0.12), transparent 52%),
    radial-gradient(circle at 50% 50%, rgba(85, 114, 255, 0.18), transparent 72%);
  filter: blur(8px);
}

.wheel-frame::after {
  content: "";
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.wheel-canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(23, 32, 70, 0.94) 0 34%, rgba(7, 15, 37, 0.98) 65%, rgba(7, 15, 37, 1) 100%);
  box-shadow:
    0 0 0 10px rgba(12, 21, 48, 0.95),
    0 0 0 12px rgba(180, 197, 255, 0.05),
    0 26px 60px rgba(0, 0, 0, 0.42),
    0 0 48px rgba(102, 101, 255, 0.16);
}

.wheel-pointer {
  position: absolute;
  top: 3.5%;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 24px solid transparent;
  border-right: 24px solid transparent;
  border-top: 44px solid #eef3ff;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.32));
}

.spin-button {
  position: absolute;
  z-index: 4;
  width: clamp(108px, 18vw, 160px);
  height: clamp(108px, 18vw, 160px);
  border-radius: 50%;
  font-size: clamp(1.25rem, 2vw, 1.9rem);
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow:
    0 0 0 8px rgba(12, 22, 51, 0.92),
    0 12px 34px rgba(111, 107, 255, 0.32),
    0 0 28px rgba(127, 103, 255, 0.26);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

.spin-button:hover {
  transform: scale(1.03);
}

.spin-button:active {
  transform: scale(0.98);
}

.spin-button:disabled {
  cursor: not-allowed;
  opacity: 0.86;
  filter: saturate(0.88);
  box-shadow:
    0 0 0 8px rgba(12, 22, 51, 0.92),
    0 8px 22px rgba(111, 107, 255, 0.16),
    0 0 14px rgba(127, 103, 255, 0.16);
}

.wheel-footer {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  min-height: 88px;
}

.result-card {
  flex: 1;
  min-width: 0;
  padding: 16px 20px;
  border-radius: 22px;
  background: rgba(24, 36, 77, 0.74);
  border: 1px solid rgba(171, 189, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.result-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

#selectedResult {
  display: block;
  font-size: clamp(1.02rem, 1.4vw, 1.2rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-actions {
  display: flex;
  gap: 10px;
}

.secondary-button,
.mini-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(181, 195, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.16s ease, background 0.16s ease;
}

.secondary-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

.secondary-button {
  min-width: 118px;
  padding: 0 20px;
  border-radius: 20px;
  font-weight: 700;
}

.mini-button {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
}

.panel-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(2, 7, 22, 0.56);
  backdrop-filter: blur(2px);
}

.side-panel {
  position: relative;
  z-index: 2;
  padding: 26px 20px;
  background:
    linear-gradient(180deg, rgba(15, 27, 59, 0.96) 0%, rgba(9, 20, 46, 0.98) 100%);
  border-left: 1px solid rgba(171, 189, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  min-height: 0;
}

.side-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.side-panel-header h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.panel-section {
  padding: 18px;
  border-radius: 22px;
  background: rgba(30, 42, 86, 0.46);
  border: 1px solid rgba(172, 188, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel-section h3 {
  margin: 0 0 14px;
  font-size: 1.02rem;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.option-item input {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border-radius: 15px;
  background: rgba(9, 17, 40, 0.88);
  border: 1px solid rgba(183, 198, 255, 0.08);
  outline: none;
}

.field input:focus,
.option-item input:focus {
  border-color: rgba(128, 128, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(109, 107, 255, 0.14);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.options-list {
  display: grid;
  gap: 10px;
}

.option-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.option-item span {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: #cfd8ff;
  font-weight: 800;
  font-size: 0.9rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  color: var(--text);
  border-bottom: 1px solid rgba(183, 198, 255, 0.06);
}

.switch-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: #8170ff;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1280px) {
  :root {
    --panel-width: 390px;
    --wheel-max-size: min(700px, calc(100svh - 205px), calc(100vw - var(--panel-width) - 88px));
  }

  .wheel-area {
    padding: 20px 20px 16px;
  }
}

@media (max-width: 1080px) {
  :root {
    --panel-width: 360px;
    --wheel-max-size: min(640px, calc(100svh - 200px), calc(100vw - var(--panel-width) - 72px));
  }

  .brand-copy h1 {
    font-size: clamp(1.55rem, 2vw, 2.2rem);
  }

  .secondary-button {
    min-width: 104px;
    padding: 0 16px;
  }
}

@media (max-width: 960px) {
  :root {
    --wheel-max-size: min(78vw, calc(100svh - 250px), 560px);
  }

  .app-card {
    grid-template-columns: 1fr;
    height: min(920px, calc(100svh - var(--safe-top) - var(--safe-bottom)));
  }

  .desktop-only {
    display: none;
  }

  .panel-backdrop[hidden] {
    display: none;
  }

  .side-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(88vw, 360px);
    height: 100%;
    border-left: 1px solid rgba(171, 189, 255, 0.08);
    transform: translateX(100%);
    transition: transform 0.26s ease;
    box-shadow: -18px 0 50px rgba(0, 0, 0, 0.34);
  }

  .side-panel.is-open {
    transform: translateX(0);
  }

  .wheel-footer {
    flex-direction: column;
    min-height: 0;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .secondary-button {
    min-height: 52px;
  }
}

@media (max-width: 640px) {
  :root {
    --shell-padding: 10px;
    --wheel-max-size: min(calc(100vw - 38px), calc(100svh - 270px), 480px);
  }

  .app-card {
    border-radius: 24px;
  }

  .wheel-area {
    padding: 16px 14px 14px;
  }

  .wheel-topbar {
    min-height: 56px;
  }

  .brand-badge {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 1.2rem;
  }

  .brand-copy h1 {
    font-size: 1.5rem;
  }

  .icon-button {
    width: 50px;
    height: 50px;
  }

  .wheel-pointer {
    border-left-width: 18px;
    border-right-width: 18px;
    border-top-width: 34px;
  }

  .spin-button {
    width: 96px;
    height: 96px;
    font-size: 1.15rem;
  }

  .result-card {
    padding: 15px 16px;
  }

  #selectedResult {
    white-space: normal;
  }
}

@media (max-height: 760px) and (min-width: 961px) {
  :root {
    --wheel-max-size: min(620px, calc(100svh - 180px), calc(100vw - var(--panel-width) - 72px));
  }

  .wheel-area {
    padding-top: 16px;
    padding-bottom: 14px;
  }

  .wheel-topbar {
    min-height: 56px;
  }

  .wheel-footer {
    min-height: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
