/* Spin the Wheel — style.css */

.app {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 72px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Fullscreen fix: hide nav overlay ── */
.wheel-section:fullscreen {
  background: var(--bg, #0a0a12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Wheel Section ── */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
}

.wheel-toolbar {
  display: flex;
  gap: 8px;
  align-self: flex-end;
}

.toolbar-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toolbar-btn:hover {
  background: var(--surface2);
}

.wheel-container {
  position: relative;
  width: min(80vw, 600px);
  aspect-ratio: 1;
}

.wheel-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Pointer ── */
.wheel-pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 28px solid var(--accent, #a855f7);
  z-index: 3;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  transform-origin: top center;
  transition: transform 0.15s ease-in;
}
.wheel-pointer.bounce {
  transition: transform 0.04s ease-out;
}

/* ── Spin Button ── */
.spin-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.3);
  background: var(--gradient-primary);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.spin-btn:hover {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.4);
}
.spin-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}
.spin-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: translate(-50%, -50%);
}

/* ── Result Banner ── */
.result-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
}
.result-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}
@keyframes pop-in {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Controls Panel ── */
.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.controls h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.control-row label {
  font-size: 13px;
  color: var(--dim);
  min-width: 110px;
  flex-shrink: 0;
}
.control-select {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.slider {
  flex: 1;
  accent-color: var(--accent, #a855f7);
}
#speed-value {
  font-size: 13px;
  color: var(--dim);
  min-width: 28px;
  text-align: right;
}

/* ── Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stepper-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.stepper-btn:hover {
  background: var(--border);
}
#seg-count {
  font-size: 15px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  color: var(--text);
}

/* ── Segment Editor ── */
.seg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.seg-row:last-child {
  border-bottom: none;
}
.seg-color {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.seg-label {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.seg-weight {
  width: 80px;
  flex-shrink: 0;
  accent-color: var(--accent, #a855f7);
}
.seg-pct {
  font-size: 12px;
  color: var(--dim);
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Action Buttons ── */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* ── History ── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-small {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-small:hover {
  background: var(--border);
}
.history-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  padding: 4px 0;
}
.history-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.history-num {
  font-size: 11px;
  color: var(--dim);
  min-width: 20px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-input {
  padding: 10px 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.modal textarea {
  padding: 10px 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Saved Wheels List ── */
.saved-wheels-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.saved-wheel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.saved-wheel-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.saved-wheel-actions {
  display: flex;
  gap: 6px;
}

/* ── Confetti Canvas ── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  0% { transform: translateX(-50%) translateY(20px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ── Buttons (reuse theme patterns) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, background 0.2s;
}
.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
}
.btn-primary:hover { opacity: 0.85; }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  align-self: center;
}
.mode-btn {
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mode-btn.active {
  background: var(--gradient-primary);
  color: #fff;
}
.mode-btn:hover:not(.active) {
  color: var(--text);
}

/* ── Dice Section ── */
.dice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  position: relative;
}
.dice-toolbar {
  display: flex;
  gap: 8px;
  align-self: flex-end;
}
.dice-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  min-height: 160px;
  padding: 20px;
}
.die-canvas {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
  transition: transform 0.2s;
}
.die-canvas.rolling {
  animation: die-shake 0.1s infinite;
}
@keyframes die-shake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 2px) rotate(-3deg); }
  50% { transform: translate(2px, -3px) rotate(2deg); }
  75% { transform: translate(-2px, 1px) rotate(-1deg); }
  100% { transform: translate(3px, -2px) rotate(3deg); }
}
.dice-roll-btn {
  position: static;
  transform: none;
  width: auto;
  height: auto;
  border-radius: 12px;
  padding: 14px 48px;
  font-size: 18px;
}
.dice-roll-btn:hover {
  transform: scale(1.05);
}
.dice-roll-btn:active {
  transform: scale(0.95);
}
.dice-roll-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

/* ── Dice Notation ── */
.dice-notation {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* ── Dice History Item ── */
.history-dice-detail {
  font-size: 11px;
  color: var(--dim);
  margin-left: 4px;
}

/* ── Utility ── */
.hidden { display: none !important; }
.dim { color: var(--dim); font-size: 13px; margin: 0; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app {
    padding: 64px 12px 48px;
  }
  .wheel-container {
    width: min(90vw, 400px);
  }
  .control-row {
    flex-wrap: wrap;
  }
  .control-row label {
    min-width: 80px;
  }
  .seg-row {
    flex-wrap: wrap;
  }
  .seg-weight {
    width: 60px;
  }
  .spin-btn {
    width: 64px;
    height: 64px;
    font-size: 13px;
  }
  .result-banner {
    font-size: 16px;
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .wheel-container {
    width: 92vw;
  }
  .action-buttons {
    flex-direction: column;
  }
  .action-buttons .btn {
    width: 100%;
  }
  .spin-btn {
    width: 56px;
    height: 56px;
    font-size: 12px;
  }
  .die-canvas {
    width: 90px;
    height: 90px;
  }
  .dice-roll-btn {
    padding: 12px 36px;
    font-size: 15px;
  }
  .mode-btn {
    padding: 6px 18px;
    font-size: 13px;
  }
}
