/* Bridges. Colours come from ../shared/base.css; the fallbacks keep the page usable without it. */
:root {
  --br-ink: #2f3a2c;
  --br-paper: var(--card, #fff);
  --br-line: var(--line, #e6e0d2);
  --br-accent: var(--accent, #a65032);
  --br-forest: var(--forest, #3d5a3a);
  --br-muted: var(--muted, #6b6b60);
  --water: #dcecf2;
  --water-dot: #b9d6e2;
  --island: #f6efdc;
  --island-edge: #8a7a5a;
  --island-done: #cfe6c4;
  --island-done-edge: #4f8a4a;
  --island-over: #f6d0c6;
  --plank: #8a6544;
}

* { box-sizing: border-box; }
body { margin: 0; background: #faf7f1; color: var(--br-ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
.br-top .header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--br-line); background: var(--br-paper); font-weight: 700; font-size: 17px; }

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

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

/* ---------- board ---------- */
.board-card { display: flex; justify-content: center; padding: 12px; background: var(--water); border: 1px solid #c7dde6; border-radius: 22px; box-shadow: 0 10px 35px #3d44350a; }
#board { width: 100%; max-width: 600px; aspect-ratio: 1; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.water-dot { fill: var(--water-dot); }
.bridge line.plank { stroke: var(--plank); stroke-width: .11; stroke-linecap: round; }
.bridge line.hit { stroke: transparent; stroke-width: .5; cursor: pointer; }
.bridge.hl line.plank { stroke: #e0a21f; }
.bridge.blocked line.plank { animation: blink .5s 2; }
.bridge.new line.plank { animation: grow .35s ease-out; }
@keyframes blink { 50% { stroke: #e0583a; } }
@keyframes grow { from { stroke-width: .3; } }
.preview { stroke: var(--plank); stroke-width: .08; stroke-dasharray: .12 .12; opacity: .7; }
.island { cursor: pointer; }
.island circle.disc { fill: var(--island); stroke: var(--island-edge); stroke-width: .06; transition: fill .2s; }
.island text { font: 700 .46px system-ui, -apple-system, sans-serif; fill: var(--br-ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.island circle.hit { fill: transparent; }
.island.done circle.disc { fill: var(--island-done); stroke: var(--island-done-edge); }
.island.over circle.disc { fill: var(--island-over); stroke: #e0583a; }
.island.sel circle.disc { stroke: var(--br-accent); stroke-width: .1; }
.island.target circle.disc { stroke: #e0a21f; stroke-width: .1; }
.island.hl circle.disc { stroke: #e0a21f; stroke-width: .12; }
.halo { fill: #fff1c7; opacity: .9; }
.board-card.solved .island circle.disc { fill: var(--island-done); stroke: var(--island-done-edge); }
.board-card.solved .bridge line.plank { stroke: #4f8a4a; }

/* ---------- tools and hints ---------- */
.br-tools { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.tool { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--br-line); background: var(--br-paper); font-weight: 600; font-size: 14px; }
.tool:disabled { opacity: .45; cursor: default; }
.tool.hint { background: #fff8e1; border-color: #f0dc9a; }
button:focus-visible { outline: 3px solid var(--br-accent); outline-offset: 2px; }
.hint-box { margin: 14px 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 { border: 0; border-radius: 24px; padding: 28px 26px 24px; max-width: min(440px, calc(100vw - 32px)); width: 100%; box-shadow: 0 30px 80px #2a302633; color: var(--br-ink); background: #fffdf8; }
dialog.wide { max-width: min(620px, calc(100vw - 32px)); }
dialog::backdrop { background: #2a302655; }
dialog h2 { font: 400 28px Georgia, serif; margin: 6px 0 14px; }
dialog .close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f2efe6; font-size: 20px; }
.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: var(--water); border-radius: 16px; padding: 10px; }
.guide-demo svg { width: 220px; }
.guide-demo .demo-plank { stroke: var(--plank); stroke-width: .11; stroke-linecap: round; stroke-dasharray: 3; stroke-dashoffset: 3; animation: draw 5s infinite; animation-delay: var(--d); }
@keyframes draw { 0%, 10% { stroke-dashoffset: 3; } 25%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: 0; } }

#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(--br-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(--br-line); background: #fff; font-size: 11px; color: var(--br-muted); }
.thumb svg { width: 46px; height: 46px; border-radius: 6px; background: var(--water); }
.thumb.solved { background: #eef6ea; border-color: #c4dcb8; color: var(--br-forest); font-weight: 700; }
.thumb.current { box-shadow: 0 0 0 2px var(--br-accent) inset; border-color: var(--br-accent); }

#win { text-align: center; }
.win-art { display: flex; justify-content: center; margin: 2px 0 12px; }
.win-art svg { width: 150px; height: 150px; border-radius: 16px; background: var(--water); 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(--br-forest); min-height: 1.4em; margin: -6px 0 6px; }
.win-note { color: var(--br-muted); margin: 0 0 18px; font-size: 14px; }
.win-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 560px) {
  .br { padding: 0 16px; }
  .board-card { padding: 6px; border-radius: 18px; }
  .br-tools .tool { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
