/* ══════════════════════════════════════════════════════
   Kotmale Dairies – Match & Win
   Brand:  #313a95 (blue) | #aed137 (green) | #fdfdfd (white)
══════════════════════════════════════════════════════ */

/* ── RESET & TOKENS ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:   #313a95;
  --blue-d: #1e2460;
  --blue-l: #4a56c4;
  --green:  #aed137;
  --green-d:#8db028;
  --white:  #fdfdfd;
  --bg:     #0b0e3a;
  --red:    #e83737;

  --header-h: 90px;
  --footer-h: 110px;
  --frame-w:  340px;
  --frame-h:  240px;
  --radius:   22px;
  --shadow:   0 10px 50px rgba(0,0,0,.55);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--white);
  user-select: none;
}

/* ── HEADER ──────────────────────────────────────────── */
#header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--blue-d) 0%, var(--blue) 100%);
  border-bottom: 3px solid var(--green);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  z-index: 10;
  box-shadow: 0 4px 30px rgba(0,0,0,.5);
}

#brand-logo {
  height: 64px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(174,209,55,.4));
}

/* ── TIMER RING ──────────────────────────────────────── */
#timer-wrap {
  position: relative;
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}

#timer-label {
  position: absolute;
  top: -20px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 2px; color: var(--green);
  text-transform: uppercase;
  white-space: nowrap;
}

#timer-display {
  position: absolute;
  display: flex; align-items: baseline; gap: 2px;
  z-index: 2;
}

#timer-value {
  font-size: 30px; font-weight: 900;
  color: var(--white);
  transition: color .3s;
  line-height: 1;
}

#timer-unit { font-size: 13px; font-weight: 700; color: var(--green); }

#timer-ring {
  position: absolute; top: 0; left: 0;
  width: 80px; height: 80px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,.12);
  stroke-width: 7;
}

#ring-progress {
  fill: none;
  stroke: var(--green);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .5s linear, stroke .3s;
}

/* ── STAGE ───────────────────────────────────────────── */
#stage {
  position: fixed;
  top: var(--header-h);
  bottom: var(--footer-h);
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(49,58,149,.3) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 50%, rgba(174,209,55,.08) 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
}

/* Subtle grid */
#stage::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

/* ── IDLE OVERLAY ────────────────────────────────────── */
#idle-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  z-index: 5;
  transition: opacity .4s;
}

#idle-icon { font-size: 70px; animation: float 3s ease-in-out infinite; }

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

#idle-text  { font-size: 28px; font-weight: 600; color: rgba(255,255,255,.75); }
#idle-text strong { color: var(--green); }
#idle-hint  { font-size: 15px; font-weight: 500; color: rgba(255,255,255,.35); letter-spacing: 1px; }

/* ── GAME AREA ───────────────────────────────────────── */
#game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  opacity: 0;
  transform: scale(.93);
  transition: opacity .5s, transform .5s;
  pointer-events: none;
}

#game-area.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

/* ── SECTION LABELS ──────────────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-bottom: 8px;
}

.label-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

/* Animated dot for spinning state */
.spinning-dot {
  background: var(--green);
  animation: dot-pulse 0.8s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .3; transform: scale(.6); }
}

/* ── IMAGE FRAMES ────────────────────────────────────── */
#top-frame,
#bot-frame {
  position: relative;
  width: var(--frame-w);
  height: var(--frame-h);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--blue-d);
  box-shadow: var(--shadow);
}

/* Static TOP frame */
#top-frame {
  border: 3px solid rgba(174,209,55,.45);
}

/* Active BOTTOM slot */
#bot-frame {
  border: 3px solid rgba(255,255,255,.15);
}

#bot-frame.spinning {
  border-color: rgba(174,209,55,.3);
}

/* Lock badge on top frame */
.lock-badge {
  position: absolute;
  top: 10px; right: 12px;
  font-size: 18px;
  opacity: .7;
  z-index: 4;
}

/* Shine overlay */
.frame-shine {
  position: absolute; inset: 0;
  background: linear-gradient(135deg,
    rgba(255,255,255,.09) 0%,
    transparent 50%,
    rgba(0,0,0,.12) 100%);
  pointer-events: none;
  z-index: 3;
  border-radius: inherit;
}

/* Scan-lines on bottom slot for slot-machine feel */
.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,.06) 3px,
    rgba(0,0,0,.06) 4px
  );
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
}

/* Top image */
#top-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── BOTTOM SLOT TRACK ───────────────────────────────── */
#bot-track {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

#bot-track img {
  width: 100%;
  height: var(--frame-h);   /* each card = frame height */
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

/* ── DIVIDER ─────────────────────────────────────────── */
#divider {
  position: relative;
  width: var(--frame-w);
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}

#divider-line {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--green) 25%,
    var(--green) 75%,
    transparent 100%);
  box-shadow: 0 0 14px rgba(174,209,55,.7);
}

#divider-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px 4px rgba(174,209,55,.5);
  z-index: 1;
}

#divider-arrows {
  position: absolute;
  bottom: 2px;
  font-size: 9px;
  letter-spacing: 4px;
  color: rgba(174,209,55,.4);
  animation: arrows-blink 1s step-start infinite;
}

@keyframes arrows-blink {
  0%,100% { opacity: .4; }
  50%      { opacity: .9; }
}

/* ── WIN GLOW on frames ──────────────────────────────── */
#top-frame.win-glow,
#bot-frame.win-glow {
  border-color: var(--green);
  box-shadow: var(--shadow),
    0 0 30px rgba(174,209,55,.7),
    0 0 80px rgba(174,209,55,.25);
  animation: win-pulse 1.2s ease-in-out infinite;
}

@keyframes win-pulse {
  0%,100% { box-shadow: var(--shadow), 0 0 30px rgba(174,209,55,.6), 0 0 80px rgba(174,209,55,.2); }
  50%      { box-shadow: var(--shadow), 0 0 55px rgba(174,209,55,.95), 0 0 130px rgba(174,209,55,.4); }
}

/* ── FOOTER ──────────────────────────────────────────── */
#controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  background: linear-gradient(to top, rgba(13,16,64,1), rgba(13,16,64,.85));
  border-top: 2px solid rgba(174,209,55,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 50px;
}

.ctrl-btn {
  min-width: 210px;
  height: 68px;
  border: none;
  border-radius: 50px;
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .2s, opacity .3s;
}

.ctrl-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  transition: opacity .2s;
  border-radius: inherit;
}

.ctrl-btn:active:not(:disabled)::after { opacity: 1; }
.ctrl-btn:hover:not(:disabled)  { transform: translateY(-3px); }
.ctrl-btn:active:not(:disabled) { transform: translateY(0); }

.ctrl-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon { font-size: 18px; }

.start-btn {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-d) 100%);
  color: var(--blue-d);
  box-shadow: 0 6px 30px rgba(174,209,55,.45);
}
.start-btn:hover:not(:disabled) { box-shadow: 0 10px 40px rgba(174,209,55,.65); }

.stop-btn {
  background: linear-gradient(135deg, var(--blue-l) 0%, var(--blue) 100%);
  color: var(--white);
  box-shadow: 0 6px 30px rgba(49,58,149,.5);
  border: 2px solid rgba(255,255,255,.18);
}
.stop-btn:hover:not(:disabled) { box-shadow: 0 10px 40px rgba(49,58,149,.75); }

/* Pulse ring on active STOP button */
.stop-btn.pulsing::before {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 60px;
  border: 3px solid var(--green);
  animation: pulse-ring 1.2s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* ── MODAL BACKDROP ──────────────────────────────────── */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,8,40,.88);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}

#modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

#result-modal {
  background: linear-gradient(150deg, #1c2380, #0d1040);
  border-radius: 32px;
  padding: 46px 56px;
  min-width: 480px;
  max-width: 560px;
  text-align: center;
  border: 2px solid rgba(174,209,55,.25);
  box-shadow: 0 24px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.05);
  transform: scale(.8);
  transition: transform .45s cubic-bezier(.34,1.56,.64,1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#modal-backdrop.open #result-modal {
  transform: scale(1);
}

.modal-section { display: none; flex-direction: column; align-items: center; gap: 12px; }
.modal-section.active { display: flex; }

/* ── WIN ── */
#modal-backdrop.modal-win #result-modal {
  border-color: var(--green);
  box-shadow:
    0 24px 80px rgba(0,0,0,.7),
    0 0 80px rgba(174,209,55,.35),
    0 0 160px rgba(174,209,55,.12);
}

#result-icon { font-size: 72px; }
#modal-backdrop.modal-win #result-icon { animation: bounce-in .6s cubic-bezier(.34,1.56,.64,1); }

@keyframes bounce-in {
  0%   { transform: scale(0) rotate(-20deg); }
  100% { transform: scale(1) rotate(0deg); }
}

#result-title {
  font-size: 52px; font-weight: 900;
  letter-spacing: 1px; line-height: 1;
  color: var(--green);
}

#result-sub {
  font-size: 17px; font-weight: 600;
  color: rgba(255,255,255,.55);
  letter-spacing: .5px;
}

/* Full product image in WIN */
#full-img-wrap {
  position: relative;
  width: 240px;
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid var(--green);
  box-shadow: 0 0 40px rgba(174,209,55,.45);
  animation: img-pop .5s .2s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes img-pop {
  0%   { transform: scale(.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#full-product-img {
  width: 100%;
  display: block;
  object-fit: cover;
}

#full-img-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(174,209,55,.18) 0%, transparent 70%);
  pointer-events: none;
}

/* ── LOSE ── */
#modal-backdrop.modal-lose #result-modal {
  border-color: var(--red);
  box-shadow: 0 24px 80px rgba(0,0,0,.7), 0 0 60px rgba(232,55,55,.25);
  animation: shake .5s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0) scale(1); }
  15%      { transform: translateX(-14px) scale(1); }
  30%      { transform: translateX(14px) scale(1); }
  45%      { transform: translateX(-10px) scale(1); }
  60%      { transform: translateX(10px) scale(1); }
  75%      { transform: translateX(-5px) scale(1); }
}

#lose-icon  { font-size: 72px; }
#lose-title { font-size: 52px; font-weight: 900; letter-spacing: 1px; color: var(--red); }
#lose-sub   { font-size: 17px; font-weight: 600; color: rgba(255,255,255,.5); }

/* Lose comparison images */
#lose-compare {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.compare-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.compare-item img {
  width: 110px;
  height: 80px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.2);
}

.compare-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
}

#compare-x {
  font-size: 36px;
  font-weight: 900;
  color: var(--red);
  text-shadow: 0 0 20px rgba(232,55,55,.6);
}

/* ── THANK YOU & RESTART ─────────────────────────────── */
#thankyou-msg {
  font-size: 18px; font-weight: 700;
  color: rgba(255,255,255,.45);
  letter-spacing: 1px;
}

#btn-restart {
  padding: 13px 38px;
  border-radius: 50px;
  border: 2px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.45);
  font-family: 'Outfit', sans-serif;
  font-size: 14px; font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all .2s;
}

#btn-restart:hover {
  background: rgba(255,255,255,.12);
  color: var(--white);
  border-color: rgba(255,255,255,.38);
}

/* ── TIMER WARNINGS ──────────────────────────────────── */
.timer-warn   #timer-value { color: #ffcc00; }
.timer-urgent #timer-value { color: #ff4444; animation: blink .5s step-end infinite; }
.timer-warn   #ring-progress { stroke: #ffcc00; }
.timer-urgent #ring-progress { stroke: #ff4444; }

@keyframes blink {
  0%,100% { opacity: 1; } 50% { opacity: 0; }
}

/* ── CONFETTI ────────────────────────────────────────── */
.confetti {
  position: fixed;
  pointer-events: none;
  z-index: 99;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-10px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
