/* =================================================================
   PRIZE WHEEL — tool-local styles
   Scoped under .pw-root so nothing here leaks into platform chrome.
   Fonts (Outfit, DM Sans) are loaded once by the platform's
   variables.css.
   ================================================================= */

.pw-root {
  --pw-primary: #7c3aed;
  --pw-primary-dark: #5b21b6;
  --pw-gold: #f5b100;
  --pw-gold-dark: #b97b00;
  --pw-success: #00a86b;
  --pw-danger: #e74c3c;
  --pw-bg: #faf8ff;
  --pw-surface: #ffffff;
  --pw-border: #e4defa;
  --pw-text: #1a1c23;
  --pw-text-muted: #6b7280;
  --pw-radius: 14px;
  --pw-radius-sm: 8px;
  --pw-radius-full: 999px;
  --pw-shadow-sm: 0 2px 8px rgba(28, 12, 60, 0.06);
  --pw-shadow-md: 0 8px 32px rgba(28, 12, 60, 0.1);
  --pw-shadow-lg: 0 24px 64px rgba(28, 12, 60, 0.16);

  font-family: var(--font-body);
  color: var(--pw-text);
}

.pw-root *,
.pw-root *::before,
.pw-root *::after {
  box-sizing: border-box;
}

.pw-main {
  max-width: 1200px;
  margin: 0 auto;
}

/* =============================================
   MODE TOGGLE (Prizes vs Participants)
   ============================================= */
.pw-modeToggle {
  display: inline-flex;
  padding: 0.3rem;
  gap: 0.25rem;
  background: var(--pw-bg);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-full);
  margin-bottom: 1.5rem;
}

.pw-modeToggle__btn {
  padding: 0.6rem 1.3rem;
  border-radius: var(--pw-radius-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--pw-text-muted);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pw-modeToggle__btn.is-active {
  background: #fff;
  color: var(--pw-primary-dark);
  box-shadow: var(--pw-shadow-sm);
}

.pw-modeToggle__btn:not(.is-active):hover {
  color: var(--pw-text);
}

/* =============================================
   LAYOUT GRID
   ============================================= */
.pw-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1.5rem;
  align-items: start;
}

.pw-grid > * {
  /* Grid items default to min-width:auto, which lets intrinsic content
     size (the canvas element's width="480" attribute, in particular)
     push the track wider than the available column — overriding that
     is what allows the card to actually shrink on narrow screens. */
  min-width: 0;
}

.pw-card {
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius);
  box-shadow: var(--pw-shadow-sm);
  padding: 1.5rem;
}

@media (max-width: 400px) {
  .pw-card {
    padding: 1rem;
  }
}

.pw-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pw-h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.pw-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border-radius: var(--pw-radius-full);
  background: var(--pw-primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
}

/* =============================================
   WHEEL CARD
   ============================================= */
.pw-card--wheel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  position: relative;
}

.pw-wheelCanvasWrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
  margin: 0 auto;
}

.pw-wheelCanvasWrap::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(124, 58, 237, 0.16) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#pw-wheelCanvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 18px 40px rgba(28, 12, 60, 0.18));
}

.pw-pointer {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 28px solid var(--pw-gold);
  filter: drop-shadow(0 4px 10px rgba(245, 177, 0, 0.5));
}

.pw-center-btn-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.pw-centerSpinBtn {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pw-primary) 0%, var(--pw-gold) 100%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.4);
  border: 4px solid #fff;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pw-centerSpinBtn:hover:not(:disabled) {
  transform: scale(1.05);
}

.pw-centerSpinBtn:active:not(:disabled) {
  transform: scale(0.96);
}

.pw-centerSpinBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pw-centerSpinBtn__pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(124, 58, 237, 0.4);
  animation: pw-pulse 2.2s ease-out infinite;
}

@keyframes pw-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.pw-spinNote {
  min-height: 1.4rem;
  font-size: 0.9rem;
  color: var(--pw-text-muted);
  text-align: center;
}

.pw-wheelActions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* =============================================
   BUTTONS
   ============================================= */
.pw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--pw-radius-full);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1.5px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.pw-btn:hover {
  transform: translateY(-1px);
}

.pw-btn--primary {
  background: linear-gradient(135deg, var(--pw-primary) 0%, var(--pw-gold) 100%);
  color: #fff;
}

.pw-btn--soft {
  background: var(--pw-bg);
  border-color: var(--pw-border);
  color: var(--pw-text);
}

.pw-btn--soft:hover {
  border-color: var(--pw-primary);
}

.pw-btn--softDanger {
  background: #fdf1f0;
  border-color: #f6cfcb;
  color: var(--pw-danger);
}

.pw-btn--softDanger:hover {
  border-color: var(--pw-danger);
}

.pw-btn--ghost {
  background: transparent;
  color: var(--pw-text);
}

.pw-btn--ghost:hover {
  background: var(--pw-bg);
}

.pw-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* =============================================
   ENTRIES CARD
   ============================================= */
.pw-help {
  font-size: 0.85rem;
  color: var(--pw-text-muted);
  margin-bottom: 0.9rem;
  line-height: 1.55;
}

.pw-code {
  background: var(--pw-bg);
  border: 1px solid var(--pw-border);
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.82em;
  color: var(--pw-primary-dark);
}

.pw-quickAdd {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

@media (max-width: 400px) {
  .pw-quickAdd {
    flex-wrap: wrap;
  }

  .pw-quickAdd__input {
    flex-basis: 100%;
  }
}

.pw-quickAdd__input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  border-radius: var(--pw-radius-sm);
  border: 1.5px solid var(--pw-border);
  outline: none;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pw-quickAdd__input:focus {
  border-color: var(--pw-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

/* Prize-idea preset chips */
.pw-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.pw-presets[hidden] {
  display: none;
}

.pw-presets__label {
  width: 100%;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pw-text-muted);
  margin-bottom: 0.15rem;
}

.pw-chip {
  padding: 0.35rem 0.75rem;
  border-radius: var(--pw-radius-full);
  border: 1px solid var(--pw-border);
  background: var(--pw-bg);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pw-text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pw-chip:hover {
  border-color: var(--pw-primary);
  background: #f3edff;
}

.pw-textarea {
  width: 100%;
  min-height: 180px;
  padding: 0.85rem 1rem;
  border-radius: var(--pw-radius-sm);
  border: 1.5px solid var(--pw-border);
  outline: none;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pw-textarea:focus {
  border-color: var(--pw-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.pw-validation {
  min-height: 1.3rem;
  font-size: 0.82rem;
  color: var(--pw-danger);
  margin-top: 0.5rem;
}

.pw-tableWrap {
  margin-top: 1rem;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-sm);
}

.pw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pw-table th {
  position: sticky;
  top: 0;
  background: var(--pw-bg);
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--pw-text-muted);
  border-bottom: 1px solid var(--pw-border);
}

.pw-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--pw-border);
}

.pw-table tr:last-child td {
  border-bottom: none;
}

.pw-colRight {
  text-align: right;
}

.pw-table .pw-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.pw-table .pw-removedRow {
  color: var(--pw-text-muted);
  text-decoration: line-through;
}

/* =============================================
   SETTINGS PANEL
   ============================================= */
.pw-settingsPanel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pw-border);
}

.pw-settingsPanel[hidden] {
  display: none;
}

.pw-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pw-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pw-text-muted);
}

.pw-select,
.pw-input {
  padding: 0.55rem 0.7rem;
  border-radius: var(--pw-radius-sm);
  border: 1.5px solid var(--pw-border);
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
}

.pw-select:focus,
.pw-input:focus {
  border-color: var(--pw-primary);
}

.pw-toggle {
  padding: 0.55rem 0.9rem;
  border-radius: var(--pw-radius-sm);
  border: 1.5px solid var(--pw-border);
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}

.pw-toggle[aria-pressed="true"] {
  background: var(--pw-primary);
  border-color: var(--pw-primary);
  color: #fff;
}

.pw-advanced {
  margin-top: 1rem;
  border-top: 1px solid var(--pw-border);
  padding-top: 0.75rem;
}

.pw-advanced__summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  font-family: var(--font-display);
  color: var(--pw-primary-dark);
  list-style: none;
}

.pw-advanced__summary::-webkit-details-marker {
  display: none;
}

.pw-advanced__summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

details[open] > .pw-advanced__summary::before {
  transform: rotate(90deg);
}

/* =============================================
   RESULTS / WINNER LIST
   ============================================= */
.pw-resultsCard {
  margin-top: 1.5rem;
}

.pw-resultGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.pw-resultBox {
  padding: 1.1rem 1.25rem;
  background: var(--pw-bg);
  border-radius: var(--pw-radius-sm);
  border: 1px solid var(--pw-border);
}

.pw-resultLabel {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--pw-text-muted);
  margin-bottom: 0.4rem;
}

.pw-resultWinner {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--pw-primary-dark);
}

.pw-resultMeta {
  font-size: 0.85rem;
  color: var(--pw-text-muted);
  margin-top: 0.3rem;
}

.pw-winnerList {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.pw-winnerList__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  background: #fff;
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-sm);
  font-size: 0.88rem;
}

.pw-winnerList__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--pw-gold);
  color: #4a3200;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.pw-empty {
  font-size: 0.85rem;
  color: var(--pw-text-muted);
  font-style: italic;
}

.pw-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.pw-actions[hidden] {
  display: none;
}

/* =============================================
   PROBABILITY PANEL
   ============================================= */
.pw-oddsNote {
  font-size: 0.8rem;
  color: var(--pw-text-muted);
  margin-top: 0.6rem;
  padding: 0.65rem 0.8rem;
  background: #f3edff;
  border-radius: var(--pw-radius-sm);
  line-height: 1.55;
}

/* =============================================
   FULLSCREEN MODE
   ============================================= */
.pw-root.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--pw-bg);
  overflow-y: auto;
  padding: 2rem 1.5rem;
}

.pw-root.is-fullscreen .pw-main {
  max-width: 640px;
}

.pw-root.is-fullscreen .pw-card--editor,
.pw-root.is-fullscreen .pw-resultsCard {
  display: none;
}

.pw-root.is-fullscreen .pw-wheelCanvasWrap {
  max-width: 560px;
}

.pw-fsExitBtn {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--pw-border);
  box-shadow: var(--pw-shadow-md);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.pw-root.is-fullscreen .pw-fsExitBtn {
  display: flex;
}

/* =============================================
   WINNER MODAL
   ============================================= */
.pw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(20, 8, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pw-modal-backdrop.is-visible {
  opacity: 1;
  pointer-events: all;
}

.pw-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--pw-shadow-lg);
  padding: 2.25rem 1.75rem 1.75rem;
  text-align: center;
  transform: scale(0.92) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.pw-modal-backdrop.is-visible .pw-modal {
  transform: scale(1) translateY(0);
}

.pw-modal__glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(ellipse, rgba(245, 177, 0, 0.35) 0%, transparent 70%);
  pointer-events: none;
}

.pw-modal__crown {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.pw-modal__label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pw-gold-dark);
  margin-bottom: 0.5rem;
}

.pw-modal__name {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--pw-primary-dark);
  word-break: break-word;
}

.pw-modal__meta {
  margin-top: 0.4rem;
  font-size: 0.88rem;
  color: var(--pw-text-muted);
}

.pw-modal__close {
  margin-top: 1.5rem;
  width: 100%;
  padding: 0.8rem;
  border-radius: var(--pw-radius-full);
  background: linear-gradient(135deg, var(--pw-primary) 0%, var(--pw-gold) 100%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
}

.pw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .pw-grid {
    grid-template-columns: 1fr;
  }

  .pw-resultGrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .pw-card {
    padding: 1.1rem;
  }

  .pw-centerSpinBtn {
    width: 76px;
    height: 76px;
    font-size: 0.75rem;
  }

  .pw-modal {
    padding: 1.75rem 1.25rem 1.5rem;
  }
}
