:root {
  --bg-1: #0a0b14;
  --bg-2: #1b0f2e;
  --bg-3: #0d1b2e;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-border: rgba(255, 255, 255, 0.1);
  --accent: #ffb020;
  --accent-2: #ff5f9e;
  --accent-3: #7c5cff;
  --text: #f6f6fb;
  --muted: #9aa0b8;

  --common: #9096a8;
  --rare: #4da3ff;
  --epic: #b56bff;
  --legendary: #ffb020;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg-1);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 176, 32, 0.18), transparent 42%),
    radial-gradient(circle at 88% 10%, rgba(124, 92, 255, 0.22), transparent 45%),
    radial-gradient(circle at 20% 90%, rgba(255, 95, 158, 0.16), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(77, 163, 255, 0.16), transparent 45%),
    linear-gradient(160deg, var(--bg-2), var(--bg-1) 45%, var(--bg-3) 100%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%, 100% 100%;
  animation: bg-drift 22s ease-in-out infinite;
}

@keyframes bg-drift {
  0%, 100% { background-position: 0% 0%, 100% 0%, 0% 100%, 100% 100%, 0 0; }
  50% { background-position: 20% 15%, 80% 20%, 15% 85%, 85% 80%, 0 0; }
}

h1, h2, h3 {
  font-family: "Baloo 2", "Inter", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  background: rgba(10, 11, 20, 0.55);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-shimmer 6s linear infinite;
}

@keyframes title-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.controls {
  display: flex;
  gap: 14px;
  align-items: center;
}

.controls button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.controls button:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.icon-btn {
  font-size: 18px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 28px;
}

.filter-chip {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.filter-chip:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.35);
  transform: translateY(-2px);
}

.filter-chip.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #1a1408;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(255, 95, 158, 0.35);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 72px;
  text-align: center;
}

.stat {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.3px;
  margin-bottom: 20px;
}

.stat span {
  color: var(--accent);
  font-weight: 700;
}

.reel-viewport {
  position: relative;
  overflow: hidden;
  height: 170px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015));
  border-radius: 20px;
  margin-bottom: 32px;
  box-shadow: inset 0 0 50px rgba(0,0,0,0.4);
  padding: 2px;
}

.reel-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 2px;
  background: conic-gradient(from var(--spin-angle, 0deg), var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-spin 4s linear infinite;
  opacity: 0.8;
  z-index: 1;
}

@keyframes border-spin {
  to { --spin-angle: 360deg; }
}

.reel-marker {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 3px;
  background: var(--text);
  box-shadow: 0 0 16px 3px rgba(255, 255, 255, 0.85);
  z-index: 3;
  transform: translateX(-50%);
  border-radius: 2px;
}

.reel-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100px;
  z-index: 2;
  pointer-events: none;
}
.reel-shadow.left { left: 0; background: linear-gradient(90deg, var(--bg-1), transparent); }
.reel-shadow.right { right: 0; background: linear-gradient(270deg, var(--bg-1), transparent); }

.reel {
  display: flex;
  gap: 12px;
  position: absolute;
  left: 0;
  top: 16px;
  will-change: transform;
  transition: filter 0.3s ease;
}

.reel.spinning {
  filter: blur(2px);
}

.reel-item {
  width: 118px;
  height: 134px;
  transition: transform 0.15s ease;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  flex: 0 0 auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.reel-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  opacity: 0.55;
  background: linear-gradient(180deg, var(--tier-color, var(--common)), transparent 55%);
  z-index: -1;
}

.reel-item.common { --tier-color: var(--common); }
.reel-item.rare { --tier-color: var(--rare); }
.reel-item.epic { --tier-color: var(--epic); }
.reel-item.legendary { --tier-color: var(--legendary); }

.reel-item img, .card-img {
  width: 86px;
  height: 64px;
  object-fit: cover;
  border-radius: 9px;
  background: #23263a;
}

.reel-item .name {
  font-size: 12px;
  text-align: center;
  color: var(--text);
}

.open-btn {
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 50%, var(--accent-3));
  background-size: 220% auto;
  color: #1a1408;
  border: none;
  padding: 18px 48px;
  font-size: 18px;
  font-weight: 800;
  font-family: "Baloo 2", sans-serif;
  letter-spacing: 0.6px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(255, 95, 158, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: btn-pulse 2.4s ease-in-out infinite, btn-gradient 5s ease infinite;
}

@keyframes btn-gradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.open-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transform: skewX(-20deg);
  animation: btn-shine 2.8s ease-in-out infinite;
}

@keyframes btn-shine {
  0% { left: -60%; }
  55%, 100% { left: 130%; }
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(255, 95, 158, 0.4); }
  50% { box-shadow: 0 10px 40px rgba(255, 176, 32, 0.6); }
}

.open-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 36px rgba(255, 95, 158, 0.5);
}

.open-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  animation: none;
}

.result {
  margin-top: 36px;
  animation: fadeUp 0.4s ease;
}

.result h2 {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 14px;
  font-weight: 500;
}

.result-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 22px 32px;
  border-radius: 20px;
  gap: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03), 0 0 50px var(--tier-glow, transparent);
  animation: result-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes result-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-card.common { --tier-glow: rgba(144, 150, 168, 0.3); }
.result-card.rare { --tier-glow: rgba(77, 163, 255, 0.4); }
.result-card.epic { --tier-glow: rgba(181, 107, 255, 0.45); }
.result-card.legendary { --tier-glow: rgba(255, 176, 32, 0.55); }

.result-card img {
  width: 190px;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
}

.result-card div:nth-of-type(1) {
  font-size: 19px;
  font-weight: 700;
}

.dish-list {
  margin-top: 52px;
  text-align: left;
}

.dish-list h3 {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 18px;
  perspective: 700px;
}

.dish-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  transform-style: preserve-3d;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.35s ease both;
  animation-delay: var(--delay, 0ms);
}

.dish-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(255, 255, 255, 0.14) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.5s ease;
  pointer-events: none;
}

.dish-card:hover::after {
  transform: translateX(120%);
}

.dish-card:hover {
  border-color: var(--tier-color, var(--panel-border));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.dish-card.common { --tier-color: var(--common); }
.dish-card.rare { --tier-color: var(--rare); }
.dish-card.epic { --tier-color: var(--epic); }
.dish-card.legendary { --tier-color: var(--legendary); }

.dish-card .card-img {
  width: 100%;
  height: 78px;
  margin-bottom: 8px;
  transition: transform 0.25s ease;
}

.dish-card:hover .card-img {
  transform: scale(1.08);
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: 40%;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall 1.4s ease-out forwards;
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), 60vh) rotate(var(--rot)); opacity: 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; gap: 12px; align-items: flex-start; }
  .controls { flex-wrap: wrap; }
}
