/*
 * One stylesheet, no framework. The palette is a kitchen table set for a game:
 * cream paper, a tomato red for anything you can press, a sunshine yellow for
 * stars — and the two sheet colours, blue for the tens and orange for the
 * units, which are the same blue and orange printed on the sheets themselves,
 * so "a folha azul" on the screen is the blue one on the floor.
 * Headings are rounded and heavy, because some of the people reading them are five.
 */
:root {
  color-scheme: light dark;
  --bg: #fff8ee;
  --surface: #ffffff;
  --panel: #fdeedd;
  --line: #f0dcc4;
  --ink: #23203a;
  --muted: #6e6878;
  --accent: #e9482a;
  --accent-soft: #ffe2d9;
  --accent-ink: #ffffff;
  --sun: #ffc93c;
  --sun-ink: #23203a;
  --tens: #2f6df6;
  --tens-soft: #e0e9ff;
  --units: #f07c12;
  --units-soft: #ffe9d2;
  --good: #2f9e5b;
  --good-soft: #dcf5e5;
  --nearly: #b5651d;
  --bad: #c7362b;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Trebuchet MS", sans-serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151f; --surface: #211e2c; --panel: #2c2838; --line: #3b3649; --ink: #f6f0e8;
    --muted: #b0a9bb; --accent: #ff7a5c; --accent-soft: #46271f; --accent-ink: #17151f;
    --sun: #ffd35c; --sun-ink: #17151f; --tens: #7ea2ff; --tens-soft: #23305a; --units: #ffa04d;
    --units-soft: #4a2f17; --good: #6fd497; --good-soft: #1f3b2d; --nearly: #ffb27a; --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 920px; margin: 0 auto; padding: 28px 16px 80px; }
main.wide { max-width: 1200px; }
h1, h2, h3 { font-family: var(--round); font-weight: 850; letter-spacing: -0.015em; }
h1 { font-size: clamp(34px, 6.4vw, 58px); line-height: 1.05; margin: 0 0 14px; }
h2 { font-size: clamp(24px, 3.6vw, 32px); margin: 44px 0 12px; }
h3 { font-size: 20px; margin: 22px 0 6px; }
a { color: var(--accent); text-underline-offset: 3px; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 22px; margin: 0 0 14px; }
li { margin-bottom: 5px; }

.lede { font-size: clamp(18px, 2.4vw, 21px); color: var(--muted); margin-bottom: 26px; max-width: 40em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; font-weight: 800; }
.tens { color: var(--tens); }
.units { color: var(--units); }
[hidden] { display: none !important; }

/* ── Header and footer, on every page via BaseLayout ─────────────────────── */
.masthead {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  max-width: 1200px; margin: 0 auto; padding: 16px 16px 0;
}
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-family: var(--round); font-weight: 900; font-size: 28px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.wordmark img { width: 36px; height: 36px; }
.wordmark .wm span { color: var(--accent); }
.masthead nav { display: flex; gap: 4px; flex-wrap: wrap; }
.masthead nav.tabs a { padding: 7px 15px; border-radius: 99px; text-decoration: none; color: var(--muted); font-weight: 700; }
.masthead nav.tabs a:hover { background: var(--panel); }
.masthead nav.tabs a[aria-current] { background: var(--accent-soft); color: var(--ink); }
.masthead nav.more { font-size: 15px; gap: 16px; margin-left: auto; }
.masthead nav.more a { color: var(--muted); text-decoration: none; }
.masthead nav.more a[aria-current] { color: var(--ink); font-weight: 700; }

.siteftr {
  max-width: 1200px; margin: 0 auto; padding: 26px 16px 48px;
  border-top: 2px dashed var(--line); color: var(--muted); font-size: 14px;
}
.siteftr .feedback-line { font-size: 15px; color: var(--ink); }
.siteftr .feedback-line a { font-weight: 800; }

/* ── Buttons, forms, panels ──────────────────────────────────────────────── */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 750 16px/1 var(--round); padding: 14px 24px; border-radius: 99px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
button:hover, .button:hover { transform: translateY(-1px); }
button:active, .button:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 60%, #000); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
button.quiet, .button.quiet { background: var(--surface); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
button.sun, .button.sun { background: var(--sun); color: var(--sun-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--sun) 60%, #000); }
button.small, .button.small { padding: 9px 15px; font-size: 14px; }
button.big, .button.big { padding: 20px 34px; font-size: 21px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

label { display: block; font-weight: 700; margin: 16px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 14px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 600; margin: 10px 0; }
label.check input { width: auto; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--line); border-radius: 14px; padding: 11px 13px;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.panel { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 18px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }
.error { color: var(--bad); }
.ok { color: var(--good); }
.note { background: var(--accent-soft); border-radius: 16px; padding: 14px 16px; font-size: 15px; }

/* ── The front page ──────────────────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 30px; align-items: center; margin: 6px 0 18px; }
@media (max-width: 780px) { .hero { grid-template-columns: 1fr; } }
.hero h1 em { font-style: normal; color: var(--accent); }
.scene { background: var(--surface); border: 2px solid var(--line); border-radius: 26px; padding: 18px; box-shadow: 0 18px 40px -26px rgba(35, 32, 58, 0.45); }
.scene svg { display: block; width: 100%; height: auto; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; counter-reset: step; }
.steps > div { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; }
.steps > div::before { counter-increment: step; content: counter(step); font-family: var(--round); font-weight: 900; font-size: 32px; color: var(--accent); display: block; }

.levels { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.levels li { margin: 0; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.levels strong { display: block; font: 900 22px var(--round); color: var(--accent); }

/* ── Stars and progress ──────────────────────────────────────────────────── */
.stars { font: 900 20px var(--round); color: var(--ink); white-space: nowrap; }
.stars::before { content: "★ "; color: var(--sun); }
.badge { display: inline-block; font: 800 13px var(--round); padding: 4px 11px; border-radius: 99px; background: var(--accent-soft); color: var(--ink); }
.meter-bar { height: 12px; border-radius: 99px; background: var(--panel); overflow: hidden; margin: 8px 0; }
.meter-bar > div { height: 100%; width: 0; background: var(--sun); transition: width 0.4s ease; }

/* ── Players ─────────────────────────────────────────────────────────────── */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 14px 0; }
.players li { margin: 0; }
.players button { width: 100%; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface); color: var(--ink); border: 3px solid var(--line); box-shadow: none; text-align: left; }
.players button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.players .who { font: 900 22px var(--round); }

.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: 14px 0; border-bottom: 2px dashed var(--line); }
.list .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list .title { font: 800 19px var(--round); }

/* ── The game ────────────────────────────────────────────────────────────── */
.stage { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .stage { grid-template-columns: minmax(0, 1fr); } }
.camera { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; touch-action: manipulation; }
.camera video, .camera canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera canvas { cursor: crosshair; }
.camera .hint { position: absolute; left: 10px; right: 10px; bottom: 10px; color: #fff; font: 700 15px var(--round); text-shadow: 0 1px 4px #000; pointer-events: none; }
.camera .off { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 20px; }

.board { text-align: center; background: var(--surface); border: 2px solid var(--line); border-radius: 26px; padding: 18px; }
.board .who { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.big-number { font: 900 clamp(90px, 20vw, 190px)/1 var(--round); color: var(--accent); margin: 10px 0; min-height: 1em; transition: transform 0.2s ease; }
.big-number.right { color: var(--good); transform: scale(1.08); }
.big-number.nearly { color: var(--nearly); }
.big-number.levelup { color: var(--sun); transform: scale(1.15) rotate(-3deg); }
.big-number .t { color: var(--tens); }
.big-number .u { color: var(--units); }
.subtitle { font: 800 clamp(18px, 2.8vw, 24px)/1.3 var(--round); min-height: 2.6em; margin: 8px 0; }
.sheets-now { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; font-weight: 800; }
.sheets-now span { padding: 6px 14px; border-radius: 99px; }
.sheets-now .tens { background: var(--tens-soft); }
.sheets-now .units { background: var(--units-soft); }

.playing .masthead, .playing .siteftr .about { display: none; }

/* ── The printable sheets ────────────────────────────────────────────────── */
.sheet-preview { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px; margin: 14px 0; }
.sheet {
  width: 297mm; height: 210mm; padding: 9mm 12mm 12mm; background: #fff; color: #111;
  display: flex; flex-direction: column; gap: 4mm; font-family: var(--round);
}
.sheet header { display: flex; justify-content: space-between; align-items: baseline; height: 12mm; }
.sheet header strong { font-size: 9mm; letter-spacing: 0.04em; }
.sheet header small { font: 3.4mm var(--sans); color: #555; }
.sheet .frame { flex: 1; border: 4mm solid #111; display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(2, 1fr); }
.sheet .frame div { display: grid; place-items: center; border: 0.4mm solid #bbb; font: 900 62mm/1 "Arial Rounded MT Bold", "Arial Black", Arial, sans-serif; }
.sheet.tens header strong, .sheet.tens .frame div { color: #2f6df6; }
.sheet.units header strong, .sheet.units .frame div { color: #f07c12; }
.sheet.vertical { width: 210mm; height: 297mm; }
.sheet.vertical .frame { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(5, 1fr); }
.sheet.vertical .frame div { font-size: 42mm; }
#sheets[data-orientation="horizontal"] .sheet-preview.vertical,
#sheets[data-orientation="vertical"] .sheet-preview.horizontal { display: none; }
.sheet-scale { transform-origin: top left; }
@media screen {
  .sheet-holder { overflow: hidden; }
}
@media print {
  @page { size: A4 landscape; margin: 0; }
  @page vertical { size: A4 portrait; margin: 0; }
  .sheet.vertical { page: vertical; }
  body { background: #fff; }
  .masthead, .siteftr, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheet-preview { border: 0; padding: 0; margin: 0; border-radius: 0; }
  .sheet-holder { height: auto !important; }
  .sheet-scale { transform: none !important; }
  .sheet { page-break-after: always; break-after: page; }
  .sheet .frame div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
