/* ============================================================
   SETUP MODAL — GIN ROYALE Premium bet/target popup
   Logical desktop: 1500 × 950, content ~90% width
   ============================================================ */

#setup-overlay {
  padding: max(6vh, env(safe-area-inset-top)) max(9vw, env(safe-area-inset-right))
           max(6vh, env(safe-area-inset-bottom)) max(9vw, env(safe-area-inset-left));
  overflow: hidden;
  align-items: center;
  justify-content: center;
}

#setup-overlay .setup-panel {
  position: relative;
  box-sizing: border-box;
  width: min(760px, 82vw);
  height: auto;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px 32px 24px;
  border-radius: 22px;
  background:
    radial-gradient(ellipse 120% 70% at 50% 0%, rgba(120, 60, 180, 0.28) 0%, transparent 52%),
    linear-gradient(180deg, #2a1248 0%, #1a0a30 42%, #120820 100%);
  border: 3px solid transparent;
  box-shadow:
    0 0 0 2px #c9a227,
    0 0 0 5px #8b6914,
    0 0 0 7px #f5d76e,
    0 0 0 9px #6b4f0a,
    0 0 28px rgba(255, 196, 64, 0.2),
    0 24px 58px rgba(0, 0, 0, 0.72);
  opacity: 0;
  transition: opacity 0.18s ease;
  overflow: hidden;
}

#setup-overlay.is-open .setup-panel {
  opacity: 1;
}

#setup-overlay.is-closing .setup-panel {
  opacity: 0;
}

#setup-overlay .setup-content {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ---------- Close — top-left ---------- */
#setup-overlay .setup-close {
  position: absolute;
  top: 16px;
  left: 16px;
  right: auto;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid #e8c04a;
  background: linear-gradient(180deg, #4a2470 0%, #2a1248 100%);
  color: #f5d76e;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  touch-action: manipulation;
  transition: filter 0.12s ease;
  z-index: 10;
}

#setup-overlay .setup-close.is-pressed { filter: brightness(1.12); }

@media (hover: hover) and (pointer: fine) {
  #setup-overlay .setup-close:hover { filter: brightness(1.08); }
}

/* ---------- Header ~20–23% ---------- */
#setup-overlay .setup-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-height: 0;
  padding-bottom: 4px;
}

#setup-overlay .setup-crown {
  width: 64px;
  height: 56px;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
  margin-bottom: 4px;
}

#setup-overlay .setup-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

#setup-overlay .setup-title__line {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: #f5d76e;
  text-transform: uppercase;
}

#setup-overlay .setup-title__premium {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  background: linear-gradient(180deg, #fff6c8 0%, #f5d04a 35%, #c9921a 70%, #ffe082 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}

/* ---------- Section headings ---------- */
#setup-overlay .setup-section-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 0 0 auto;
  margin: 10px 0 8px;
}

#setup-overlay .setup-section-head:first-of-type {
  margin-top: 6px;
}

#setup-overlay .setup-section-head__orn {
  width: 110px;
  height: 22px;
  object-fit: contain;
  object-position: center;
  opacity: 0.9;
  flex-shrink: 1;
  max-width: 28%;
}

#setup-overlay .setup-section-head__orn--flip { transform: scaleX(-1); }

#setup-overlay .setup-section-head__text {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #f5d76e;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

/* ---------- Shared inset trays (aligned widths) ---------- */
#setup-overlay .setup-inset {
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0.52) 100%);
  border: 1px solid rgba(232, 192, 74, 0.35);
  border-radius: 14px;
  padding: 10px 10px 12px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.45);
  flex: 0 0 auto;
}

#setup-overlay .setup-inset--target {
  padding: 10px 10px 12px;
}

/* ---------- BET tiles ---------- */
#setup-overlay .setup-bet-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
}

#setup-overlay .setup-bet-grid > .setup-bet:nth-child(7) { grid-column: 3; }
#setup-overlay .setup-bet-grid > .setup-bet:nth-child(8) { grid-column: 4; }

#setup-overlay .setup-bet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 108px;
  min-width: 0;
  box-sizing: border-box;
  padding: 12px 8px 18px;
  border: 2px solid rgba(232, 192, 74, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(45, 22, 72, 0.95) 0%, rgba(28, 12, 48, 0.98) 100%);
  cursor: pointer;
  touch-action: manipulation;
  transition: box-shadow 0.14s ease, border-color 0.14s ease, background 0.14s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#setup-overlay .setup-bet__art {
  width: 64px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-bottom: 8px;
}

#setup-overlay .setup-bet .bet-icon {
  width: 64px;
  height: 56px;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

#setup-overlay .setup-bet:nth-child(n + 7) .setup-bet__art,
#setup-overlay .setup-bet:nth-child(n + 7) .bet-icon {
  width: 58px;
  height: 52px;
}

#setup-overlay .setup-bet__val {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1;
  height: 16px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#setup-overlay .setup-bet__pointer {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%) scale(0);
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 11px solid #f5d04a;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  transition: transform 0.14s ease;
  pointer-events: none;
}

#setup-overlay .setup-bet.is-active {
  border-color: #f5d04a;
  background: linear-gradient(180deg, #8b4cc8 0%, #6a2ea0 45%, #54207e 100%);
  box-shadow:
    0 0 22px rgba(180, 90, 255, 0.5),
    0 0 0 2px rgba(245, 208, 74, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

#setup-overlay .setup-bet.is-active .setup-bet__pointer {
  transform: translateX(-50%) scale(1);
}

#setup-overlay .setup-bet.is-pressed:not(.is-active) { filter: brightness(0.96); }

@media (hover: hover) and (pointer: fine) {
  #setup-overlay .setup-bet:not(.is-active):hover {
    border-color: rgba(232, 192, 74, 0.7);
    background: linear-gradient(180deg, rgba(58, 28, 88, 0.98) 0%, rgba(38, 16, 62, 0.98) 100%);
  }
}

/* ---------- TARGET tiles ---------- */
#setup-overlay .setup-target-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
}

#setup-overlay .setup-target {
  position: relative;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 58px;
  padding: 0 4px 8px;
  border: 2px solid rgba(232, 192, 74, 0.4);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(40, 18, 65, 0.96) 0%, rgba(24, 10, 42, 0.98) 100%);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.14s ease, border-color 0.14s ease, background 0.14s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#setup-overlay .setup-target__pointer {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%) scale(0);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #f5d04a;
  transition: transform 0.14s ease;
  pointer-events: none;
}

#setup-overlay .setup-target.is-active {
  border-color: #7ec8ff;
  background: linear-gradient(180deg, #2a7fd4 0%, #1565c0 50%, #0d47a1 100%);
  color: #fff;
  box-shadow:
    0 0 22px rgba(66, 165, 245, 0.55),
    0 0 0 2px rgba(245, 208, 74, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#setup-overlay .setup-target.is-active .setup-target__pointer {
  transform: translateX(-50%) scale(1);
}

#setup-overlay .setup-target.is-pressed:not(.is-active) { filter: brightness(0.96); }

@media (hover: hover) and (pointer: fine) {
  #setup-overlay .setup-target:not(.is-active):hover {
    border-color: rgba(232, 192, 74, 0.65);
  }
}

/* ---------- START button — 65–70% of modal ---------- */
#setup-overlay .setup-start {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 74%;
  height: 72px;
  min-height: 56px;
  margin: auto auto 0;
  padding: 0 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  flex: 0 0 auto;
  transition: filter 0.14s ease;
}

#setup-overlay .setup-start__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
}

#setup-overlay .setup-start__text {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  background: linear-gradient(180deg, #fff8dc 0%, #f5d04a 40%, #c9921a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

#setup-overlay .setup-start__orn {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 20px;
  object-fit: contain;
  object-position: center;
  opacity: 0.88;
  pointer-events: none;
  flex-shrink: 0;
}

#setup-overlay .setup-start__orn--flip { transform: scaleX(-1); }

#setup-overlay .setup-start.is-pressed { filter: brightness(1.06); }

#setup-overlay .setup-start:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.85);
}

@media (hover: hover) and (pointer: fine) {
  #setup-overlay .setup-start:not(:disabled):hover { filter: brightness(1.05); }
}

/* START is 68% of the modal, not of the 90% content column */
#setup-overlay .setup-content > .setup-start {
  width: 70%;
}

/* ---------- Responsive: shrink internals, never scale the modal ---------- */
@media (max-width: 640px) {
  #setup-overlay {
    padding: max(4vh, env(safe-area-inset-top)) max(6vw, env(safe-area-inset-right))
             max(4vh, env(safe-area-inset-bottom)) max(6vw, env(safe-area-inset-left));
  }

  #setup-overlay .setup-header { padding-left: 36px; }
  #setup-overlay .setup-bet-grid > .setup-bet { grid-column: span 2; }
  #setup-overlay .setup-bet-grid > .setup-bet:nth-child(7) { grid-column: 2 / span 2; }
  #setup-overlay .setup-bet-grid > .setup-bet:nth-child(8) { grid-column: 4 / span 2; }
  #setup-overlay .setup-bet { height: 96px; }
  #setup-overlay .setup-content > .setup-start { width: 86%; height: 60px; }
  #setup-overlay .setup-start__text { font-size: 22px; }
  #setup-overlay .setup-start__orn { width: 40px; height: 12px; }
}

@media (max-height: 700px) {
  #setup-overlay .setup-panel {
    width: min(680px, 82vw);
    height: auto;
    max-height: 88dvh;
    padding: 18px 26px;
  }

  #setup-overlay .setup-close {
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 22px;
  }

  #setup-overlay .setup-crown { width: 44px; height: 38px; margin-bottom: 0; }
  #setup-overlay .setup-title__line { font-size: 12px; }
  #setup-overlay .setup-title__premium { font-size: 22px; }
  #setup-overlay .setup-section-head { margin: 6px 0 6px; gap: 8px; }
  #setup-overlay .setup-section-head__text { font-size: 15px; }
  #setup-overlay .setup-section-head__orn { width: 56px; height: 12px; }
  #setup-overlay .setup-inset { padding: 8px 8px 10px; }
  #setup-overlay .setup-bet-grid,
  #setup-overlay .setup-target-row { gap: 6px; }
  #setup-overlay .setup-bet { height: 78px; padding: 4px 4px 10px; }
  #setup-overlay .setup-bet__art,
  #setup-overlay .setup-bet .bet-icon { width: 48px; height: 42px; margin-bottom: 2px; }
  #setup-overlay .setup-bet:nth-child(n + 7) .setup-bet__art,
  #setup-overlay .setup-bet:nth-child(n + 7) .bet-icon { width: 44px; height: 40px; }
  #setup-overlay .setup-bet__val { font-size: 13px; height: 14px; }
  #setup-overlay .setup-target { height: 44px; font-size: 15px; }
  #setup-overlay .setup-content > .setup-start { height: 52px; min-height: 48px; margin-top: 10px; }
  #setup-overlay .setup-start__text { font-size: 20px; }
  #setup-overlay .setup-start__orn { width: 36px; height: 10px; }
}
