:root {
  --ink: #3b2a1c; --ink2: #7a5c40; --paper: #efe6d6; --paper2: #e4d7c1; --gold: #d9a63a; --gold2: #f3d27a;
  --wood: #6b4f36; --wood2: #4a3624;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #d8ccb6; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--sans); color: var(--ink); user-select: none; -webkit-user-select: none; }
#app {
  position: relative; height: 100%; width: 100%; max-width: 520px; margin: 0 auto; overflow: hidden;
  background: radial-gradient(120% 70% at 50% 35%, #f7f1e6 0%, var(--paper) 55%, var(--paper2) 100%);
  box-shadow: 0 0 60px rgba(60, 40, 20, 0.18);
}
#stage { position: absolute; inset: 0; touch-action: none; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
svg { width: 24px; height: 24px; }

/* ---------- botões base ---------- */
.icon-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.45); color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 8px rgba(60,40,20,0.12); }
.primary { min-height: 56px; padding: 0 26px; border-radius: 28px; background: linear-gradient(180deg, #4a3624, #2f2116); color: #f7ecd6; font-family: var(--serif); font-size: 19px; letter-spacing: 0.02em; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 6px 18px rgba(40,25,10,0.3), inset 0 1px 0 rgba(255,230,190,0.2); }
.primary svg { color: var(--gold2); }
.primary.big { min-height: 68px; min-width: 240px; flex-direction: column; gap: 2px; font-size: 22px; }
.primary.big small { font-family: var(--sans); font-size: 12px; opacity: 0.75; letter-spacing: 0.03em; }
.secondary { min-height: 52px; padding: 0 20px; border-radius: 26px; background: rgba(255,255,255,0.55); color: var(--ink); font-family: var(--serif); font-size: 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: inset 0 0 0 1px rgba(90,60,30,0.18); }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none !important; }
.hud > * { pointer-events: none; }
.hud button { pointer-events: auto; }
.hud.dragging button { pointer-events: none; }
.hud-top { position: absolute; top: calc(var(--st) + 8px); left: calc(var(--sl) + 10px); right: calc(var(--sr) + 10px); height: 48px; display: flex; align-items: center; gap: 10px; }
.hud-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.hud-num { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink2); }
.hud-name { font-family: var(--serif); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.hud-stars { display: flex; gap: 1px; }
.star svg { width: 16px; height: 16px; display: block; }
.star.on { color: var(--gold); filter: drop-shadow(0 1px 1px rgba(120,80,20,0.35)); }
.star.off { color: rgba(90,60,30,0.2); }
.hud-meter { width: 74px; height: 7px; border-radius: 4px; background: rgba(90,60,30,0.15); overflow: hidden; }
.hud-meter i { display: block; height: 100%; background: linear-gradient(90deg, #b27a1c, #f3d27a, #d9a63a); transform-origin: left; transition: transform 0.15s; }
.hud-meter.low i { animation: blink 0.8s infinite alternate; }
.hud-timer { display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.hud-timer svg { width: 14px; height: 14px; }
.hud-timer.over { opacity: 0.5; }
.hud-chips { position: absolute; top: calc(var(--st) + 62px); left: 0; right: 0; display: flex; justify-content: center; gap: 6px; opacity: 0; }
.hud-chips.fade { animation: chips 3.4s ease forwards; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: rgba(255,255,255,0.6); color: var(--ink2); box-shadow: inset 0 0 0 1px rgba(90,60,30,0.15); }
.hud-caption { position: absolute; top: calc(var(--st) + 92px); left: 50%; translate: -50% 0; width: max-content; max-width: 86%; padding: 6px 16px; border-radius: 18px; background: rgba(250,245,236,0.88); box-shadow: 0 2px 10px rgba(60,40,20,0.12); text-align: center; font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--ink); opacity: 0; transform: translateY(6px); transition: opacity 0.4s, transform 0.4s; text-shadow: 0 1px 0 rgba(255,255,255,0.7); }
.hud-caption.on { opacity: 0.9; transform: none; }
.hud-bottom { position: absolute; left: calc(var(--sl) + 14px); right: calc(var(--sr) + 14px); bottom: calc(var(--sb) + 14px); height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hud-btn { position: relative; width: 72px; height: 72px; min-width: 56px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: rgba(255,255,255,0.6); box-shadow: 0 4px 14px rgba(60,40,20,0.14), inset 0 0 0 1px rgba(90,60,30,0.12); color: var(--ink); }
.hud-btn span { font-size: 11px; letter-spacing: 0.04em; }
.hud-btn svg { width: 26px; height: 26px; }
.hud-btn:disabled { opacity: 0.35; }
.hud-btn:active:not(:disabled) { transform: scale(0.94); }
.hud-btn .dots { position: absolute; top: 7px; right: 8px; display: flex; gap: 2px; }
.hud-btn .dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(90,60,30,0.2); }
.hud-btn .dots i.on { background: var(--gold); }
.hud-btn[data-a=flip] { margin: 0 auto; }
.hud-btn.pulse { animation: pulse 0.6s ease 3; }

/* ---------- título ---------- */
.screen { position: absolute; inset: 0; }
.title { display: flex; flex-direction: column; align-items: center; pointer-events: none !important; }
.title > * { pointer-events: auto; }
.title-top { position: absolute; top: calc(var(--st) + 10px); right: calc(var(--sr) + 12px); }
.title-brand { position: absolute; top: calc(var(--st) + 7vh); text-align: center; pointer-events: none; }
.title-brand h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 44px; letter-spacing: 0.28em; padding-left: 0.28em; }
.title-brand .jp { margin: 4px 0 0; font-size: 18px; letter-spacing: 0.5em; padding-left: 0.5em; color: var(--ink2); }
.title-brand .tag { margin: 10px 0 0; font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink2); }
.title-actions { position: absolute; bottom: calc(var(--sb) + 9vh); display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------- ateliê (prateleira) ---------- */
.shelf { display: flex; flex-direction: column; background: radial-gradient(120% 60% at 50% 0%, #3a2a1d, #241912 70%); color: #f2e6cf; }
.shelf-top { padding: calc(var(--st) + 10px) calc(var(--sr) + 14px) 10px calc(var(--sl) + 12px); display: flex; align-items: center; gap: 12px; }
.shelf-top .icon-btn { background: rgba(255,255,255,0.1); color: #f2e6cf; }
.shelf-top h2 { flex: 1; margin: 0; font-family: var(--serif); font-weight: 500; font-size: 24px; letter-spacing: 0.1em; }
.shelf-total { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--gold2); }
.shelf-total svg { width: 16px; height: 16px; color: var(--gold); }
.shelf-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 14px calc(var(--sb) + 30px); }
.shelf-list h3 { font-family: var(--serif); font-weight: 500; font-size: 16px; letter-spacing: 0.08em; color: #d8c3a0; margin: 26px 4px 6px; }
.plank { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 8px 16px; margin-bottom: 18px; }
.plank::after { content: ''; position: absolute; left: -6px; right: -6px; bottom: 0; height: 14px; border-radius: 3px; background: linear-gradient(180deg, #8a6544, #5a3f28 60%, #3a2819); box-shadow: 0 8px 14px rgba(0,0,0,0.45); }
.niche { position: relative; display: flex; flex-direction: column; align-items: center; min-height: 140px; padding: 6px 4px 22px; border-radius: 10px 10px 2px 2px; background: radial-gradient(90% 70% at 50% 30%, rgba(255,230,190,0.08), rgba(0,0,0,0.25)); color: #f2e6cf; }
.niche.open { background: radial-gradient(90% 70% at 50% 35%, rgba(255,214,140,0.28), rgba(0,0,0,0.2)); animation: glow 2.4s ease-in-out infinite alternate; }
.niche.locked { opacity: 0.55; }
.niche-art { width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
.niche-art canvas { width: 92%; height: auto; }
.niche.done .niche-art canvas { filter: drop-shadow(0 6px 8px rgba(0,0,0,0.45)); }
.niche-num { font-family: var(--serif); font-size: 14px; display: flex; align-items: center; gap: 3px; color: #e9d7b5; }
.niche-num svg { width: 12px; height: 12px; }
.niche-stars { position: absolute; bottom: 6px; display: flex; gap: 1px; min-height: 14px; }
.niche-stars .star svg { width: 13px; height: 13px; }
.niche-stars .star.off { color: rgba(255,255,255,0.18); }
.niche-stars em { font-size: 11px; font-style: normal; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold2); }

/* ---------- folhas (resultado, pausa) ---------- */
.sheet { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.result { background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(40,25,12,0.25)); }
.result-card, .pause-card { width: 100%; margin: 0 10px calc(var(--sb) + 10px); padding: 18px 18px 16px; border-radius: 26px; background: rgba(250,245,236,0.96); box-shadow: 0 -10px 40px rgba(40,25,10,0.25); text-align: center; }
.result-card { transform: translateY(110%); transition: transform 0.6s cubic-bezier(.2,.8,.2,1); }
.result.in .result-card { transform: none; }
.result-kicker { margin: 0; font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink2); }
.result-name { margin: 4px 0 0; font-family: var(--serif); font-weight: 500; font-size: 24px; }
.result-jp { margin: 2px 0 6px; color: var(--ink2); letter-spacing: 0.2em; }
.result-stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 8px; }
.result-stars .star svg { width: 38px; height: 38px; }
.star.pop { animation: pop 0.5s cubic-bezier(.2,1.6,.4,1); }
.result-crit { list-style: none; margin: 0 auto 4px; padding: 0; max-width: 360px; text-align: left; font-size: 13px; }
.result-crit li { display: flex; gap: 8px; padding: 3px 0; color: var(--ink); }
.result-crit li b { width: 26px; flex: none; font-weight: 600; font-size: 11px; color: var(--ink2); padding-top: 1px; }
.result-crit li.ok::after { content: '✓'; margin-left: auto; color: #6a8a3a; }
.result-crit li.no { color: rgba(59,42,28,0.5); }
.result-crit li.no::after { content: '·'; margin-left: auto; }
.result-note { margin: 6px 0 12px; font-size: 12px; color: var(--ink2); font-style: italic; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }
.result-actions button { min-height: 56px; padding: 0 10px; font-size: 15px; }
.result-actions svg { width: 20px; height: 20px; }
.pause { background: rgba(40,25,12,0.35); align-items: center; }
.pause-card { margin-bottom: 0; max-width: 420px; }
.pause-title { margin: 0 0 12px; font-family: var(--serif); font-weight: 500; }
.pause-actions { display: grid; gap: 8px; }
.pause.settings-only .pause-actions button:not([data-a=resume]) { display: none; }
.toggles { margin-top: 14px; text-align: left; }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-top: 1px solid rgba(90,60,30,0.1); font-size: 15px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 46px; height: 28px; border-radius: 14px; background: rgba(90,60,30,0.2); position: relative; transition: background 0.2s; flex: none; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle input:checked + i { background: var(--gold); }
.toggle input:checked + i::after { transform: translateX(18px); }
.toggle input:focus-visible + i { outline: 3px solid var(--gold); outline-offset: 2px; }
.pause-tip { margin: 10px 0 0; font-size: 12px; color: var(--ink2); font-style: italic; }

@keyframes pulse { 50% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(217,166,58,0.35); } }
@keyframes pop { 0% { transform: scale(0.3); } 100% { transform: scale(1); } }
@keyframes glow { to { box-shadow: 0 0 22px rgba(255,200,110,0.25); } }
@keyframes blink { to { opacity: 0.35; } }
@keyframes chips { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.reduce-motion *, .reduce-motion *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
@media (prefers-reduced-motion: reduce) { *, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
