* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Georgia', 'Times New Roman', serif;
}

body {
  background: url('background.webp') center/cover no-repeat;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vmin;
  width: min(82vh, 92vw);
}

#board-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: url('board.webp') center/contain no-repeat;
  border-radius: 3%;
  overflow: hidden;
}

#board-grid {
  position: absolute;
  top: 4%;
  bottom: 4%;
  left: 4%;
  right: 4%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 0;
  touch-action: none;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 14%;
  transition: background 0.15s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.cell:not(.empty):hover {
  background: rgba(255, 255, 255, 0.25);
}

.cell img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.25));
  transition: transform 0.18s;
}

.cell:not(.empty):hover img {
  transform: scale(1.06);
}

.cell.selected {
  background: rgba(255, 215, 80, 0.55);
  box-shadow: inset 0 0 0 3px rgba(255, 200, 0, 0.95);
  animation: pulse 0.9s infinite alternate;
}

.cell.selected img {
  transform: scale(1.12);
}

.cell.swipe-path {
  background: rgba(120, 230, 120, 0.55);
  box-shadow: inset 0 0 0 3px rgba(60, 200, 60, 0.95);
}

.cell.swipe-path img {
  transform: scale(1.12);
}

@keyframes pulse {
  from { box-shadow: inset 0 0 0 3px rgba(255, 200, 0, 0.7), 0 0 10px 2px rgba(255, 215, 0, 0.4); }
  to   { box-shadow: inset 0 0 0 3px rgba(255, 200, 0, 1),   0 0 22px 6px rgba(255, 215, 0, 0.9); }
}

.cell.spawn img { animation: spawnAnim 0.45s ease-out; }
@keyframes spawnAnim {
  0%   { transform: scale(0)   rotate(-180deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(10deg);   opacity: 1; }
  100% { transform: scale(1)   rotate(0);       opacity: 1; }
}

.cell.hint img { animation: hintWiggle 0.6s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes hintWiggle {
  0%, 100% { transform: rotate(-10deg) scale(1.08); }
  50%      { transform: rotate(10deg)  scale(1.08); }
}

#hud {
  position: relative;
  width: 100%;
  height: 14vmin;
  display: flex;
  flex-direction: row;
  gap: 4%;
  align-items: center;
  justify-content: center;
}

#juicer-btn {
  height: 100%;
  aspect-ratio: 1;
  border-radius: 10%;
  background: white;
  border: none;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.35),
    inset 0 0 0 5px #fff,
    inset 0 0 0 6px rgba(0,0,0,0.05);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.2s;
  position: relative;
}

#juicer-btn:hover { transform: scale(1.06); }
#juicer-btn:active { transform: scale(0.94); }
#juicer-btn.disabled { opacity: 0.55; cursor: not-allowed; }
#juicer-btn.disabled:hover { transform: none; }

#juicer-btn img {
  width: 84%;
  height: 84%;
  object-fit: contain;
  pointer-events: none;
  transition: opacity 0.3s;
}

#progress-container {
  width: 50%;
  height: 40%;
  background: rgba(255,255,255,0.45);
  border-radius: 1000px;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.7),
    0 4px 12px rgba(0,0,0,0.25);
}

#progress-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(to right, #ff5d8f 0%, #ffa15c 40%, #ffd93d 70%, #6bcf7f 100%);
  border-radius: 1000px;
  width: 0%;
  transition: width 0.5s cubic-bezier(.16,.84,.44,1);
  box-shadow: 0 0 12px rgba(255, 200, 80, 0.6);
}

#progress-fill::after {
  content: '';
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 30%;
  background: linear-gradient(to right, rgba(255,255,255,0.55), transparent);
  border-radius: 1000px 0 0 1000px;
}

#win-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,107,157,0.92) 0%, rgba(40,10,60,0.97) 80%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: clamp(12px, 3vh, 30px);
  z-index: 100;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s;
  padding: clamp(12px, 3vh, 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#win-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

#win-overlay h1 {
  font-size: clamp(2.25rem, min(13vw, 11vh), 8rem);
  margin: 0;
  color: #ffd93d;
  text-shadow:
    0 0 30px rgba(255,217,61,0.9),
    0 0 60px rgba(255,217,61,0.6),
    0 4px 10px rgba(0,0,0,0.5);
  letter-spacing: 0.05em;
  animation: titleIn 1s cubic-bezier(.16,1,.3,1);
  text-align: center;
}

@keyframes titleIn {
  from { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1)   rotate(0);     opacity: 1; }
}

.coupon {
  padding: clamp(18px, 4vw, 30px) clamp(24px, 7vw, 50px);
  background: white;
  color: #d8336c;
  border-radius: 22px;
  text-align: center;
  border: 4px dashed #ff6b9d;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  animation: couponIn 1.2s cubic-bezier(.16,1,.3,1) 0.3s both;
  max-width: 90vw;
  flex-shrink: 0;
}

@keyframes couponIn {
  from { transform: translateY(60px) rotate(-3deg) scale(0.85); opacity: 0; }
  to   { transform: translateY(0)    rotate(0)    scale(1);    opacity: 1; }
}

.coupon-percent {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: bold;
  line-height: 1;
  background: linear-gradient(135deg, #ff5d8f, #ff8e3c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.coupon-label {
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  margin-top: 8px;
  color: #444;
  font-style: italic;
}

.coupon-code {
  margin-top: 18px;
  padding: 10px 22px;
  background: #fff7e0;
  border: 2px dashed #d8336c;
  border-radius: 10px;
  font-family: 'Courier New', monospace;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: #d8336c;
  letter-spacing: 0.15em;
  font-weight: bold;
  display: inline-block;
}

#replay-btn {
  margin-top: 8px;
  padding: 12px 32px;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.7);
  color: white;
  border-radius: 30px;
  font-family: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
#replay-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.05);
}

.cell.disabled {
  pointer-events: none;
  background: transparent !important;
}
