/* ==========================================================================
   Pattern Detective — The Balance Files
   Standalone companion site for Maths Explorers Club Unit 6.
   Design language: dark teal chrome, light-blue accent, cream sections,
   rounded cards, soft shadows, pill tags (all code written for this site).
   ========================================================================== */
:root {
  --teal-darkest: #123c3c; --teal-dark: #1a4f4f; --teal-mid: #2b6f6f;
  --accent: #7dc1d1; --accent-soft: #a9d6e1; --accent-tint: #eaf5f8;
  --ink: #17262e; --ink-soft: #4c636d; --line: #dde9ec;
  --paper: #fff; --cream: #f7f4ee; --radius: 18px;
  --shadow: 0 10px 30px rgba(18, 60, 60, 0.10);
  --shadow-hover: 0 18px 44px rgba(18, 60, 60, 0.18);
  --good-bg: #d6efdd; --good-line: #4d9c66; --good-ink: #1e5c33;
  --bad-bg: #f8dcdc; --bad-line: #c66; --bad-ink: #8a2f2f;
  --gold: #b8860b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--ink); background: var(--paper); line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--teal-mid); text-decoration: none; }
a:hover { color: var(--teal-dark); }
.container { width: min(1180px, 92%); margin: 0 auto; }

/* skip link + header */
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--teal-darkest); padding: .6rem 1rem; border-radius: 0 0 10px 0; z-index: 200; }
.skip-link:focus { left: 0; }

/* site header */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--teal-darkest); border-bottom: 1px solid rgba(125, 193, 209, 0.18); }
.nav { display: flex; align-items: center; justify-content: space-between; padding: .9rem 0; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand:hover { color: var(--accent-soft); }
.brand-logo { height: 34px; width: 34px; }
.brand .brand-name { color: var(--accent); }
.brand:hover .brand-name { color: var(--accent-soft); }
.nav-links { display: flex; align-items: center; gap: .4rem; list-style: none; }
.nav-links a { color: #dcebee; font-size: .95rem; padding: .45rem .9rem; border-radius: 999px; transition: background .2s, color .2s; }
.nav-links a:hover { background: rgba(125, 193, 209, 0.15); color: #fff; }
.nav-links a.active { background: var(--accent); color: var(--teal-darkest); font-weight: 600; }
.nav-toggle { display: none; background: none; border: 1px solid rgba(125,193,209,.4); color: #fff; border-radius: 10px; padding: .4rem .7rem; font-size: 1.1rem; cursor: pointer; }
@media (max-width: 900px) {
  .nav { flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--teal-darkest); flex-direction: column; align-items: stretch; padding: .8rem 4%; border-bottom: 1px solid rgba(125,193,209,.25); }
  .nav-links.open { display: flex; }
  .nav-links a.back-home { margin-right: 0; margin-bottom: .3rem; }
}

/* back link to parent site */
.nav-links a.back-home { border: 1px solid rgba(125,193,209,.4); color: var(--accent-soft); margin-right: .4rem; }
.nav-links a.back-home:hover { background: rgba(125,193,209,.15); color: #fff; }

/* hero */
.hero { position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(1100px 500px at 50% -10%, rgba(125,193,209,.22), transparent 60%),
              linear-gradient(160deg, var(--teal-darkest) 0%, var(--teal-dark) 55%, #22605f 100%);
  text-align: center; padding: 5rem 0 4.2rem; }
#hero-particles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.hero-inner { position: relative; z-index: 2; }
.pill { display: inline-block; padding: .4rem 1.1rem; border-radius: 999px; background: rgba(125,193,209,.16); border: 1px solid rgba(125,193,209,.45); color: var(--accent-soft); font-size: .9rem; letter-spacing: .4px; margin-bottom: 1.4rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.15; font-weight: 800; margin-bottom: 1rem; }
.hero h1 .hl { color: var(--accent); }
.hero p.lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: #cfe4e8; max-width: 720px; margin: 0 auto 1rem; }
.hero p.sub { color: #a9c8cd; max-width: 640px; margin: 0 auto 2.2rem; font-size: .98rem; }
.btn-row { display: flex; gap: .9rem; justify-content: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: .55rem; padding: .85rem 1.7rem; border-radius: 999px; font-weight: 700; font-size: 1rem; cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s; border: none; font-family: inherit; }
.btn-primary { background: var(--accent); color: var(--teal-darkest); box-shadow: 0 8px 22px rgba(125,193,209,.35); }
.btn-primary:hover { background: var(--accent-soft); transform: translateY(-2px); color: var(--teal-darkest); }
.btn-ghost { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.16); transform: translateY(-2px); color: #fff; }
.hero-figure { position: relative; z-index: 2; margin: 3rem auto 0; width: min(860px, 92%); border-radius: 24px; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,.35); border: 1px solid rgba(125,193,209,.25); background: rgba(255,255,255,.04); padding: 1.5rem; }
.hero-figure.hero-img { padding: 0; }
.hero-figure.hero-img img { display: block; width: 100%; height: auto; }

/* sections */
.section { padding: 4.5rem 0; }
.section.alt { background: var(--cream); }
.section-head { text-align: center; max-width: 760px; margin: 0 auto 3rem; }
.section-label { display: inline-block; font-size: .82rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--teal-mid); background: var(--accent-tint); border: 1px solid var(--line); padding: .35rem 1rem; border-radius: 999px; margin-bottom: 1rem; }
.section-head h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 800; margin-bottom: .8rem; }
.section-head p { color: var(--ink-soft); }

/* game cards */
.games-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2rem; }
.games-grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .games-grid, .games-grid.three { grid-template-columns: 1fr; } }
.game-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .2s, box-shadow .25s; }
.game-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }
.game-thumb { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--accent-tint); display: grid; place-items: center; }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-body { padding: 1.6rem 1.7rem 1.8rem; display: flex; flex-direction: column; flex: 1; }
.game-body h3 { font-size: 1.35rem; font-weight: 800; margin-bottom: .5rem; }
.game-body p { color: var(--ink-soft); font-size: .96rem; margin-bottom: 1.1rem; }
.tags { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1.3rem; }
.tag { font-size: .78rem; font-weight: 600; color: var(--teal-mid); background: var(--accent-tint); border: 1px solid var(--line); padding: .25rem .7rem; border-radius: 999px; }
.game-actions { margin-top: auto; display: flex; gap: .7rem; flex-wrap: wrap; }
.btn-play { background: var(--accent); color: var(--teal-darkest); padding: .65rem 1.4rem; font-size: .95rem; }
.btn-play:hover { background: var(--accent-soft); color: var(--teal-darkest); transform: translateY(-2px); }
.btn-learn { background: transparent; color: var(--teal-mid); border: 1px solid var(--line); padding: .65rem 1.2rem; font-size: .95rem; }
.btn-learn:hover { background: var(--accent-tint); color: var(--teal-dark); }

/* why grid + prose */
.why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6rem; margin-top: 1rem; }
@media (max-width: 900px) { .why-grid { grid-template-columns: 1fr; } }
.why-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.8rem 1.6rem; box-shadow: var(--shadow); text-align: center; }
a.link-card { display: block; color: inherit; transition: transform .2s, box-shadow .25s; }
a.link-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); color: inherit; }
a.link-card h3 { color: var(--teal-dark); }
.why-icon { width: 54px; height: 54px; margin: 0 auto 1rem; border-radius: 16px; background: var(--accent-tint); border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.5rem; }
.why-card h3 { font-size: 1.08rem; font-weight: 700; margin-bottom: .5rem; }
.why-card p { color: var(--ink-soft); font-size: .92rem; }
.prose { max-width: 820px; margin: 2.5rem auto 0; color: var(--ink-soft); }
.prose h3 { color: var(--ink); font-size: 1.25rem; margin: 1.6rem 0 .6rem; }
.prose p { margin-bottom: 1rem; }
.prose ul { margin: 0 0 1rem 1.2rem; }
.prose li { margin-bottom: .4rem; }

/* learn page */
.chapter { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; margin-bottom: 2rem; }
.chapter h3 { font-size: 1.35rem; font-weight: 800; margin-bottom: .4rem; }
.chapter p { color: var(--ink-soft); max-width: 760px; margin-bottom: .7rem; }
.key-idea { display: inline-block; background: var(--accent-tint); border: 1px solid var(--line); border-radius: 14px; padding: .7rem 1.2rem; font-weight: 700; color: var(--teal-dark); margin: 1rem 0; font-size: 1.05rem; }
.chapter-img { display: block; width: 100%; height: auto; border-radius: 14px; margin: .8rem 0 .2rem; }
.hundred { display: grid; grid-template-columns: repeat(10, 1fr); gap: .25rem; max-width: 420px; margin: 1.2rem 0; }
.hundred span { text-align: center; font-size: .8rem; font-weight: 700; padding: .3rem 0; border-radius: 8px; background: var(--cream); border: 1px solid var(--line); color: var(--ink-soft); }
.hundred span.on { background: var(--accent); color: var(--teal-darkest); border-color: var(--teal-mid); }
.mini-btn { font: inherit; font-weight: 700; background: var(--accent-tint); color: var(--teal-dark); border: 1px solid var(--line); border-radius: 999px; padding: .35rem 1rem; cursor: pointer; margin: .2rem .3rem .2rem 0; }
.mini-btn:hover, .mini-btn.on { background: var(--accent); color: var(--teal-darkest); }
.wordpower { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .95rem; }
.wordpower th, .wordpower td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.wordpower th { color: var(--teal-dark); background: var(--accent-tint); }
.wordpower td:first-child { font-weight: 700; white-space: nowrap; color: var(--teal-dark); }
.activity { background: var(--accent-tint); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; margin: 1rem 0; }
.activity h4 { margin-bottom: .3rem; }
.activity p, .activity li { font-size: .95rem; color: var(--ink-soft); }
.activity ul { margin: .4rem 0 0 1.2rem; }
.remember { background: var(--teal-darkest); color: #fff; border-radius: var(--radius); padding: 1.6rem 1.8rem; margin: 2rem 0; font-weight: 600; }
.remember strong { color: var(--accent-soft); }

/* game pages */
.game-hero { color: #fff; background: radial-gradient(900px 400px at 50% -10%, rgba(125,193,209,.22), transparent 60%), linear-gradient(160deg, var(--teal-darkest), var(--teal-dark)); padding: 3.2rem 0 2.6rem; text-align: center; }
.game-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; margin-bottom: .5rem; }
.game-hero p { color: #cfe4e8; max-width: 620px; margin: 0 auto; }
.game-wrap { padding-bottom: 4.5rem; }
.game-shell { position: relative; max-width: 900px; margin: -1.6rem auto 0; background: var(--paper); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-hover); padding: 1.8rem; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.hud .stat { font-weight: 700; color: var(--teal-dark); background: var(--accent-tint); border: 1px solid var(--line); border-radius: 999px; padding: .35rem 1rem; font-size: .95rem; }
.stage-box { display: grid; place-items: center; padding: 1.2rem; background: var(--cream); border: 1px solid var(--line); border-radius: 16px; min-height: 200px; text-align: center; }
.stage-box .sentence { font-size: clamp(1.5rem, 3.5vw, 2.2rem); font-weight: 800; letter-spacing: 1px; }
.necklace { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 1rem; }
.bead { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--ink-soft); }
.bead.red { background: #e2554f; border-color: #b03a35; color: #fff; }
.bead.blue { background: #4f7de2; border-color: #3554b0; color: #fff; }
.bead.target { outline: 3px dashed var(--gold); outline-offset: 2px; }
.prompt { font-size: 1.15rem; font-weight: 700; color: var(--teal-dark); margin-bottom: .4rem; }
.feedback { min-height: 1.6rem; margin-top: .9rem; font-weight: 600; color: var(--ink-soft); }
.feedback.good { color: var(--good-ink); }
.feedback.bad { color: var(--bad-ink); }
.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin-top: 1.4rem; }
.option-btn { font: inherit; font-size: 1.25rem; font-weight: 800; color: var(--teal-dark); background: var(--accent-tint); border: 2px solid var(--line); border-radius: 16px; padding: 1rem; cursor: pointer; transition: transform .12s, background .15s, border-color .15s; }
.option-btn:hover { border-color: var(--teal-mid); transform: translateY(-2px); }
.option-btn.good { background: var(--good-bg); border-color: var(--good-line); color: var(--good-ink); }
.option-btn.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.option-btn:disabled { cursor: default; transform: none; }
.tf-row { display: flex; gap: 1rem; justify-content: center; margin-top: 1.4rem; }
.tf-btn { font: inherit; font-size: 1.3rem; font-weight: 800; padding: .9rem 2.6rem; border-radius: 999px; border: 2px solid var(--line); background: var(--accent-tint); color: var(--teal-dark); cursor: pointer; transition: transform .12s, background .15s; }
.tf-btn:hover { transform: translateY(-2px); border-color: var(--teal-mid); }
.tf-btn.good { background: var(--good-bg); border-color: var(--good-line); color: var(--good-ink); }
.tf-btn.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.scale-stage svg { max-width: 380px; width: 100%; }
.beam { transform-origin: 190px 90px; transition: transform .5s ease; }
.beam.tip-left { transform: rotate(-7deg); }
.beam.tip-right { transform: rotate(7deg); }
.overlay { position: absolute; inset: 0; background: rgba(247, 244, 238, .96); border-radius: 24px; place-items: center; text-align: center; padding: 2rem; z-index: 40; display: none; }
.overlay:not([hidden]) { display: grid; }
.overlay h3 { font-size: 1.6rem; font-weight: 800; margin-bottom: .4rem; }
.overlay .stars { font-size: 2rem; margin: .6rem 0; letter-spacing: .3rem; }
.overlay p { color: var(--ink-soft); margin-bottom: 1.2rem; }
.grownups { margin-top: 2.2rem; background: var(--cream); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem 1.4rem; }
.grownups h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.grownups p, .grownups li { font-size: .92rem; color: var(--ink-soft); }

.reflist { list-style: none; margin: 0 0 .6rem; }
.reflist li { padding: .8rem 0; border-bottom: 1px dashed var(--line); font-size: .95rem; color: var(--ink-soft); }
.reflist li:last-child { border-bottom: none; }
.reflist a { word-break: break-all; font-weight: 600; }
.reflist strong { color: var(--ink); }

/* footer */
.site-footer { background: var(--teal-darkest); color: #cfe4e8; padding: 3rem 0 2rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 2rem; }
@media (max-width: 1000px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer h4 { color: var(--accent); margin-bottom: .6rem; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: .35rem; }
.footer-links a { color: #dcebee; }
.footer-links a:hover { color: #fff; }
.footer-bottom { margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid rgba(125,193,209,.2); font-size: .88rem; color: #a9c8cd; }
.footer-note { margin-top: .8rem; font-size: .8rem; color: #8fb4ba; max-width: 720px; }
