/* Sparkle Scrub. Colours come from ../shared/base.css; the fallbacks keep the page usable without it. */
:root {
  --sc-ink: #2f3a2c;
  --sc-paper: var(--card, #fff);
  --sc-line: var(--line, #e6e0d2);
  --sc-accent: var(--accent, #a65032);
  --sc-forest: var(--forest, #3d5a3a);
  --sc-muted: var(--muted, #6b6b60);
  --sc-water: #4f8fc9;
  --sc-foam: #eaf5fb;
}

* { box-sizing: border-box; }
body { margin: 0; background: #faf7f1; color: var(--sc-ink); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 1px solid var(--sc-line); background: var(--sc-paper); font-weight: 700; font-size: 17px; }

.sc { max-width: 760px; margin: 0 auto 56px; padding: 0 24px; }

/* ---------- mode switch ---------- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 18px; background: #efebe1; margin: 0 0 12px; }
.modes button { border: 0; border-radius: 14px; background: transparent; padding: 10px 8px; font-weight: 700; font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.modes button small { font-weight: 400; font-size: 11px; color: var(--sc-muted); }
.modes button[aria-selected="true"] { background: var(--sc-paper); box-shadow: 0 2px 10px #3d44351a; }

.sc-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin: 2px 0 12px; }
.sc-head h1 { font: 400 clamp(24px, 5vw, 32px) Georgia, serif; margin: 4px 0 0; letter-spacing: -.5px; }
.sc-head .eyebrow { color: var(--sc-accent); text-transform: uppercase; }
.soft-btn { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--sc-line); background: var(--sc-paper); font-weight: 600; font-size: 14px; white-space: nowrap; }
.primary { padding: 12px 20px; border-radius: 14px; border: 0; background: var(--sc-forest); color: #fff; font-weight: 700; }

/* ---------- scene picker ---------- */
.scenes { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; scroll-snap-type: x proximity; }
.scenes::-webkit-scrollbar { display: none; }
.scene-btn { flex: 0 0 auto; position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px; padding: 6px 6px 7px; border-radius: 16px; border: 1px solid var(--sc-line); background: var(--sc-paper); font-size: 11px; font-weight: 700; scroll-snap-align: start; }
.scene-btn canvas { display: block; width: 68px; height: 68px; border-radius: 11px; }
.scene-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.scene-btn[aria-current="true"] { border-color: var(--sc-forest); box-shadow: 0 0 0 2px var(--sc-forest) inset; }
.scene-btn .shine { position: absolute; top: 2px; right: 4px; font-size: 13px; }

/* ---------- scrubbing stage ---------- */
.stage-card { position: relative; display: flex; justify-content: center; padding: 10px; background: #e8eef0; border: 1px solid #d3dde0; border-radius: 24px; box-shadow: 0 10px 35px #3d44350d; }
.stage-card canvas { display: block; border-radius: 16px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.stage-tip { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 8px 14px; border-radius: 99px; background: #fffdf8ee; font-weight: 700; font-size: 15px; box-shadow: 0 4px 16px #3d443522; pointer-events: none; transition: opacity .4s ease; animation: tip-bob 1.6s ease-in-out infinite; white-space: nowrap; }
.stage-tip.gone { opacity: 0; }
@keyframes tip-bob { 50% { transform: translate(-50%, -6px); } }
.stage-done { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; margin-top: 12px; padding: 14px 18px; background: #fff8e1; border: 1px solid #f0dc9a; border-radius: 18px; animation: done-in .5s cubic-bezier(.2, 1.4, .4, 1); }
.stage-done b { font: 24px Georgia, serif; display: block; }
.stage-done p { margin: 2px 0 0; font-size: 13px; color: var(--sc-muted); }
.done-badge { font-size: 34px; line-height: 1; grid-row: span 2; }
.done-text { min-width: 0; }
.done-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@keyframes done-in { from { transform: translateY(16px) scale(.9); opacity: 0; } }

.scrub-bar { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.tools { display: grid; grid-template-columns: 3fr 4fr; gap: 10px; }
.tool-group { background: var(--sc-paper); border: 1px solid var(--sc-line); border-radius: 18px; padding: 8px 10px 10px; min-width: 0; }
.tool-label { font-size: 10px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--sc-muted); margin: 0 0 6px 2px; }
.tool-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.tool-btn { display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 0; padding: 6px 4px 5px; border-radius: 14px; border: 1px solid var(--sc-line); background: #fbfaf6; font-weight: 700; font-size: 12px; touch-action: manipulation; }
.tool-btn span { font-size: 26px; line-height: 1.15; }
.tool-btn[aria-checked="true"] { background: #eaf5fb; border-color: var(--sc-water); box-shadow: 0 0 0 2px var(--sc-water) inset; }
#scrubTools .tool-btn[aria-checked="true"] { background: #fff8e1; border-color: #e0a21f; box-shadow: 0 0 0 2px #e0a21f inset; }
.tool-say { margin: -2px 2px 0; font-size: 13px; color: var(--sc-muted); min-height: 1.3em; }
.tool-btn.nudge { animation: nudge 0.9s ease-in-out 3; }
@keyframes nudge { 30% { transform: translateY(-6px) rotate(-4deg); } 60% { transform: translateY(0) rotate(3deg); } }
.meter { background: var(--sc-paper); border: 1px solid var(--sc-line); border-radius: 16px; padding: 10px 14px; }
.meter-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--sc-muted); }
.meter-label b { font-size: 20px; color: var(--sc-ink); font-variant-numeric: tabular-nums; }
.meter-bar { height: 12px; border-radius: 99px; background: #ece8dd; margin-top: 6px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #7fc3e8, #4f8fc9); transition: width .25s ease; }
.meter.rinse .meter-bar span { background: linear-gradient(90deg, #a6e3d0, #3fa58a); }
.meter.done .meter-bar span { background: linear-gradient(90deg, #f6d365, #f0a04b); }

/* ---------- floor puzzles ---------- */
.sc-levels { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0; padding: 4px 2px 12px; scrollbar-width: none; }
.sc-levels::-webkit-scrollbar { display: none; }
.level-tab { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 88px; padding: 9px 12px; border-radius: 14px; border: 1px solid var(--sc-line); background: var(--sc-paper); }
.level-tab b { font-size: 14px; white-space: nowrap; }
.level-tab span { font-size: 11px; color: var(--sc-muted); font-variant-numeric: tabular-nums; }
.level-tab[aria-current="true"] { background: var(--sc-forest); border-color: var(--sc-forest); color: #fff; }
.level-tab[aria-current="true"] span { color: #ffffffcc; }

.floor-card { display: flex; justify-content: center; padding: 12px; background: #e9e2d2; border: 1px solid #d8cfbb; border-radius: 22px; box-shadow: 0 10px 35px #3d44350d; }
.floor-card canvas { display: block; border-radius: 12px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline: none; }
.floor-card canvas:focus-visible { box-shadow: 0 0 0 3px #a65032; }
.floor-card.solved { background: #e3efdc; border-color: #c4dcb8; }
.floor-status { display: flex; justify-content: center; gap: 16px; margin-top: 10px; font-size: 14px; color: var(--sc-muted); font-variant-numeric: tabular-nums; }
.floor-status b { color: var(--sc-ink); }
.sc-tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tool { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--sc-line); background: var(--sc-paper); font-weight: 600; font-size: 14px; }
.tool.hint { background: #fff8e1; border-color: #f0dc9a; }
.hint-box { margin: 12px 0 0; padding: 14px 16px; border-radius: 16px; background: #fff8e1; border: 1px solid #f0dc9a; font-size: 15px; line-height: 1.5; }
.hint-box.ok { background: #eef6ea; border-color: #c4dcb8; }

/* ---------- dialogs ---------- */
dialog.wide { max-width: min(620px, calc(100vw - 32px)); }
.guide-list { padding-left: 20px; margin: 14px 0 20px; line-height: 1.55; font-size: 15px; }
.guide-list li { margin-bottom: 6px; }
.guide-demo { display: flex; justify-content: center; background: #e9e2d2; border-radius: 16px; padding: 10px; }
.guide-demo canvas { border-radius: 8px; }

#listBody section { margin-bottom: 18px; }
#listBody h3 { font-size: 14px; margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; }
#listBody h3 span { font-weight: 400; color: var(--sc-muted); text-align: right; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 4px; border-radius: 12px; border: 1px solid var(--sc-line); background: #fff; font-size: 11px; color: var(--sc-muted); }
.thumb svg { width: 46px; height: 46px; border-radius: 6px; }
.thumb.solved { background: #eef6ea; border-color: #c4dcb8; color: var(--sc-forest); font-weight: 700; }
.thumb.current { box-shadow: 0 0 0 2px var(--sc-accent) inset; border-color: var(--sc-accent); }

#win { text-align: center; }
.win-art { font-size: 44px; margin: 2px 0 8px; animation: win-in .6s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes win-in { from { transform: scale(.4) rotate(-6deg); opacity: 0; } }
.win-points { font-weight: 700; color: var(--sc-forest); min-height: 1.4em; margin: -6px 0 6px; }
.win-note { margin: 0 0 18px; font-size: 14px; }
.win-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 560px) {
  .sc { padding: 0 16px; }
  .stage-card { padding: 6px; border-radius: 18px; }
  .floor-card { padding: 6px; border-radius: 18px; }
  .tools { grid-template-columns: 1fr; gap: 8px; }
  .tool-btn span { font-size: 24px; }
  .sc-tools .tool { flex: 1; }
  .scene-btn { width: 74px; }
  .scene-btn canvas { width: 58px; height: 58px; }
  .sc-head .soft-btn { padding: 8px 10px; font-size: 13px; }
  .stage-done { grid-template-columns: auto minmax(0, 1fr); }
  .done-actions { grid-column: 1 / -1; justify-content: stretch; }
  .done-actions button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
