/* ============================================================
   CHOCO DUBAI RUSH — Premium mobile-first styles
   Embeddable in Shopify (no frameworks)
   ============================================================ */

:root {
  --brown-deep: #1a0f0a;
  --brown-mid: #3d2314;
  --brown-soft: #5c4033;
  --gold: #d4af37;
  --gold-light: #f5e6c8;
  --gold-dark: #8b6914;
  --sand: #e8c47a;
  --sand-dark: #c4a35a;
  --cream: #fff8ee;
  --danger: #c0392b;
  --safe: #27ae60;
  --glass: rgba(26, 15, 10, 0.72);
  --radius: 18px;
  --font-display: "Cinzel", "Times New Roman", serif;
  --font-body: "Outfit", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--brown-deep);
  color: var(--cream);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--brown-deep);
  isolation: isolate;
}

@media (min-width: 481px) {
  #game-root {
    box-shadow: 0 0 60px rgba(212, 175, 55, 0.25);
    border-left: 1px solid rgba(212, 175, 55, 0.2);
    border-right: 1px solid rgba(212, 175, 55, 0.2);
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

.screen[hidden] {
  display: none !important;
}

/* ---------- Splash ---------- */
#screen-splash {
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
}

#splash-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.splash-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: calc(24px + var(--safe-top)) 28px calc(32px + var(--safe-bottom));
  animation: fadeUp 0.9s ease both;
}

.brand-logo {
  display: block;
  width: min(72vw, 240px);
  height: auto;
  margin: 0 auto 18px;
  filter: drop-shadow(0 8px 24px rgba(212, 175, 55, 0.35));
  animation: floatLogo 3.2s ease-in-out infinite;
}

.select-logo {
  display: block;
  width: min(42vw, 150px);
  height: auto;
  margin: 0 auto 10px;
  filter: drop-shadow(0 4px 12px rgba(212, 175, 55, 0.25));
}

.splash-subtitle {
  margin: 0 0 36px;
  font-size: 1.05rem;
  color: rgba(255, 248, 238, 0.8);
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.4);
}

.btn-gold {
  color: var(--brown-deep);
  background: linear-gradient(180deg, #f5e6c8 0%, #d4af37 48%, #b8860b 100%);
  box-shadow:
    0 8px 24px rgba(212, 175, 55, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-gold:hover {
  box-shadow: 0 10px 28px rgba(212, 175, 55, 0.55);
}

.btn-ghost {
  margin-top: 10px;
  color: var(--gold-light);
  background: transparent;
  border: 1.5px solid rgba(212, 175, 55, 0.45);
}

.btn-lg {
  min-width: 220px;
  min-height: 56px;
  font-size: 1rem;
}

.pulse {
  animation: pulseGold 2s ease-in-out infinite;
}

/* ---------- Product select ---------- */
#screen-select {
  background: #1a0f0a;
  padding: calc(16px + var(--safe-top)) 0 calc(16px + var(--safe-bottom));
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.select-header,
.product-carousel-wrap,
.select-footer {
  position: relative;
  z-index: 1;
}

.select-header {
  text-align: center;
  padding: 8px 24px 8px;
  flex-shrink: 0;
}

.select-header h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--gold);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.select-header p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 248, 238, 0.7);
}

.product-carousel-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 0;
  overflow: visible;
}

.product-carousel {
  display: flex;
  gap: 16px;
  padding: 12px 24px 20px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
  touch-action: pan-x;
}

.product-carousel::-webkit-scrollbar {
  display: none;
}

.product-card {
  flex: 0 0 min(72vw, 260px);
  scroll-snap-align: center;
  background: linear-gradient(165deg, rgba(26, 15, 10, 0.88), rgba(13, 27, 42, 0.92));
  border: 1.5px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.product-card.selected {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(212, 175, 55, 0.35),
    0 16px 40px rgba(212, 175, 55, 0.22);
  transform: scale(1.03);
}

.product-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(145deg, #2a1810, #1a0f0a);
  position: relative;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.product-thumb canvas,
.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #1a1210;
}

.weight-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brown-deep);
  background: linear-gradient(180deg, #f5e6c8, #d4af37);
}

.product-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  min-height: 2.4em;
}

.product-price {
  margin: 0;
  color: var(--gold);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.product-card .btn-select {
  width: 100%;
  min-height: 44px;
  border-radius: 999px;
  border: none;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-light);
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.product-card.selected .btn-select {
  background: linear-gradient(180deg, #f5e6c8, #d4af37);
  color: var(--brown-deep);
  border-color: transparent;
}

.select-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 24px 12px;
  background: linear-gradient(180deg, transparent, rgba(10, 6, 4, 0.65));
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.selected-label {
  margin: 0 0 12px;
  font-size: 0.8rem;
  color: rgba(255, 248, 238, 0.55);
  min-height: 1.2em;
}

@media (max-height: 760px) {
  .select-header {
    padding: 6px 18px 6px;
  }

  .select-logo {
    width: min(36vw, 120px);
    margin-bottom: 6px;
  }

  .select-header h2 {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }

  .select-header p {
    font-size: 0.76rem;
  }

  .product-card {
    flex-basis: min(64vw, 220px);
    padding: 10px;
    gap: 6px;
  }

  .product-name {
    font-size: 0.86rem;
    min-height: 2.1em;
  }

  .product-price {
    font-size: 0.95rem;
  }

  .product-card .btn-select {
    min-height: 38px;
    font-size: 0.82rem;
  }

  .btn-lg {
    min-height: 48px;
    min-width: 190px;
    font-size: 0.9rem;
  }

  .select-footer {
    padding-bottom: calc(10px + var(--safe-bottom));
  }
}

/* ---------- Game ---------- */
#screen-game {
  background: #1a0f0a;
  touch-action: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 12px 0;
  pointer-events: none;
  gap: 8px;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.hud-right {
  flex-direction: row;
}

.hud-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  padding: 8px 12px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.hud-time {
  color: var(--gold-light);
}

.hud-time.urgent {
  color: #ff6b5a;
  border-color: rgba(255, 107, 90, 0.5);
  animation: urgentPulse 0.6s ease infinite;
}

.hud-score {
  color: var(--gold);
}

.hud-icon {
  font-size: 0.85rem;
  opacity: 0.9;
}

.hud-product {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid var(--gold);
  overflow: hidden;
  background: var(--glass);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.35);
}

.hud-product canvas,
.hud-product img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hud-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  background: var(--glass);
  backdrop-filter: blur(8px);
  color: var(--cream);
  font-size: 0.85rem;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.power-bar {
  position: absolute;
  top: calc(78px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.power-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(39, 174, 96, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  animation: bounceIn 0.4s ease;
}

.power-pill.turbo {
  background: rgba(212, 175, 55, 0.9);
  color: var(--brown-deep);
}

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 6;
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
}

.ctrl-btn {
  pointer-events: auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid rgba(46, 125, 50, 0.55);
  background: rgba(76, 175, 80, 0.38);
  backdrop-filter: blur(6px);
  color: #1b5e20;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, background 0.1s ease;
}

.ctrl-btn:active {
  transform: scale(0.92);
  background: rgba(76, 175, 80, 0.55);
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    opacity: 0.55;
  }
}

/* ---------- Overlays / Modals ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 4, 0.45);
}

.countdown #countdown-num {
  font-family: var(--font-display);
  font-size: 5.5rem;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(212, 175, 55, 0.6);
  animation: countPop 0.85s ease;
}

.modal-logo {
  display: block;
  width: 110px;
  height: auto;
  margin: 0 auto 10px;
  filter: drop-shadow(0 4px 12px rgba(212, 175, 55, 0.3));
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(212, 175, 55, 0.18), transparent 55%),
    rgba(10, 6, 4, 0.78);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.35s ease;
}

.modal[hidden],
.overlay[hidden],
.power-bar[hidden],
.power-pill[hidden] {
  display: none !important;
}

.modal-card {
  width: min(100%, 340px);
  text-align: center;
  padding: 28px 24px;
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, 0.22), transparent 60%),
    linear-gradient(180deg, #3d2314 0%, #1a0f0a 100%);
  border: 1.5px solid rgba(212, 175, 55, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.modal-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--gold);
}

.modal-card p {
  margin: 0 0 8px;
  color: rgba(255, 248, 238, 0.8);
  font-size: 0.92rem;
}

.modal-score {
  margin: 14px 0 !important;
  font-weight: 700;
  color: var(--gold-light) !important;
}

.high-score {
  font-size: 0.8rem !important;
  opacity: 0.7;
  margin-bottom: 16px !important;
}

.modal-card .btn {
  width: 100%;
  margin-top: 8px;
}

.win-sparkle {
  font-size: 1.6rem;
  color: var(--gold);
  animation: floatLogo 2s ease-in-out infinite;
}

.win-congrats {
  font-family: var(--font-display);
  color: var(--gold-light) !important;
  font-size: 1.05rem !important;
}

.win-product {
  margin: 12px auto;
  width: 88px;
  height: 88px;
  border-radius: 14px;
  border: 2px solid var(--gold);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.3);
}

.win-product canvas,
.win-product img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reward-box {
  margin: 16px 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px dashed rgba(212, 175, 55, 0.5);
}

.reward-label {
  font-size: 0.75rem !important;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}

.reward-off {
  font-family: var(--font-display);
  font-size: 1.6rem !important;
  color: var(--gold) !important;
  font-weight: 700;
  margin: 4px 0 !important;
}

.coupon-code {
  font-family: ui-monospace, monospace;
  font-size: 1.15rem !important;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--gold-light) !important;
  margin: 0 !important;
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulseGold {
  0%, 100% { box-shadow: 0 8px 24px rgba(212, 175, 55, 0.4); }
  50% { box-shadow: 0 8px 36px rgba(212, 175, 55, 0.7); }
}

@keyframes urgentPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes bounceIn {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes countPop {
  0% { transform: scale(0.4); opacity: 0; }
  40% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
