@import url('https://fonts.googleapis.com/css2?family=Chivo:wght@400;600;700&family=Manrope:wght@500;700&display=swap');

:root {
  --bg-1: #ffb4d9;
  --bg-2: #a7c5ff;
  --bg-3: #ffe7a1;
  --cookie-1: #f6c27a;
  --cookie-2: #e19b4c;
  --cookie-3: #f8d9a6;
  --accent: #ff6fa6;
  --gold: #f6e27f;
  --gold-deep: #d8a300;
  --paper: #fffaf0;
  --paper-edge: #f1e2c4;
  --text: #1d1b2b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', 'Chivo', 'Segoe UI', sans-serif;
  color: var(--text);
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.25), transparent 30%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
}

.background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

.container {
  position: relative;
  z-index: 2;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 18px 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #1e132d;
}

.logo {
  font-size: clamp(1.2rem, 2.8vw, 1.7rem);
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
}

.counter {
  font-size: 0.95rem;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.1);
  color: #1c1033;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.cookie-area {
  position: relative;
  display: grid;
  place-items: center;
  width: min(90vw, 520px);
  height: min(75vh, 520px);
}

.cookie {
  position: relative;
  width: clamp(180px, 40vw, 240px);
  height: clamp(140px, 32vw, 180px);
  cursor: pointer;
  filter: drop-shadow(0 18px 35px rgba(0, 0, 0, 0.25));
  animation: float 3s ease-in-out infinite;
  transition: transform 0.6s ease, filter 0.4s ease;
}

.cookie:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.7);
  outline-offset: 6px;
}

.cookie.bounce {
  animation: bounce 1.4s ease-in-out infinite;
}

.cookie.spin {
  animation: spin 0.7s linear;
}

.cookie.open {
  animation: none;
}

.cookie-half {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 35%, #fff0c9 8%, transparent 12%),
    radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.7) 12%, transparent 18%),
    linear-gradient(145deg, var(--cookie-1), var(--cookie-2) 55%, var(--cookie-3));
  border-radius: 50% 50% 46% 54% / 60% 52% 48% 40%;
  box-shadow: inset -12px -16px 20px rgba(0, 0, 0, 0.12);
  transition: transform 0.7s cubic-bezier(0.22, 0.68, 0.24, 1.15), filter 0.4s ease;
}

.cookie-half::after {
  content: '';
  position: absolute;
  inset: 32% 20%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.08), transparent 70%);
  filter: blur(6px);
  transform: rotate(-10deg);
}

.cookie-half.left {
  clip-path: polygon(0 0, 52% 0, 52% 100%, 0 100%);
  transform-origin: 70% 50%;
}

.cookie-half.right {
  clip-path: polygon(48% 0, 100% 0, 100% 100%, 48% 100%);
  transform-origin: 30% 50%;
}

.cookie-core {
  position: absolute;
  inset: 38% 44%;
  background: radial-gradient(ellipse at 30% 30%, #f9e3b5 10%, #dea15a 55%, #c58036 80%);
  border-radius: 50%;
  box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.25);
  transition: opacity 0.5s ease;
}

.shine {
  position: absolute;
  inset: 10% 18%;
  background: radial-gradient(circle at 25% 15%, rgba(255, 255, 255, 0.55), transparent 35%);
  opacity: 0.8;
  pointer-events: none;
}

.cookie.open .left {
  transform: translate(-90px, -14px) rotate(-26deg);
}

.cookie.open .right {
  transform: translate(90px, -14px) rotate(26deg);
}

.cookie.open .cookie-core {
  opacity: 0;
}

.cookie:hover {
  transform: translateY(-6px) scale(1.02);
  filter: drop-shadow(0 22px 42px rgba(0, 0, 0, 0.3));
}

.scroll {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translate(-50%, 12px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.23, 0.92, 0.26, 1.2), opacity 0.8s ease;
}

.scroll.show {
  opacity: 1;
  transform: translate(-50%, -14px) scale(1);
}

.scroll-paper {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  background: linear-gradient(90deg, #fff6e3, var(--paper), #fff6e3);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: clamp(260px, 60vw, 420px);
  padding: 12px 18px;
  border: 2px solid var(--paper-edge);
}

.scroll-end {
  width: 26px;
  height: 62px;
  background: radial-gradient(ellipse at 50% 40%, #f5dcb0, #e9c98f 70%, #cfa56e);
  border-radius: 14px;
  box-shadow: inset -2px -4px 6px rgba(0, 0, 0, 0.12);
}

.scroll-end.left-end {
  margin-right: 10px;
}

.scroll-end.right-end {
  margin-left: 10px;
}

.scroll-content {
  text-align: center;
  padding: 6px 10px;
}

.fortune-text {
  font-size: clamp(0.98rem, 2.2vw, 1.2rem);
  font-weight: 700;
  line-height: 1.35;
}

.scroll.golden .scroll-paper {
  background: linear-gradient(90deg, #fff3d8, #ffe9a9, #fff3d8);
  border-color: #f1c04d;
  box-shadow: 0 16px 45px rgba(255, 196, 53, 0.45);
}

.scroll.golden .fortune-text {
  color: #b57b00;
  text-shadow: 0 0 12px rgba(255, 230, 150, 0.8);
}

.scroll.golden .scroll-end {
  background: radial-gradient(ellipse at 50% 40%, #ffe9a3, #f4c54d 70%, #c18e20);
}

.btn {
  border: none;
  background: linear-gradient(120deg, #ff7db7, #ff9c6f);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 22px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(255, 103, 161, 0.35);
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(255, 103, 161, 0.45);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.hint {
  font-size: 0.9rem;
  color: rgba(20, 12, 42, 0.76);
}

.loading-ring {
  position: absolute;
  width: clamp(230px, 45vw, 280px);
  height: clamp(230px, 45vw, 280px);
  border-radius: 50%;
  border: 6px dashed rgba(255, 255, 255, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-ring::after {
  content: '';
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.7);
  animation: blink 1s ease-in-out infinite;
}

.loading-ring.active {
  display: flex;
}

.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #fff 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  opacity: 0.9;
  animation: drift var(--t) linear infinite;
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px) scale(1.02); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { transform: scale(0.96); opacity: 0.75; }
  50% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(0.96); opacity: 0.75; }
}

@keyframes blink {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0); opacity: 0.8; }
  50% { opacity: 1; }
  100% { transform: translate3d(var(--x), 120vh, 0); opacity: 0; }
}

@media (max-width: 640px) {
  .hud { flex-direction: column; gap: 10px; }
  .cookie-area { height: 68vh; }
  .scroll-paper { min-width: 240px; }
  .btn { width: 100%; }
}
