/* =====================================================================
   Digits by Hand — shared styles
   ===================================================================== */
:root {
  --bg: #f6f2ea;
  --bg-glow: #fff7e8;
  --dot: rgba(60, 48, 20, 0.10);
  --surface: #fffdf9;
  --surface-2: #f3eee3;
  --ink: #191c22;
  --ink-2: #4a4f5b;
  --muted: #868b96;
  --line: #e6dfcf;
  --line-2: #d8cfba;
  --accent: #ff5a2b;
  --accent-hover: #f04a1b;
  --accent-soft: #ffe7dc;
  --on-accent: #ffffff;
  --pen: #2b54e0;
  --pen-soft: #e3e9ff;
  --ok: #138a55;
  --ok-soft: #dcf3e7;
  --bad: #d23f2f;
  --bad-soft: #fde3df;
  --hl: #ffdf6b;
  --paper: #fffefa;
  --paper-line: rgba(43, 84, 224, 0.075);
  --stroke-ink: #15181f;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.05), 0 10px 30px -12px rgba(40, 30, 10, 0.18);
  --shadow-lg: 0 2px 6px rgba(40, 30, 10, 0.05), 0 28px 60px -20px rgba(40, 30, 10, 0.30);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317;
    --bg-glow: #1d1a16;
    --dot: rgba(255, 255, 255, 0.06);
    --surface: #1b1d23;
    --surface-2: #23262e;
    --ink: #f3f0e9;
    --ink-2: #c3c1ba;
    --muted: #8d8f98;
    --line: #2d3039;
    --line-2: #3a3e49;
    --accent: #ff6a3d;
    --accent-hover: #ff7d55;
    --accent-soft: #3b2219;
    --pen: #7d9bff;
    --pen-soft: #1f2846;
    --ok: #4bd08f;
    --ok-soft: #173326;
    --bad: #ff7a6b;
    --bad-soft: #3a1c19;
    --hl: rgba(255, 106, 61, 0.38);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.3), 0 28px 60px -20px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, var(--bg-glow), transparent 70%),
    radial-gradient(var(--dot) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-hand);
  font-size: 24px;
  line-height: 1;
  transform: rotate(-6deg);
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.45);
}
.brand-name { font-size: 1.02rem; }
.lang {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.9rem;
}
.lang select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; padding-inline-end: 14px; cursor: pointer; font-weight: 500; }
.lang::after { content: ''; position: absolute; inset-inline-end: 11px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.lang select:focus-visible { outline: none; }
.lang:focus-within { outline: 3px solid var(--pen); outline-offset: 2px; }

.banner {
  max-width: 1040px;
  margin: 0 auto 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--pen-soft);
  color: var(--pen);
  font-size: 0.86rem;
  text-align: center;
  width: calc(100% - 40px);
}

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px 40px; }

.screen { animation: rise 0.5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.005em;
  transition: transform 0.15s var(--ease), background-color 0.15s, box-shadow 0.15s, opacity 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 22px -10px var(--accent); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 14px 26px -10px var(--accent); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }
[dir='rtl'] .flip-rtl { transform: scaleX(-1); }
.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: background-color 0.15s, transform 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------------- Home ---------------- */
.home-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
  padding: 28px 0 24px;
}
.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 18px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}
.kicker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.hero h1 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(2.3rem, 5.6vw, 4.1rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
  text-wrap: balance;
}
[lang='ar'] .hero h1, [lang='zh'] .hero h1 { font-family: var(--font-ui); line-height: 1.2; letter-spacing: 0; }
.hero h1 .line { display: block; }
.hl {
  background-image: linear-gradient(transparent 58%, var(--hl) 58%, var(--hl) 92%, transparent 92%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  animation: marker 0.9s 0.35s var(--ease) forwards;
  padding: 0 0.06em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
[dir='rtl'] .hl { background-position: right; }
@keyframes marker { to { background-size: 100% 100%; } }
.lead { margin: 0 0 26px; max-width: 34em; font-size: 1.1rem; color: var(--ink-2); text-wrap: pretty; }

.digit-strip { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; max-width: 520px; margin: 0 0 26px; direction: ltr; }
.digit-strip span {
  display: grid; place-items: center;
  aspect-ratio: 46 / 52;
  border-radius: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px -10px rgba(40, 30, 10, 0.5);
  font-family: var(--font-hand);
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 600;
  color: #1b2340;
  transform: rotate(var(--r, 0deg));
  animation: bob 4s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.digit-strip span:nth-child(odd) { color: #2b54e0; }
@keyframes bob { 50% { transform: rotate(var(--r, 0deg)) translateY(-5px); } }

.stats { display: flex; flex-wrap: wrap; gap: 26px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.9rem; font-weight: 650; line-height: 1.1; letter-spacing: -0.02em; }
.stat span { font-size: 0.86rem; color: var(--muted); }

.form-card { padding: 28px; }
.form-card h2 { margin: 0 0 18px; font-size: 1.25rem; letter-spacing: -0.01em; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-weight: 600; }
.hand-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.hand-opt { position: relative; }
.hand-opt input { position: absolute; opacity: 0; pointer-events: none; }
.hand-card {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
  min-height: 104px;
  padding: 18px 6px 12px;  /* top-aligned: emojis stay level when a label wraps */
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.hand-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.hand-emoji { font-size: 32px; line-height: 1; display: inline-flex; gap: 0; }
.hand-emoji .mirror { display: inline-block; transform: scaleX(-1); }
.hand-opt input:checked + .hand-card { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.hand-opt input:focus-visible + .hand-card { outline: 3px solid var(--pen); outline-offset: 2px; }
.hand-card::after {
  content: '';
  position: absolute; top: 8px; inset-inline-end: 8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  transform: scale(0);
  transition: transform 0.2s var(--ease);
}
.hand-opt input:checked + .hand-card::after { transform: scale(1); }
.field-error { margin: 8px 0 0; color: var(--bad); font-size: 0.88rem; font-weight: 500; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.select {
  position: relative;
}
.select select {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  min-height: 46px;
  padding: 0 34px 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 500;
  text-overflow: ellipsis;
  cursor: pointer;
}
[dir='rtl'] .select select { padding: 0 14px 0 34px; }
.select select:hover { border-color: var(--line-2); }
.select::after { content: ''; position: absolute; inset-inline-end: 15px; top: 50%; width: 7px; height: 7px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.privacy {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 18px 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 0.84rem;
  color: var(--ink-2);
  line-height: 1.45;
}
.privacy svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--ok); }
.digits-note { margin: 12px 0 0; font-size: 0.86rem; color: var(--ink-2); text-align: center; }
.digits-note:empty { display: none; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.info-card { padding: 24px; }
.info-card h3 { margin: 0 0 14px; font-size: 1.05rem; }
.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); }
.tips .tip-ico { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tips .tip-ico svg { width: 18px; height: 18px; }
.tips li span:last-child { padding-top: 4px; }
details { border-top: 1px solid var(--line); }
details:first-of-type { border-top: 0; }
summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; font-size: 1.3rem; font-weight: 400; color: var(--muted); transition: transform 0.2s var(--ease); }
details[open] summary::after { transform: rotate(45deg); }
details p { margin: 0 0 14px; color: var(--ink-2); font-size: 0.95rem; }

/* ---------------- Draw ---------------- */
.draw-wrap { max-width: 520px; margin: 0 auto; padding-top: 4px; }
.draw-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin: 0; padding: 0; list-style: none; direction: ltr; }
.progress li { min-width: 0; }
.progress button {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 40px;
  margin: 0 auto;
  display: grid; place-items: center;
  padding: 0;
  border-radius: 9px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s var(--ease);
}
.progress button canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.progress button.done { background: var(--paper); border-color: var(--line-2); color: transparent; }
.progress button.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent); transform: translateY(-2px); }
.progress button:disabled { cursor: default; }

.prompt { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.prompt-label { margin: 0; font-size: 0.92rem; color: var(--ink-2); font-weight: 500; }
.prompt-label b { display: block; font-size: 1.15rem; color: var(--ink); font-weight: 650; letter-spacing: -0.01em; }
.prompt-digit {
  display: grid; place-items: center;
  width: 76px; height: 76px; flex: none;
  border-radius: 20px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
  direction: ltr;
}
.prompt-digit.pop { animation: pop 0.35s var(--ease); }
@keyframes pop { from { transform: scale(0.7) rotate(-8deg); opacity: 0; } }
.style-tip {
  margin: -2px 0 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--pen-soft);
  color: var(--pen);
  font-size: 0.88rem;
  font-weight: 500;
}

.pad {
  position: relative;
  width: min(100%, 460px);
  width: min(100%, 460px, calc(100vh - 360px));
  width: min(100%, 460px, calc(100svh - 360px));
  min-width: 250px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 24px;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 10% 10%;
  background-position: -1px -1px;
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 2; }
.pad-guide { position: absolute; inset: 8%; border: 2px dashed rgba(43, 84, 224, 0.20); border-radius: 18px; pointer-events: none; z-index: 1; }
.pad-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: #9a9fab;
  font-size: 0.95rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.25s;
}
.pad-placeholder svg { width: 34px; height: 34px; opacity: 0.8; animation: wiggle 2.4s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: translate(6px, -4px) rotate(-8deg); } }
.pad.has-ink .pad-placeholder { opacity: 0; }
.pad-msg { min-height: 1.5em; margin: 10px 0 2px; text-align: center; font-size: 0.9rem; font-weight: 600; color: var(--bad); }
.controls { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.controls .spacer { flex: 1; }
.keys-hint { margin: 14px 0 0; text-align: center; font-size: 0.78rem; color: var(--muted); }
@media (hover: none) { .keys-hint { display: none; } }

/* ---------------- Review ---------------- */
.review-wrap { max-width: 640px; margin: 0 auto; padding-top: 8px; }
.screen-title { margin: 0 0 6px; font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; }
[lang='ar'] .screen-title, [lang='zh'] .screen-title { font-family: var(--font-ui); }
.screen-sub { margin: 0 0 22px; color: var(--ink-2); }
.review-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; direction: ltr; }
.review-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s var(--ease), box-shadow 0.18s;
  animation: rise 0.45s var(--ease) both;
}
.review-tile:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow-lg); }
.review-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.review-tile .tag {
  position: absolute; top: 6px; left: 6px;
  min-width: 22px; height: 22px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.78rem; font-weight: 700;
}
.review-tile .redo {
  position: absolute; inset: auto 0 0 0;
  padding: 6px 4px;
  background: linear-gradient(transparent, rgba(255, 90, 43, 0.95));
  color: #fff;
  font-size: 0.72rem; font-weight: 700;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s, transform 0.18s var(--ease);
}
.review-tile:hover .redo, .review-tile:focus-visible .redo { opacity: 1; transform: none; }
/* Touch screens: no hover, so show a small pencil badge instead of a label that would cover the digit */
@media (hover: none) {
  .review-tile .redo {
    inset: auto 5px 5px auto;
    width: 20px; height: 20px; padding: 0;
    border-radius: 7px;
    font-size: 0;
    opacity: 1; transform: none;
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9l-4-4L4 16z'/%3E%3C/svg%3E") center / 12px no-repeat;
  }
  .review-tile:hover { transform: none; }
}
.screen-title:focus { outline: none; }
.send-error { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 500; font-size: 0.92rem; }

/* ---------------- Thanks ---------------- */
.thanks-wrap { max-width: 560px; margin: 0 auto; padding-top: 16px; }
.thanks-card { padding: 34px 28px 28px; text-align: center; }
.check { width: 74px; height: 74px; margin: 0 auto 16px; }
.check circle { fill: var(--ok-soft); }
.check path { fill: none; stroke: var(--ok); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.6s 0.25s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.thanks-card .screen-sub { margin-bottom: 8px; }
.thanks-total { margin: 0 0 22px; font-size: 0.92rem; color: var(--muted); }
.thanks-digits { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin: 0 0 26px; direction: ltr; }
.thanks-digits canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); animation: rise 0.4s var(--ease) both; }
.thanks-actions { display: grid; gap: 10px; }
.thanks-actions .hint { margin: 0 0 8px; font-size: 0.86rem; color: var(--muted); }

/* ---------------- Footer, toast, confetti ---------------- */
.footer { padding: 18px 20px 26px; text-align: center; font-size: 0.82rem; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

/* ---------------- Responsive ---------------- */
@media (max-width: 880px) {
  .home-grid { grid-template-columns: 1fr; gap: 26px; padding-top: 12px; }
  .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  main { padding: 0 14px 30px; }
  .topbar { padding: 10px 14px; }
  .brand-name { font-size: 0.95rem; }
  .form-card { padding: 20px 16px; }
  .hand-card { min-height: 92px; font-size: 0.82rem; }
  .hand-emoji { font-size: 28px; }
  .digit-strip span { font-size: 22px; border-radius: 8px; }
  .digit-strip { gap: 5px; }
  .lead { font-size: 1rem; }
  .review-grid { gap: 8px; }
  .prompt-digit { width: 62px; height: 62px; font-size: 38px; border-radius: 16px; }
  .controls .btn { padding: 0 14px; }
  .controls .btn .label-opt { display: none; }
  .pad {
    width: min(100%, calc(100vh - 330px));
    width: min(100%, calc(100svh - 330px));
  }
}

/* ---------------- Phones: focused drawing mode ---------------- */
button, .hand-card, .chip, summary, a { touch-action: manipulation; }   /* no double-tap zoom */
@media (pointer: coarse) {
  select, input { font-size: 16px !important; }   /* below 16px, iPhones zoom in on focus */
}
@media (max-width: 520px), (max-height: 520px) {
  body.drawing .topbar, body.drawing .footer { display: none; }
  body.drawing main { padding-top: 12px; }
}
@media (max-height: 720px) and (orientation: portrait) {
  .draw-top { margin-bottom: 10px; }
  .prompt { margin-bottom: 8px; }
  .prompt-digit { width: 56px; height: 56px; font-size: 34px; border-radius: 15px; }
  .pad-msg { margin-top: 6px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  body.drawing .banner { display: none; }
  .draw-wrap {
    max-width: 860px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas: "top pad" "prompt pad" "tip pad" "msg pad" "controls pad";
    column-gap: 24px;
  }
  .draw-top { grid-area: top; margin-bottom: 10px; }
  .prompt { grid-area: prompt; margin-bottom: 8px; }
  .style-tip { grid-area: tip; margin: 0 0 8px; }
  .pad { grid-area: pad; margin: 0; }
  .pad-msg { grid-area: msg; text-align: start; }
  .controls { grid-area: controls; }
  .keys-hint { display: none; }
  .prompt-digit { width: 56px; height: 56px; font-size: 34px; border-radius: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .hl { background-size: 100% 100%; }
}
