/* The bonus wheel page: the iron stand with its drum and hammer, the win card, the prize list and the rules.

   The machine is one canvas of 760 x 675 px, the same as the Blender art (art/wheel/build_wheel_art.py, 1 unit =
   100 px): drum centre at (380, 410), radius 170, tiles 420 px wide; the hammer's hinge at (660, 195).
   Change these together with the art. */

.wheel-page {
  max-width: calc(1180px + 2 * var(--gutter));
}

.wheel-head {
  text-align: center;
}

.wheel-head h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

.wheel-lead {
  max-width: 560px;
  margin: 8px auto 0;
  color: var(--ash);
  opacity: 0.8;
  font-size: var(--text-sm);
  line-height: 1.55;
  text-wrap: balance;
}

/* ---------- the machine ---------- */

.wheel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-machine {
  --drum-x: 380px;
  --drum-y: 410px;
  --drum-r: 170px;
  --drum-w: 420px;
  position: relative;
  width: 760px;
  height: 675px;
  margin-top: -12px;
}

.wheel-stand,
.wheel-hammer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.wheel-stand {
  z-index: 2;
  filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.6));
}

.wheel-hammer {
  z-index: 4;
  transform-origin: 86.842% 28.889%;
  filter: drop-shadow(-6px 14px 14px rgba(0, 0, 0, 0.55));
  will-change: transform;
}

/* The drum: a 3D ring of tiles seen through a window as tall as the drum. */
.wheel-drum-view {
  position: absolute;
  z-index: 1;
  left: calc(var(--drum-x) - var(--drum-w) / 2);
  top: calc(var(--drum-y) - var(--drum-r));
  width: var(--drum-w);
  height: calc(var(--drum-r) * 2);
  overflow: hidden;
  perspective: 1100px;
  background: #0c0a09;
}

.wheel-drum {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.wheel-face {
  position: absolute;
  top: calc(var(--face-height) / -2);
  left: 0;
  /* The picture and the text sit together in the middle of the tile, on both axes. */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  height: var(--face-height);
  padding: 0 34px;
  backface-visibility: hidden;
  /* Forged plates: dark iron, a lighter top edge, a rivet in each corner, the prize's colour on both ends. */
  background:
    radial-gradient(circle at 14px 12px, #4a4341 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 14px calc(100% - 12px), #4a4341 0 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 14px) 12px, #4a4341 0 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 14px) calc(100% - 12px), #4a4341 0 2.5px, transparent 3.5px),
    linear-gradient(90deg, var(--accent) 0 5px, transparent 5px calc(100% - 5px), var(--accent) calc(100% - 5px)),
    linear-gradient(180deg, #2c2725, #1c1817 55%, #141110);
  border-top: 1px solid rgba(255, 236, 222, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.7);
}

/* Darkness by how far the tile has turned from the front (--dim, set by wheel-drum.js). */
.wheel-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #070505;
  opacity: var(--dim, 0);
  pointer-events: none;
}

.wheel-face .prize-picture {
  width: 76px;
  height: 58px;
}

.wheel-face-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* Whole-pixel line boxes, so the two lines sit at the same height on every tile. */
.wheel-face-title {
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-face-sub {
  overflow: hidden;
  color: var(--ash);
  font-size: var(--text-sm);
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-face.is-won {
  background:
    linear-gradient(90deg, var(--accent) 0 5px, transparent 5px calc(100% - 5px), var(--accent) calc(100% - 5px)),
    radial-gradient(ellipse 70% 120% at 50% 50%, rgba(255, 107, 26, 0.28), transparent 70%),
    linear-gradient(180deg, #3a2a20, #24180f 55%, #170f0b);
  box-shadow: inset 0 0 0 1px var(--line-ember), inset 0 0 24px rgba(255, 107, 26, 0.35);
}

/* Light and shadow on the round drum: dark towards the top and bottom, a soft band of light above the middle,
   and an ember-edged window around the tile in front. */
.wheel-drum-shade {
  position: absolute;
  z-index: 1;
  left: calc(var(--drum-x) - var(--drum-w) / 2);
  top: calc(var(--drum-y) - var(--drum-r));
  width: var(--drum-w);
  height: calc(var(--drum-r) * 2);
  background:
    linear-gradient(180deg, rgba(5, 4, 4, 1) 0%, rgba(5, 4, 4, 0.7) 12%, transparent 34%, transparent 66%,
      rgba(5, 4, 4, 0.75) 88%, rgba(5, 4, 4, 1) 100%),
    linear-gradient(90deg, rgba(5, 4, 4, 0.55), transparent 9%, transparent 91%, rgba(5, 4, 4, 0.55)),
    linear-gradient(180deg, transparent 28%, rgba(255, 220, 190, 0.07) 38%, transparent 46%);
  pointer-events: none;
}

/* The front tile's ember light falling on the rims, the bearings and the stand around it. */
.wheel-glow {
  position: absolute;
  z-index: 3;
  inset: 0;
  background:
    radial-gradient(ellipse 120px 70px at calc(var(--drum-x) - var(--drum-w) / 2) var(--drum-y), rgba(255, 107, 26, 0.32), transparent 70%),
    radial-gradient(ellipse 120px 70px at calc(var(--drum-x) + var(--drum-w) / 2) var(--drum-y), rgba(255, 107, 26, 0.32), transparent 70%),
    radial-gradient(ellipse 260px 40px at var(--drum-x) calc(var(--drum-y) + var(--drum-r) + 20px), rgba(255, 107, 26, 0.12), transparent 70%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.wheel-machine.is-won .wheel-glow {
  animation: wheel-glow-flare 1.2s ease-out;
}

@keyframes wheel-glow-flare {
  0% { filter: brightness(2.4); }
  100% { filter: brightness(1); }
}

.wheel-drum-shade::before,
.wheel-drum-shade::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ember) 12%, var(--ember-light) 50%, var(--ember) 88%, transparent);
  box-shadow: 0 0 12px rgba(255, 107, 26, 0.7);
  opacity: 0.85;
}

/* The two lines frame the front tile (96 px high, wheel-drum.js) at the same distance above and below. */
.wheel-drum-shade::before {
  top: calc(50% - 50px);
}

.wheel-drum-shade::after {
  top: calc(50% + 48px);
}

/* Ember arrows on both sides point at the tile in front. */
.wheel-arrow {
  position: absolute;
  z-index: 3;
  top: calc(var(--drum-y) - 14px);
  width: 0;
  height: 0;
  border-block: 14px solid transparent;
  filter: drop-shadow(0 0 8px rgba(255, 107, 26, 0.8));
}

.wheel-arrow-left {
  left: calc(var(--drum-x) - var(--drum-w) / 2 - 36px);
  border-left: 22px solid var(--ember);
}

.wheel-arrow-right {
  left: calc(var(--drum-x) + var(--drum-w) / 2 + 14px);
  border-right: 22px solid var(--ember);
}

/* The hammer's hit: a white-hot flash on the drum's top and sparks flying from it. */
.wheel-impact {
  position: absolute;
  z-index: 5;
  left: 435px;
  top: calc(var(--drum-y) - var(--drum-r));
  width: 0;
  height: 0;
  pointer-events: none;
}

.wheel-impact::before {
  content: "";
  position: absolute;
  left: -90px;
  top: -60px;
  width: 180px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 245, 225, 0.95), rgba(255, 179, 71, 0.55) 30%, rgba(255, 107, 26, 0) 70%);
  opacity: 0;
}

.wheel-impact.is-hit::before {
  animation: wheel-flash 420ms ease-out;
}

@keyframes wheel-flash {
  0% { opacity: 1; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1.25); }
}

.wheel-spark {
  position: absolute;
  left: -2px;
  top: -2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ember-light);
  box-shadow: 0 0 6px 1px var(--ember);
}

/* ---------- controls and the win card ---------- */

.wheel-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  /* The button sits on a riveted iron plate fixed to the stand's base beam (Gemini's review: not a loose web button). */
  position: relative;
  z-index: 6;
  margin-top: -64px;
}

.wheel-plate {
  display: flex;
  padding: 10px;
  border: 1px solid #4a4341;
  border-radius: 14px;
  background:
    radial-gradient(circle at 9px 9px, #5a524f 0 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 9px) 9px, #5a524f 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 9px calc(100% - 9px), #5a524f 0 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), #5a524f 0 2.5px, transparent 3.5px),
    linear-gradient(180deg, #2e2927, #1a1615 60%, #120f0e);
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 236, 222, 0.12), 0 0 26px rgba(255, 107, 26, 0.18);
}

.wheel-action {
  min-width: 280px;
}

.wheel-status {
  margin: 0;
  color: var(--ash);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.wheel-win {
  --accent: var(--ember);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  width: min(600px, 100%);
  margin-top: 20px;
  border-color: var(--line-ember);
  box-shadow: var(--plate-edge), inset 4px 0 0 var(--accent);
}

.wheel-win.is-new {
  animation: wheel-win-in 380ms var(--ease-out, ease-out);
}

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

.wheel-win .prize-picture {
  width: 108px;
  height: 84px;
}

.wheel-win-kicker {
  margin: 0;
  color: var(--ember-light);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wheel-win-title {
  margin: 4px 0 6px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.wheel-win-terms {
  margin: 0;
  color: var(--ash);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.wheel-win-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 10px 0 0;
  font-size: var(--text-sm);
}

.wheel-win-code code {
  padding: 5px 10px;
  border: 1px dashed var(--ember);
  border-radius: var(--radius-inner);
  color: var(--white-hot);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: copy;
}

.wheel-win-code a {
  color: var(--ember-light);
  text-underline-offset: 3px;
}

/* ---------- prize pictures (also used by the profile's Bonuses tab) ---------- */

.prize-picture {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 56px;
  height: 44px;
}

.prize-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.prize-image-skin {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

.prize-image-anvil {
  max-width: 70%;
  max-height: 70%;
}

/* A ticket with notches on both sides for the deposit codes. */
.prize-ticket {
  display: grid;
  place-items: center;
  width: 100%;
  height: 72%;
  border-radius: 6px;
  background: var(--ember-fill);
  color: var(--ember-ink);
  font-size: 1.05em;
  font-weight: 900;
  letter-spacing: -0.01em;
  -webkit-mask: radial-gradient(circle at 0 50%, transparent 6px, #000 6.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 6px, #000 6.5px) right / 51% 100% no-repeat;
  mask: radial-gradient(circle at 0 50%, transparent 6px, #000 6.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 6px, #000 6.5px) right / 51% 100% no-repeat;
  box-shadow: 0 0 18px rgba(255, 107, 26, 0.35);
}

.wheel-face .prize-ticket,
.wheel-win .prize-ticket {
  font-size: 1.35rem;
}

.prize-badge {
  position: absolute;
  right: -4px;
  bottom: -2px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--gold);
  color: var(--ember-ink);
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
}

/* ---------- the panels under the machine ---------- */

.wheel-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--gutter);
  align-items: start;
  margin-top: 48px;
}

.wheel-panel h2 {
  margin: 0;
  font-size: 1.25rem;
}

.wheel-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.wheel-refresh {
  margin: 0;
  color: var(--ash);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.wheel-prizes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.wheel-prize {
  --accent: var(--ember);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px 8px 10px;
  border: var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-inner);
  background: var(--surface-control);
}

.wheel-prize-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wheel-prize-title {
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-prize-sub {
  overflow: hidden;
  color: var(--ash);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-prize-chance {
  color: var(--gold);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.wheel-steps {
  display: grid;
  gap: 14px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: wheel-step;
}

.wheel-steps li {
  position: relative;
  padding-left: 44px;
  color: var(--ash);
  line-height: 1.5;
  counter-increment: wheel-step;
}

.wheel-steps li::before {
  content: counter(wheel-step);
  position: absolute;
  left: 0;
  top: -2px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-ember);
  border-radius: 50%;
  color: var(--ember-light);
  font-weight: 800;
}

.wheel-steps strong {
  color: var(--white-hot);
}

.wheel-small {
  margin: 16px 0 0;
  color: var(--ash);
  font-size: var(--text-xs);
  line-height: 1.55;
}

/* Desktop first (owner): narrower windows scale the machine down and stack the panels. */
@media (max-width: 860px) {
  .wheel-machine {
    zoom: 0.8;
  }

  .wheel-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .wheel-machine {
    zoom: 0.48;
  }

  .wheel-prizes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- the profile's Bonuses tab ---------- */

.bonus-card {
  --accent: var(--ember);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  margin-top: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line-ember);
  border-radius: var(--radius);
  background: var(--surface-control);
  box-shadow: inset 4px 0 0 var(--accent);
}

.bonus-card .prize-picture {
  width: 104px;
  height: 80px;
}

.bonus-card .prize-ticket {
  font-size: 1.35rem;
}

.bonus-card-kicker {
  margin: 0;
  color: var(--ember-light);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bonus-card-title {
  margin: 4px 0 6px;
  font-size: 1.2rem;
}

.bonus-card-terms {
  margin: 0;
  color: var(--ash);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.bonus-card-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.bonus-card-code code {
  padding: 7px 12px;
  border: 1px dashed var(--ember);
  border-radius: var(--radius-inner);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.bonuses-history-title {
  margin: 24px 0 10px;
  color: var(--ash);
  font-size: var(--text-sm);
  font-weight: 700;
}

.bonus-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bonus-row {
  --accent: var(--ember);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 10px;
  border: var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-inner);
  background: var(--surface-control);
  opacity: 0.6;
}

.bonus-row-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bonus-row-title {
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bonus-row-date,
.bonus-row-state {
  color: var(--ash);
  font-size: var(--text-xs);
}

/* The panels under the machine: forged plates like the drum's tiles, a rivet in each corner (Gemini's review). */
.wheel-panel {
  background:
    radial-gradient(circle at 12px 12px, #4a4341 0 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 12px) 12px, #4a4341 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 12px calc(100% - 12px), #4a4341 0 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 12px) calc(100% - 12px), #4a4341 0 2.5px, transparent 3.5px),
    linear-gradient(180deg, rgba(255, 236, 222, 0.025), transparent 40%),
    var(--plate);
  border-color: rgba(255, 236, 222, 0.1);
  padding: 24px 28px;
}

/* The small tickets in the prize list and the Bonuses history: "+15%" must fit between the notches. */
.wheel-prize .prize-ticket,
.bonus-row .prize-ticket {
  font-size: 0.78rem;
}

/* Reduced motion: no brightness flare on a win either. */
@media (prefers-reduced-motion: reduce) {
  .wheel-machine.is-won .wheel-glow {
    animation: none;
  }
}

/* The check of a spin in the bonus history (profile-bonuses.js): at the row's end, never dimmed with the row */
.bonus-row-check {
  margin-left: 8px;
  flex: none;
  opacity: 1;
}
