:root {
  --bg: #f6e7d2;
  --card: #fffaf2;
  --ink: #3d2320;
  --muted: #8a6a5c;
  --accent: #e0662f;
  --accent-ink: #fff;
  --ring: #f2c48d;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow-x: hidden; }
main { max-width: 520px; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom)); min-height: 100%; }
h1 { font-size: 26px; margin: 20px 0 4px; text-align: center; }
.sub { margin: 0 0 16px; text-align: center; color: var(--muted); }
.screen { display: none; }
.screen.active { display: block; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid button {
  background: var(--card); border: 3px solid transparent; border-radius: 18px; padding: 8px 4px 4px;
  aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; cursor: pointer; min-width: 0;
  box-shadow: 0 2px 0 rgba(61, 35, 32, .08);
}
.grid button:active { transform: scale(.97); border-color: var(--ring); }
.grid img { width: 100%; height: 100%; min-width: 0; object-fit: contain; }
.grid .group { grid-column: 1 / -1; margin: 14px 2px 0; font-size: 18px; }
.grid .group:first-child { margin-top: 0; }

.bar { display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; font-weight: 600; }
.stage-wrap { position: relative; background: var(--card); border-radius: 22px; overflow: hidden; touch-action: none; }
#stage { display: block; width: 100%; aspect-ratio: 3 / 4; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.hint {
  position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-size: 14px;
  color: var(--muted); pointer-events: none;
}

.adjust { margin-top: 10px; }
.adjust label { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.adjust input { flex: 1; accent-color: var(--accent); }
.tiny { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

.actions, .send-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.send-row input {
  flex: 1 1 100%; font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--ring); background: var(--card); color: var(--ink);
}
button, .button {
  font: inherit; font-size: 17px; font-weight: 700; border: 0; border-radius: 14px; padding: 14px 18px;
  cursor: pointer; flex: 1; text-align: center; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #b44d1f; }
.primary:disabled { opacity: .6; }
.secondary { background: var(--card); color: var(--ink); border: 2px solid var(--ring); }
.ghost { background: none; color: var(--ink); padding: 6px 8px; flex: 0 0 auto; font-size: 16px; white-space: nowrap; }
[hidden] { display: none !important; }
.error { color: #c0392b; text-align: center; min-height: 1.2em; font-weight: 600; }

#done { text-align: center; padding-top: 24px; }
#done img { width: 70%; max-width: 280px; filter: drop-shadow(0 6px 10px rgba(61, 35, 32, .2)); animation: bob 1.6s ease-in-out infinite; }
#done button { margin-top: 16px; width: 100%; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(2deg); } }
