.contest-modal[hidden] { display: none; }
.contest-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  box-sizing: border-box;
}
.contest-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 14, .80);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.contest-modal__panel {
  position: relative;
  width: min(100%, 420px);
  max-height: calc(100dvh - 32px);
  margin-top: 36px;
  overflow: visible;
  padding: 72px 26px 30px;
  border: 3px solid #0b0b0e;
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 55%),
    radial-gradient(93% 78% at 50% 42%, #e458e4, #3f126b);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .28),
    inset 0 -6px 18px rgba(24, 4, 44, .55),
    0 18px 44px rgba(0, 0, 0, .5);
  color: #fff;
  font-family: SupercellText-Regular, system-ui, sans-serif;
  text-align: center;
  box-sizing: border-box;
}
/* patterned overlay to match the store sections */
.contest-modal__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 19px;
  background: url(../images/brawl-pattern-new-SHECXIEU.png) center / 260px repeat;
  opacity: .10;
  pointer-events: none;
  mix-blend-mode: overlay;
}
.contest-modal__panel > * { position: relative; }

/* floating gem hero */
.contest-modal__gems {
  position: absolute;
  top: -48px;
  left: 50%;
  width: 110px;
  height: auto;
  transform: translateX(-50%);
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .55));
  pointer-events: none;
  z-index: 2;
}

/* Header buttons: Close and Back */
.contest-modal__close,
.contest-modal__back {
  position: absolute;
  top: 14px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid #1a0730;
  border-radius: 50%;
  background: rgba(24, 6, 44, .65);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .35);
  transition: background .15s ease, transform .15s ease;
  z-index: 10;
  box-sizing: border-box;
}
.contest-modal__close {
  right: 14px;
  font-family: system-ui, sans-serif;
  font-size: 24px;
  line-height: 1;
}
.contest-modal__back {
  left: 14px;
}
.contest-modal__back[hidden] {
  display: none !important;
}
.contest-modal__close:hover,
.contest-modal__back:hover {
  background: #1a0730;
  transform: scale(1.08);
}
.contest-modal__close:active,
.contest-modal__back:active {
  transform: scale(0.95);
}

.contest-modal__panel h2,
.contest-modal__panel .contest-title {
  margin: 0 8px 8px;
  color: #fff;
  font-family: Lilita, brawl-fallback, SupercellText-Bold, system-ui, sans-serif;
  font-size: clamp(23px, 5.5vw, 29px);
  line-height: 1.15;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  text-shadow:
    2px 2px 0 #2a0b4a, -2px 2px 0 #2a0b4a,
    2px -2px 0 #2a0b4a, -2px -2px 0 #2a0b4a,
    0 4px 0 #2a0b4a;
}
.contest-modal__panel p.contest-subtitle {
  margin: 0 4px 18px;
  color: #fbeaff;
  font-size: 15px;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(20, 4, 40, .6);
}

.contest-step[hidden] { display: none; }
.contest-step {
  animation: fadeInStep .2s ease-out;
  width: 100%;
}

@keyframes fadeInStep {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.contest-modal__panel form { display: grid; gap: 12px; text-align: left; width: 100%; }
.contest-modal__panel .form-group { display: grid; gap: 6px; }
.contest-modal__panel label {
  color: #fff;
  font-family: Lilita, brawl-fallback, SupercellText-Bold, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: .5px;
  text-shadow: 0 1px 2px rgba(20, 4, 40, .6);
}
.contest-modal__panel input:not(.pin-digit) {
  display: block;
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 3px solid #1a0730;
  border-radius: 12px;
  background: #fff;
  color: #17171c;
  font-family: SupercellText-Bold, brawl-fallback, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  box-shadow: inset 0 2px 4px rgba(26, 7, 48, .18);
  box-sizing: border-box;
}
.contest-modal__panel input::placeholder {
  color: #8f889c;
  font-family: SupercellText-Bold, brawl-fallback, system-ui, sans-serif;
  font-weight: 700;
  opacity: 0.9;
}

/* 6-digit PIN Boxes */
.pin-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 4px 0 8px;
  width: 100%;
}
.pin-inputs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
  box-sizing: border-box;
}
.pin-digit {
  width: 100%;
  height: 54px;
  padding: 0;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #17171c;
  background: #ffffff;
  border: 3px solid #1a0730;
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(26, 7, 48, .18);
  font-family: Lilita, brawl-fallback, SupercellText-Bold, system-ui, sans-serif;
  box-sizing: border-box;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.pin-digit:focus {
  border-color: #ffd84a;
  background-color: #fffef5;
  box-shadow: inset 0 2px 4px rgba(26, 7, 48, .12), 0 0 0 3px rgba(255, 216, 74, 0.65);
}
.pin-hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: #f6d8ff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(20, 4, 40, .6);
}

/* Resend code link */
.contest-resend {
  display: inline-block;
  margin-top: 8px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  color: #ffd84a;
  text-decoration: underline;
  cursor: pointer;
  transition: opacity .15s ease;
}
.contest-resend:disabled {
  color: #f6d8ff;
  opacity: .6;
  text-decoration: none;
  cursor: default;
}

/* Password wrapper */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.password-wrapper input {
  padding-right: 48px;
}
.password-toggle {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #6d667c;
  cursor: pointer;
  transition: transform .1s ease, color .15s ease, background-color .15s ease;
}
.password-toggle:hover {
  color: #17171c;
  background-color: rgba(26, 7, 48, 0.08);
  transform: scale(1.08);
}
.password-toggle:active {
  transform: scale(0.92);
}
.password-toggle svg {
  display: block;
  pointer-events: none;
}
.password-toggle svg[hidden] {
  display: none !important;
}

/* Buttons */
.contest-btn-next,
.contest-btn-finish {
  justify-self: stretch;
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  padding: 12px 20px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe144 0%, #ffbe10 52%, #f59500 100%);
  box-shadow:
    0 0 0 3px #1a0730,
    0 6px 0 #1a0730,
    0 8px 14px rgba(0, 0, 0, 0.4);
  color: #351300;
  font-family: Lilita, brawl-fallback, SupercellText-Bold, system-ui, sans-serif;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.contest-btn-next:hover,
.contest-btn-finish:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow:
    0 0 0 3px #1a0730,
    0 8px 0 #1a0730,
    0 10px 16px rgba(0, 0, 0, 0.45);
}
.contest-btn-next:active,
.contest-btn-finish:active {
  transform: translateY(4px);
  box-shadow:
    0 0 0 3px #1a0730,
    0 2px 0 #1a0730,
    0 4px 6px rgba(0, 0, 0, 0.35);
}
.contest-btn-next:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.contest-modal__panel button:focus-visible,
.contest-modal__panel input:focus-visible {
  outline: 3px solid #ffd84a;
  outline-offset: 3px;
}

/* Success Step */
.contest-step--success {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.contest-success-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: linear-gradient(#56e338, #2a9413);
  box-shadow: 0 0 0 3px #1a0730, 0 6px 14px rgba(0, 0, 0, .4);
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .4);
  animation: popIcon .35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIcon {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.contest-success-card {
  margin: 10px 0 14px;
  padding: 16px 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  background: rgba(26, 7, 48, .55);
  backdrop-filter: blur(4px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .3);
  width: 100%;
  box-sizing: border-box;
}
.contest-success-text {
  margin: 0;
  color: #fff;
  font-family: Lilita, brawl-fallback, SupercellText-Bold, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}

.contest-modal__message {
  margin: 12px 0 0 !important;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(26, 7, 48, .4);
  color: #fff;
  font-family: SupercellText-Bold, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}
.contest-modal__message:empty { display: none; }
.contest-modal-open { overflow: hidden; }
._CTA_77c81 ._LoginButton_e2577 ._IdLogo_e2577 { display: none; }
._LinkButton_7ee0e {
  font-family: Lilita, brawl-fallback, SupercellText-Bold, system-ui, sans-serif !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  letter-spacing: .5px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
._LinkButton_7ee0e:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
}
._LinkButton_7ee0e:active {
  transform: translateY(1px);
}

/* Responsive Adaptation */
@media (max-width: 420px) {
  .contest-modal { padding: 12px; }
  .contest-modal__panel {
    padding: 68px 18px 24px;
    margin-top: 30px;
    border-radius: 20px;
  }
  .contest-modal__gems { top: -42px; width: 100px; }
  .contest-modal__close,
  .contest-modal__back {
    top: 12px;
    width: 38px;
    height: 38px;
  }
  .contest-modal__close { right: 12px; }
  .contest-modal__back { left: 12px; }
  .pin-inputs { gap: 6px; }
  .pin-digit {
    height: 48px;
    font-size: 21px;
    border-radius: 10px;
  }
  .contest-btn-next,
  .contest-btn-finish {
    font-size: 18px;
    min-height: 50px;
  }
}

@media (max-width: 340px) {
  .contest-modal { padding: 8px; }
  .contest-modal__panel {
    padding: 64px 14px 20px;
    border-radius: 18px;
  }
  .contest-modal__gems { top: -36px; width: 92px; }
  .contest-modal__panel h2,
  .contest-modal__panel .contest-title { font-size: 21px; margin-inline: 4px; }
  .contest-modal__panel p.contest-subtitle { font-size: 13.5px; }
  .pin-inputs { gap: 4px; }
  .pin-digit {
    height: 44px;
    font-size: 19px;
    border-radius: 8px;
    border-width: 2.5px;
  }
  .contest-btn-next,
  .contest-btn-finish {
    font-size: 16px;
    min-height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .contest-modal__panel form button,
  .contest-btn-next,
  .contest-btn-finish,
  .contest-modal__close,
  .contest-modal__back,
  .contest-step,
  .contest-success-icon,
  ._LinkButton_7ee0e { transition: none; animation: none; }
}
