:root {
  --bg-0: #0c0508;
  --bg-1: #1a0810;
  --wine: #6b1424;
  --gold: #e3c56a;
  --gold-bright: #f8e7a8;
  --gold-deep: #b8892a;
  --cream: #f6edd6;
  --ink: #2a140c;
  --muted: rgba(246, 237, 214, 0.64);
  --line: rgba(227, 197, 106, 0.28);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  --font: "Noto Sans TC", "PingFang HK", "Noto Sans CJK HK", "Microsoft JhengHei", sans-serif;
  --serif: "Noto Serif TC", "Songti TC", "Noto Serif CJK TC", serif;
  --radius: 22px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--cream);
  font-family: var(--font);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

.ambiance {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 600px at 50% -10%, rgba(140, 28, 48, 0.45), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(80, 40, 10, 0.28), transparent 50%),
    linear-gradient(180deg, #16070c 0%, #0c0508 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.45;
}

.orb-a {
  width: 340px;
  height: 340px;
  left: -80px;
  top: 20%;
  background: #8a1c32;
}

.orb-b {
  width: 280px;
  height: 280px;
  right: -60px;
  top: 8%;
  background: #c9a227;
  opacity: 0.22;
}

.orb-c {
  width: 420px;
  height: 420px;
  right: 10%;
  bottom: -140px;
  background: #3d1020;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.85'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(36px, 6vw, 64px);
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff6d4 0%, #e3c56a 52%, #b8892a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.lede {
  max-width: 38rem;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.lede strong {
  color: var(--gold-bright);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 28px;
  align-items: start;
}

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

.wheel-frame {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1;
  filter: drop-shadow(0 28px 50px rgba(0, 0, 0, 0.55));
}

.wheel-disc {
  position: absolute;
  inset: 6.5%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #3a2410 0 68%, #c9a227 69%, #f3e5ab 72%, #8a6a22 74%, #1a0c08 75%);
  box-shadow:
    inset 0 0 0 10px #2a160c,
    0 0 0 8px #c9a227,
    0 0 0 11px #7a5a18,
    0 0 40px rgba(227, 197, 106, 0.28);
}

.wheel {
  width: 100%;
  height: 100%;
  display: block;
  transform-origin: 50% 50%;
  will-change: transform;
}

.wheel-shine {
  position: absolute;
  inset: 3.5%;
  border-radius: 50%;
  pointer-events: none;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.05) 32%, transparent 48%);
  mix-blend-mode: screen;
}

.hub {
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 30%, #fff3c2, #e3c56a 42%, #8a6418 78%, #3a2408 100%);
  box-shadow:
    0 0 0 6px #2a160c,
    0 0 0 8px #f0d78a,
    inset 0 4px 8px rgba(255, 255, 255, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.hub-mark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(22px, 5.4vw, 42px);
  color: #6b1424;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  line-height: 1;
}

.wheel-frame.is-done .hub-mark {
  font-size: clamp(14px, 3.2vw, 22px);
  letter-spacing: 0.08em;
}

.pointer {
  position: absolute;
  top: 0;
  left: 50%;
  width: 42px;
  height: 68px;
  margin-left: -21px;
  z-index: 5;
  transform-origin: 50% 78%;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
}

.pointer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 58px solid #f3e5ab;
  transform: translateX(-50%);
}

.pointer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 42px solid #b8892a;
  transform: translateX(-50%);
}

.pointer-jewel {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e3c56a 45%, #8a1c32 80%);
  box-shadow: 0 0 0 3px #2a160c, 0 0 12px rgba(227, 197, 106, 0.7);
  z-index: 1;
}

.pointer.tick {
  animation: pointer-tick 90ms ease-out;
}

@keyframes pointer-tick {
  0% { transform: rotate(-16deg); }
  100% { transform: rotate(0deg); }
}

.status {
  margin: 22px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.status strong {
  color: var(--gold-bright);
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  width: min(100%, 520px);
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease, background 0.18s ease;
  touch-action: manipulation;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  flex: 1 1 220px;
  color: #3a1a08;
  background: linear-gradient(180deg, #fff1b0 0%, #e3c56a 48%, #b8892a 100%);
  box-shadow: 0 10px 24px rgba(184, 137, 42, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-primary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(0.25);
}

.btn-ghost {
  flex: 0 0 auto;
  color: var(--gold-bright);
  background: transparent;
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: rgba(227, 197, 106, 0.08);
}

.board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: linear-gradient(180deg, rgba(48, 16, 24, 0.72), rgba(20, 8, 12, 0.78));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--gold);
}

.count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--cream);
}

.count-gold {
  color: var(--gold-bright);
}

.pills {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  min-height: 40px;
}

.pills li {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(227, 197, 106, 0.35);
  background: rgba(255, 236, 180, 0.06);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pills .is-gone {
  opacity: 0.28;
  text-decoration: line-through;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: rise 0.45s ease;
}

.results .empty {
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px 0 2px;
  animation: none;
}

.results .ord {
  width: 52px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.results .num {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 2, 4, 0.72);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  width: min(100%, 380px);
  text-align: center;
  padding: 36px 28px 28px;
  border-radius: 28px;
  border: 1px solid rgba(227, 197, 106, 0.45);
  background:
    radial-gradient(600px 200px at 50% 0%, rgba(227, 197, 106, 0.18), transparent 55%),
    linear-gradient(180deg, #3a141c, #16080c);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to { opacity: 1; transform: none; }
}

.modal-kicker {
  margin: 0;
  letter-spacing: 0.28em;
  color: var(--gold);
  font-weight: 600;
}

.modal-number {
  margin: 10px 0 4px;
  font-family: var(--serif);
  font-size: clamp(84px, 18vw, 128px);
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(180deg, #fff6d4, #e3c56a 60%, #b8892a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal-sub {
  margin: 0 0 24px;
  color: var(--muted);
}

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

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .app {
    padding-top: 18px;
  }

  .board {
    width: min(100%, 520px);
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pointer.tick,
  .modal-card,
  .results li {
    animation: none;
  }
}
