:root {
  --bg: #eef3fb; --card: #ffffff; --ink: #1d2640; --muted: #5b6684; --line: #cfdaee;
  --blue: #2b6fe0; --blue-ink: #ffffff; --green: #1c8f50; --orange: #b4560c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141a2b; --card: #1f2740; --ink: #eef2fb; --muted: #aab4cd; --line: #38425f; --blue: #6ba0f5; --blue-ink: #0d1424; --green: #58cf8c; --orange: #f5a860; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Andika, system-ui, sans-serif; font-size: 18px; line-height: 1.4; }
main { max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: Fredoka, Andika, system-ui, sans-serif; font-weight: 600; margin: 0; }
h1 { font-size: 34px; }
.top p { margin: 6px 0 0; color: var(--muted); }
.progress { margin: 12px 0 0; font-weight: 700; color: var(--green); min-height: 25px; }
.group { margin-top: 20px; }
.group h3 { font-size: 22px; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { display: block; width: 100%; padding: 0; text-align: left; background: var(--card); color: inherit; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; font: inherit; position: relative; }
.card:hover, .card:focus-visible { border-color: var(--blue); }
.card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #fff; }
.card b { display: block; padding: 8px 10px 0; font-family: Fredoka, Andika, sans-serif; font-weight: 600; font-size: 18px; }
.card small { display: block; padding: 0 10px 10px; color: var(--muted); font-size: 15px; }
.card .done { position: absolute; top: 6px; right: 6px; background: var(--green); color: var(--blue-ink); border-radius: 999px; padding: 2px 9px; font-weight: 700; font-size: 14px; }
footer { margin-top: 28px; }
a { color: var(--blue); font-weight: 700; }

button { font: inherit; font-weight: 700; border-radius: 14px; min-height: 52px; padding: 10px 18px; cursor: pointer; border: 2px solid transparent; touch-action: manipulation; }
.primary { background: var(--blue); color: var(--blue-ink); flex: 2; font-size: 20px; }
.ghost { background: var(--card); color: var(--ink); border-color: var(--line); flex: 1; }
button:focus-visible, .card:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar .ghost { flex: 0 0 auto; min-height: 44px; padding: 6px 12px; font-size: 16px; }
.bar h2 { font-size: 24px; min-width: 0; }
.stage { position: relative; background: #eef3fb; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); aspect-ratio: 16 / 9; }
video { display: block; width: 100%; height: 100%; }
.bigplay { position: absolute; inset: 0; margin: auto; width: 84px; height: 84px; border-radius: 50%; background: var(--blue); color: var(--blue-ink); font-size: 34px; padding: 0; border: 0; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.dots { display: flex; gap: 5px; margin: 12px 0 0; }
.dots i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.dots i.on { background: var(--blue); }
.stepn { margin: 10px 0 0; color: var(--orange); font-weight: 700; font-size: 16px; min-height: 22px; }
.say { margin: 4px 0 12px; font-size: 22px; font-weight: 700; min-height: 62px; }
.controls { display: flex; gap: 10px; }
.auto { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 16px; min-height: 32px; }
.auto input { width: 20px; height: 20px; }

/* On a phone held upright, zoom the video in on its drawing page, so the drawing fills the width.
   The page is 720 x 540 at (280, 72) in the 1280 x 720 video; the step number and words are shown below instead. */
@media (max-width: 699px) {
  .stage { aspect-ratio: 4 / 3; background: #fff; }
  video { position: absolute; width: 177.78%; height: auto; max-width: none; aspect-ratio: 16 / 9; left: -38.89%; top: -13.33%; }
}

/* On a bigger screen, keep the video short enough that the buttons stay in view. */
@media (min-width: 700px) and (min-height: 621px) {
  .stage { width: min(100%, calc(60vh * 16 / 9)); margin: 0 auto; }
}

/* On a wide, short screen, put the video beside the words so both fit without scrolling. */
@media (min-width: 700px) and (max-height: 620px) {
  #player { max-width: none; display: grid; grid-template-columns: minmax(0, 3fr) minmax(220px, 1.2fr); grid-template-rows: auto auto auto auto auto auto 1fr; column-gap: 16px; padding-top: 8px; }
  .bar { grid-column: 1 / -1; margin-bottom: 6px; }
  .stage { grid-column: 1; grid-row: 2 / 8; align-self: start; max-height: calc(100vh - 80px); }
  .dots, .stepn, .say, .controls, .auto { grid-column: 2; }
  .dots { margin-top: 0; }
  .say { font-size: 19px; }
  .controls { flex-direction: column; }
  .primary, .ghost { flex: none; }
}
