/* SHABDA Akshara: warm brown / gold / cream (the SHABDA vision palette), light and dark.
   Touch targets ≥ 56 px; works from 360 px wide; landscape puts the letter beside the buttons. */

@font-face { font-family: "VijayaDV"; src: url("../fonts/VijayaDV.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Noto Sans Telugu"; src: url("../fonts/NotoSansTelugu-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Noto Sans Kannada"; src: url("../fonts/NotoSansKannada-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("../fonts/NotoSans-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  color-scheme: light;
  --bg: #fbf4e6;
  --surface: #fffbf3;
  --sunk: #f5e6c8;
  --ink: #2d1f0e;
  --muted: #5e4a2c;
  --line: #dcc8a0;
  --band: #1a1510;
  --band-2: #2d1f0e;
  --band-ink: #f5e6c8;
  --gold: #b8860b;          /* decoration only (stars, rings); not for text on cream */
  --gold-text: #7d5b07;
  --primary: #2d1f0e;
  --on-primary: #f5e6c8;
  --soft: #f5e6c8;
  --on-soft: #2d1f0e;
  --ok: #2f6b3f;
  --again: #8a4510;
  --danger: #a3321f;
  --guide: #e2cc9e;
  --pen: #c2581b;
  --focus: #7d5b07;
  --f-ui: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1510;
    --surface: #2d1f0e;
    --sunk: #3a2914;
    --ink: #f5e6c8;
    --muted: #d6c29c;
    --line: #5a4428;
    --gold: #e0b13a;
    --gold-text: #ecc35e;
    --primary: #e0b13a;
    --on-primary: #1a1510;
    --soft: #3f2d16;
    --on-soft: #f5e6c8;
    --ok: #93d6a4;
    --again: #f5b475;
    --danger: #f39482;
    --guide: #54401f;
    --pen: #f6a24c;
    --focus: #ecc35e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1510;
  --surface: #2d1f0e;
  --sunk: #3a2914;
  --ink: #f5e6c8;
  --muted: #d6c29c;
  --line: #5a4428;
  --gold: #e0b13a;
  --gold-text: #ecc35e;
  --primary: #e0b13a;
  --on-primary: #1a1510;
  --soft: #3f2d16;
  --on-soft: #f5e6c8;
  --ok: #93d6a4;
  --again: #f5b475;
  --danger: #f39482;
  --guide: #54401f;
  --pen: #f6a24c;
  --focus: #ecc35e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 18px;
  line-height: 1.5;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0.4em 0 0.5em; }
h2 { font-size: 1.15rem; margin: 1em 0 0.4em; }
h1:focus, h2:focus { outline: none; }
p { margin: 0.4em 0; }
.center { text-align: center; }
.lead { font-size: 1.1rem; }
.note, .hint, .opt { color: var(--muted); }
.hint, .opt { font-size: 0.95rem; }
.error { color: var(--danger); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* brand band */
.band {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(90deg, var(--band), var(--band-2));
  color: var(--band-ink);
  min-height: 56px;
}
.band-mark img { display: block; border-radius: 9px; }
.band-name { font-size: 1.15rem; letter-spacing: 0.02em; }
.band-name b { color: #e8bf55; letter-spacing: 0.08em; }

main { max-width: 600px; margin: 0 auto; padding: 8px 16px 32px; }

/* cards and forms */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
}
.card > h2:first-child { margin-top: 0; }
.field { margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
fieldset.field legend, .field > label { display: block; font-weight: 700; margin-bottom: 6px; padding: 0; }
input[type="text"], input:not([type]), input[type="email"], textarea {
  width: 100%;
  min-height: 56px;
  font: inherit;
  font-size: 1.15rem;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
}
input:focus-visible, textarea:focus-visible { border-color: var(--focus); }
textarea { min-height: 160px; font-size: 1rem; margin: 8px 0; }

.choices { display: grid; gap: 10px; }
.choices-3 { grid-template-columns: repeat(3, 1fr); }
.choices-script { grid-template-columns: repeat(2, 1fr); }
.choice {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--gold-text); background: var(--sunk); box-shadow: inset 0 0 0 2px var(--gold-text); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.choice-script { flex-direction: column; gap: 0; min-height: 96px; }
.choice-script .sample { font-size: 2.6rem; line-height: 1.15; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; min-width: 56px;
  padding: 10px 20px;
  border-radius: 16px;
  border: 2px solid transparent;
  font: inherit; font-weight: 700; font-size: 1.1rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-soft { background: var(--soft); color: var(--on-soft); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); margin-top: 12px; }
.btn-wide { width: 100%; }
.btn-icon { padding: 0; width: 56px; }
.btn-big { min-height: 76px; flex-direction: column; gap: 2px; font-size: 1.05rem; }
.ico { width: 26px; height: 26px; flex: none; }
.btn-big .ico { width: 32px; height: 32px; }
.row { display: flex; gap: 12px; margin: 14px 0; }
.row > .btn { flex: 1; }

/* home: the children */
.kids {
  list-style: none; margin: 16px 0 24px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.kid {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 10px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 24px;
  font: inherit;
  cursor: pointer;
}
.kid:active { transform: scale(0.98); }
.avatar {
  display: grid; place-items: center;
  width: 104px; height: 104px;
  border-radius: 50%;
  font-size: 3.2rem; font-weight: 700;
  color: #fffaf0;
  box-shadow: 0 0 0 4px var(--gold);
}
.av0 { background: #8a4510; }
.av1 { background: #2f6b3f; }
.av2 { background: #34539a; }
.av3 { background: #7d2d4a; }
.av4 { background: #6b4f0a; }
.av5 { background: #1c6466; }
.kid-name { font-size: 1.35rem; font-weight: 700; margin-top: 6px; }
.kid-script { color: var(--muted); font-size: 0.95rem; }

.kid-rows { list-style: none; margin: 0 0 12px; padding: 0; }
.kid-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kid-row:last-child { border-bottom: 0; }
.kid-row-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.kid-row .btn { padding: 8px 12px; font-size: 1rem; }

/* writing */
.write-top { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.write-name { flex: 1; margin: 0; font-size: 1.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star-count { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--gold-text); white-space: nowrap; }
.group-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
.group-name { margin: 0; color: var(--muted); font-weight: 600; }
.dots { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold); }
.dot.done { background: var(--gold); }
.dot.now { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }

.stage {
  position: relative;
  width: min(100%, 58vh, 520px);
  aspect-ratio: 1 / 1;
  margin: 6px auto;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage .ink { touch-action: none; cursor: crosshair; }
.roman { text-align: center; color: var(--muted); font-size: 1rem; margin: 2px 0; min-height: 1.5em; }
.bubble {
  text-align: center; font-size: 2.4rem; font-weight: 700;
  margin: 4px auto; padding: 4px 18px; width: fit-content;
  background: var(--sunk); color: var(--ink); border-radius: 18px;
}
.feedback { text-align: center; font-size: 1.35rem; font-weight: 700; min-height: 2em; margin: 4px 0; }
.feedback.ok { color: var(--ok); }
.feedback.again { color: var(--again); }
.time-note { text-align: center; color: var(--muted); }
.controls { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 10px; margin-top: 6px; }

/* a short burst of stars on a pass */
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst span { position: absolute; left: 50%; top: 50%; font-size: 2.6rem; color: var(--gold); opacity: 0; }
.burst.go span { animation: fly 1.2s ease-out forwards; }
.burst .b1 { --dx: -120px; --dy: -110px; }
.burst .b2 { --dx: 120px; --dy: -100px; }
.burst .b3 { --dx: -130px; --dy: 90px; }
.burst .b4 { --dx: 125px; --dy: 105px; }
.burst .b5 { --dx: 0px; --dy: -150px; }
@keyframes fly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3); }
}
@media (prefers-reduced-motion: reduce) {
  .burst.go span { animation: none; opacity: 1; transform: translate(calc(-50% + var(--dx) * 0.6), calc(-50% + var(--dy) * 0.6)); }
}

/* summary and job card */
.sum-stars { font-size: 2rem; font-weight: 700; color: var(--gold-text); margin: 0; }
.letters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.chip {
  display: inline-grid; place-items: center;
  min-width: 56px; height: 56px; padding: 0 10px;
  font-size: 2rem; line-height: 1;
  background: var(--sunk); border-radius: 14px;
}
.none { color: var(--muted); }

.month-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.month-switch h2 { margin: 0; font-size: 1.3rem; text-align: center; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.tiles div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 4px; text-align: center; }
.tiles dt { color: var(--muted); font-size: 0.85rem; }
.tiles dd { margin: 0; font-size: 1.6rem; font-weight: 700; }
.jc-table { width: 100%; border-collapse: collapse; }
.jc-table th, .jc-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.jc-table thead th { font-size: 0.9rem; color: var(--muted); }
.jc-letter { font-size: 1.8rem; font-weight: 400; }

/* landscape phones: the letter beside the buttons */
@media (orientation: landscape) and (max-height: 560px) {
  .band { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
  main { max-width: 980px; }
  .screen-write:not([hidden]) {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "stage top" "stage group" "stage roman" "stage bubble" "stage fb" "stage time" "stage controls";
    column-gap: 18px; align-items: start;
  }
  .write-top { grid-area: top; }
  .group-line { grid-area: group; }
  .stage { grid-area: stage; width: min(78vh, 420px); margin: 0; }
  .roman { grid-area: roman; }
  .bubble { grid-area: bubble; }
  .feedback { grid-area: fb; }
  .time-note { grid-area: time; }
  .controls { grid-area: controls; }
}

@media (max-width: 380px) {
  h1 { font-size: 1.5rem; }
  .tiles dd { font-size: 1.35rem; }
  .avatar { width: 88px; height: 88px; font-size: 2.7rem; }
  .kids { grid-template-columns: repeat(2, 1fr); }
}
