:root {
  --pink: #ef4f91;
  --pink-dark: #b93269;
  --pink-soft: #ffd7e4;
  --cream: #fffaf7;
  --ink: #1c171a;
  --muted: #7e6871;
  --browser-bottom-clearance: 0px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-height: 100%;
  overflow-x: clip;
  overflow-y: auto;
  background: #f8d8e2;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
  overflow-y: visible;
  color: var(--ink);
  background: #f8d8e2;
  font-family: Arial, Helvetica, sans-serif;
  touch-action: pan-y;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  padding: 28px clamp(18px, 4vw, 64px) 22px;
  background:
    radial-gradient(circle at 8% 9%, rgba(255,255,255,.95) 0 2px, transparent 3px),
    radial-gradient(circle at 91% 17%, rgba(239,79,145,.28) 0 3px, transparent 4px),
    linear-gradient(135deg, #fffaf8 0%, #fff4f7 48%, #f9dce6 100%);
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.app-shell::before {
  width: 170px;
  height: 170px;
  top: 95px;
  left: -76px;
  border: 1px solid rgba(239,79,145,.22);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(239,79,145,.05), 0 0 0 52px rgba(239,79,145,.035);
}

.app-shell::after {
  width: 110px;
  height: 110px;
  right: 4%;
  bottom: 7%;
  background-image: radial-gradient(#e8518d 1.3px, transparent 1.3px);
  background-size: 11px 11px;
  opacity: .24;
  transform: rotate(12deg);
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.ambient-one {
  width: 280px;
  height: 280px;
  background: rgba(255, 157, 188, .17);
  top: -140px;
  right: 18%;
}

.ambient-two {
  width: 240px;
  height: 240px;
  background: rgba(255, 255, 255, .7);
  bottom: -120px;
  left: 9%;
}

.brand-header,
.draw-card,
footer { position: relative; z-index: 2; }

.brand-header {
  width: min(1120px, 100%);
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  min-height: 50px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-right: 11px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 25px;
  font-style: italic;
  font-weight: 700;
}

.brand-name {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .08em;
}

.brand-subtitle {
  margin: 5px 0 0;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .27em;
}

.history-button {
  margin-left: auto;
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(28, 23, 26, .13);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, .72);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(81, 31, 50, .07);
}

.history-button:hover { background: #fff; transform: translateY(-1px); }
.history-button span { font-weight: 700; }
.history-button b {
  display: grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 6px;
  color: #fff;
  background: var(--pink);
  border-radius: 99px;
  font-size: 11px;
}

.draw-card {
  width: min(1120px, 100%);
  min-height: min(690px, calc(100svh - 154px));
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid rgba(31, 23, 27, .1);
  border-radius: 38px;
  background: rgba(255, 255, 255, .74);
  box-shadow: 0 28px 90px rgba(114, 46, 72, .14), inset 0 1px 0 #fff;
  backdrop-filter: blur(16px);
}

.intro-copy { text-align: center; }

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: var(--pink-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .22em;
}

.eyebrow span { width: 30px; height: 1px; background: var(--pink); }

.intro-copy h1 {
  margin: 9px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6vw, 70px);
  line-height: .95;
  letter-spacing: -.055em;
}

.intro-copy h1 em { color: var(--pink); font-weight: 400; }

.intro-copy > p {
  margin: 12px auto 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-style: italic;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.12fr) minmax(300px, .88fr);
  align-items: center;
  gap: clamp(30px, 6vw, 82px);
  max-width: 900px;
  margin: 30px auto 0;
}

.wheel-stage {
  width: min(440px, 100%);
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  margin: auto;
}

.wheel {
  width: 91%;
  aspect-ratio: 1;
  position: relative;
  border: 9px solid #fff;
  border-radius: 50%;
  overflow: hidden;
  transition: transform 4.6s cubic-bezier(.12,.74,.08,1);
  box-shadow:
    0 0 0 2px var(--ink),
    0 0 0 10px #f7b7cb,
    0 0 0 12px var(--ink),
    0 24px 45px rgba(95, 36, 59, .22);
  will-change: transform;
  background: conic-gradient(
    #171416 0deg 60deg,
    #ffd3e0 60deg 120deg,
    #f28fb2 120deg 180deg,
    #fff8f5 180deg 240deg,
    #ef4f91 240deg 300deg,
    #b93269 300deg 360deg
  );
}

.wheel.is-spinning { filter: saturate(1.05); }

.wheel-lines {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    rgba(28,23,26,.55) 0deg 1deg, transparent 1.05deg 59.45deg,
    rgba(28,23,26,.55) 59.5deg 60.5deg, transparent 60.55deg 119.45deg,
    rgba(28,23,26,.55) 119.5deg 120.5deg, transparent 120.55deg 179.45deg,
    rgba(28,23,26,.55) 179.5deg 180.5deg, transparent 180.55deg 239.45deg,
    rgba(28,23,26,.55) 239.5deg 240.5deg, transparent 240.55deg 299.45deg,
    rgba(28,23,26,.55) 299.5deg 300.5deg, transparent 300.55deg 359deg,
    rgba(28,23,26,.55) 359deg 360deg
  );
}

.wheel-label {
  --label-angle: 0deg;
  --label-ink: #1c171a;
  --label-radius: clamp(112px, 16vw, 150px);
  position: absolute;
  left: 50%;
  top: 50%;
  width: 31%;
  color: var(--label-ink);
  transform:
    translate(-50%, -50%)
    rotate(var(--label-angle))
    translateY(calc(var(--label-radius) * -1))
    rotate(calc(var(--label-angle) * -1));
  text-align: center;
  font-size: clamp(8px, 1.6vw, 12px);
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,.2);
}

.wheel-label-voucher-30,
.wheel-label-voucher-60 { font-size: clamp(9px, 1.7vw, 13px); }

.wheel-center {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 25%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 5px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 0 0 1.5px var(--ink), 0 6px 16px rgba(0,0,0,.22);
}

.wheel-center span { font-family: Georgia, serif; font-size: 8px; letter-spacing: .2em; }
.wheel-center strong { font-family: Georgia, serif; font-size: clamp(10px, 2vw, 17px); letter-spacing: .03em; }

.pointer {
  position: absolute;
  z-index: 5;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 48% 48%;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 0 9px 20px rgba(80,24,46,.22);
}

.pointer::after {
  content: "";
  position: absolute;
  bottom: -17px;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid var(--ink);
}

.pointer span {
  width: 16px;
  height: 16px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: inset 0 0 0 4px #ffd3e1;
}

.wheel-shadow {
  position: absolute;
  z-index: -1;
  bottom: 0;
  width: 69%;
  height: 9%;
  border-radius: 50%;
  background: rgba(70, 25, 42, .14);
  filter: blur(13px);
}

.control-panel {
  padding: 28px;
  border: 1px solid rgba(239,79,145,.18);
  border-radius: 25px;
  background: rgba(255,250,248,.82);
  box-shadow: 0 17px 40px rgba(91,36,57,.08);
}

.step-pill {
  width: fit-content;
  margin-bottom: 21px;
  padding: 8px 12px;
  border-radius: 99px;
  color: var(--pink-dark);
  background: #ffe5ed;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
}

.control-panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.control-panel label span { color: #9d8a91; font-weight: 500; }

.control-panel input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid #e6cbd4;
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}

.control-panel input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(239,79,145,.12);
}

.control-panel input::placeholder { color: #b7a7ad; }

.spin-button {
  width: 100%;
  min-height: 58px;
  margin-top: 12px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .11em;
  cursor: pointer;
  box-shadow: 0 11px 22px rgba(29,23,26,.19);
  transition: transform .18s, background .18s, opacity .18s;
}

.spin-button span { margin-left: 8px; color: #ff83b2; }
.spin-button:hover:not(:disabled) { background: var(--pink-dark); transform: translateY(-2px); }
.spin-button:active:not(:disabled) { transform: translateY(0); }
.spin-button:disabled { cursor: wait; opacity: .76; }

.helper-text {
  margin: 13px 0 23px;
  color: var(--muted);
  text-align: center;
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
}

.helper-text span { color: var(--pink); font-style: normal; }

.prize-preview {
  padding-top: 18px;
  border-top: 1px solid #eddbe1;
}

.prize-preview > p {
  margin: 0 0 10px;
  color: #9a7e89;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .2em;
}

.prize-preview > div { display: flex; flex-wrap: wrap; gap: 6px; }

.prize-preview span {
  padding: 6px 8px;
  border: 1px solid #edd9e0;
  border-radius: 7px;
  color: #7c5966;
  background: #fff;
  font-size: 8px;
  font-weight: 800;
}

footer {
  width: min(1120px, 100%);
  margin: 17px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  color: #987783;
}

footer p { margin: 0; font-family: Georgia, serif; font-size: 11px; font-style: italic; }
footer span { font-size: 8px; font-weight: 900; letter-spacing: .16em; }

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background: rgba(34, 20, 26, .62);
  backdrop-filter: blur(12px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  animation: fade-in .28s ease-out;
}

.result-modal,
.history-modal {
  width: min(480px, 100%);
  max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  position: relative;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 30px;
  background: #fffaf8;
  box-shadow: 0 32px 90px rgba(23,11,16,.35);
  animation: modal-in .35s cubic-bezier(.17,.82,.31,1.08);
}

.result-modal {
  padding: 40px 32px 31px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.result-modal::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  top: -100px;
  left: -80px;
  border-radius: 50%;
  background: #ffd8e4;
}

.result-icon {
  width: 60px;
  height: 60px;
  position: relative;
  display: grid;
  place-items: center;
  margin: 0 auto 17px;
  border-radius: 50%;
  color: #fff;
  background: var(--pink);
  font-size: 28px;
  box-shadow: 0 8px 23px rgba(239,79,145,.3);
}

.result-kicker {
  margin: 0 0 8px !important;
  color: var(--pink-dark) !important;
  font-size: 9px !important;
  font-weight: 900;
  font-style: normal !important;
  letter-spacing: .22em;
}

.result-modal h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 400;
}

.result-prize {
  margin: 17px 0 11px;
  padding: 19px 15px;
  border: 1.5px dashed var(--pink);
  border-radius: 18px;
  color: var(--ink);
  background: #ffe8ef;
  font-family: Georgia, serif;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 800;
  line-height: 1.08;
}

.result-modal > p:not(.result-kicker) {
  margin: 0 0 21px;
  color: var(--muted);
  font-size: 13px;
}

.result-modal button {
  width: 100%;
  min-height: 53px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.result-modal button:hover { background: var(--pink-dark); }
.result-modal small { display: block; margin-top: 11px; color: #a39098; font-size: 10px; }
.spark { position: absolute; color: var(--pink); font-size: 23px; animation: twinkle 1.2s infinite alternate; }
.spark-one { top: 49px; left: 16%; }
.spark-two { top: 78px; right: 15%; animation-delay: .35s; }

.history-modal {
  display: flex;
  flex-direction: column;
  padding: 26px;
  overflow: hidden;
}

.history-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 19px; }
.history-heading p { margin: 0 0 6px; color: var(--pink-dark); font-size: 8px; font-weight: 900; letter-spacing: .2em; }
.history-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 28px; }
.history-heading > button {
  width: 38px;
  height: 38px;
  border: 1px solid #eadbe0;
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.empty-history { padding: 45px 20px; text-align: center; color: #9e838e; }
.empty-history span { color: var(--pink); font-size: 32px; }
.empty-history p { margin: 10px 0 0; font-family: Georgia, serif; font-style: italic; }

#historyContent {
  min-height: 0;
  overflow: hidden;
}

.history-list {
  max-height: min(470px, calc(100dvh - 230px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.history-list article {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 13px 2px;
  border-bottom: 1px solid #f0e2e7;
}

.history-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--pink-dark);
  background: #ffe4ec;
  font-size: 10px;
  font-weight: 900;
}

.history-list h3 { margin: 0 0 4px; font-size: 13px; }
.history-list p { margin: 0; color: var(--pink-dark); font-family: Georgia, serif; font-size: 12px; }
.history-list time { color: #9e8991; font-size: 10px; }

.history-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.history-actions button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid #ead5dd;
  border-radius: 11px;
  color: #855b6b;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.history-actions .close-history { border-color: var(--ink); color: #fff; background: var(--ink); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes twinkle { to { transform: rotate(20deg) scale(1.25); opacity: .55; } }

@media (max-width: 800px) {
  :root {
    /*
      Safari iOS memakai toolbar bawah mengambang yang tidak selalu masuk ke
      env(safe-area-inset-bottom). Ruang ini membuat konten terakhir dapat
      digulir sampai benar-benar berada di atas toolbar tersebut.
    */
    --browser-bottom-clearance: 140px;
  }

  html {
    scroll-padding-bottom: calc(20px + env(safe-area-inset-bottom) + var(--browser-bottom-clearance));
  }

  .app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    padding:
      max(18px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      calc(20px + env(safe-area-inset-bottom) + var(--browser-bottom-clearance))
      max(14px, env(safe-area-inset-left));
  }
  .brand-header { margin-bottom: 13px; }
  .draw-card { min-height: auto; padding: 26px 18px 24px; border-radius: 28px; }
  .game-layout { grid-template-columns: 1fr; gap: 22px; margin-top: 24px; }
  .wheel-stage { width: min(390px, 92vw); }
  .control-panel { max-width: 480px; width: 100%; margin: auto; padding: 22px; }
  footer { padding-bottom: 8px; }
}

@media (max-width: 480px) {
  .brand-mark { width: 36px; height: 36px; font-size: 21px; }
  .brand-name { font-size: 15px; }
  .brand-subtitle { font-size: 6.5px; }
  .history-button { min-height: 38px; padding: 6px 8px 6px 11px; }
  .history-button-copy { display: none; }
  .history-button b { height: 23px; min-width: 23px; }
  .eyebrow { gap: 8px; font-size: 7.5px; letter-spacing: .17em; }
  .eyebrow span { width: 18px; }
  .intro-copy h1 { font-size: 44px; }
  .intro-copy > p { max-width: 300px; font-size: 13px; line-height: 1.45; }
  .wheel-stage { width: min(350px, 87vw); }
  .wheel { border-width: 7px; box-shadow: 0 0 0 2px var(--ink), 0 0 0 7px #f7b7cb, 0 0 0 9px var(--ink), 0 18px 36px rgba(95,36,59,.2); }
  .pointer { width: 44px; height: 53px; top: -3px; }
  .pointer::after { bottom: -15px; border-left-width: 11px; border-right-width: 11px; border-top-width: 20px; }
  .wheel-label { font-size: 8px; }
  .wheel-label-manicure, .wheel-label-voucher-60 { font-size: 6.5px; letter-spacing: .03em; }
  footer span { display: none; }
  footer p { text-align: center; }
  .result-modal { padding: 35px 20px 24px; border-radius: 25px; }
  .history-modal { padding: 22px 18px; border-radius: 25px; }
  .modal-backdrop {
    place-items: start center;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .result-modal,
  .history-modal {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: auto 0;
  }
  .history-list {
    max-height: calc(100dvh - 212px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .wheel { transition-duration: .01ms; }
}
