:root {
  --green: #14532d; --green2: #166534; --bg: #f5f5f0; --card: #fff; --ink: #1c1917; --muted: #78716c;
  --light: #eeeed2; --dark: #769656; --good: #16a34a; --bad: #dc2626; --blue: #2563eb; --r: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
main { max-width: 1180px; margin: 0 auto; padding: 0 12px 90px; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1 { font-size: 1.15rem; margin: 0; flex: 1; }
h2 { margin: .3em 0; } h3 { margin: 0 0 8px; font-size: 1rem; }
.fine { font-size: .78rem; color: var(--muted); } .muted { color: var(--muted); font-size: .9rem; }
.lead { font-size: 1.05rem; color: #44403c; }
.warn { color: #b45309; background: #fffbeb; padding: 8px 10px; border-radius: 10px; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.logo { font-size: 1.6rem; color: var(--green); }
.icon-btn { border: 0; background: #e7e5e4; width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; }
.grade { border: 1px solid #d6d3d1; border-radius: 10px; padding: 7px 8px; background: #fff; font: inherit; font-size: .9rem; }

.home { display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 8px auto; }
.big-btn { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--card); border: 1px solid #e7e5e4;
  border-radius: var(--r); text-align: left; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.big-btn b { display: block; font-size: 1.05rem; } .big-btn small { color: var(--muted); }
.big-btn.primary { background: var(--green); color: #fff; border: 0; padding: 26px 20px; }
.big-btn.primary small { color: #bbf7d0; } .big-btn.primary b { font-size: 1.3rem; }
.big-ico { font-size: 1.9rem; width: 44px; text-align: center; }
.link-btn { text-align: center; color: var(--green2); text-decoration: underline; font-size: .95rem; margin-top: -6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.btn { border: 1px solid #d6d3d1; background: #fff; border-radius: 12px; padding: 10px 16px; font-weight: 600; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; border-style: dashed; }
.btn.big { font-size: 1.1rem; padding: 14px 26px; }
.link { border: 0; background: none; color: var(--green2); text-decoration: underline; padding: 4px; font-size: .9rem; }
.center { text-align: center; padding: 30px 10px; }
.spinner { width: 42px; height: 42px; border: 4px solid #d6d3d1; border-top-color: var(--green); border-radius: 50%;
  animation: spin 0.9s linear infinite; margin: 20px auto; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; display: inline-block; margin: 0 6px -2px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pick { border: 2px solid #e7e5e4; background: #fff; border-radius: var(--r); padding: 6px; display: flex; flex-direction: column; gap: 6px; font-size: .85rem; }
.pick img { width: 100%; border-radius: 8px; }

/* puzzle layout: phone = one column; iPad/laptop = two columns */
.puzzle { display: grid; gap: 14px; }
@media (min-width: 820px) { .puzzle { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
  .board-col { position: sticky; top: 64px; } }
.board-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; background: #e7e5e4; border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: .95rem; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.side-src { font-size: .8rem; color: var(--muted); }
.banner { background: #ecfccb; border: 1px solid #bef264; padding: 8px 12px; border-radius: 12px; font-size: .9rem; margin-bottom: 8px; }
.board-wrap { position: relative; }
.board { width: 100%; max-width: 620px; margin: 0 auto; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.board-svg { width: 100%; height: 100%; display: block; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.photo-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000c; border-radius: 6px; z-index: 3; }
.sq.light { fill: var(--light); } .sq.dark { fill: var(--dark); }
.hl-last { fill: #f6f669; opacity: .55; } .hl-sel { fill: #baca44; opacity: .75; }
.hl-check { fill: url(#none); fill: #ef4444; opacity: .55; }
.hl-unsure { fill: none; stroke: #dc2626; stroke-width: .06; stroke-dasharray: .12 .08; }
.dot { fill: rgba(0,0,0,.22); } .dot-cap { fill: none; stroke: rgba(0,0,0,.22); stroke-width: .08; }
.coords text { font-size: .19px; font-weight: 700; } .c-light { fill: var(--light); } .c-dark { fill: var(--dark); }
.arrow-num { font-size: .26px; font-weight: 800; fill: #fff; pointer-events: none; }
.arrows { pointer-events: none; }
.dragging { pointer-events: none; }

.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; justify-content: center; }
.tool { border: 1px solid #d6d3d1; background: #fff; border-radius: 10px; padding: 8px 10px; font-size: .88rem; font-weight: 600; }
.tool.on { background: var(--green); color: #fff; border-color: var(--green); }
.palette { display: flex; flex-wrap: wrap; gap: 4px; background: #fff; border: 1px solid #e7e5e4; border-radius: 12px; padding: 8px; margin-bottom: 8px; }
.palette button { width: 44px; height: 44px; border: 1px solid #e7e5e4; background: var(--light); border-radius: 8px; padding: 2px; }
.palette button svg { width: 100%; height: 100%; }
.palette button.on { outline: 3px solid var(--green); }
.palette .eraser { font-size: 1.2rem; color: var(--bad); background: #fff; }
.palette .done { width: auto; padding: 0 16px; background: var(--green); color: #fff; font-weight: 700; }
.palette .fine { width: 100%; margin: 4px 0 0; }

.engine { background: #fff; border: 1px solid #e7e5e4; border-radius: var(--r); padding: 10px 12px; }
.eng-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.toplist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.toplist button { width: 100%; display: grid; grid-template-columns: 28px auto auto 1fr; gap: 8px; align-items: center; text-align: left;
  border: 1px solid #f0efed; background: #fafaf9; border-radius: 10px; padding: 8px; }
.toplist .num { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.toplist .ev { font-size: .85rem; color: #44403c; } .toplist .line { font-size: .78rem; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.card { background: var(--card); border: 1px solid #e7e5e4; border-radius: var(--r); padding: 14px; margin-bottom: 14px; }
.q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qnum { font-weight: 800; color: var(--green); } .tag { background: #f0fdf4; color: var(--green2); font-size: .78rem; padding: 3px 8px; border-radius: 99px; font-weight: 600; }
.question { font-size: 1.12rem; font-weight: 600; margin: 10px 0 12px; line-height: 1.35; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: center; text-align: left; border: 2px solid #e7e5e4; background: #fff; border-radius: 12px;
  padding: 12px 14px; font-size: 1.05rem; min-height: 52px; }
.opt .l { width: 30px; height: 30px; border-radius: 50%; background: #f5f5f4; display: grid; place-items: center; font-weight: 800; flex: none; }
.opt.picked { border-color: var(--blue); background: #eff6ff; }
.opt.right { border-color: var(--good); background: #f0fdf4; } .opt.right .l { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: #fef2f2; } .opt.wrong .l { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; color: inherit; opacity: 1; }
.hintbox { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hint { margin: 0; background: #fefce8; border: 1px solid #fde68a; padding: 8px 10px; border-radius: 10px; font-size: .95rem; }
.result { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: #f5f5f4; font-size: 1.02rem; }
.result.good { background: #dcfce7; } .result.bad { background: #fee2e2; }
.why { line-height: 1.45; }
details summary { cursor: pointer; font-weight: 600; color: var(--green2); }
.optnotes { padding-left: 18px; line-height: 1.4; } .optnotes li { margin: 6px 0; }
.nudge { background: #eff6ff; border-radius: 10px; padding: 8px 10px; font-size: .92rem; }
.lbl { display: block; font-size: .85rem; font-weight: 600; margin: 8px 0; }
.lbl textarea, .lbl input, .lbl select { width: 100%; font: inherit; padding: 8px; border: 1px solid #d6d3d1; border-radius: 8px; margin-top: 4px; }
.lbl.inline { display: flex; align-items: center; gap: 8px; } .lbl.inline input { margin: 0; }

.coach .feed { max-height: 260px; overflow-y: auto; font-size: .95rem; line-height: 1.4; }
.feed p { margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: #f5f5f4; }
.feed p.kid { background: #eff6ff; }
.ask { display: flex; gap: 6px; margin-top: 8px; }
.ask input { flex: 1; font: inherit; padding: 10px; border: 1px solid #d6d3d1; border-radius: 10px; min-width: 0; }
.switch { display: flex; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); margin-top: 8px; }

.mock-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fffffff0; border-top: 1px solid #e7e5e4; z-index: 10; backdrop-filter: blur(6px); }
.timer { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 110px; background: var(--green); color: #fff; padding: 6px 12px;
  border-radius: 99px; font-weight: 800; z-index: 6; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--bad); }
.mock-intro { max-width: 520px; margin: 0 auto; }
.score { font-size: 3rem; font-weight: 800; color: var(--green); margin: 10px 0; }
.results { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 720px; margin: 0 auto; }
.results button { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; text-align: left; border: 1px solid #e7e5e4;
  background: #fff; border-radius: 10px; padding: 10px; align-items: center; }
.results .ok span:first-child { color: var(--good); font-weight: 800; } .results .no span:first-child { color: var(--bad); font-weight: 800; }

.bars { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 90px; gap: 10px; align-items: center; font-size: .9rem; }
.bar { background: #e7e5e4; border-radius: 99px; height: 12px; overflow: hidden; } .bar div { background: var(--green2); height: 100%; }
.tests { padding-left: 18px; }

.promo { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 50; }
.promo-box { background: #fff; border-radius: 16px; padding: 14px 18px; text-align: center; }
.promo-row { display: flex; gap: 8px; } .promo-row button { width: 64px; height: 64px; border: 1px solid #e7e5e4; background: var(--light); border-radius: 12px; }
.promo-row svg { width: 100%; height: 100%; }
