:root {
  --pink: #ffb6d9;
  --pink-dark: #ff87c2;
  --pink-deep: #e86aa8;
  --blue: #a8d8ff;
  --blue-dark: #7ac0fa;
  --text: #2d2d3f;
  --text-light: #8888a0;
  --gradient: linear-gradient(135deg, var(--pink), var(--blue));
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --nav-height: 64px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  line-height: 1.6;
  min-height: 100%;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #ffe0f0, #fff 35%, #cdeaff);
  z-index: -1;
}

/* ============================================
   NAVIGATION
   ============================================ */

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 5%;
  height: var(--nav-height);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

/* Hamburger */
.nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 101;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

nav ul {
  display: none;
  flex-direction: column;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 16px 5%;
  gap: 4px;
  list-style: none;
  box-shadow: var(--shadow-md);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

nav ul.open {
  display: flex;
}

nav ul li {
  width: 100%;
}

nav ul li a {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

nav ul li a:hover {
  background: rgba(168, 216, 255, 0.12);
}

#account-section {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
  padding: 12px 16px;
}

.logged-in {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  color: var(--pink-deep);
  font-size: 0.95rem;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  width: 100%;
}

.account-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 135, 194, 0.35);
}

.account-link {
  color: var(--blue-dark);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(168, 216, 255, 0.12);
  transition: background 0.2s;
}

.account-link:hover {
  background: rgba(168, 216, 255, 0.28);
}

.logout-btn {
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.logout-btn:hover {
  color: #d32f2f;
  background: rgba(211, 47, 47, 0.08);
}

/* ============================================
   HERO
   ============================================ */

.hero {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 32px 5%;
}

.hero-content {
  max-width: 700px;
}

.hero h1 {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  line-height: 1.15;
}

.hero p {
  font-size: clamp(1rem, 3vw, 1.25rem);
  color: var(--text-light);
  margin-bottom: 28px;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   BUTTONS
   ============================================ */

.button, .account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  border-radius: 14px;
  border: none;
  background: var(--gradient);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  min-height: 48px;
}

.button:hover, .account-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 135, 194, 0.35);
}

.button:active {
  transform: translateY(-1px);
}

.download-btn {
  margin-top: 8px;
}

.htmx-btn {
  border: none;
  background: var(--pink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.2s;
}

.htmx-btn:hover {
  background: var(--pink-deep);
  transform: translateY(-2px);
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

/* ============================================
   SECTIONS
   ============================================ */

section {
  padding: 48px 5%;
}

section:first-of-type {
  padding-top: 32px;
}

h2 {
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  font-weight: 800;
  color: var(--pink-dark);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.card h3 {
  font-size: 1.15rem;
  color: var(--pink-deep);
  margin-bottom: 6px;
}

.card p {
  color: var(--text-light);
}

/* ============================================
   FEATURES GRID
   ============================================ */

.features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.feature {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px 22px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s, box-shadow 0.25s;
}

.feature:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.feature h3 {
  font-size: 1.1rem;
  color: var(--pink-deep);
  margin-bottom: 6px;
}

.feature p {
  font-size: 0.95rem;
  color: var(--text-light);
}

.feature-list {
  margin: 10px 0 0 20px;
  color: var(--text-light);
}

.feature-list li {
  margin-bottom: 4px;
}

/* ============================================
   DOWNLOAD
   ============================================ */

.download-box {
  text-align: center;
}

.download-box h3 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.download-box p {
  margin-bottom: 16px;
}

.release-notes {
  margin-top: 20px;
}

/* ============================================
   FAQ / INFO
   ============================================ */

#faq h3, .info-item h3, .faq-item h3 {
  font-size: 1.1rem;
  color: var(--pink-deep);
  margin-bottom: 4px;
}

#faq p, .info-item p {
  color: var(--text-light);
}

.info {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.info-item {
  background: rgba(255, 255, 255, 0.6);
  padding: 20px 22px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* ============================================
   GUIDE
   ============================================ */

#guide {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 32px 5%;
  margin: 0 5% 40px;
}

#guide h2 {
  text-align: center;
}

.guide-image {
  margin-top: 12px;
  width: 100%;
  max-width: 500px;
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.guide-image img {
  width: 100%;
  height: auto;
  display: block;
}

.image-placeholder {
  margin-top: 10px;
  width: 100%;
  max-width: 300px;
  height: 60px;
  background: rgba(168, 216, 255, 0.2);
  border: 2px dashed var(--blue);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

/* ============================================
   LEADERBOARD
   ============================================ */

#leaderboard {
  max-width: 700px;
  margin: 0 auto;
}

#leaderboard h2 {
  text-align: center;
}

.rank-col {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-light);
  width: 48px;
}

.rank-1 td:first-child {
  color: #ffb300;
}

.rank-2 td:first-child {
  color: #90a4ae;
}

.rank-3 td:first-child {
  color: #a1887f;
}

.rank-1 {
  background: rgba(255, 179, 0, 0.06);
}

.rank-2 {
  background: rgba(144, 164, 174, 0.06);
}

.rank-3 {
  background: rgba(161, 136, 127, 0.06);
}

.empty-state {
  text-align: center;
  color: var(--text-light);
  font-size: 1rem;
  padding: 40px 0;
}

/* ============================================
   STATS TABLE
   ============================================ */

#account {
  max-width: 800px;
  margin: 0 auto;
}

#account h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
}

#account p {
  color: var(--text-light);
  margin-bottom: 16px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -5%;
  padding: 0 5%;
}

.stats-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.9rem;
}

.stats-table td, .stats-table th {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-align: left;
  white-space: nowrap;
}

.stats-table th {
  color: var(--pink-dark);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-table td {
  color: var(--text);
}

.stats-table tr:last-child td {
  border-bottom: none;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: slideUp 0.25s ease;
}

.modal h2 {
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #eee;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.modal input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 182, 217, 0.2);
}

.modal .button {
  width: 100%;
  margin-top: 4px;
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  border: none;
  background: none;
  font-size: 1.6rem;
  color: var(--text-light);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.switch-auth {
  margin-top: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-light);
}

.switch-auth a {
  color: var(--pink-deep);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.switch-auth a:hover {
  opacity: 0.7;
}

/* ============================================
   ALERTS
   ============================================ */

.success {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #e8fce8;
  color: #1b7a2e;
  font-size: 0.9rem;
  font-weight: 500;
}

.error {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fce8e8;
  color: #b71c1c;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ============================================
   ANIMATIONS
   ============================================ */

.floating {
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  50% { transform: translateY(-12px); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   TABLET (768px+)
   ============================================ */

@media (min-width: 768px) {
  nav {
    padding: 0 6%;
  }

  .nav-toggle {
    display: none;
  }

  nav ul {
    display: flex;
    flex-direction: row;
    position: static;
    background: none;
    backdrop-filter: none;
    padding: 0;
    gap: 6px;
    box-shadow: none;
    border-radius: 0;
  }

  nav ul li {
    width: auto;
  }

  nav ul li a {
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  #account-section {
    padding: 0;
  }

  .account-btn {
    width: auto;
    padding: 8px 18px;
  }

  section {
    padding: 64px 8%;
  }

  section:first-of-type {
    padding-top: 48px;
  }

  .features {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .feature {
    padding: 28px 24px;
  }

  .card {
    padding: 36px;
  }

  #guide {
    padding: 40px 8%;
    margin: 0 8% 40px;
  }

  .info-item {
    padding: 24px 28px;
  }

  .table-wrapper {
    margin: 0;
    padding: 0;
  }
}

/* ============================================
   DESKTOP (1024px+)
   ============================================ */

@media (min-width: 1024px) {
  nav {
    padding: 0 10%;
  }

  nav ul {
    gap: 10px;
  }

  nav ul li a {
    padding: 8px 18px;
  }

  .hero {
    padding: 32px 10%;
  }

  section {
    padding: 80px 10%;
  }

  .features {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
  }

  #guide {
    padding: 50px 10%;
    margin: 0 10% 50px;
  }
}

/* ============================================
   DARK MODE SUPPORT (optional, respects system)
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .floating {
    animation: none;
  }

  .modal,
  .modal-overlay {
    animation: none;
  }

  .feature:hover,
  .button:hover,
  .account-btn:hover,
  .htmx-btn:hover {
    transform: none;
  }
}
