/* ============================================================
   กงล้อธรรมจักร — สไตล์ธงธรรมจักรไทย (แดงบนพื้นครีม)
   ============================================================ */

.wheel-block {
  --wheel-red: #C8102E;
  --wheel-red-deep: #8E0E1F;
  --wheel-cream: #FBF4E7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.wheel-stage {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding-top: 20px;
}

.wheel-pointer {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  filter: drop-shadow(0 3px 5px rgba(142, 14, 31, 0.28));
}

.wheel-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wheel-btn:focus-visible {
  outline: 2px solid var(--wheel-red-deep);
  outline-offset: 6px;
  border-radius: 50%;
}

.wheel-btn svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(142, 14, 31, 0.10));
}

.wheel-block.is-spinning .wheel-btn {
  cursor: default;
}

/* โรเตอร์ (ส่วนที่หมุน) */
.wheel-rotor {
  transform-box: view-box;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* 8 ช่องของมรรค */
.wheel-seg {
  fill: var(--wheel-cream);
  transition: fill 0.3s ease;
}

.wheel-seg.is-win {
  fill: #F7DCD3;
}

/* ลายเส้นประดับ — สีแดงตามธงธรรมจักร */
.art-ring {
  fill: none;
  stroke: var(--wheel-red);
  stroke-width: 2.2;
}

.art-ring-med {
  fill: none;
  stroke: var(--wheel-red);
  stroke-width: 2.6;
}

.art-ring-thin {
  fill: none;
  stroke: var(--wheel-red);
  stroke-width: 1.4;
}

.art-line {
  fill: none;
  stroke: var(--wheel-red);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.art-line-thin {
  fill: none;
  stroke: var(--wheel-red);
  stroke-width: 1.5;
}

.art-dot {
  fill: var(--wheel-red);
}

.art-dot-sm {
  fill: var(--wheel-red);
}

.art-diamond {
  fill: var(--wheel-red);
}

.seg-name {
  font-family: 'Pridi', serif;
  font-size: 15.5px;
  font-weight: 500;
  fill: #AE1026;
}

/* ปุ่มควบคุมกงล้อ + ปุ่มเปิด/ปิดเสียง */
.wheel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.wheel-controls .btn-icon {
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: var(--ink-muted);
}

.wheel-controls .btn-icon:hover {
  color: var(--accent-dark);
}

.wheel-controls .btn-icon .icon-sound-on {
  display: block;
}

.wheel-controls .btn-icon .icon-sound-off {
  display: none;
}

.wheel-controls .btn-icon.is-muted .icon-sound-on {
  display: none;
}

.wheel-controls .btn-icon.is-muted .icon-sound-off {
  display: block;
}

.wheel-status {
  margin: 0;
  min-height: 1.6em;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

.wheel-noscript {
  max-width: 40ch;
  margin: 0 auto;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* ---------- Modal ผลลัพธ์ ---------- */
body.modal-open {
  overflow: hidden;
}

.wheel-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.wheel-modal[hidden] {
  display: none;
}

.wheel-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 33, 24, 0.55);
}

.wheel-modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: min(86vh, 720px);
  overflow: auto;
  padding: clamp(26px, 4vw, 38px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: 0 24px 60px rgba(42, 33, 24, 0.25);
  animation: wheel-modal-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes wheel-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--accent-dark);
  border-color: var(--accent);
}

.modal-eyebrow {
  margin: 0 0 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold-dark);
}

.modal-title {
  margin: 0 0 4px;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  line-height: 1.4;
}

.modal-pali {
  margin: 0 0 14px;
  color: var(--ink-muted);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.modal-meaning {
  margin: 0 0 16px;
}

.modal-desc {
  font-size: 1rem;
  line-height: 1.85;
}

.modal-desc p {
  margin: 0 0 0.9em;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

@media (max-width: 560px) {
  .wheel-stage {
    max-width: 400px;
  }

  .seg-name {
    font-size: 14px;
  }

  .wheel-controls {
    width: 100%;
  }

  .wheel-controls .btn-primary {
    flex: 1;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-modal-card {
    animation: none;
  }

  .wheel-rotor {
    transition: none !important;
  }

  .wheel-seg {
    transition: none;
  }
}

/* ---------- โหมดกลางคืน ---------- */
html[data-theme="dark"] .wheel-block {
  --wheel-cream: #2A231C;
}

html[data-theme="dark"] .seg-name {
  fill: #E89B93;
}

html[data-theme="dark"] .wheel-seg.is-win {
  fill: #4A2A26;
}
