/* Volt Arcade — shared styles. Colours and lettering follow the book's artwork. */
:root {
  --night: #0e0a3c;
  --deep: #1b1366;
  --panel: #241a7a;
  --volt: #ffd21f;
  --amber: #ff9a1f;
  --pink: #ff2e9a;
  --cyan: #21e6ff;
  --lime: #6dff5a;
  --copper: #e58a3c;
  --ink: #fff8e1;
  --soft: #c9c3ff;
  --display: "Marker Felt", "Chalkboard SE", "Comic Sans MS", "Comic Neue", cursive;
  --body: ui-rounded, "SF Pro Rounded", "Avenir Next", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 18px/1.5 var(--body);
  background:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 9%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 62%, #ffe9a8 50%, transparent 51%),
    radial-gradient(2px 2px at 90% 71%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 22% 86%, #9ff 50%, transparent 51%),
    radial-gradient(1200px 700px at 80% -10%, #3a1c9c 0%, transparent 60%),
    var(--night);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.1; margin: 0; }
p { margin: 0 0 .8em; }
a { color: var(--cyan); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--cyan); outline-offset: 3px; border-radius: 8px; }

/* Lettering borrowed from the cover: yellow with stacked colour shadows */
.zap-type {
  color: var(--volt);
  text-shadow: 2px 2px 0 #ff3b30, 4px 4px 0 #2a6bff, 6px 6px 0 rgba(0,0,0,.35);
  letter-spacing: .04em;
  transform: rotate(-2deg);
  display: inline-block;
}

.btn {
  border: 0; border-radius: 999px;
  padding: .7em 1.4em;
  background: var(--volt); color: #2a1500;
  font-family: var(--display); font-size: 1.25rem;
  box-shadow: 0 5px 0 #c77700;
  text-decoration: none; display: inline-block;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #c77700; }
.btn.alt { background: var(--cyan); box-shadow: 0 5px 0 #0a8fa3; color: #00242b; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.age {
  display: inline-block; white-space: nowrap;
  padding: .15em .7em; border-radius: 999px;
  background: var(--pink); color: #fff; font-weight: 700; font-size: .9rem;
}
.stars { color: var(--volt); letter-spacing: .1em; font-size: 1.3rem; white-space: nowrap; }
.stars .off { color: #5a4fc0; }

/* ---------- Hub ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 2rem; align-items: center;
  max-width: 1080px; margin: 0 auto; padding: 2.5rem 1.25rem 1rem;
}
.hero h1 { font-size: clamp(3rem, 9vw, 6.2rem); }
.hero h1 span { display: block; }
.hero .lede { font-size: 1.3rem; max-width: 30ch; margin-top: 1.4rem; }
.hero img {
  width: 100%; height: auto; border-radius: 28px; display: block;
  transform: rotate(3deg);
  box-shadow: 0 0 0 6px var(--volt), 0 0 60px rgba(255,210,31,.45);
}
.journey { max-width: 1080px; margin: 0 auto; padding: 1rem 1.25rem 3rem; position: relative; }
.journey > h2 { font-size: 2rem; margin: 1.5rem 0 1.5rem 96px; color: var(--ink); }
.wire {
  position: absolute; left: calc(1.25rem + 36px); top: 6.2rem; bottom: 9.5rem; width: 10px;
  border-radius: 5px; background: var(--copper);
  overflow: hidden;
}
.wire::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 34px, #fff6c2 34px 44px);
  animation: flow 1.2s linear infinite;
}
@keyframes flow { to { transform: translateY(44px); } }
.end { display: flex; align-items: center; gap: 1.25rem; position: relative; }
.end .node { width: 82px; flex: none; text-align: center; font-size: 3rem; line-height: 1; }
.end p { margin: 0; color: var(--soft); }
.stop {
  position: relative; display: grid;
  grid-template-columns: 82px 150px minmax(0, 1fr) auto; gap: 1.25rem; align-items: center;
  margin: 1.4rem 0; color: inherit; text-decoration: none;
}
.stop .node {
  width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  background: var(--night); border: 5px solid var(--copper);
  display: grid; place-items: center; font-family: var(--display); font-size: 1.3rem; z-index: 1;
}
.stop.done .node { background: var(--volt); color: #2a1500; border-color: #fff6c2; box-shadow: 0 0 22px var(--volt); }
.stop img {
  width: 150px; height: 150px; object-fit: cover; border-radius: 50%;
  border: 5px solid var(--c, var(--cyan)); box-shadow: 0 0 26px var(--c, var(--cyan));
}
.stop h3 { font-size: 2rem; color: var(--c, var(--cyan)); margin: .25rem 0; }
.stop p { margin: 0; max-width: 46ch; }
.stop:hover img, .stop:focus-visible img { transform: scale(1.05) rotate(-3deg); }
.stop img { transition: transform .15s; }
.bulb-end { font-size: 4rem !important; filter: grayscale(1) brightness(.6); transition: filter .6s; }
.grownups {
  max-width: 1080px; margin: 0 auto 3rem; padding: 1.5rem 1.25rem;
  border-top: 2px dashed #4a3fb5; color: var(--soft); font-size: 1rem;
}
.grownups h2 { font-size: 1.5rem; color: var(--ink); margin-bottom: .6rem; }
.grownups p { max-width: 72ch; }

/* ---------- Game pages ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.2rem;
  max-width: 980px; margin: 0 auto; padding: 1rem 1.25rem;
}
.bar h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); flex: 1 1 auto; }
.back { font-family: var(--display); font-size: 1.15rem; text-decoration: none; color: var(--ink);
  padding: .35em .9em; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--soft); }
.sound { background: none; border: 0; font-size: 1.6rem; padding: .2em; }
.stage { max-width: 980px; margin: 0 auto; padding: 0 1.25rem 3rem; }
.say {
  display: flex; align-items: center; gap: 1rem;
  background: var(--deep); border: 3px solid var(--cyan); border-radius: 22px;
  padding: .8rem 1.1rem; margin-bottom: 1.2rem; min-height: 86px;
  box-shadow: 0 0 18px rgba(33,230,255,.35);
}
.say svg { width: 64px; height: 70px; flex: none; }
.say p { margin: 0; font-size: 1.15rem; }
.hud { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: center; margin-bottom: 1rem; font-weight: 700; }
.hud .pill { background: var(--panel); padding: .25em .9em; border-radius: 999px; }
.row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: 1.2rem; }

/* win dialog */
.finish { position: fixed; inset: 0; background: rgba(8,5,40,.82); display: grid; place-items: center; padding: 1rem; z-index: 20; }
.finish .card {
  background: var(--deep); border: 4px solid var(--volt); border-radius: 30px;
  padding: 1.6rem 1.8rem; max-width: 460px; text-align: center;
  box-shadow: 0 0 70px rgba(255,210,31,.5);
}
.finish svg { width: 120px; height: 130px; }
.finish h2 { font-size: 2.4rem; }
.finish .stars { font-size: 2.6rem; display: block; margin: .3rem 0; }
.finish .row { justify-content: center; }

/* ---------- Match ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); max-width: 720px; margin: 0 auto; }
.cardbtn {
  aspect-ratio: 1; border: 0; border-radius: 20px; padding: 0; position: relative;
  background: linear-gradient(135deg, #ffb52e, #ff5fa2 55%, #7a4dff);
  box-shadow: 0 5px 0 rgba(0,0,0,.35);
  font-size: clamp(1.4rem, 6vw, 3rem);
}
.cardbtn .bolt { font-size: 1em; }
.cardbtn .face { display: none; flex-direction: column; align-items: center; justify-content: center; height: 100%; line-height: 1.1; }
.cardbtn .face small { font: 700 clamp(.7rem, 2.2vw, 1rem) var(--body); color: #2a1500; margin-top: .2em; }
.cardbtn.up, .cardbtn.matched { background: #fff8e1; }
.cardbtn.up .face, .cardbtn.matched .face { display: flex; }
.cardbtn.up .bolt, .cardbtn.matched .bolt { display: none; }
.cardbtn.matched { box-shadow: 0 0 0 5px var(--lime), 0 0 26px var(--lime); }

/* ---------- Highway ---------- */
.canvas-wrap { position: relative; border-radius: 24px; overflow: hidden; border: 4px solid var(--pink); box-shadow: 0 0 30px rgba(255,46,154,.45); }
.canvas-wrap canvas { display: block; width: 100%; height: auto; touch-action: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(14,10,60,.7); text-align: center; padding: 1rem; }
.overlay h2 { font-size: 2rem; margin-bottom: .8rem; }
.pad { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }
.pad button { width: 96px; height: 72px; border-radius: 20px; border: 0; background: var(--panel); font-size: 2rem; box-shadow: 0 5px 0 #0b0733; }

/* ---------- Circuit ---------- */
.board { display: grid; gap: 5px; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); max-width: min(100%, 640px); margin: 0 auto; }
.tile { aspect-ratio: 1; border: 0; padding: 0; border-radius: 12px; background: var(--panel); display: grid; place-items: center; }
.tile svg { width: 100%; height: 100%; transition: transform .18s; }
.tile path { stroke: #8d6a55; stroke-width: 16; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tile.on { background: #3a2a9c; }
.tile.on path { stroke: var(--volt); filter: drop-shadow(0 0 6px var(--volt)); }
.endcap { display: grid; place-items: center; font-size: clamp(1.4rem, 5vw, 2.6rem); position: relative; }
.endcap::after { content: ""; position: absolute; top: 50%; height: 16%; margin-top: -8%; background: #8d6a55; border-radius: 8px; }
.endcap.src::after { right: -5px; width: 30%; background: var(--volt); }
.endcap.dst::after { left: -5px; width: 30%; }
.endcap.dst.lit::after { background: var(--volt); }
.endcap.dst { filter: grayscale(1) brightness(.7); }
.endcap.dst.lit { filter: drop-shadow(0 0 16px var(--volt)); }
.blank { visibility: hidden; }

/* ---------- LED card ---------- */
.cardlab { background: #fff8e1; border-radius: 24px; padding: 8px; border: 4px solid var(--lime); box-shadow: 0 0 30px rgba(109,255,90,.4); }
.cardlab svg { display: block; width: 100%; height: auto; }
.cardlab [data-act] { cursor: pointer; }
.cardlab [data-act]:focus-visible { outline: 4px solid #0a7bff; outline-offset: 4px; }
.flowing { stroke-dasharray: 6 16; animation: dash .7s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -22; } }

/* ---------- Ohm lab ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.2rem; }
.bench, .notes { background: var(--deep); border-radius: 24px; padding: 1.1rem 1.2rem; }
.bench { border: 4px solid var(--amber); box-shadow: 0 0 30px rgba(255,154,31,.35); }
.bench svg { width: 100%; height: auto; display: block; }
.notes h2 { font-size: 1.5rem; margin-bottom: .5rem; color: var(--volt); }
.notes dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.notes dt { color: var(--soft); }
.notes dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.formula { font-family: var(--display); font-size: 1.35rem; background: var(--night); border-radius: 14px; padding: .6rem .9rem; margin-bottom: 1rem; }
.slider { width: 100%; accent-color: var(--volt); height: 34px; }
.readout { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
details { margin-top: .8rem; }
summary { cursor: pointer; color: var(--cyan); }

@media (max-width: 760px) {
  body { font-size: 17px; }
  .hero { grid-template-columns: 1fr; padding-top: 1.5rem; }
  .hero img { max-width: 320px; margin: 0 auto; }
  .journey > h2 { margin-left: 62px; }
  .wire { left: calc(1.25rem + 20px); }
  .end .node { width: 50px; font-size: 2.2rem; }
  .stop { grid-template-columns: 50px 84px minmax(0, 1fr); gap: .8rem; }
  .stop img { width: 84px; height: 84px; }
  .stop h3 { font-size: 1.5rem; }
  .stop .stars { grid-column: 3; }
  .lab { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .wire::after, .flowing { animation: none; }
  .tile svg, .stop img { transition: none; }
}

[hidden] { display: none !important; }
