/* mathracerapp.com – gemensam stil. Färgerna är spelets: mörkgrå panel, gul numpad, röd kantmarkering. */
:root {
  --bg: #15161a;
  --bg-2: #1e1f25;
  --panel: #26272e;
  --line: #33353d;
  --text: #f4f4f6;
  --muted: #a9adb8;
  --yellow: #f6b21b;
  --yellow-2: #ffd34d;
  --red: #e0352b;
  --green: #3ec96a;
  --blue: #3aa7ff;
  --purple: #8e5cf5;
  --radius: 22px;
  --max: 1120px;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--yellow-2); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.1; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); }
h2 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.wrap { width: min(var(--max), 100% - 32px); margin: 0 auto; }

/* Topprad */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(21, 22, 26, .82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 18px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-size: 1.2rem; text-decoration: none; color: var(--text); }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.nav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: .95rem; }
.nav a:hover, .nav a[aria-current] { color: var(--text); background: var(--panel); }
.nav .store { display: inline-flex; align-items: center; gap: 8px; }
.nav .store img { height: 32px; width: auto; }
@media (max-width: 720px) { .nav a:not(.store) { display: none; } }

/* Knappar */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--yellow); color: #1a1300; text-decoration: none; font-weight: 800;
  padding: 14px 24px; border-radius: 999px; box-shadow: 0 6px 0 #b67d06, 0 14px 30px rgba(0,0,0,.35);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #b67d06, 0 18px 34px rgba(0,0,0,.4); }
.badge-link img { height: 56px; width: auto; }
.badge-link:hover img { filter: brightness(1.1); }

/* Hero */
.hero {
  position: relative; min-height: 92vh; display: grid; align-items: center; overflow: hidden;
  isolation: isolate;
}
.hero-bg { position: absolute; inset: -10% 0 0 0; z-index: -2; will-change: transform; }
.hero-bg img { width: 100%; height: 110%; object-fit: cover; object-position: center 40%; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(21,22,26,.35) 0%, rgba(21,22,26,.15) 35%, rgba(21,22,26,.92) 85%, var(--bg) 100%);
}
.hero .wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: end; padding: 80px 0 40px; }
.hero-logo { width: min(460px, 80%); filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)); }
.hero p.lead { font-size: clamp(1.15rem, 2.2vw, 1.5rem); max-width: 34ch; text-shadow: 0 2px 14px rgba(0,0,0,.6); }
.hero-cta { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 18px 0 14px; }
.pills { display: flex; gap: 10px; flex-wrap: wrap; }
.pill { background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .9rem; backdrop-filter: blur(6px); }
.pill::before { content: "✓ "; color: var(--green); }
.phone { justify-self: center; width: min(320px, 70vw); border-radius: 36px; padding: 10px; background: #0b0b0d; box-shadow: 0 30px 60px rgba(0,0,0,.6), inset 0 0 0 2px #2a2b31; transform: rotate(-4deg); }
.phone img { border-radius: 28px; }
.phone.flat { transform: none; }
@media (max-width: 860px) {
  .hero .wrap { grid-template-columns: 1fr; padding-top: 40px; }
  .phone { transform: rotate(0); width: min(260px, 70vw); }
}

/* Sektioner */
.section { padding: clamp(64px, 9vw, 120px) 0; position: relative; }
.section.alt { background: var(--bg-2); }
.section .kicker { color: var(--yellow); font-weight: 800; text-transform: uppercase; letter-spacing: .14em; font-size: .85rem; margin-bottom: 10px; }
.story { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
.story.flip .text { order: 2; }
.story > *, .hero .wrap > *, .grid > * { min-width: 0; }
.story .text p { max-width: 48ch; }
.story .text ul { padding-left: 1.2em; }
.story .text li { margin-bottom: .4em; }
@media (max-width: 860px) { .story { grid-template-columns: 1fr; } .story.flip .text { order: 0; } }

/* Kort */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.grid { display: grid; gap: 18px; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid.three, .grid.four { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid.three, .grid.four { grid-template-columns: 1fr; } }

/* Banor */
.tracks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.track { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; background: var(--panel); border: 1px solid var(--line); }
.track img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.track:hover img { transform: scale(1.05); }
.track .label { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px; background: linear-gradient(0deg, rgba(0,0,0,.75), transparent); display: flex; justify-content: space-between; align-items: end; font-family: var(--font-head); font-size: 1.2rem; }
.track .label small { font-family: var(--font-body); color: var(--yellow-2); font-weight: 800; font-size: .85rem; }
.track.season::after { content: "Seasonal"; position: absolute; top: 12px; right: 12px; background: var(--red); color: #fff; font-weight: 800; font-size: .75rem; padding: 4px 10px; border-radius: 999px; }
@media (max-width: 860px) { .tracks { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .tracks { grid-template-columns: 1fr; } }

/* Garage */
.garage { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 28px; }
.garage img { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 10px 16px rgba(0,0,0,.5)); transition: transform .3s; }
.garage img:hover { transform: translateY(-6px) scale(1.06); }
@media (max-width: 860px) { .garage { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 520px) { .garage { grid-template-columns: repeat(3, 1fr); } }

/* Adaptiv mätare (CSS-illustration) */
.meter { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.meter .bar { height: 18px; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); position: relative; margin: 26px 0 10px; }
.meter .knob { position: absolute; top: 50%; left: 15%; width: 36px; height: 36px; transform: translate(-50%, -50%); background: #fff; border-radius: 50%; box-shadow: 0 6px 16px rgba(0,0,0,.5); transition: left 2.4s cubic-bezier(.3,.8,.3,1); }
.meter.in .knob { left: 62%; }
.meter .ends { display: flex; justify-content: space-between; color: var(--muted); font-weight: 700; font-size: .9rem; }
.meter .log { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 8px; }
.meter .log li { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 14px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; opacity: 0; transform: translateX(-12px); transition: opacity .5s, transform .5s; }
.meter .log li:nth-child(1) { transition-delay: .2s; } .meter .log li:nth-child(2) { transition-delay: .9s; } .meter .log li:nth-child(3) { transition-delay: 1.6s; } .meter .log li:nth-child(4) { transition-delay: 2.3s; }
.meter.in .log li { opacity: 1; transform: none; }
.meter .log b.up { color: var(--green); } .meter .log b.down { color: var(--blue); }

/* Nötning (CSS-illustration) */
.review { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.review .row { display: flex; gap: 10px; flex-wrap: wrap; }
.review .q { font-family: var(--font-head); font-size: 1.4rem; background: #0f1013; border-radius: 14px; padding: 10px 16px; border: 2px solid transparent; opacity: 0; transform: scale(.8); transition: opacity .4s, transform .4s, border-color .3s; }
.review.in .q { opacity: 1; transform: none; }
.review .q.wrong { border-color: var(--red); }
.review .q.back { border-color: var(--yellow); box-shadow: 0 0 0 6px rgba(246,178,27,.15); }
.review .q.done { border-color: var(--green); }
.review.in .q:nth-child(1) { transition-delay: .1s; } .review.in .q:nth-child(2) { transition-delay: .3s; } .review.in .q:nth-child(3) { transition-delay: .5s; }
.review.in .q:nth-child(4) { transition-delay: .7s; } .review.in .q:nth-child(5) { transition-delay: .9s; } .review.in .q:nth-child(6) { transition-delay: 1.1s; }
.review.in .q:nth-child(7) { transition-delay: 1.3s; } .review.in .q:nth-child(8) { transition-delay: 1.5s; } .review.in .q:nth-child(9) { transition-delay: 1.7s; }
.review .legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 16px; font-size: .9rem; color: var(--muted); font-weight: 700; }
.review .legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.review .legend .l-wrong::before { background: var(--red); } .review .legend .l-back::before { background: var(--yellow); } .review .legend .l-done::before { background: var(--green); }

/* Profiler */
.avatars { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.avatars img { width: 58px; height: 58px; border-radius: 50%; background: #e2e8f4; border: 3px solid var(--yellow); object-fit: cover; }

/* Siffror */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 36px; }
.stat { text-align: center; }
.stat .n { font-family: var(--font-head); font-size: clamp(2.2rem, 5vw, 3.4rem); color: var(--yellow-2); }
.stat .l { color: var(--muted); font-weight: 700; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Trygghet */
.safe .grid .card h3 { display: flex; align-items: center; gap: 10px; }
.safe .grid .card h3 .ok { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #052; font-size: 1rem; }

/* Bubble-sektion */
.bubble { background: #0a0616 url("bubble/space.jpg") center / cover no-repeat; position: relative; isolation: isolate; }
.bubble::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(10,6,22,.92) 0%, rgba(10,6,22,.7) 55%, rgba(10,6,22,.35) 100%); }
.bubble .kicker { color: #9ad7ff; }
.bubble .btn { background: linear-gradient(90deg, #3ad0ff, #8e5cf5); color: #fff; box-shadow: 0 6px 0 #2b2160, 0 14px 30px rgba(0,0,0,.45); }

/* Sidfot */
footer { border-top: 1px solid var(--line); padding: 40px 0 60px; color: var(--muted); font-size: .95rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 20px 40px; align-items: center; }
footer nav { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* Textsidor */
.doc { padding: 56px 0 90px; }
.doc .wrap { max-width: 760px; }
.doc h1 { margin-bottom: .3em; }
.doc h2 { font-size: 1.5rem; margin-top: 1.8em; }
.doc h3 { font-size: 1.15rem; margin-top: 1.4em; }
.doc ul { padding-left: 1.3em; }
.doc .updated { color: var(--muted); font-weight: 700; margin-bottom: 2em; }
.doc .contact { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; }
.doc .contact a { font-family: var(--font-head); font-size: 1.3rem; }

/* Scrollanimationer: element med data-reveal glider in när de kommer i bild */
[data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--i, 0) * 90ms); }
[data-reveal="left"]  { transform: translateX(-40px); }
[data-reveal="right"] { transform: translateX(40px); }
[data-reveal="pop"]   { transform: scale(.85); }
[data-reveal].in { opacity: 1; transform: none; }

/* Bilen som kör längs sidans nederkant i takt med scrollen */
.road { position: fixed; left: 0; right: 0; bottom: 0; height: 14px; z-index: 30; pointer-events: none;
  background: repeating-linear-gradient(90deg, var(--red) 0 28px, #fff 28px 56px); opacity: .9; }
.road::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg), transparent 12%, transparent 88%, var(--bg)); }
.road-car { position: fixed; bottom: 4px; left: 0; width: 92px; z-index: 31; pointer-events: none; transform: translateX(-10vw); filter: drop-shadow(0 6px 8px rgba(0,0,0,.6)); will-change: transform; }
@media (max-width: 720px) { .road-car { width: 64px; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  .meter .knob, .meter .log li, .review .q, .track img, .garage img { transition: none; }
  .meter .knob { left: 62%; } .meter .log li { opacity: 1; transform: none; } .review .q { opacity: 1; transform: none; }
  .road, .road-car { display: none; }
  .hero-bg { transform: none !important; }
}
