:root {
  color-scheme: dark;
  --bg: #0b0807;
  --surface: rgba(23, 15, 12, 0.92);
  --surface-strong: #1c120e;
  --surface-soft: rgba(255, 255, 255, 0.055);
  --border: rgba(247, 206, 105, 0.2);
  --gold: #f2c14e;
  --gold-light: #ffe59b;
  --red: #b5231c;
  --red-dark: #70120e;
  --text: #fffaf0;
  --muted: #c7bdb3;
  --danger: #ff8a80;
  --success: #9be7b0;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 17% 20%, rgba(164, 28, 20, 0.28), transparent 34rem),
    radial-gradient(circle at 84% 76%, rgba(217, 153, 41, 0.14), transparent 34rem),
    linear-gradient(145deg, #090605 0%, #160d0a 52%, #080605 100%);
  overflow-x: hidden;
}
button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1380px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  align-items: center;
  gap: clamp(28px, 5vw, 82px);
}

.wheel-panel { min-width: 0; text-align: center; }
.wheel-stage {
  position: relative;
  width: min(100%, 760px);
  aspect-ratio: 1;
  margin: 0 auto;
  filter: drop-shadow(0 30px 45px rgba(0,0,0,.52));
  isolation: isolate;
}
.wheel-stage::before {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 217, 111, .2), rgba(125, 25, 15, .08) 48%, transparent 70%);
  filter: blur(18px);
  z-index: -1;
}
.wheel-stage picture { position: absolute; inset: 0; }
.wheel-stage img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.wheel-image {
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  will-change: transform;
}
.wheel-image.is-spinning {
  transition-property: transform;
  transition-duration: var(--spin-duration, 6500ms);
  transition-timing-function: cubic-bezier(.12,.58,.1,1);
}
.wheel-frame { position: relative; z-index: 2; pointer-events: none; }
.wheel-caption { max-width: 560px; margin: -26px auto 0; color: var(--muted); font-size: .92rem; line-height: 1.6; }

.redeem-panel {
  width: 100%;
  padding: clamp(26px, 4vw, 46px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(36, 23, 18, .95), rgba(15, 10, 8, .95));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.brand-header { margin-bottom: 28px; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .22em; }
.brand-header h1 { margin: 0; font-size: clamp(2.25rem, 5vw, 4.25rem); line-height: .95; letter-spacing: -.055em; }
.brand-header p { margin: 16px 0 0; color: var(--muted); line-height: 1.65; }

.redeem-form { display: grid; gap: 11px; }
.redeem-form label { margin-top: 5px; color: var(--gold-light); font-size: .8rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.redeem-form input, .search-field input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  outline: none;
  background: rgba(0,0,0,.26);
  color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.redeem-form input { height: 54px; padding: 0 16px; }
.redeem-form input::placeholder, .search-field input::placeholder { color: #817770; }
.redeem-form input:focus, .search-field input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(242,193,78,.12); background: rgba(0,0,0,.38); }
.redeem-form input[aria-invalid="true"] { border-color: var(--danger); }

.form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.button {
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 850;
  letter-spacing: .035em;
  transition: filter .18s ease, opacity .18s ease, transform .18s ease;
}
.button:hover:not(:disabled) { filter: brightness(1.08); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(255,229,155,.72); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: #1c1104; background: linear-gradient(180deg, #ffe999, #d69620); box-shadow: 0 10px 30px rgba(214,150,32,.2); }
.button-secondary { border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.07); }
.button-compact { min-height: 38px; padding: 0 15px; border: 1px solid rgba(255,255,255,.13); background: rgba(255,255,255,.06); font-size: .8rem; }

.status-notice { margin: -8px 0 20px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,138,128,.28); background: rgba(181,35,28,.12); color: #ffd1cc; font-size: .86rem; line-height: 1.5; }
.archive-note { margin: 22px 0 0; color: #847a73; font-size: .74rem; line-height: 1.5; }

.modal[hidden], .toast[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,2,2,.82); backdrop-filter: blur(8px); }
.modal-dialog { position: relative; width: min(920px, 100%); max-height: min(800px, calc(100vh - 40px)); display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; border: 1px solid var(--border); border-radius: 24px; background: #150e0b; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.modal-header h2 { margin: 0; font-size: 1.55rem; }
.icon-button { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; background: rgba(255,255,255,.06); cursor: pointer; font-size: 1.55rem; line-height: 1; }
.history-meta { padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .84rem; }
.search-field { width: min(320px, 55%); }
.search-field input { height: 40px; padding: 0 13px; }
.table-scroll { min-height: 0; overflow: auto; border-block: 1px solid rgba(255,255,255,.07); }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { padding: 13px 24px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.055); }
th { position: sticky; top: 0; z-index: 1; background: #201510; color: var(--gold-light); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
td:first-child, th:first-child { width: 82px; text-align: center; }
td:last-child { font-weight: 700; color: #f5d782; }
.pagination { padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .82rem; }
.empty-state { margin: 0; padding: 50px 20px; text-align: center; color: var(--muted); }

.toast { position: fixed; z-index: 80; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(520px, calc(100% - 32px)); padding: 14px 18px; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; background: #231711; box-shadow: var(--shadow); color: var(--text); text-align: center; line-height: 1.45; }
.toast[data-type="error"] { border-color: rgba(255,138,128,.35); color: #ffd5d1; }
.toast[data-type="success"] { border-color: rgba(155,231,176,.35); color: #d7ffe1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
noscript { display: block; padding: 16px; text-align: center; color: var(--danger); }

@media (max-width: 980px) {
  .app-shell { width: min(760px, calc(100% - 28px)); grid-template-columns: 1fr; gap: 8px; padding: 18px 0 34px; }
  .wheel-stage { width: min(100%, 650px); }
  .wheel-caption { margin-top: -34px; padding-inline: 22px; }
  .redeem-panel { margin-top: 10px; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 520px); }
  .wheel-stage { width: calc(100% + 30px); margin-left: -15px; }
  .wheel-caption { margin-top: -28px; font-size: .78rem; }
  .redeem-panel { padding: 24px 18px; border-radius: 22px; }
  .form-actions { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: end; }
  .modal-dialog { max-height: 92vh; border-radius: 24px 24px 0 0; }
  .history-meta { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  th, td { padding: 12px 13px; }
  td:first-child, th:first-child { width: 58px; }
  .pagination { padding-inline: 14px; }
  .button-compact { padding-inline: 12px; font-size: .74rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
.button-contact { width: 100%; margin-top: 12px; border: 1px solid rgba(155,231,176,.2); background: rgba(155,231,176,.07); color: #c7f8d4; text-decoration: none; }
.wheel-stage > .wheel-image,
.wheel-stage > .wheel-frame {
  position: absolute;
  inset: 0;
}
.wheel-stage > .wheel-image { z-index: 1; }
.wheel-stage > .wheel-frame { z-index: 2; }
