:root {
  --navy: #1b4d70;
  --navy-dark: #123650;
  --blue: #2386ab;
  --gold: #f3b63f;
  --red: #c8362b;
  --cream: #fdf3dc;
  --text: #1d3f5e;
  --font-ar: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-en: "Bebas Neue", "Cairo", Impact, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }

body {
  font-family: var(--font-ar);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  animation: pageIn .45s ease both;
}
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- scene background ---------- */
.bg-scene::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url(../images/Spin2-03.webp) center 80% / cover no-repeat;
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 5vh;
}

/* ---------- logo ---------- */
.logo-svg { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.logo-svg svg { width: 62px; height: 62px; }
.logo-svg b { font-size: 1.05rem; font-weight: 700; color: #1f6f9a; white-space: nowrap; }
.logo-svg b i { font-style: normal; color: #e35a3b; }
.logo-img { max-width: 100%; max-height: 100%; display: block; }

/* ---------- registration page ---------- */
.form-wrap { position: relative; width: 100%; max-width: 445px; padding-top: 112px; }
.logo-badge {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 214px; height: 214px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .25));
  z-index: 2;
}
.form-card {
  background: var(--blue);
  border-radius: 38px;
  padding: 118px 34px 34px;
  box-shadow: 0 22px 40px rgba(18, 54, 80, .3);
  text-align: center;
}
.form-title { margin: 0 0 26px; color: #fff; font-size: clamp(1.15rem, 5vw, 1.45rem); font-weight: 700; line-height: 1.7; }

.field { margin-bottom: 16px; text-align: left; }
.pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 999px;
  padding: 0 18px;
  height: 44px;
  direction: ltr;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .08);
  transition: box-shadow .2s;
}
.pill:focus-within { box-shadow: 0 0 0 4px rgba(255, 255, 255, .45); }
.ico { width: 26px; height: 26px; flex: none; fill: var(--blue); }
.pill input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-en);
  font-size: 1.35rem;
  letter-spacing: .08em;
  color: var(--navy);
}
.pill input::placeholder { color: #a9c3cf; }
.pill input[type=number] { -moz-appearance: textfield; }
.pill input::-webkit-outer-spin-button, .pill input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field.has-error .pill { box-shadow: 0 0 0 3px #ffb4a8; }
.error { display: block; margin: 5px 14px 0; color: #ffe3dd; font-size: .85rem; font-weight: 600; text-align: right; direction: rtl; }
.error:empty { display: none; }

.alert {
  background: #fff1f2; color: #be123c; border-radius: 14px;
  padding: 10px 14px; margin-bottom: 16px; font-weight: 600;
}

.btn-submit {
  margin-top: 10px;
  min-width: 170px;
  height: 56px;
  padding: 0 34px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-family: var(--font-en);
  font-size: 1.7rem;
  letter-spacing: .12em;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .15), 0 10px 18px rgba(0, 0, 0, .15);
  transition: transform .15s;
}
.btn-submit:hover:not(:disabled) { transform: translateY(-2px); }
.btn-submit:active:not(:disabled) { transform: translateY(2px); }
.btn-submit:disabled { opacity: .7; cursor: not-allowed; }

/* ---------- wheel page ---------- */
.bg-scene.bg-plain::before { background-image: url(../images/scene.webp) ; }
.page-wheel {  padding-top: clamp(28px, 5vh, 56px); gap: 0; }
.ribbon-title {
  margin: 0 0 clamp(26px, 5vh, 52px);
  padding: 6px 38px 10px;
  border-radius: 20px;
  color: #fff;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 900;
  background: linear-gradient(#e24b3c, #b52c22);
  border: 3px solid #f08a7f;
  box-shadow: 0 5px 0 #8e1f17, 0 10px 18px rgba(0, 0, 0, .25);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}

.stage {
  position: relative;
  width: min(92vw, 520px, calc((100vh - 350px) / 1.254));
  aspect-ratio: 1000 / 1254;
  margin: 60px auto 4px;
}
.stage img { -webkit-user-drag: none; user-select: none; }
.w-base { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.w-rot {
  position: absolute;
  left: 0; top: 3.99%;
  width: 100%; aspect-ratio: 1;
  will-change: transform;
}
.w-rot img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.w-pointer { position: absolute; left: 40.4%; top: -0.4%; width: 19.62%; z-index: 3; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .25)); }
.wheel-hub {
  position: absolute;
  top: 43.87%; left: 50%;
  width: 21.6%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 0; padding: 0;
  border-radius: 50%;
  background: url(../images/hub-logo.webp) center / cover no-repeat;
  cursor: pointer;
  z-index: 4;
}

/* decorative gold confetti */
.cf {
  position: fixed; z-index: 1; pointer-events: none;
  width: 22px; height: 38px;
  background: #f6c343; border: 3px solid #d6a21c; border-radius: 3px;
  opacity: .85;
}
.cf1 { left: 4vw;  top: 30vh; transform: rotate(-25deg); }
.cf2 { left: 11vw; top: 58vh; transform: rotate(30deg); width: 16px; height: 28px; }
.cf3 { left: 2vw;  top: 78vh; transform: rotate(-50deg); width: 18px; height: 32px; }
.cf4 { right: 5vw; top: 26vh; transform: rotate(35deg); }
.cf5 { right: 3vw; top: 54vh; transform: rotate(-30deg); width: 16px; height: 28px; }
.cf6 { right: 9vw; top: 74vh; transform: rotate(20deg); width: 18px; height: 32px; }
@media (max-width: 520px) { .cf { transform-origin: center; opacity: .75; } .cf1, .cf4 { top: 22vh; } }

.btn-spin {
  position: relative; z-index: 3;
  min-width: 210px; height: 58px;
  padding: 0 40px;
  border: 0; border-radius: 999px;
  font-family: var(--font-ar);
  font-size: 1.3rem; font-weight: 900;
  color: #fff;
  background: linear-gradient(#e24b3c, #b52c22);
  box-shadow: 0 5px 0 #8e1f17, 0 12px 20px rgba(0, 0, 0, .25);
  cursor: pointer;
  transition: transform .15s;
}
.btn-spin:hover:not(:disabled) { transform: translateY(-2px); }
.btn-spin:active:not(:disabled) { transform: translateY(3px); }
.btn-spin:disabled { opacity: .75; cursor: not-allowed; }
.message { position: relative; z-index: 3; min-height: 1.4em; margin: 12px 0 0; font-weight: 700; color: #be123c; }
.hint { position: relative; z-index: 3; margin: 4px 0 0; color: #3d5a70; font-weight: 600; font-size: .95rem; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- result page ---------- */
.top-logo { position: absolute; top: 14px; left: 16px; z-index: 3; }
.top-logo .logo-img { width: clamp(150px, 38vw, 260px); height: auto; }
.top-logo .logo-svg { flex-direction: row; gap: 8px; }

.page-result {  padding-top: 56px; padding-bottom: 9vh; }
.result-card {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 640 / 605;
  container-type: inline-size;
  background: url(../images/result_card.webp) center / 100% 100% no-repeat;
  animation: pop .6s cubic-bezier(.2, 1.4, .4, 1) both;
}
.rc-title, .rc-prize {
  position: absolute; margin: 0;
  transform: translate(-50%, -50%);
  white-space: nowrap; text-align: center;
  font-family: var(--font-ar); font-weight: 900; color: #7a1d2b;
  line-height: 1;
}
.rc-title { left: 50%; top: 57.9%; font-size: 6.6cqw; }
.rc-prize { left: 51.6%; top: 68.2%; font-size: 8.2cqw; color: #184d71; }
.code-line { position: relative; z-index: 2; margin: 0; padding: 6px 16px; border-radius: 999px; background: rgba(255, 255, 255, .8); font-size: .85rem; color: #3d5a70; }
.code-line b { letter-spacing: .06em; color: var(--navy); user-select: all; }

.back-link {
  position: relative; z-index: 3;
  color: var(--navy); font-weight: 700; text-decoration: none;
  padding: 10px 24px; border-radius: 999px; background: rgba(255, 255, 255, .85);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15);
}

@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 380px) {
  .logo-badge { width: 190px; height: 190px; }
  .form-card { padding: 118px 22px 28px; }
  .result-body { margin-inline: 3%; }
}
@media (prefers-reduced-motion: reduce) {
  body, .trophy svg, .prize-splash { animation: none; }
}

/* decorative close icon on the form card (as in the design) */
.form-card { position: relative; }
.page:not(.page-wheel):not(.page-result) { padding-top: 6vh; }

/* spin hint */
.spin-hint { position: relative; z-index: 3; margin: 14px 0 0; padding: 8px 22px; border-radius: 999px; background: rgba(255,255,255,.85); color: var(--navy); font-weight: 800; box-shadow: 0 3px 8px rgba(0,0,0,.15); animation: hintPulse 1.6s ease-in-out infinite; }
.spin-hint.is-error { color: #be123c; animation: none; }
.spin-hint:empty { display: none; }
.stage { cursor: pointer; }
.wheel-hub { animation: hubPulse 1.6s ease-out infinite; }
@keyframes hintPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes hubPulse { 0% { box-shadow: 0 0 0 0 rgba(251,191,36,.7); } 100% { box-shadow: 0 0 0 22px rgba(251,191,36,0); } }


/* per-segment labels: they travel with the wheel but stay upright */
.w-labels { position: absolute; inset: 0; }
.w-labels .lbl { position: absolute; }
.w-labels .lbl img { position: static; inset: auto; width: 100%; height: auto; display: block; }

/* ===== BACKGROUNDS (one image shows at a time; later rules override earlier ones) =====
   Pages 1 + 3  (.bg-scene)             phone/tablet: Spin2-03.webp   | 1023px and wider: bg3.webp
   Page 2       (.bg-scene.bg-plain)    phone/tablet: scene.webp      | 1023px and wider: bg2.webp */
@media (min-width: 1023px) {
  .bg-scene::before { background-image: url(../images/bg3.webp); }
  .bg-scene.bg-plain::before { background-image: url(../images/bg2.webp); }
}

/* result page actions */
.result-actions { position: relative; z-index: 3; display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.share-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 999px; background: #25d366; color: #fff; font-weight: 800; text-decoration: none; box-shadow: 0 3px 10px rgba(37,211,102,.45); }
.share-btn svg { width: 22px; height: 22px; fill: #fff; }
.share-btn:hover { background: #1fbd5b; }

/* phones: bigger prize card (the artwork has a transparent margin, so it can bleed past the page padding) and stacked buttons */
@media (max-width: 480px) {
  .page-result { padding: 64px 0 5vh; }
  .result-card { width: min(100vw, 520px); max-width: none; flex: none; }
  .result-actions { flex-direction: column; align-items: stretch; width: min(100% - 32px, 340px); gap: 12px; margin-top: 8px; }
  .share-btn, .back-link { justify-content: center; min-height: 54px; padding: 12px 20px; font-size: 1.05rem; text-align: center; }
}

/* wider than a tablet: big prize card (scales with the screen, always leaves room for the buttons) */
@media (min-width: 1024px) {
  .result-card { width: min(780px, 60vw, calc((100vh - 170px) / .945)); }
  .page-result { padding-top: 40px; padding-bottom: 28px; }
  .share-btn, .back-link { font-size: 1.1rem; padding: 12px 30px; }
}

/* ===== registration page: card artwork (blue frame + title) with the real form fields laid over it ===== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page-reg { flex-direction: column; justify-content: flex-start; gap: 0; padding: clamp(14px, 3vh, 34px) 14px 3vh; }
.reg-logo { display: block; width: clamp(190px, 60vw, 300px); height: auto; margin: 0 auto clamp(4px, 1.5vh, 14px); position: relative; z-index: 2; }
.reg-alert { position: relative; z-index: 3; width: min(92vw, 460px); text-align: center; margin: 0 0 8px; }
.reg-card {
  position: relative; z-index: 2;
  width: min(94vw, 500px, calc((100vh - 150px) * .8117));
  aspect-ratio: 1000 / 1232;
  background: url(../images/reg-card.webp) center / 100% 100% no-repeat;
  filter: drop-shadow(0 14px 22px rgba(10, 50, 85, .28));
}
.reg-card .slot { position: absolute; left: 11.78%; width: 78.85%; height: 8.81%; margin: 0; }
.reg-card .slot-name  { top: 41.18%; }
.reg-card .slot-age   { top: 53.38%; }
.reg-card .slot-phone { top: 65.71%; }
.reg-card .pill { height: 100%; padding: 0 5%; gap: 4%; border-radius: 999px; background: #f4f4f4; border: 2px solid #b8b8b8; box-shadow: none; direction: ltr; }
.reg-card .pill:focus-within { border-color: #0a78bd; background: #fff; box-shadow: 0 0 0 3px rgba(10, 120, 189, .22); }
.reg-card .ico { width: 8%; height: 56%; fill: #1b86b2; }
.reg-card .pill input { font-size: clamp(1rem, 4.6vw, 1.55rem); letter-spacing: .1em; color: #0a4f7a; }
.reg-card .pill input::placeholder { color: #b8c7d2; }
.reg-card .field.has-error .pill { border-color: #e24b3c; box-shadow: 0 0 0 3px rgba(226, 75, 60, .18); }
.reg-card .error { position: absolute; top: 100%; right: 4%; left: 4%; margin: 2px 0 0; color: #c0392b; font-size: clamp(.7rem, 2.9vw, .85rem); font-weight: 700; text-align: right; direction: rtl; line-height: 1.2; }
.reg-submit {
  position: absolute; left: 29.55%; top: 79.59%; width: 45.39%; height: 12.06%;
  border: 0; border-radius: 999px; cursor: pointer; color: #fff;
  font-family: var(--font-en); font-size: clamp(1.4rem, 7vw, 2.3rem); letter-spacing: .14em; line-height: 1;
  background: linear-gradient(180deg, #00a8e6, #0079c1);
  box-shadow: 0 7px 0 #00629c, 0 12px 16px rgba(0, 70, 120, .3);
  transition: transform .15s;
}
.reg-submit:hover:not(:disabled) { transform: translateY(-2px); }
.reg-submit:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 #00629c; }
.reg-submit:disabled { opacity: .7; cursor: not-allowed; }

/* Arabic inputs: right-to-left, icon on the right, Arabic font */
.reg-card .pill { direction: rtl; }
.reg-card .pill input { direction: rtl; text-align: right; font-family: var(--font-ar); font-weight: 700; letter-spacing: 0; font-size: clamp(1rem, 4.4vw, 1.4rem); }
.reg-card .pill input::placeholder { font-weight: 700; }
.reg-card .slot-age input, .reg-card .slot-phone input { unicode-bidi: plaintext; }

/* gap between a field and its error message */
.reg-card .error { margin-top: 6px; line-height: 1.35; }
.reg-card .pill { height: 90%; }
.reg-card .error { margin-top: 6px; font-size: clamp(.68rem, 2.8vw, .85rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-card .error { top: 80%; margin-top: 5px; }

/* phones: push logo + card further down the page */
@media (max-width: 767px) {
  .page-reg { padding-top: clamp(40px, 9vh, 90px); }
  .reg-card { width: min(94vw, 500px, calc((100vh - 230px) * .8117));
  margin-top: 20px; }
}

/* Arabic submit button */
.reg-submit { font-family: var(--font-ar); font-weight: 900; letter-spacing: 0; font-size: clamp(1.25rem, 6vw, 2rem); }
.reg-submit { white-space: nowrap; }

/* longer wheel-page title: fit narrow screens */
.ribbon-title { max-width: 94vw; text-align: center; line-height: 1.3; font-size: clamp(1.1rem, 5vw, 2rem); padding: 6px clamp(18px, 5vw, 38px) 10px; }
