/* Wheel-first desktop composition. Loaded last to override legacy layout rules. */
.headerbar {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px !important;
}

.headerbar > .sectiontabs {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.headerbar > .sectiontabs button {
  flex: 0 0 auto;
  padding: 9px 13px !important;
  font-size: 14px !important;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  text-decoration-color: color-mix(in srgb, currentColor 72%, transparent);
}

/* All inactive tools share one color; selection alone uses the accent. */
.headerbar > .sectiontabs button[aria-selected="false"] {
  color: var(--ink);
}

.headerbar > .sectiontabs button[aria-selected="true"] {
  color: var(--gold);
}

/* Number mode keeps its primary action in the large result field. */
.canvaswrap[data-mode="instant"] > #drawbar {
  top: 72% !important;
  width: min(380px, 58%) !important;
}

.canvaswrap[data-mode="instant"] > #drawbar #draw {
  width: 100% !important;
  aspect-ratio: auto !important;
  border: 0 !important;
  border-radius: 12px !important;
  padding: 18px 24px !important;
  background: var(--gold) !important;
  box-shadow: 0 10px 28px #0004 !important;
  color: var(--buttonink) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
}

.canvaswrap[data-mode="instant"] > #drawbar .draw-full {
  display: block !important;
}

.canvaswrap[data-mode="instant"] > #drawbar .draw-compact {
  display: none !important;
}

@media (max-width: 720px) {
  .canvaswrap[data-mode="instant"] > #drawbar {
    width: min(340px, 82%) !important;
  }
}

@media (max-width: 1450px) {
  .headerbar > .head-actions .secure {
    display: none;
  }
}

@media (max-width: 1050px) {
  .headerbar {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "brand spacer actions"
      "nav nav nav";
    row-gap: 7px !important;
    padding: 10px 0;
  }

  .headerbar > .brand { grid-area: brand; }
  .headerbar > .sectiontabs { grid-area: nav; }
  .headerbar > .head-actions { grid-area: actions; }
}

@media (max-width: 720px) {
  .headerbar > .sectiontabs {
    display: flex;
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    gap: 2px;
    scroll-padding-inline: 4px;
  }

  .headerbar > .sectiontabs button {
    padding: 9px 6px !important;
    font-size: 14px !important;
    min-height: 44px;
    white-space: nowrap;
  }
}

@media (min-width: 1200px) {
  main {
    max-width: 1560px !important;
    padding: 22px 20px 24px !important;
  }

  .workspace {
    display: grid !important;
    grid-template-columns: 278px minmax(0, 1fr) !important;
    gap: 16px !important;
    align-items: start !important;
  }

  .workspace > .setup {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 278px !important;
  }

  .workspace > .stagepanel {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 248px !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    min-width: 0 !important;
  }

  .stagepanel > .stagehead,
  .stagepanel > .giveaway-title,
  .stagepanel > .canvaswrap,
  .stagepanel > #pointerReadout {
    grid-column: 1 !important;
  }

  .stagepanel > .stagehead { grid-row: 1 !important; }
  .stagepanel > .giveaway-title { grid-row: 2 !important; }
  .stagepanel > .canvaswrap { grid-row: 3 !important; }
  .stagepanel > #pointerReadout { grid-row: 4 !important; }

  .stagepanel > .wheel-details {
    grid-column: 2 !important;
    grid-row: 1 / 5 !important;
  }

  .canvaswrap:has(#wheelStudio:not([hidden])) {
    width: min(100%, calc(100vh - 175px)) !important;
    height: auto !important;
    max-width: 820px !important;
    max-height: none !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 auto !important;
  }
}

.stagehead {
  padding: 14px 16px !important;
}

.stagehead h2 {
  font-size: 16px;
}

.modeindex,
.pill {
  font-size: 11px;
}

.wheel-details {
  min-width: 0 !important;
  padding: 16px 14px !important;
  border-left: 1px solid var(--line) !important;
}

.wheel-details .result {
  min-height: 0 !important;
  padding: 18px 12px !important;
}

.wheel-details .result strong {
  font-size: clamp(20px, 1.7vw, 27px) !important;
  line-height: 1.12;
}

.wheel-details .result-congrats {
  font-size: clamp(16px, 1.2vw, 18px) !important;
  white-space: nowrap;
}

.wheel-details .result-winner {
  font-size: clamp(22px, 1.65vw, 27px) !important;
}

.wheel-details .presentation-note {
  margin: 14px 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  font-size: 12px !important;
  line-height: 1.45 !important;
}

.wheel-details .stagefoot {
  padding: 11px 0 0 !important;
  font-size: 11px !important;
}

.wheel-details .stagefoot button {
  font-size: 11px !important;
}

.wheel-details .history {
  margin-top: 16px !important;
  padding-top: 15px !important;
}

.wheel-details .history .sectionheading {
  padding-bottom: 10px !important;
}

.wheel-details #historyRows {
  max-height: 300px !important;
}

.wheel-details .historyrow {
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 4px 10px !important;
  padding: 11px 2px !important;
  font-size: 12px !important;
}

.wheel-details .historyrow .history-meta {
  grid-column: 1 / 3;
  font-size: 11px;
}

.setup {
  padding: 16px !important;
}

.giveaway-title-editor {
  padding: 13px !important;
  margin-bottom: 14px !important;
}

.giveaway-title-editor small {
  font-size: 11px !important;
}

.setupheading {
  margin-bottom: 12px !important;
}

.setup .tabs {
  margin-bottom: 12px !important;
}

.quickadd {
  padding: 11px !important;
  margin-bottom: 13px !important;
}

.quickadd > div {
  grid-template-columns: 1fr !important;
}

.quickadd button {
  width: 100%;
  padding: 9px 10px;
}

.setup textarea {
  height: 148px !important;
  min-height: 120px;
  padding: 10px 11px !important;
  line-height: 1.5 !important;
}

.setup .divider {
  margin: 15px 0 !important;
}

.setup .switchrow {
  margin-top: 0 !important;
}

.settingsheading {
  margin-bottom: 11px !important;
}

#wheelSpeedControls:not(.canvaswrap > #wheelSpeedControls) {
  gap: 8px !important;
  min-height: 190px !important;
  margin-bottom: 10px !important;
}

#wheelSpeedControls:not(.canvaswrap > #wheelSpeedControls) .wheel-setting {
  grid-template-rows: 43px 125px !important;
  padding: 6px 3px !important;
}

#wheelSpeedControls:not(.canvaswrap > #wheelSpeedControls) input[type="range"] {
  height: 118px !important;
}

#wheelSpeedControls:not(.canvaswrap > #wheelSpeedControls) .rangecaptions {
  height: 116px !important;
}

#pointerReadout {
  padding: 8px 16px 13px !important;
  min-height: 50px !important;
}

@media (max-width: 1199px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .workspace > .stagepanel {
    order: 1;
  }

  .workspace > .setup {
    order: 2;
  }

  .stagepanel {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 240px !important;
  }

  .stagepanel > .stagehead,
  .stagepanel > .giveaway-title,
  .stagepanel > .canvaswrap,
  .stagepanel > #pointerReadout {
    grid-column: 1 !important;
  }

  .stagepanel > .wheel-details {
    grid-column: 2 !important;
    grid-row: 1 / 5 !important;
  }

  .canvaswrap:has(#wheelStudio:not([hidden])) {
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
  }
}

@media (max-width: 760px) {
  .stagepanel {
    display: block !important;
  }

  .wheel-details {
    border-left: 0 !important;
    border-top: 1px solid var(--line) !important;
  }
}
