/* ========================================================
   gemtalk PLAYGROUND - Main Platform Stylesheet
   Modern, Sleek, Bright Casual Game Platform
   ======================================================== */

:root {
  --primary-purple: #7c3aed;
  --primary-purple-light: #8b5cf6;
  --primary-blue: #2563eb;
  --primary-blue-light: #3b82f6;
  --primary-mint: #059669;
  --primary-mint-light: #10b981;
  --primary-pink: #ec4899;
  --primary-amber: #f59e0b;
  --primary-red: #ef4444;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverted: #ffffff;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 25px rgba(124, 58, 237, 0.25);

  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ========================================================
   Header
   ======================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-normal);
}

.header-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  cursor: pointer;
}

.logo-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-blue) 50%, var(--primary-mint) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  color: white;
  transition: transform var(--transition-bounce);
}
.logo-link:hover .logo-icon-wrap {
  transform: rotate(8deg) scale(1.08);
}

.logo-text-wrap {
  display: flex;
  flex-direction: column;
}

.brand-gemtalk {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--primary-purple), var(--primary-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-playground {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-item {
  padding: 0.5rem 0.9rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}
.nav-item:hover, .nav-item.active {
  color: var(--primary-purple);
  background: rgba(124, 58, 237, 0.08);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-bar-wrap {
  position: relative;
  width: 220px;
  transition: width var(--transition-normal);
}
.search-bar-wrap:focus-within {
  width: 280px;
}
.search-input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.2rem;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-card-subtle);
  outline: none;
  transition: all var(--transition-fast);
}
.search-input:focus {
  background: #ffffff;
  border-color: var(--primary-purple-light);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-clear-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  font-size: 0.85rem;
  padding: 2px;
}
.search-clear-btn.visible {
  display: block;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-btn:hover {
  background: var(--bg-card-subtle);
  color: var(--primary-purple);
  border-color: var(--border-hover);
}

/* ========================================================
   Main Content Layout
   ======================================================== */
.main-wrapper {
  flex: 1;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem 1.5rem;
}

/* ========================================================
   Hero Banner
   ======================================================== */
.hero-banner {
  position: relative;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #f5f3ff 0%, #eff6ff 50%, #ecfdf5 100%);
  border: 1px solid rgba(199, 210, 254, 0.5);
  padding: 3.5rem 2.5rem;
  margin-bottom: 2.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.hero-bg-art {
  position: absolute;
  right: -20px;
  bottom: -40px;
  width: 400px;
  height: 300px;
  opacity: 0.18;
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.12);
  color: var(--primary-purple);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.85rem;
}

.hero-title .highlight-purple {
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.12rem;
  color: var(--text-secondary);
  max-width: 620px;
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-blue) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  border-color: var(--primary-purple-light);
  color: var(--primary-purple);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-mint {
  background: linear-gradient(135deg, var(--primary-mint) 0%, #06b6d4 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-mint:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.hero-stats {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  border-top: 1px solid rgba(199, 210, 254, 0.6);
  padding-top: 1.25rem;
}

.hero-stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-stat-item svg {
  color: var(--primary-purple);
}

/* ========================================================
   Categories Bar
   ======================================================== */
.categories-section {
  margin-bottom: 2rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--bg-card-subtle);
  color: var(--text-secondary);
}

.category-tabs {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.category-tab:hover {
  border-color: var(--primary-purple-light);
  color: var(--primary-purple);
  background: #faf5ff;
}

.category-tab.active {
  background: var(--primary-purple);
  color: white;
  border-color: var(--primary-purple);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.28);
}

.category-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.tab-count {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
}

/* ========================================================
   Popular Games Spotlight Section
   ======================================================== */
.popular-section {
  margin-bottom: 2.5rem;
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.popular-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  overflow: hidden;
}
.popular-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-purple-light);
  box-shadow: var(--shadow-lg);
}

.popular-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.popular-card-info {
  flex: 1;
  min-width: 0;
}

.popular-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.popular-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hot-badge {
  font-size: 0.65rem;
  font-weight: 800;
  background: #fee2e2;
  color: #dc2626;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

/* ========================================================
   Game Cards Grid (All Games)
   ======================================================== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.game-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.game-card:hover {
  transform: translateY(-6px);
  border-color: rgba(124, 58, 237, 0.35);
  box-shadow: var(--shadow-xl);
}

.game-card-header {
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.game-icon-box {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-bounce);
}

.game-card:hover .game-icon-box {
  transform: scale(1.1) rotate(5deg);
}

.game-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.category-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.cat-random {
  background: #fdf2f8;
  color: #be185d;
}
.cat-speed {
  background: #eff6ff;
  color: #1d4ed8;
}
.cat-brain {
  background: #f5f3ff;
  color: #6d28d9;
}
.cat-party {
  background: #ecfdf5;
  color: #047857;
}

.game-card-body {
  padding: 0 1.5rem 1.25rem 1.5rem;
  flex: 1;
}

.game-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.game-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-record-pill {
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

.game-card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #fafaf9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-play-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.game-card:hover .game-play-btn {
  background: var(--primary-purple);
  color: white;
  border-color: var(--primary-purple);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.game-play-btn svg {
  transition: transform var(--transition-fast);
}
.game-card:hover .game-play-btn svg {
  transform: translateX(4px);
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-color);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}
.empty-state-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.empty-state-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ========================================================
   Game Play View (Stage Container)
   ======================================================== */
.game-view-container {
  display: none;
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.game-view-container.active {
  display: block;
}

.game-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.game-view-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.game-view-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.game-view-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.game-view-category {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.game-view-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-stage-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.game-instructions {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.2rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.game-instructions svg {
  color: var(--primary-purple);
  flex-shrink: 0;
}

/* ========================================================
   Footer
   ======================================================== */
.app-footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 1.5rem;
}

.footer-container {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.footer-brand-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-btn {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.footer-btn:hover {
  background: #ffffff;
  color: var(--primary-red);
  border-color: var(--primary-red);
}

/* ========================================================
   Modal / Toast UI
   ======================================================== */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-bounce);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* ========================================================
   Responsive Media Queries
   ======================================================== */
@media (max-width: 768px) {
  .header-container {
    padding: 0.75rem 1rem;
  }
  .search-bar-wrap {
    width: 140px;
  }
  .search-bar-wrap:focus-within {
    width: 190px;
  }
  .hero-banner {
    padding: 2rem 1.25rem;
    margin-bottom: 1.75rem;
  }
  .hero-title {
    font-size: 1.85rem;
  }
  .hero-subtitle {
    font-size: 0.95rem;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .games-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .game-stage-card {
    padding: 1.25rem;
    min-height: 440px;
  }
  .footer-container {
    flex-direction: column;
    text-align: center;
  }
}
