/* Global layout & typography */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Header & navigation */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.logo-link {
  text-decoration: none;
}

.site-logo {
  width: 40px;
  height: auto;
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.site-name {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Desktop nav */
.nav-links {
  position: relative;
}

.nav-primary {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-link {
  color: #ffffff;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-block;
}

.nav-link:hover {
  color: #e5e7eb;
  transform: scale(1.05);
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
}

/* Base hidden state */
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  min-width: 220px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  margin-top: 8px;
  overflow: hidden;
  animation: fadeInDown 0.3s ease;
  z-index: 2000;
}

/* Shown when .open is on parent dropdown */
.dropdown.open .dropdown-content {
  display: block;
}

.dropdown-content a {
  color: #4a5568;
  padding: 12px 20px;
  text-decoration: none;
  display: block;
  transition: all 0.2s ease;
  font-size: 14px;
}

.dropdown-content a:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  padding-left: 28px;
}

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.6);
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}

.mobile-menu {
  display: none; /* hidden by default on desktop */
  background: #047857;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 0.25s ease;
}

.mobile-menu.open {
  transform: scaleY(1);
}

.mobile-menu-inner {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.5rem 1rem;
  gap: 0.35rem;
}

.mobile-menu-inner a {
  color: #ecfdf5;
  text-decoration: none;
  padding: 0.4rem 0;
  font-weight: 500;
  border-bottom: 1px solid rgba(16, 185, 129, 0.35);
}

.mobile-menu-inner a:last-child {
  border-bottom: none;
}

/* Hero / page header */
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  padding: 80px 20px 70px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120"><path d="M0,0 Q300,60 600,30 T1200,0 L1200,120 L0,120 Z" fill="rgba(255,255,255,0.1)"/></svg>') repeat-x bottom;
  background-size: 1200px 120px;
  opacity: 0.3;
}

.page-header h1 {
  font-size: 2.9rem;
  font-weight: 900;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  animation: slideInDown 0.6s ease;
}

.page-header p {
  font-size: 1.25rem;
  opacity: 0.95;
  position: relative;
  z-index: 1;
  animation: slideInUp 0.6s ease;
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.pulse-animation {
  animation: pulse 2s ease-in-out infinite;
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Main game layout */
.game-container {
  max-width: 1400px;
  margin: -60px auto 60px;
  padding: 0 20px;
  position: relative;
  z-index: 10;
}

.game-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
}

/* Game cards */
.game-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.6s ease;
}

.card-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #667eea;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.game-btn {
  padding: 14px 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-bottom: 12px;
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.45);
}

.game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.55);
}

.game-btn.secondary {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.4);
}

.game-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Canvas */
#gameCanvas {
  width: 100%;
  border-radius: 16px;
  background: #f7f7f7;
  display: block;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.game-helper-text {
  text-align: center;
  margin-top: 20px;
  color: #667eea;
  font-weight: 600;
  font-size: 14px;
}

/* Info boxes */
.info-box {
  padding: 18px 20px;
  border-radius: 12px;
  margin-top: 14px;
}

.info-box-primary {
  background: linear-gradient(135deg, #f0f4ff 0%, #e9e4f0 100%);
  border-left: 4px solid #667eea;
}

.info-box-secondary {
  background: linear-gradient(135deg, #ecfeff 0%, #e0f2fe 100%);
  border-left: 4px solid #0ea5e9;
}

.info-box-features {
  background: linear-gradient(135deg, #fef3c7 0%, #ffedd5 100%);
  border-left: 4px solid #f59e0b;
}

.info-box-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 15px;
  color: #4b5563;
}

.info-box-body {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.7;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: linear-gradient(135deg, #f0f4ff 0%, #e9e4f0 100%);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  border-left: 4px solid #667eea;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: #667eea;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 900;
  color: #764ba2;
}

/* Game history */
.history-item {
  background: linear-gradient(135deg, #f0f4ff 0%, #e9e4f0 100%);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideInRight 0.5s ease;
}

.history-score {
  font-size: 18px;
  font-weight: 700;
  color: #667eea;
}

.history-date {
  font-size: 12px;
  color: #9ca3af;
}

/* Notification */
.notification {
  position: fixed;
  top: 100px;
  right: 20px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  padding: 20px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
  z-index: 10000;
  animation: slideInRight 0.5s ease;
  max-width: 300px;
}

.notification.error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: #ffffff;
  border-radius: 24px;
  padding: 40px;
  max-width: 600px;
  width: 90%;
  max-height: 80%;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-title {
  font-size: 32px;
  font-weight: 900;
  color: #667eea;
  margin-bottom: 24px;
  text-align: center;
}

/* Ads */
.adsense-container {
  background: linear-gradient(135deg, #f0f4ff 0%, #e9e4f0 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 24px 0;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #c7d2fe;
}

.adsense-placeholder {
  text-align: center;
  color: #667eea;
  font-size: 14px;
}

/* Certificate section */
.certificate-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.certificate-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #4b5563;
  margin-bottom: 8px;
}

.certificate-text {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 12px;
}

.certificate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.certificate-form input[type="text"] {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.certificate-form input[type="text"]:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* Mobile on-screen controls */
.mobile-controls {
  display: none;
  margin-top: 18px;
  gap: 12px;
  justify-content: center;
}

.mobile-ctrl-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #10b981;
  color: #ecfdf5;
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-ctrl-btn:last-child {
  background: #14b8a6;
}

.mobile-ctrl-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(16, 185, 129, 0.5);
}

/* Blog section */
.blog-section {
  max-width: 900px;
  margin: 80px auto;
  padding: 0 20px;
}

.blog-content {
  background: #ffffff;
  border-radius: 24px;
  padding: 60px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  line-height: 1.8;
}

.blog-content h2 {
  font-size: 2.3rem;
  font-weight: 900;
  color: #1f2933;
  margin-bottom: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.blog-content h3 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2d3748;
  margin-top: 40px;
  margin-bottom: 20px;
}

.blog-content h4 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #4a5568;
  margin-top: 24px;
  margin-bottom: 8px;
}

.blog-content p {
  color: #4a5568;
  font-size: 0.98rem;
  margin-bottom: 18px;
  line-height: 1.9;
}

.blog-content ul,
.blog-content ol {
  color: #4a5568;
  margin-left: 24px;
  margin-bottom: 18px;
}

.blog-content li {
  margin-bottom: 8px;
  line-height: 1.8;
}

.blog-content strong {
  color: #4f46e5;
  font-weight: 700;
}

.blog-content a {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
}

.blog-content a:hover {
  color: #1d4ed8;
}

/* Highlight box */
.highlight-box {
  background: linear-gradient(135deg, #f0f4ff 0%, #e9e4f0 100%);
  padding: 24px;
  border-radius: 12px;
  border-left: 4px solid #667eea;
  margin: 32px 0;
}

/* Footer */
.footer {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  color: #ffffff;
  padding: 60px 0 20px;
  margin-top: 80px;
}

.footer-column h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column ul li {
  margin-bottom: 12px;
}

.footer-column ul li a {
  color: #cbd5e0;
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-block;
}

.footer-column ul li a:hover {
  color: #667eea;
  transform: translateX(5px);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 40px;
  padding-top: 30px;
  text-align: center;
  color: #a0aec0;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* 🔒 Force desktop nav items to hide on mobile */
  .nav-links,
  .nav-primary,
  .nav-extra {
    display: none !important;
  }

  /* ✅ Show mobile menu container on small screens so .open works */
  .mobile-menu {
    display: block;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .page-header {
    padding: 72px 16px 56px;
  }

  .page-header h1 {
    font-size: 2.1rem;
  }

  .page-header p {
    font-size: 1rem;
  }

  .game-card {
    padding: 24px;
  }

  .blog-content {
    padding: 32px 24px;
  }

  .blog-content h2 {
    font-size: 1.9rem;
  }

  .blog-content h3 {
    font-size: 1.3rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .mobile-controls {
    display: flex;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .blog-content {
    padding: 26px 18px;
  }

  .page-header h1 {
    font-size: 1.9rem;
  }
}
