/* Lucky Wheel page. Only what this page needs — the topbar, panel, buttons and
   colour tokens all come from theme.css. */

/* The panel head's own border-bottom sits directly above this, so the layout
   needs breathing room under it — without the gap the wheel butts against the
   rule. */
.wheel-layout {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: flex-start;
}

.wheel-stage {
  position: relative;
  flex: 0 0 auto;
  width: min(520px, 90vw);
  aspect-ratio: 1;
  margin-inline: auto;
}

.wheel-stage canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-alt);
  /* The rim ring is what stops the slices bleeding into the page background,
     which on a dark olive theme they otherwise nearly match. */
  box-shadow: 0 0 0 6px var(--panel-border), 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* Pointer: a triangle above the wheel, pointing down at twelve o'clock — the
   same angle wheel.js measures every slice from. Move one and the other is
   wrong, so they are commented on both sides. */
.wheel-pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 30px solid var(--amber);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6));
  z-index: 2;
}

.wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--panel);
  border: 4px solid var(--panel-border);
  z-index: 1;
}

/* Shown while a new round is being fetched. The wheel is dimmed rather than
   hidden so the page does not jump, and the spin button is disabled at the same
   time — the slices are about to change, and letting somebody spend 500 points
   on a wheel that is mid-swap is the failure this state exists to prevent. */
.wheel-stage .wheel-loading {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 50%;
  background: rgba(20, 21, 15, 0.72);
  color: var(--text-dim);
  font-size: 14px;
  z-index: 3;
}

.wheel-stage.is-loading .wheel-loading {
  display: flex;
}

.wheel-stage.is-loading canvas {
  filter: grayscale(0.6) brightness(0.7);
}

.wheel-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--panel-border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: wheel-spinner-turn 0.8s linear infinite;
}

@keyframes wheel-spinner-turn {
  to {
    transform: rotate(360deg);
  }
}

/* A viewer who has asked for less motion still needs to know something is
   happening — keep the overlay and the text, drop the rotation. */
@media (prefers-reduced-motion: reduce) {
  .wheel-spinner {
    animation: none;
  }
}

.wheel-side {
  flex: 1 1 280px;
  min-width: 260px;
}


/* The button groups. Same trap as the pager and the result dialog: an author
   `display` rule beats the UA's `[hidden] { display: none }`, and the ticket
   group is toggled by script. */
.wheel-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

/* Space between the free-spin group and the points one, so the two are read as
   two offers rather than one list of five buttons. */
#ticket-buttons {
  margin-bottom: 14px;
}

/* The per-spin price under a multi-spin button. It is the only number on the
   page that is computed rather than sent, and it is what makes a pack's
   discount visible — 4,200 for ten means nothing next to 450 for one until it
   is shown as 420 each. */
.wheel-spin-per {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.75;
}

/* The multi-spin result list. Scrolls rather than growing: a x50 press must not
   push the dialog's buttons off the bottom of a phone screen. */
.wheel-result-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
  text-align: left;
}

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

.wheel-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.wheel-result-row.is-jackpot {
  background: rgba(138, 107, 31, 0.22);
}

.wheel-result-row-name {
  flex: 1;
  font-size: 14px;
}

.wheel-result-row-chance {
  font-size: 12px;
  color: var(--text-dim);
}


/* The ticket button sits above the points one and is visually the cheaper
   offer, because it is — spending a free spin should not look like the
   afterthought next to spending 450 points. */
.wheel-ticket-btn {
  background: var(--amber);
  border-color: var(--amber);
  color: #201d12;
  margin-bottom: 8px;
}

.wheel-spin-btn {
  width: 100%;
  font-size: 18px;
  padding: 14px 20px;
}

.wheel-note {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 14px;
}

.wheel-side-heading {
  margin: 24px 0 8px;
  font-size: 15px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wheel-legend,
.wheel-history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wheel-legend-item,
.wheel-history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 14px;
}

/* Thumbnail in the legend row. The source icons are 50×50 (see CLAUDE.md), so
   this stays under that and uses `contain` rather than `cover` — stretching a
   50px source to fill the box is what caused the reported "ภาพแตก" elsewhere. */
.wheel-legend-thumb {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
}

/* The package-icon fallback stands in for an item with no image, or one whose
   image fails to load. Sized and centred to occupy exactly the same box, so a
   list mixing the two does not jitter. */
.wheel-legend-thumb-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* The icon is .ti, i.e. 1em square, so this is what sizes it. */
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
}

.wheel-legend-item {
  align-items: center;
}

.wheel-legend-name {
  /* Takes the leftover width, so the thumbnail and the odds keep their size and
     the name is the only thing that gives way. */
  flex: 1 1 auto;

  /* Item names run long and the odds beside them are the point of the row, so
     the name is what gives way. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-legend-chance,
.wheel-history-meta {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.wheel-legend-item.is-jackpot,
.wheel-history-row.is-jackpot {
  color: var(--amber);
  font-weight: 600;
}

.wheel-history-empty {
  padding: 7px 10px;
  color: var(--text-dim);
  font-size: 14px;
}

/* History rows carry the prize's thumbnail, so they need the same three-part
   layout as the legend rather than the plain two-column one. */
.wheel-history-row {
  align-items: center;
}

.wheel-history-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.wheel-result-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.wheel-result {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.wheel-result-kicker {
  margin: 0 0 4px;
  color: var(--amber);
  font-size: 14px;
  letter-spacing: 0.05em;
}

.wheel-result h3 {
  margin: 0 0 12px;
  font-size: 22px;
}

.wheel-result-image {
  /* Same cap as the item cards: the source icons are 50×50 and stretching them
     is what produced the reported "ภาพแตก". See CLAUDE.md. */
  max-width: 96px;
  max-height: 96px;
  object-fit: contain;
  margin-bottom: 12px;
}

.wheel-result-sub {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.wheel-result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 720px) {
  .wheel-layout {
    gap: 20px;
  }
  .wheel-side {
    width: 100%;
  }
}
