/* Stylus Practice
   Layout: one narrow column, one task per screen, large controls for older hands and eyes. */

:root {
  --bg: #F2F5F8;
  --surface: #FFFFFF;
  --ink: #13203A;
  --muted: #45536A;
  --line: #C7D0DB;
  --accent: #0B6B6B;
  --accent-ink: #FFFFFF;
  --accent-soft: #D6ECEA;
  --success: #23692F;
  --success-soft: #DCF0E0;
  --on-success: #FFFFFF;
  --guide: #8C9BB0;
  --pen: #1D4ED8;
  --start: #1E8E3E;
  --target: #C2410C;
  --focus: #E89B0C;
  --c-red: #C62828;
  --c-blue: #1D4ED8;
  --c-green: #2E7D32;
  --c-purple: #7B1FA2;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F151E;
    --surface: #18212D;
    --ink: #EEF2F7;
    --muted: #B3BECB;
    --line: #34414F;
    --accent: #43BDB4;
    --accent-ink: #05201E;
    --accent-soft: #123F3C;
    --success: #74D488;
    --success-soft: #163821;
    --on-success: #08200F;
    --guide: #6E8096;
    --pen: #7FA9FF;
    --start: #4ADE80;
    --target: #FB8B3C;
    --c-red: #FF6B6B;
    --c-blue: #7FA9FF;
    --c-green: #6FD27E;
    --c-purple: #D08BFF;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.25rem;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#home, #boxes, #done, #certificate { overflow-y: auto; }
#trace { overflow: hidden; }
.screen-center { justify-content: center; align-items: center; text-align: center; }

h1 { font-size: 2.1rem; line-height: 1.15; margin: 0; text-wrap: balance; }
h2 { font-size: 1.6rem; line-height: 1.2; margin: 0; text-wrap: balance; }
h1:focus, h2:focus { outline: none; }
p { margin: 0; }

.lede { margin-top: 6px; color: var(--muted); }
.hint { color: var(--muted); font-size: 1.05rem; }
.instruction { color: var(--muted); margin-top: 4px; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.25rem;
  min-height: 60px;
  padding: 12px 22px;
  border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-quiet { background: transparent; color: var(--accent); padding-left: 4px; padding-right: 12px; min-height: 52px; align-self: flex-start; }
.btn-wide { width: 100%; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

/* Home */
.level-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.level {
  width: 100%;
  min-height: 92px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.level:active { border-color: var(--accent); }
.level:disabled { cursor: not-allowed; opacity: 0.6; }
.level-icon {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.level-icon svg { width: 34px; height: 34px; }
.level-text { display: flex; flex-direction: column; min-width: 0; }
.level-number { font-size: 0.95rem; font-weight: 700; color: var(--accent); letter-spacing: 0.04em; text-transform: uppercase; }
.level-name { font-weight: 700; font-size: 1.3rem; }
.level-desc { color: var(--muted); font-size: 1.05rem; }
.status {
  font-size: 1rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  white-space: nowrap;
}
.status.is-done { background: var(--success-soft); color: var(--success); }
.status.is-locked { background: transparent; color: var(--muted); border: 2px solid var(--line); }

.privacy-note {
  margin-top: auto;
  font-size: 1rem;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

/* Activity screens */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.step { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

.pad {
  position: relative;
  flex: 1;
  min-height: 220px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pad canvas { position: absolute; top: 0; left: 0; touch-action: none; }

.pad-message {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: var(--on-success);
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 999px;
  pointer-events: none;
}

.meter-row { display: flex; align-items: center; gap: 12px; }
.meter-label { font-size: 1rem; color: var(--muted); font-weight: 700; }
.meter { flex: 1; height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
.meter-fill.is-full { background: var(--success); }

.feedback { min-height: 1.45em; font-weight: 600; }

.trace-word { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin-top: 6px; color: var(--ink); letter-spacing: 0.02em; }

.actions { display: flex; gap: 12px; }
.actions .btn { flex: 1; }


/* Level 1: checkboxes */
.box-options { display: flex; flex-direction: column; gap: 12px; }
.box-options.is-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.box-options.is-grid .check { min-height: 64px; padding: 10px 12px; gap: 10px; font-size: 1.2rem; }
.check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 600;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.check.is-checked { border-color: var(--swatch, var(--accent)); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.check-box {
  flex: none;
  width: 44px; height: 44px;
  border: 3px solid var(--swatch, var(--ink));
  border-radius: 8px;
  background: var(--surface);
  display: grid; place-items: center;
  color: #FFFFFF;
}
.check-box svg { width: 30px; height: 30px; visibility: hidden; }
.check input:checked + .check-box { background: var(--swatch, var(--accent)); border-color: var(--swatch, var(--accent)); }
.check input:checked + .check-box svg { visibility: visible; }
.check input:focus-visible + .check-box { outline: 4px solid var(--focus); outline-offset: 3px; }
.check input:disabled ~ .check-label { color: var(--muted); }

.color-panel {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); text-align: center;
}
.color-step {
  align-self: stretch;
  font-weight: 700; font-size: 1.3rem;
  padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--ink);
}
.color-step.flash { animation: flash 0.5s ease-out; }
@keyframes flash { from { transform: scale(1.04); } to { transform: scale(1); } }
.color-panel .hint { font-size: 0.95rem; }
.color-text { font-size: 2.6rem; font-weight: 800; line-height: 1.1; color: var(--muted); }

.feedback.is-good { color: var(--success); }

.big-button {
  width: 100%;
  min-height: 200px;
  font-size: 2rem;
  border-radius: 28px;
  background: var(--accent);
  color: var(--accent-ink);
}

/* Done */
.done-check {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: grid; place-items: center;
}
.done-check svg { width: 60px; height: 60px; }
.done-text { color: var(--muted); max-width: 32ch; }
#done .btn { max-width: 420px; }

/* Certificate */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 700; }
.field input {
  font: inherit;
  font-size: 1.3rem;
  min-height: 60px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}
.cert-image {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  -webkit-touch-callout: default;
}

@media (prefers-reduced-motion: reduce) {
  .color-step.flash { animation: none; }
  .meter-fill { transition: none; }
}
