/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #0d0d0d;
  --secondary:  #1a1a1a;
  --accent:     #00ff41;
  --accent-dim: rgba(0, 255, 65, 0.12);
  --text:       #ffffff;
  --text-sec:   #a0a0a0;
  --border:     #2a2a2a;
  --success:    #00ff41;
  --danger:     #ff4d4d;
  --card-bg:    rgba(26, 26, 26, 0.8);
  --radius:     14px;
  --shadow:     0 4px 32px rgba(0, 0, 0, 0.7);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--primary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ──────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.nav-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 28px;
}

/* Hamburger button — hidden on desktop */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 200;
}

.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.25s ease;
}

.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-links a {
  color: var(--text-sec);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
}

.hero-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(0, 255, 65, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 80%, rgba(13, 13, 13, 0.8) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 640px;
}

.hero-icon {
  width: 120px;
  height: 120px;
  border-radius: 28px;
  box-shadow: 0 8px 48px rgba(0, 255, 65, 0.25);
}

.hero-title {
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #ffffff 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.hero-tagline {
  font-size: clamp(18px, 3vw, 22px);
  color: var(--text-sec);
  font-weight: 400;
  line-height: 1.5;
}

.app-store-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: var(--primary);
  padding: 14px 28px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 16px;
  margin-top: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.app-store-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-decoration: none;
  color: var(--primary);
}

.apple-icon {
  width: 20px;
  height: 20px;
  fill: var(--primary);
  flex-shrink: 0;
}

/* ── Shared section styles ────────────────────────────── */
.section-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 24px;
}

.section-title {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 10px;
}

.section-sub {
  color: var(--text-sec);
  font-size: 16px;
  margin-bottom: 48px;
}

/* ── Game Modes ───────────────────────────────────────── */
.modes { background: rgba(20, 20, 20, 0.5); }

.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.mode-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(0, 255, 65, 0.08);
}

.mode-card--kudosu:hover { border-color: var(--danger); box-shadow: 0 8px 32px rgba(255,77,77,0.1); }

.mode-emoji { font-size: 36px; line-height: 1; }

.mode-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.mode-desc {
  font-size: 14px;
  color: var(--text-sec);
  line-height: 1.6;
  flex: 1;
}

.mode-tag {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 170, 255, 0.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  width: fit-content;
  margin-top: 4px;
}

.mode-tag--danger {
  background: rgba(255, 77, 77, 0.1);
  color: var(--danger);
  border-color: rgba(255, 77, 77, 0.3);
}

/* ── Leaderboard ──────────────────────────────────────── */
.leaderboard { border-top: 1px solid var(--border); }

.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.lb-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sec);
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.lb-tab--active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.lb-tab:hover:not(.lb-tab--active) { border-color: var(--text-sec); color: var(--text); }

.lb-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.lb-table th {
  background: rgba(0, 51, 78, 0.8);
  color: var(--text-sec);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.lb-table td {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(0, 95, 115, 0.3);
  color: var(--text);
}

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

.lb-table tr:hover td { background: rgba(0, 170, 255, 0.04); }

.lb-rank {
  color: var(--text-sec);
  font-weight: 700;
  width: 40px;
}

.lb-rank--gold   { color: #ffd700; }
.lb-rank--silver { color: #c0c0c0; }
.lb-rank--bronze { color: #cd7f32; }

.lb-name  { font-weight: 600; }
.lb-score { color: var(--accent); font-weight: 700; }
.lb-time  { color: var(--text-sec); font-variant-numeric: tabular-nums; }

.lb-loading {
  text-align: center;
  color: var(--text-sec);
  padding: 40px !important;
  font-style: italic;
}

.lb-error {
  text-align: center;
  color: var(--text-sec);
  padding: 40px !important;
}

/* ── Leaderboard layout (table + board preview) ───────── */
.lb-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.lb-layout .lb-table-wrap {
  flex: 1;
  min-width: 0;
}

.lb-preview {
  width: 220px;
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 180px;
  justify-content: center;
}

.lb-preview-hint {
  color: var(--text-sec);
  font-size: 13px;
  text-align: center;
  font-style: italic;
}

.lb-preview-meta {
  text-align: center;
}

.lb-preview-player {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.lb-preview-diff {
  font-size: 12px;
  color: var(--text-sec);
  text-transform: capitalize;
  margin-top: 2px;
}

/* Mini sudoku board */
.mini-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1px;
  background: var(--border);
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  width: 180px;
  height: 180px;
}

.mini-cell {
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.mini-cell.given {
  background: rgba(0, 170, 255, 0.18);
  color: var(--accent);
}

.mini-cell.empty {
  background: var(--primary);
  color: transparent;
}

/* Thicker borders between 3x3 boxes */
.mini-cell:nth-child(3n+1):not(:nth-child(1)):not(:nth-child(10)):not(:nth-child(19)):not(:nth-child(28)):not(:nth-child(37)):not(:nth-child(46)):not(:nth-child(55)):not(:nth-child(64)):not(:nth-child(73)) {
  border-left: 2px solid var(--border);
}

.mini-board-row-3 { border-top: 2px solid var(--border); }
.mini-board-row-6 { border-top: 2px solid var(--border); }

.lb-table tr { cursor: pointer; }
.lb-table tr.lb-row--active td { background: rgba(0, 170, 255, 0.08); }

/* ── Footer ───────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  background: rgba(0, 16, 30, 0.8);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.footer-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--text-sec);
  font-size: 14px;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--text); text-decoration: none; }

.footer-copy {
  color: var(--border);
  font-size: 12px;
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 24px;
}

.footer-social-link {
  color: var(--text);
  opacity: 0.5;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.2s;
  text-decoration: none;
}

.footer-social-link:hover { opacity: 1; text-decoration: none; }

.footer-powered {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-sec);
  font-size: clamp(0.65em, 2vw, 0.75em);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s;
  text-align: center;
}

.footer-powered:hover { opacity: 1; text-decoration: none; }

.footer-powered-icon {
  width: clamp(16px, 4vw, 20px);
  height: clamp(16px, 4vw, 20px);
  border-radius: 5px;
  flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-hamburger { display: flex; }

  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: rgba(13, 13, 13, 0.98);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    z-index: 99;
  }

  .nav-links.active { display: flex; }

  .nav-links a {
    padding: 14px 24px;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }

  .nav-links a:last-child { border-bottom: none; }
}

@media (max-width: 600px) {
  .modes-grid { grid-template-columns: 1fr; }
  .lb-table th:nth-child(3),
  .lb-table td:nth-child(3) { display: none; }
  .lb-layout { flex-direction: column; }
  .lb-layout .lb-table-wrap { width: 100%; }
  .lb-preview { width: 100%; }
  .mini-board { width: 160px; height: 160px; }
}
