:root {
  --bg: #070a12;
  --bg-soft: #0d1322;
  --card: rgba(17, 25, 43, 0.76);
  --card-strong: rgba(25, 36, 60, 0.88);
  --text: #f4f7fb;
  --muted: #9ba9bd;
  --muted-2: #6f7f95;
  --line: rgba(255, 255, 255, 0.11);
  --gold: #f5c96b;
  --blue: #00b4ff;
  --blue-soft: rgba(0, 180, 255, 0.16);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }

.site-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 14% 12%, rgba(0, 180, 255, 0.18), transparent 28%),
    radial-gradient(circle at 84% 6%, rgba(245, 201, 107, 0.14), transparent 28%),
    radial-gradient(circle at 50% 80%, rgba(55, 80, 160, 0.18), transparent 36%),
    linear-gradient(180deg, #060913 0%, #0a0d16 52%, #05070d 100%);
}

.site-bg::before {
  content: "";
  position: absolute;
  inset: -30%;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.035) 75%);
  background-size: 92px 92px;
  background-position: 0 0, 0 46px, 46px -46px, -46px 0;
  transform: rotate(-8deg);
  opacity: 0.22;
  mask-image: radial-gradient(circle at 50% 20%, #000, transparent 62%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(var(--max), calc(100% - 32px));
  margin: 14px auto 0;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 10, 18, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 50px rgba(0,0,0,0.22);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 780;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
}
/* Real ChessCodex app icon as <img>.  The source PNG is the same
   stacked "Chess Codex" lockup shipped to Android/iOS — rounded
   square, lime→teal gradient, white wordmark + knight.  We render
   it at 36 px in the topbar and 32 px in the footer; the served
   asset is 96 px so it stays crisp on 3× retina screens.  A 16 px
   rounded radius matches the app icon's iOS-style mask without
   covering content. */
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(0, 139, 167, 0.28);
}
.footer-brand .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.brand-text { line-height: 1; }

.topnav { display: flex; gap: 8px; align-items: center; }
.topnav a {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 999px;
}
.topnav a:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.section-pad { width: min(var(--max), calc(100% - 32px)); margin: 0 auto; }
.hero {
  min-height: calc(100svh - 78px);
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  gap: 54px;
  align-items: center;
  padding-top: 54px;
  padding-bottom: 80px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 780;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 820px;
  margin-bottom: 20px;
  font-size: clamp(44px, 7.2vw, 92px);
  line-height: 0.94;
  letter-spacing: -0.065em;
}
h2 {
  margin-bottom: 16px;
  font-size: clamp(32px, 4.8vw, 58px);
  line-height: 1.0;
  letter-spacing: -0.05em;
}
h3 {
  margin-bottom: 8px;
  font-size: 21px;
  line-height: 1.16;
  letter-spacing: -0.03em;
}
.lead {
  max-width: 620px;
  color: #c6d2e1;
  font-size: clamp(18px, 2.1vw, 23px);
}

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 28px; }
.store-button {
  min-width: 174px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 13px 18px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.store-button:hover { transform: translateY(-2px); border-color: rgba(0,180,255,0.48); }
.store-button.primary { background: linear-gradient(135deg, var(--blue), #6be1ff); color: #03111d; box-shadow: 0 18px 44px rgba(0,180,255,0.22); }
.store-button.ghost { color: var(--muted); }
.store-kicker { font-size: 11px; font-weight: 780; text-transform: uppercase; opacity: 0.78; letter-spacing: 0.08em; }
.store-name { font-size: 18px; font-weight: 850; letter-spacing: -0.02em; }

.hero-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 720px;
}
.hero-points div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.045);
}
.hero-points strong { display: block; font-size: 15px; margin-bottom: 3px; }
.hero-points span { display: block; color: var(--muted); font-size: 13px; }

.hero-visual { position: relative; display: grid; place-items: center; min-height: 650px; }
.phone-wrap {
  position: relative;
  width: min(330px, 84vw);
  aspect-ratio: 9 / 19.5;
  padding: 12px;
  border-radius: 42px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.05)),
    linear-gradient(135deg, #182238, #070b14);
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,0.06);
  overflow: hidden;
}
.hero-phone { width: min(356px, 86vw); transform: rotate(2deg); }
.phone-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.22), transparent 22%, transparent 74%, rgba(0,180,255,0.16));
  z-index: 3;
}
.phone-notch {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 94px;
  height: 22px;
  border-radius: 999px;
  background: #05070d;
  z-index: 4;
  opacity: 0.92;
}
.phone-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 31px;
  background: #05070d;
}

.floating-card {
  position: absolute;
  z-index: 5;
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 42px rgba(0,0,0,0.30);
}
.floating-card span { display: block; color: var(--muted); font-size: 12px; }
.floating-card strong { display: block; font-size: 16px; }
.card-a { left: 2%; top: 23%; }
.card-b { right: 1%; bottom: 21%; }

.section { padding-top: 36px; padding-bottom: 36px; }
.section-heading { max-width: 760px; }
.centered { margin: 0 auto 38px; text-align: center; }
.section-lead { color: var(--muted); max-width: 680px; margin-left: auto; margin-right: auto; font-size: 17px; }

.intro-grid { padding-top: 40px; padding-bottom: 52px; }
.feature-grid { display: grid; gap: 16px; }
.feature-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.feature-card, .video-card, .database-cards article, .trust-card, .faq-list details {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 14px 50px rgba(0,0,0,0.18);
  backdrop-filter: blur(16px);
}
.feature-card { padding: 24px; border-radius: var(--radius-lg); }
.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 22px;
}
.feature-card p, .video-copy p, .database-copy p, .database-cards p, .trust-card p, .faq-list p { color: var(--muted); }

.howto { padding-top: 80px; padding-bottom: 78px; }
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.video-card {
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.video-card .phone-wrap { width: min(250px, 100%); margin: 0 auto; border-radius: 36px; padding: 10px; }
.video-card .small-phone video { border-radius: 26px; }
.video-card .small-phone .phone-notch { top: 15px; width: 74px; height: 18px; }
.featured-video {
  grid-column: span 2;
  display: grid;
  grid-template-columns: minmax(230px, 0.7fr) 1fr;
  align-items: center;
}
.featured-video .phone-wrap { width: min(285px, 100%); }
.repertoire-card { grid-column: span 2; flex-direction: row; align-items: center; }
.repertoire-card .phone-wrap { flex: 0 0 245px; }
.video-copy { padding: 0 6px 6px; }
.step {
  display: inline-flex;
  margin-bottom: 11px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.micro-note {
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 15px;
  border: 1px solid rgba(245, 201, 107, 0.26);
  background: rgba(245, 201, 107, 0.08);
  color: #e8d49b !important;
  font-size: 13px;
}
.diagram-card {
  background:
    radial-gradient(circle at 20% 12%, rgba(245,201,107,0.12), transparent 34%),
    radial-gradient(circle at 80% 82%, rgba(0,180,255,0.15), transparent 38%),
    var(--card);
}

.database-section {
  display: grid;
  grid-template-columns: 0.86fr 1.14fr;
  gap: 28px;
  align-items: center;
  padding-top: 70px;
  padding-bottom: 70px;
}
.database-copy p { font-size: 17px; }
.database-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.database-cards article { padding: 22px; border-radius: var(--radius-lg); }
.database-cards span {
  display: inline-flex;
  margin-bottom: 28px;
  padding: 7px 9px;
  border-radius: 999px;
  color: #06101d;
  background: var(--gold);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.trust-section { padding-top: 34px; padding-bottom: 70px; }
.trust-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  padding: clamp(24px, 4vw, 42px);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 18% 20%, rgba(0,180,255,0.13), transparent 38%),
    var(--card-strong);
}
.check-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.check-list li {
  position: relative;
  padding-left: 34px;
  color: #d6e1ee;
}
.check-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: -2px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.faq-section { padding-top: 70px; padding-bottom: 86px; }
.faq-list { max-width: 840px; margin: 0 auto; display: grid; gap: 12px; }
.faq-list details { border-radius: 20px; padding: 18px 20px; }
.faq-list summary { cursor: pointer; font-weight: 790; letter-spacing: -0.02em; }
.faq-list p { margin: 12px 0 0; }

.footer {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  flex-wrap: wrap;
}
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a:hover { color: var(--text); }
.footer p { margin: 0; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; min-height: auto; text-align: left; padding-top: 46px; gap: 36px; }
  .hero-visual { min-height: auto; }
  .hero-phone { transform: none; }
  .floating-card { display: none; }
  .feature-grid.three, .database-section, .trust-card { grid-template-columns: 1fr; }
  .database-cards { grid-template-columns: 1fr; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-video, .repertoire-card { grid-column: span 2; }
}

@media (max-width: 680px) {
  .topbar { width: calc(100% - 20px); margin-top: 10px; }
  .topnav { display: none; }
  .section-pad { width: min(100% - 22px, var(--max)); }
  .hero { padding-top: 36px; padding-bottom: 44px; }
  h1 { font-size: clamp(44px, 14vw, 68px); }
  h2 { font-size: clamp(32px, 10vw, 46px); }
  .lead { font-size: 18px; }
  .cta-row { display: grid; grid-template-columns: 1fr; }
  .store-button { width: 100%; }
  .hero-points { grid-template-columns: 1fr; }
  .phone-wrap { width: min(310px, 88vw); }
  .video-grid { grid-template-columns: 1fr; }
  .featured-video, .repertoire-card { grid-column: span 1; display: flex; flex-direction: column; }
  .repertoire-card .phone-wrap { flex: initial; }
  .video-card { border-radius: 26px; }
  .howto { padding-top: 58px; }
  .database-section, .faq-section { padding-top: 54px; padding-bottom: 58px; }
  .footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .store-button { transition: none; }
}
/* Desktop-only How-to layout refinement.
   Keeps mobile unchanged, but makes desktop feel ordered and balanced. */
@media (min-width: 981px) {
  .howto .video-grid {
    grid-template-columns: 1fr;
    gap: 30px;
    max-width: 1120px;
    margin-inline: auto;
  }

  .howto .video-card,
  .howto .featured-video,
  .howto .repertoire-card {
    grid-column: 1 / -1 !important;
    display: grid !important;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    align-items: center;
    gap: clamp(32px, 5vw, 72px);
    padding: clamp(22px, 3vw, 34px);
  }

  .howto .video-card:nth-child(even),
  .howto .featured-video:nth-child(even),
  .howto .repertoire-card:nth-child(even) {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  }

  .howto .video-card:nth-child(even) .phone-wrap,
  .howto .featured-video:nth-child(even) .phone-wrap,
  .howto .repertoire-card:nth-child(even) .phone-wrap {
    order: 2;
    justify-self: end;
  }

  .howto .video-card:nth-child(even) .video-copy,
  .howto .featured-video:nth-child(even) .video-copy,
  .howto .repertoire-card:nth-child(even) .video-copy {
    order: 1;
  }

  .howto .video-card:nth-child(odd) .phone-wrap,
  .howto .featured-video:nth-child(odd) .phone-wrap,
  .howto .repertoire-card:nth-child(odd) .phone-wrap {
    justify-self: start;
  }

  .howto .video-card .phone-wrap,
  .howto .video-card .small-phone,
  .howto .featured-video .phone-wrap,
  .howto .repertoire-card .phone-wrap {
    width: min(320px, 100%);
    flex: initial;
    margin: 0;
  }

  .howto .video-copy {
    max-width: 560px;
    padding: 0;
  }

  .howto .step {
    display: inline-block;
    margin-bottom: 18px;
    font-size: 24px;
    line-height: 1;
    letter-spacing: 0.13em;
    color: var(--blue);
  }

  .howto .video-copy h3 {
    font-size: clamp(27px, 2.4vw, 38px);
    line-height: 1.05;
    margin-bottom: 12px;
  }

  .howto .video-copy p {
    font-size: 17px;
    line-height: 1.58;
  }

  .howto .micro-note {
    display: inline-block;
    max-width: 520px;
    margin-top: 18px;
    font-size: 14px;
    line-height: 1.5;
  }
}


/* Language switcher */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-left: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
}
.lang-switch a {
  min-width: 34px;
  padding: 7px 9px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}
.lang-switch a:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.lang-switch a.active,
.lang-switch a[aria-current="page"] {
  color: #04131b;
  background: linear-gradient(135deg, var(--blue), #71e4ff);
  box-shadow: 0 6px 20px rgba(0,180,255,0.20);
}
.top-actions { display: flex; align-items: center; gap: 8px; }

.legal-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.legal-main {
  flex: 1;
  padding-top: 88px;
  padding-bottom: 88px;
}
.legal-card {
  max-width: 840px;
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(17, 25, 43, 0.74);
  box-shadow: var(--shadow);
}
.legal-card p { color: #c6d2e1; }
.legal-card ul { color: #c6d2e1; padding-left: 20px; }
.legal-card li { margin: 8px 0; }
.legal-card .store-button { display: inline-flex; margin-top: 12px; }

@media (max-width: 680px) {
  .topbar { gap: 10px; }
  .brand-text { font-size: 15px; }
  .lang-switch { margin-left: auto; gap: 2px; padding: 3px; }
  .lang-switch a { min-width: 31px; padding: 6px 7px; font-size: 11px; }
}
