/* Block Drop. Colours come from ../shared/base.css; the fallbacks keep the page usable without it. */
:root {
  --bd-ink: #2f3a2c;
  --bd-paper: var(--card, #fff);
  --bd-line: var(--line, #e6e0d2);
  --bd-accent: var(--accent, #a65032);
  --bd-forest: var(--forest, #3d5a3a);
  --bd-muted: var(--muted, #6b6b60);
  --well: #f3eee2;
  --well-edge: #d8cfbb;
}

* { box-sizing: border-box; }
body { margin: 0; background: #faf7f1; color: var(--bd-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(--bd-line); background: var(--bd-paper); font-weight: 700; font-size: 17px; }

.bd { 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(--bd-muted); }
.modes button[aria-selected="true"] { background: var(--bd-paper); box-shadow: 0 2px 10px #3d44351a; }

/* ---------- levels and heading ---------- */
.bd-levels { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0; padding: 4px 2px 12px; scrollbar-width: none; }
.bd-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(--bd-line); background: var(--bd-paper); }
.level-tab b { font-size: 14px; white-space: nowrap; }
.level-tab span { font-size: 11px; color: var(--bd-muted); font-variant-numeric: tabular-nums; }
.level-tab[aria-current="true"] { background: var(--bd-forest); border-color: var(--bd-forest); color: #fff; }
.level-tab[aria-current="true"] span { color: #ffffffcc; }

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

/* ---------- well and side panel ---------- */
.play-area { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; align-items: start; }
.well-card { position: relative; display: flex; justify-content: center; align-items: flex-start; padding: 12px; background: #e9e2d2; border: 1px solid var(--well-edge); border-radius: 22px; box-shadow: 0 10px 35px #3d44350d; }
.well-card canvas { display: block; border-radius: 10px; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; box-shadow: inset 0 0 0 1px #d8cfbb; }
.well-card.solved { background: #e3efdc; border-color: #c4dcb8; }
.well-cover { position: absolute; inset: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; text-align: center; padding: 20px; background: #fffdf8e6; border-radius: 12px; }
.well-cover p { margin: 0; font-size: 16px; line-height: 1.5; max-width: 16em; }
.well-cover b { font-size: 22px; }

.side { display: flex; flex-direction: column; gap: 10px; }
.side-box { background: var(--bd-paper); border: 1px solid var(--bd-line); border-radius: 16px; padding: 10px 12px; }
.side-label { font-size: 10px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--bd-muted); margin-bottom: 6px; }
.queue { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.q-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px; border-radius: 10px; border: 2px solid transparent; }
.q-item span { font-size: 11px; color: var(--bd-muted); font-variant-numeric: tabular-nums; }
.q-item.now { border-color: #e0a21f; background: #fff8e1; }
.q-item.used { opacity: .55; }
.q-item svg { display: block; }
.count .c-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 12px; color: var(--bd-muted); }
.count .c-row b { font-size: 20px; color: var(--bd-ink); font-variant-numeric: tabular-nums; }
.count small { display: block; margin-top: 6px; font-size: 11.5px; line-height: 1.35; color: #b84031; }
.count.warn { background: #fdf0ec; border-color: #f0c8bc; }
.count.ok { background: #eef6ea; border-color: #c4dcb8; text-align: center; }
.count.ok b { font-size: 26px; color: var(--bd-forest); }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 12px; color: var(--bd-muted); }
.stat b { font-size: 22px; color: var(--bd-ink); font-variant-numeric: tabular-nums; }
canvas.next { display: block; margin: 0 auto; }
.speeds { display: grid; gap: 4px; }
.speeds button { padding: 7px 8px; border-radius: 10px; font-size: 13px; text-align: left; display: flex; gap: 6px; align-items: center; background: #f6f4ee; border: 1px solid transparent; }
.speeds button[aria-checked="true"] { background: #fff; border-color: var(--bd-forest); font-weight: 700; }

/* ---------- pad and tools ---------- */
.pad { display: grid; grid-template-columns: repeat(3, 64px) minmax(110px, 1fr); gap: 8px; margin-top: 12px; }
#freeView .pad { grid-template-columns: repeat(4, 60px) minmax(100px, 1fr); }
.pad-btn { min-height: 54px; padding: 0; border-radius: 16px; border: 1px solid var(--bd-line); background: var(--bd-paper); font-size: 20px; font-weight: 700; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.pad-btn:active:not(:disabled) { transform: translateY(1px); background: #f2efe6; }
.pad-btn.drop { background: var(--bd-forest); border-color: var(--bd-forest); color: #fff; font-size: 17px; }
.bd-tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tool { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--bd-line); background: var(--bd-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(--bd-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(--bd-line); background: #fff; font-size: 11px; color: var(--bd-muted); }
.thumb svg { width: 46px; height: 46px; border-radius: 6px; background: var(--well); }
.thumb.solved { background: #eef6ea; border-color: #c4dcb8; color: var(--bd-forest); font-weight: 700; }
.thumb.current { box-shadow: 0 0 0 2px var(--bd-accent) inset; border-color: var(--bd-accent); }

#win { text-align: center; }
.win-art { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; margin: 2px 0 12px; 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(--bd-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) {
  .bd { padding: 0 16px; }
  .play-area { grid-template-columns: minmax(0, 1fr) 92px; gap: 8px; }
  .well-card { padding: 6px; border-radius: 18px; }
  .well-cover { inset: 6px; }
  .side { gap: 6px; }
  .side-box { padding: 8px; border-radius: 12px; }
  .q-item { padding: 2px 3px; }
  .q-item svg { width: 44px; height: 22px; }
  .queue { gap: 2px; }
  .q-item span { display: none; }
  .count .c-row { flex-direction: column; align-items: flex-start; gap: 0; font-size: 10.5px; }
  .count .c-row b { font-size: 18px; }
  .stat { flex-direction: column; gap: 0; font-size: 10.5px; }
  .speeds button { font-size: 11.5px; padding: 6px; }
  .pad { grid-template-columns: repeat(3, 1fr) 1.6fr; }
  #freeView .pad { grid-template-columns: repeat(4, 1fr) 1.5fr; gap: 6px; }
  .bd-tools .tool { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
