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

:root {
  --bg-dark: #0a0e17;
  --bg-card: #131a2b;
  --bg-card-hover: #1a2340;
  --accent-gold: #d4a942;
  --accent-red: #e8637a;
  --accent-green: #4ade80;
  --accent-blue: #60a5fa;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255,255,255,0.06);
  --glow-gold: 0 0 20px rgba(212,169,66,0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --header-bg: rgba(10, 14, 23, 0.85);
  --slider-bg: rgba(10,14,23,0.9);
  --intro-bg-1: #1a1f35;
  --intro-bg-2: #0a0e17;
}

[data-theme="light"] {
  --bg-dark: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f5;
  --accent-gold: #b8892e;
  --text-primary: #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border: rgba(0,0,0,0.08);
  --glow-gold: 0 0 20px rgba(184,137,46,0.2);
  --header-bg: rgba(240, 242, 245, 0.9);
  --slider-bg: rgba(240,242,245,0.95);
  --intro-bg-1: #e8e0d0;
  --intro-bg-2: #f0f2f5;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== INTRO / OKEY 101 ANIMATION ===== */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse at center, var(--intro-bg-1) 0%, var(--intro-bg-2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.intro-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.intro-content {
  text-align: center;
}

.okey-tiles-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 30px;
  perspective: 800px;
}

.okey-tile {
  width: 65px;
  height: 90px;
  background: linear-gradient(145deg, #f5f0e1, #e8dcc8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.2rem;
  color: #1a1a2e;
  font-weight: 700;
  box-shadow:
    0 4px 15px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 0 0 2px rgba(212,169,66,0.5);
  opacity: 0;
  transform: rotateY(180deg) scale(0.5);
  animation: tileFlip 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.tile-1 { animation-delay: 0.2s; color: #1a1a2e; }
.tile-2 { animation-delay: 0.4s; color: #1a1a2e; }
.tile-3 { animation-delay: 0.6s; color: #1a1a2e; }
.tile-4 { animation-delay: 0.8s; color: #1a1a2e; }

@keyframes tileFlip {
  0%   { opacity: 0; transform: rotateY(180deg) scale(0.5) translateY(40px); }
  60%  { transform: rotateY(-10deg) scale(1.1) translateY(-10px); }
  100% { opacity: 1; transform: rotateY(0deg) scale(1) translateY(0); }
}

.intro-score {
  opacity: 0;
  animation: scoreReveal 0.8s ease forwards;
  animation-delay: 1.2s;
}

.score-line {
  font-family: 'Orbitron', monospace;
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-gold), #f0d78c, var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 12px;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(212,169,66,0.4));
}

.score-sub {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  color: var(--text-secondary);
  letter-spacing: 8px;
  margin-top: 4px;
}

@keyframes scoreReveal {
  0%   { opacity: 0; transform: scale(0.8); }
  50%  { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

.intro-tagline {
  margin-top: 35px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
  animation-delay: 1.8s;
}

@keyframes fadeUp {
  0%   { opacity: 0; transform: translateY(15px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Okey tile shimmer effect */
.okey-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.3) 45%,
    rgba(255,255,255,0.5) 50%,
    rgba(255,255,255,0.3) 55%,
    transparent 60%
  );
  opacity: 0;
  animation: shimmer 2s ease-in-out infinite;
  animation-delay: 1.5s;
}

@keyframes shimmer {
  0%, 100% { opacity: 0; transform: translateX(-100%); }
  50% { opacity: 1; transform: translateX(100%); }
}

/* ===== APP CONTAINER ===== */
.app {
  max-width: 700px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

@media (min-width: 768px) {
  .app {
    max-width: 900px;
  }
  .menu-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .menu-item {
    margin-bottom: 0;
  }
}

@media (min-width: 1200px) {
  .app {
    max-width: 1100px;
  }
  .menu-items {
    grid-template-columns: repeat(3, 1fr);
  }
}

.app.hidden {
  opacity: 0;
  pointer-events: none;
}

.app.visible {
  opacity: 1;
  pointer-events: auto;
  animation: appIn 0.8s ease forwards;
}

@keyframes appIn {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 20px 12px;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212,169,66,0.05), transparent);
  pointer-events: none;
}

.header-content {
  position: relative;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.logo-img {
  height: 56px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-gold), #b8892e);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: var(--glow-gold);
}

.dice {
  animation: diceFloat 3s ease-in-out infinite;
}

@keyframes diceFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(5deg); }
}

.logo-text h1 {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-gold), #f0d78c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.logo-text .subtitle {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 4px;
}

/* ===== SEARCH BAR ===== */
.search-wrapper {
  position: relative;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  height: 44px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.search-bar:focus-within {
  border-color: rgba(212,169,66,0.4);
  box-shadow: 0 0 0 3px rgba(212,169,66,0.1);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 0 10px;
  font-family: 'Inter', sans-serif;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.clear-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.clear-btn:hover {
  background: rgba(255,255,255,0.2);
}

.clear-btn.hidden {
  display: none;
}

/* ===== CATEGORY SLIDER ===== */
.category-slider {
  position: sticky;
  top: var(--header-height, 120px);
  z-index: 90;
  background: var(--slider-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.slider-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 20px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
}

.slider-track::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 50px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.category-chip .chip-icon {
  font-size: 1rem;
}

.category-chip:hover {
  background: var(--bg-card-hover);
}

.category-chip.active {
  background: linear-gradient(135deg, var(--accent-gold), #b8892e);
  color: #0a0e17;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(212,169,66,0.3);
  transform: scale(1.03);
}

/* ===== MENU CONTENT ===== */
.menu-content {
  padding: 20px 20px 0;
}

.menu-section {
  margin-bottom: 32px;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.menu-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.35rem;
  letter-spacing: 1.5px;
  color: var(--text-primary);
}

.section-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ===== MENU ITEMS ===== */
.menu-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
  /* Okey card-deal animation */
  opacity: 0;
  transform: translateX(-30px) scale(0.95);
  animation: cardDeal 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.menu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.menu-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.1);
}

.menu-item:hover::before {
  opacity: 1;
}

@keyframes cardDeal {
  0%   { opacity: 0; transform: translateX(-30px) scale(0.95) rotateY(15deg); }
  60%  { transform: translateX(4px) scale(1.01) rotateY(-2deg); }
  100% { opacity: 1; transform: translateX(0) scale(1) rotateY(0); }
}

.item-image {
  width: 50px;
  height: auto;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
  margin-right: 12px;
}

.item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.item-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.option-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(139,92,246,0.1);
  color: #a78bfa;
  white-space: nowrap;
}

.option-tag em {
  font-style: normal;
  color: #d4a942;
  font-weight: 600;
}

.item-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-name {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
  line-height: 1.3;
}

.item-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 3px 10px;
  border-radius: 20px;
  width: fit-content;
  margin-top: 3px;
  box-shadow: 0 0 8px rgba(0,0,0,0.15);
  animation: badgePulse 2.5s ease-in-out infinite;
}

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

.item-badge.popular {
  background: rgba(96,165,250,0.15);
  color: var(--accent-blue);
}

.item-badge.new {
  background: rgba(74,222,128,0.15);
  color: var(--accent-green);
}

.item-badge.special {
  background: rgba(232,99,122,0.15);
  color: var(--accent-red);
}

.item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.item-price {
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-gold);
}

.item-price-large {
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.size-labels {
  display: flex;
  gap: 10px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== SEARCH RESULTS ===== */
.search-results {
  padding: 20px;
  min-height: 60vh;
}

.search-results.hidden {
  display: none;
}

.search-results-header {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.search-results-list .menu-item {
  margin-bottom: 8px;
}

.search-results-list .result-category {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 3px;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-results .no-results-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.no-results p {
  font-size: 0.95rem;
}

/* highlight matching text */
mark {
  background: rgba(212,169,66,0.3);
  color: var(--accent-gold);
  border-radius: 2px;
  padding: 0 1px;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 40px 20px 60px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.footer-dice {
  font-size: 2rem;
  margin-bottom: 10px;
}

.footer p {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-gold);
  letter-spacing: 2px;
}

.footer span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

.footer-powered {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

.footer-powered a {
  color: var(--accent-gold);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent-gold), #f0d78c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: filter 0.2s;
}

.footer-powered a:hover {
  filter: brightness(1.3);
}

/* ===== SCROLL TO TOP ===== */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--accent-gold);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s, background 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top:hover {
  background: var(--accent-gold);
  color: #0a0e17;
  border-color: var(--accent-gold);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Light mode overrides */
[data-theme="light"] .logo-text h1 {
  background: linear-gradient(135deg, #8a6820, #b8892e);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="light"] .score-line {
  background: linear-gradient(135deg, #8a6820, #b8892e, #8a6820);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="light"] .okey-tile {
  background: linear-gradient(145deg, #fff, #f0ead8);
  box-shadow:
    0 4px 15px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 0 0 2px rgba(184,137,46,0.4);
}

[data-theme="light"] .category-chip {
  background: #fff;
  border-color: rgba(0,0,0,0.1);
  color: var(--text-secondary);
}

[data-theme="light"] .category-chip.active {
  background: linear-gradient(135deg, var(--accent-gold), #d4a942);
  color: #fff;
}

[data-theme="light"] .search-bar {
  background: #fff;
  border-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .menu-item {
  border-color: rgba(0,0,0,0.06);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

[data-theme="light"] .footer-powered a {
  background: linear-gradient(135deg, #8a6820, #b8892e);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="light"] .header-bg {
  background: linear-gradient(135deg, rgba(184,137,46,0.05), transparent);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 360px) {
  .okey-tile { width: 55px; height: 75px; font-size: 1.8rem; }
  .score-line { font-size: 2.8rem; }
  .category-chip { padding: 7px 12px; font-size: 0.75rem; }
}

/* ===== SCROLL ANIMATION UTILITY ===== */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }
.stagger-9 { animation-delay: 0.45s; }
.stagger-10 { animation-delay: 0.5s; }
.stagger-11 { animation-delay: 0.55s; }
.stagger-12 { animation-delay: 0.6s; }

/* ===== PARTICLE BURST (okey win effect) ===== */
.particle {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  border-radius: 2px;
  animation: particleBurst 1s ease-out forwards;
}

@keyframes particleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0);
  }
}
