.wheel-spinner-app {
  --ws-surface: var(--surface);
  --ws-muted-surface: var(--card-muted);
  --ws-fg: var(--fg);
  --ws-muted: var(--muted);
  --ws-border: var(--border);
  --ws-accent: var(--accent);
  --ws-focus: var(--focus-ring);
  display: grid;
  gap: clamp(18px, 3vw, 28px);
  overflow: clip;
  padding: clamp(14px, 2.5vw, 24px);
}

.wheel-spinner-app [hidden] {
  display: none !important;
}

:root.dark body[data-page-id="wheel-spinner"] {
  --primary-bg: #2f6cff;
  --primary-hover-bg: #245bdf;
}

.wheel-spinner-app[aria-busy="true"] .wheel-spinner-workspace {
  opacity: 0.72;
}

.wheel-spinner-app.is-spinning .wheel-spinner-editor,
.wheel-spinner-app.is-spinning .wheel-spinner-settings {
  opacity: 0.68;
}

.wheel-spinner-head,
.wheel-spinner-actions,
.wheel-spinner-inline-actions,
.wheel-spinner-result-actions,
.wheel-spinner-history-head,
.wheel-spinner-counts,
.wheel-spinner-presentation-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.wheel-spinner-head,
.wheel-spinner-history-head {
  justify-content: space-between;
  gap: 12px 20px;
}

.wheel-spinner-head h2,
.wheel-spinner-history h3,
.wheel-spinner-content h2,
.wheel-spinner-content h3,
.wheel-spinner-dialog h2 {
  margin-block: 0;
}

.wheel-spinner-head p,
.wheel-spinner-field p {
  margin-block: 5px 0;
}

.wheel-spinner-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(320px, 1.18fr);
  gap: clamp(18px, 3vw, 32px);
  align-items: start;
  transition: opacity 160ms ease;
}

.wheel-spinner-controls {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.wheel-spinner-editor,
.wheel-spinner-settings {
  display: grid;
  gap: 12px;
  min-width: 0;
  transition: opacity 160ms ease;
}

.wheel-spinner-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.wheel-spinner-field > label,
.wheel-spinner-field > legend,
.wheel-spinner-list-summary {
  display: block;
  margin-bottom: 8px;
  color: var(--ws-fg);
  font-weight: 700;
}

.wheel-spinner-title,
.wheel-spinner-entries {
  inline-size: 100%;
}

.wheel-spinner-entries {
  min-block-size: 230px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: max(1rem, 16px);
  line-height: 1.55;
  white-space: pre-wrap;
}

.wheel-spinner-help,
.wheel-spinner-status,
.wheel-spinner-label-note,
.wheel-spinner-empty,
.wheel-spinner-error,
.wheel-spinner-counts {
  margin: 0;
}

.wheel-spinner-help,
.wheel-spinner-status,
.wheel-spinner-label-note,
.wheel-spinner-empty,
.wheel-spinner-counts {
  color: var(--ws-muted);
}

.wheel-spinner-error {
  color: var(--trade-pill-sell-fg);
  font-weight: 650;
}

.wheel-spinner-counts {
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

.wheel-spinner-counts > span:not(:last-child)::after {
  content: "·";
  margin-inline-start: 10px;
  color: var(--ws-border);
}

.wheel-spinner-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.wheel-spinner-palette-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wheel-spinner-choice {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: var(--control-min-h);
  cursor: pointer;
}

.wheel-spinner-choice input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.wheel-spinner-choice span {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--control-min-h);
  padding: 9px 10px;
  border: 1px solid var(--ws-border);
  border-radius: 11px;
  background: var(--ws-surface);
  color: var(--ws-fg);
  font-size: 0.93rem;
  line-height: 1.25;
  text-align: center;
}

.wheel-spinner-choice input:checked + span {
  border-color: var(--ws-accent);
  box-shadow: inset 0 0 0 1px var(--ws-accent);
  background: var(--accent-50);
  color: var(--ws-accent);
  font-weight: 700;
}

.wheel-spinner-choice input:focus-visible + span {
  outline: 3px solid var(--ws-focus);
  outline-offset: 2px;
}

.wheel-spinner-choice input:disabled + span {
  cursor: not-allowed;
  opacity: 0.58;
}

.wheel-spinner-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--control-min-h);
  padding: 10px 12px;
  border: 1px solid var(--ws-border);
  border-radius: 11px;
  background: var(--ws-surface);
  cursor: pointer;
}

.wheel-spinner-toggle input {
  inline-size: 22px;
  block-size: 22px;
  flex: 0 0 auto;
  accent-color: var(--ws-accent);
}

.wheel-spinner-stage-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.wheel-spinner-stage-title {
  width: min(100%, 620px);
  margin: 0 auto;
  color: var(--ws-fg);
  font-size: clamp(1.1rem, 2.7vw, 1.6rem);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
}

.wheel-spinner-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 620px);
  aspect-ratio: 1;
  margin-inline: auto;
  isolation: isolate;
}

.wheel-spinner-stage::before {
  position: absolute;
  z-index: -2;
  inset: 7%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--ws-accent) 11%, transparent), transparent 66%);
  content: "";
  filter: blur(16px);
}

.wheel-spinner-canvas {
  display: block;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.2), 0 0 0 1px color-mix(in srgb, var(--ws-border) 75%, transparent);
  transform: rotate(0rad);
  transform-origin: center;
  will-change: transform;
}

.wheel-spinner-pointer {
  position: absolute;
  z-index: 3;
  inset-block-start: 0.5%;
  inset-inline-start: 50%;
  width: clamp(28px, 7.5%, 46px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  filter: drop-shadow(0 5px 6px rgba(15, 23, 42, 0.28));
}

.wheel-spinner-pointer::before {
  display: block;
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 100%, 5% 5%, 95% 5%);
  background: var(--ws-fg);
  content: "";
}

.wheel-spinner-hub {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 17%;
  aspect-ratio: 1;
  border: clamp(4px, 0.7vw, 7px) solid var(--ws-surface);
  border-radius: 50%;
  background: var(--ws-fg);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.3);
  color: var(--ws-surface);
  pointer-events: none;
}

.wheel-spinner-hub::after {
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.9;
}

.wheel-spinner-stage.is-empty .wheel-spinner-canvas {
  opacity: 0.42;
  filter: saturate(0.45);
}

.wheel-spinner-stage-message {
  position: absolute;
  z-index: 4;
  max-width: 68%;
  padding: 10px 14px;
  border: 1px solid var(--ws-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ws-surface) 92%, transparent);
  box-shadow: var(--shadow);
  color: var(--ws-fg);
  text-align: center;
}

.wheel-spinner-primary-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(100%, 620px);
  margin-inline: auto;
}

.wheel-spinner-spin {
  min-height: 54px;
  font-size: 1.08rem;
  font-weight: 800;
}

.wheel-spinner-reveal {
  min-height: 54px;
}

.wheel-spinner-presentation-actions {
  justify-content: center;
}

.wheel-spinner-status {
  min-height: 1.6em;
  text-align: center;
}

.wheel-spinner-label-note {
  text-align: center;
}

.wheel-spinner-list-details {
  border: 1px solid var(--ws-border);
  border-radius: 12px;
  background: var(--ws-muted-surface);
}

.wheel-spinner-list-details > summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
}

.wheel-spinner-list {
  max-height: 220px;
  margin: 0;
  padding: 0 16px 14px 42px;
  overflow: auto;
  overflow-wrap: anywhere;
  scrollbar-gutter: stable;
}

.wheel-spinner-list li {
  padding-block: 4px;
}

.wheel-spinner-history {
  display: grid;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--ws-border);
}

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

.wheel-spinner-history-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--ws-border);
  border-radius: 10px;
  background: var(--ws-muted-surface);
  overflow-wrap: anywhere;
}

.wheel-spinner-history-index {
  color: var(--ws-muted);
  font-variant-numeric: tabular-nums;
}

.wheel-spinner-content {
  display: grid;
  gap: 20px;
}

.wheel-spinner-content section {
  scroll-margin-top: 16px;
}

.wheel-spinner-content ul,
.wheel-spinner-content ol {
  padding-inline-start: 1.45rem;
}

.wheel-spinner-content details {
  padding-block: 10px;
  border-bottom: 1px solid var(--ws-border);
}

.wheel-spinner-content details > summary {
  cursor: pointer;
  font-weight: 700;
}

.wheel-spinner-dialog:not([open]) {
  display: none;
}

.wheel-spinner-dialog {
  width: min(calc(100% - 28px), 560px);
  max-height: min(86vh, 700px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--ws-border);
  border-radius: 18px;
  background: var(--ws-surface);
  color: var(--ws-fg);
  box-shadow: 0 28px 80px rgba(4, 11, 27, 0.38);
}

.wheel-spinner-dialog::backdrop {
  background: rgba(4, 11, 27, 0.68);
  backdrop-filter: blur(3px);
}

body.wheel-spinner-dialog-fallback-open {
  overflow: hidden;
}

.wheel-spinner-app.has-result-modal-fallback {
  overflow: visible;
}

.wheel-spinner-app.has-result-modal-fallback::before {
  content: "";
  position: fixed;
  z-index: 11000;
  inset: 0;
  background: rgba(4, 11, 27, 0.68);
  backdrop-filter: blur(3px);
}

.wheel-spinner-dialog.is-fallback-modal[open] {
  display: block;
  position: fixed;
  z-index: 11001;
  inset: 0;
  height: fit-content;
  margin: auto;
}

.wheel-spinner-dialog-inner {
  display: grid;
  gap: 18px;
  padding: clamp(20px, 4vw, 32px);
  text-align: center;
}

.wheel-spinner-winner-label {
  margin: 0;
  color: var(--ws-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.wheel-spinner-result-title {
  margin: 0;
  color: var(--ws-muted);
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.wheel-spinner-winner {
  margin: 0;
  color: var(--ws-fg);
  font-size: clamp(1.65rem, 7vw, 3rem);
  font-weight: 850;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.wheel-spinner-result-meta {
  margin: 0;
  color: var(--ws-muted);
}

.wheel-spinner-result-actions {
  justify-content: center;
}

.wheel-spinner-close {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
  min-width: 44px;
  min-height: 44px;
}

.wheel-spinner-app:fullscreen,
.wheel-spinner-app.is-presenting {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--bg);
}

.wheel-spinner-app:fullscreen {
  overflow: auto;
  overscroll-behavior: contain;
}

.wheel-spinner-app.is-presenting {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: auto;
  height: auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.wheel-spinner-app:fullscreen,
.wheel-spinner-app.is-presenting {
  grid-template-rows: auto 1fr;
  align-content: start;
}

.wheel-spinner-app:fullscreen .wheel-spinner-head,
.wheel-spinner-app:fullscreen .wheel-spinner-controls,
.wheel-spinner-app:fullscreen .wheel-spinner-label-note,
.wheel-spinner-app:fullscreen .wheel-spinner-history,
.wheel-spinner-app.is-presenting .wheel-spinner-head,
.wheel-spinner-app.is-presenting .wheel-spinner-controls,
.wheel-spinner-app.is-presenting .wheel-spinner-label-note,
.wheel-spinner-app.is-presenting .wheel-spinner-history {
  display: none;
}

.wheel-spinner-app:fullscreen .wheel-spinner-list-details,
.wheel-spinner-app.is-presenting .wheel-spinner-list-details {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.wheel-spinner-app:fullscreen .wheel-spinner-list-details > summary,
.wheel-spinner-app.is-presenting .wheel-spinner-list-details > summary {
  display: none;
}

.wheel-spinner-app:fullscreen .wheel-spinner-workspace,
.wheel-spinner-app.is-presenting .wheel-spinner-workspace {
  display: block;
}

.wheel-spinner-app:fullscreen .wheel-spinner-stage,
.wheel-spinner-app.is-presenting .wheel-spinner-stage {
  height: min(76vh, 90vw, 860px);
  width: min(76vh, 90vw, 860px);
}

.wheel-spinner-app:fullscreen .wheel-spinner-stage-title,
.wheel-spinner-app.is-presenting .wheel-spinner-stage-title {
  width: min(90vw, 860px);
  font-size: clamp(1.35rem, 3vw, 2.15rem);
}

@media (max-width: 820px) {
  .wheel-spinner-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .wheel-spinner-stage-column {
    order: 2;
  }

  .wheel-spinner-controls {
    order: 1;
  }

  .wheel-spinner-entries {
    min-block-size: 180px;
  }
}

@media (max-width: 520px) {
  body[data-page-id="wheel-spinner"] > header.container h1 {
    margin-block: 10px 6px;
    font-size: clamp(1.65rem, 9vw, 2.1rem);
    line-height: 1.12;
  }

  body[data-page-id="wheel-spinner"] > header.container .lead {
    margin-block: 6px;
    font-size: 1rem;
    line-height: 1.45;
  }

  body[data-page-id="wheel-spinner"] > header.container > p.small {
    display: none;
  }

  body[data-page-id="wheel-spinner"] > header.container .lang-switch {
    margin-block: 8px 4px;
  }

  .wheel-spinner-choice-grid,
  .wheel-spinner-palette-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wheel-spinner-primary-action {
    grid-template-columns: minmax(0, 1fr);
  }

  .wheel-spinner-result-actions > .button {
    flex: 1 1 100%;
  }

  .wheel-spinner-counts {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .wheel-spinner-counts > span:not(:last-child)::after {
    content: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-spinner-app,
  .wheel-spinner-app *,
  .wheel-spinner-app *::before,
  .wheel-spinner-app *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .wheel-spinner-canvas {
    border: 2px solid CanvasText;
    forced-color-adjust: none;
  }

  .wheel-spinner-pointer::before {
    background: CanvasText;
  }

  .wheel-spinner-choice input:checked + span {
    outline: 2px solid Highlight;
    outline-offset: -4px;
  }
}

@media print {
  .wheel-spinner-app .wheel-spinner-controls,
  .wheel-spinner-app .wheel-spinner-actions,
  .wheel-spinner-app .wheel-spinner-presentation-actions,
  .wheel-spinner-app .wheel-spinner-result-actions {
    display: none !important;
  }

  .wheel-spinner-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}
