/* Beasties: Isle Hop (app key bridges, BridgesGame.swift). .brg is the container: every size is a multiple of
 * --u = 1/374 of its width (the app's 374 pt board panel: LabFrame 8 + 4 pt around 350 pt of cells). The map is one
 * SVG in 100 units per cell (water, waves, rings, planks, islands), drawn the same by PHP and beasties-bridges.js.
 * Colours from the app: water #2B5FA8 at 28 %, ice #AEE6FF, wood #B27A45 / joints #7A4C2A, ink #0E0B1A,
 * island stone M3Ink.wing #4A3F86, "missing" badge #FF8A3D, number badge and selection Theme.zap #FFD400, red #FF4D6D.
 * Dark like the app in both themes. */
.brg { --u: calc(100cqw / 374); position: relative; container-type: inline-size; box-sizing: border-box; width: 100%; }
.brg-panel { position: absolute; left: 0; top: 0; right: 0; bottom: calc(6 * var(--u)); border-radius: calc(20 * var(--u)); background: #241e45; box-shadow: inset 0 0 0 calc(3 * var(--u)) #0e0b1a, 0 calc(6 * var(--u)) 0 #0e0b1a; }
.brg-well { position: absolute; inset: calc(8 * var(--u)); border-radius: calc(14 * var(--u)); background: #1a1533; box-shadow: inset 0 0 0 calc(3 * var(--u)) #0e0b1a; }
.brg-grid { position: absolute; left: calc(12 * var(--u)); top: calc(12 * var(--u)); width: calc(350 * var(--u)); height: calc(350 * var(--u) / var(--w) * var(--h)); }
.brg-svg, .brg-fxs { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.brg-fxs { z-index: 3; pointer-events: none; }
.brg-fx { position: absolute; inset: 0; z-index: 8; pointer-events: none; }

.brg-water { fill: #2b5fa8; fill-opacity: .28; }
.brg-wave { fill: none; stroke: #aee6ff; stroke-opacity: .22; stroke-width: 6; stroke-linecap: round; }
.brg-wr { fill: none; stroke: #aee6ff; stroke-opacity: .18; stroke-width: 4; }
/* planks: shadow, wood, joints, ink outline (drawPlanks) */
.brg-ps { fill: #0e0b1a; }
.brg-pw { fill: #b27a45; }
.brg-pj { fill: none; stroke: #7a4c2a; stroke-width: 4.5; }
.brg-po { fill: none; stroke: #0e0b1a; stroke-width: 5.5; }
.brg-p.is-try .brg-pw { fill: #ede7ff; fill-opacity: .35; }
.brg-p.is-try .brg-pj { stroke-opacity: 0; }
.brg-p.is-try .brg-po { stroke: #ede7ff; stroke-dasharray: 10 8; }
.brg-p.is-try .brg-ps { fill-opacity: 0; }
/* a wrong bridge: red, shakes across its direction, fades (WrongBridge); the bridge it would cross blinks (WhyLink) */
.brg-p.is-wrong .brg-pw, .brg-p.is-why .brg-pw { fill: #ff4d6d; }
.brg-p.is-wrong .brg-pj, .brg-p.is-why .brg-pj { stroke: #b03753; }
.brg-p.is-wrong { animation: brg-wrong-h .8s ease-out forwards; }
.brg-p.is-wrong.is-v { animation-name: brg-wrong-v; }
@keyframes brg-wrong-h { 0% { opacity: 1; } 6% { transform: translateY(9px); } 14% { transform: translateY(-9px); } 22% { transform: translateY(8px); } 30% { transform: translateY(-6px); } 38% { transform: none; opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes brg-wrong-v { 0% { opacity: 1; } 6% { transform: translateX(9px); } 14% { transform: translateX(-9px); } 22% { transform: translateX(8px); } 30% { transform: translateX(-6px); } 38% { transform: none; opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.brg-p.is-why { animation: brg-why 1.9s linear forwards; }
@keyframes brg-why { 0%, 21% { opacity: 1; } 29% { opacity: .2; } 37%, 69% { opacity: 1; } 100% { opacity: 0; } }
.brg-whyr { fill: none; stroke: #ff4d6d; stroke-width: 9; filter: drop-shadow(0 0 5px rgba(255, 77, 109, .7)); animation: brg-why 1.9s linear forwards; }
/* connections known to stay empty (solution player, tip cards) */
.brg-no { fill: none; stroke: #8f86b8; stroke-width: 6; stroke-linecap: round; opacity: .85; }
.brg-no.is-try { stroke: #ede7ff; opacity: .7; }
/* dashed hints from the selected island (BridgesHints) */
.brg-hint { fill: none; stroke: #ffd400; stroke-opacity: .7; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 14 16; }
/* islands (BridgesIsland) */
.brg-i { cursor: default; }
.brg-in { transform-box: fill-box; transform-origin: center; }
.brg-sh { fill: #0e0b1a; }
.brg-st { fill: #4a3f86; }
.brg-hi { fill: #605695; }
.brg-ring { fill: none; stroke: #0e0b1a; stroke-width: 7; }
.brg-ring.is-sel { stroke: #ffd400; }
.brg-sel { fill: #ffd400; fill-opacity: .25; }
.brg-num { fill: #ede7ff; font-family: var(--display); font-weight: 700; font-size: 46px; text-anchor: middle; dominant-baseline: central; }
.brg-badge circle { fill: #ff8a3d; stroke: #0e0b1a; stroke-width: 4.9; }
.brg-badge.is-done circle { fill: #ffd400; }
.brg-badge text { fill: #0e0b1a; font-family: var(--display); font-weight: 700; font-size: 26px; text-anchor: middle; dominant-baseline: central; }
.brg-i.is-pop .brg-in { animation: brg-pop .45s ease-out; }
@keyframes brg-pop { 0% { transform: none; } 22% { transform: scale(1.22); } 100% { transform: none; } }
.brg-i.is-shake .brg-in { animation: brg-shake .25s ease-out; }
@keyframes brg-shake { 20% { transform: translateX(8px); } 50% { transform: translateX(-8px); } 75% { transform: translateX(5px); } }
.brg-i.is-cheer .brg-in { animation: brg-cheer .6s ease-out var(--dl, 0s); }
@keyframes brg-cheer { 0%, 100% { transform: none; } 30% { transform: translateY(-28px); } 55% { transform: translateY(4px); } }
/* site only: yellow rings / links the guide points at; a broken guess turns them red */
.brg-hl { fill: none; stroke: #ffd400; stroke-width: 7; filter: drop-shadow(0 0 6px rgba(255, 212, 0, .7)); animation: brg-hl .8s ease-in-out infinite alternate; pointer-events: none; }
.brg-hl.is-link { stroke-width: 34; stroke-opacity: .45; stroke-linecap: round; filter: none; }
.brg-svg.is-contra .brg-hl { stroke: #ff4d6d; filter: drop-shadow(0 0 6px rgba(255, 77, 109, .8)); }
@keyframes brg-hl { from { opacity: .55; } to { opacity: 1; } }
/* FX: dust where a bridge lands, a ring around a finished island, the "All joined!" banner */
.brg-dust { fill: none; stroke: #e8c9a0; stroke-width: 6; animation: brg-dust .6s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes brg-dust { from { transform: scale(.4); opacity: .9; } to { transform: scale(1.2); opacity: 0; } }
.brg-burst { fill: none; stroke: #ffd400; stroke-width: 6; animation: brg-dust .7s cubic-bezier(.2, .7, .3, 1) forwards; transform-box: fill-box; transform-origin: center; }
.brg-banner { position: absolute; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-4deg); padding: .3em .7em; border-radius: 14px; background: #ffd400; color: #0e0b1a; font-family: var(--display); font-weight: 800; font-style: normal; font-size: max(1.2rem, 9cqw); line-height: 1; white-space: nowrap; text-transform: uppercase; box-shadow: inset 0 0 0 3px #0e0b1a, 0 5px 0 #0e0b1a; animation: brg-banner 1.8s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes brg-banner { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-4deg) scale(.3); } 15%, 78% { opacity: 1; transform: translate(-50%, -50%) rotate(-4deg) scale(1); } 100% { opacity: 0; transform: translate(-50%, -62%) rotate(-4deg) scale(1); } }
/* level page: one invisible button per island (keyboard, screen readers) */
.brg-btns { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.brg-b { --C: calc(100% / var(--w)); position: absolute; left: calc(var(--x) * 100% / var(--w)); top: calc(var(--y) * 100% / var(--h)); width: calc(100% / var(--w)); height: calc(100% / var(--h)); padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; pointer-events: none; }
.brg-b:focus-visible { outline: 3px solid #ffd400; outline-offset: -2px; }

/* ---------- tools (GameToolbar: Undo, Restart) ---------- */
.brg-tools { grid-template-columns: repeat(2, 1fr); max-width: 60%; margin-inline: auto; }
.brg-tool.is-off { opacity: .4; }
button.brg-tool { border: 0; background: none; font: inherit; color: #ede7ff; cursor: pointer; padding: 0; }
button.brg-tool:disabled { cursor: default; }
button.brg-tool:focus-visible { outline: 2px solid #ffd400; outline-offset: 2px; border-radius: 10px; }

/* ---------- the game screen (LabScreen) ---------- */
.gx.is-bridges { --pw: 19%; }
.gx-head.is-bridges { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; margin-top: 2px; }
.gx-head.is-bridges .gx-icons, .gx-head.is-bridges .gx-pill { margin-top: 14px; }
.gx-head.is-bridges .gx-pill { white-space: nowrap; }
.gx-head.is-bridges .gx-title { gap: 1px; }
.gx.is-bridges .gx-stars, .brg-head .gx-stars { justify-content: center; gap: 3px; margin-top: 2px; }
.gx.is-bridges .st, .brg-head .st { width: 17px; height: 17px; }
.brg-line { display: block; margin-top: 2px; font-size: .66rem; font-weight: 600; color: #8f86b8; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; transition: color .2s; }
.brg-line.is-why { color: #ff4d6d; }
.gx-stage.is-bridges { position: relative; }
.gx-stage.is-bridges .brg { z-index: 1; }
.bst-phone .gx.is-bridges .gx-stage { margin-top: auto; }
.bst-phone .gx.is-bridges .gx-bottom { margin-bottom: auto; }
.bst-phone .gx.is-bridges .brg-tools { margin-top: 14px; }
.gx.is-bridges .gx-home { margin-top: 0; }

/* ---------- on a card: Gnatz peeks over the board ---------- */
.bst-board-card.is-bridges { padding: 12px 14px 16px; background: linear-gradient(180deg, #2a1c63, #17112f); border-color: #0e0b1a; color: #ede7ff; max-width: 420px; }
.brg-ui { --pw: 19%; position: relative; }
.brg-ui .gx-peek, .gx.is-bridges .gx-peek { --px: .5; }

/* ---------- on the site ---------- */
.bst-mini.is-bridges { background: #1a1533; }
.bst-tier.is-bridges .bst-tier-board { margin-bottom: 10px; }
.bst-fan-card.is-bridges { display: flex; background: #241e45; border-color: #0e0b1a; }
.bst-fan-card.is-bridges .bst-fan-well { flex: 1; display: flex; align-items: center; min-width: 0; padding: 2px; }
.bst-how-pic .bst-scene-visual:has(> .bst-how-brg) { height: 100%; display: grid; place-items: center; }
.bst-how-pic .bst-scene:has(.bst-how-brg) { grid-template-columns: minmax(0, 1fr); width: 100%; height: 100%; }
.bst-how-brg { height: 96%; aspect-ratio: .82; display: grid; align-items: center; }
.bst-how-brg .bst-board-card { width: 100%; box-sizing: border-box; padding: 6px 8px 8px; border-radius: 16px; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .brg *, .brg-ui *, .gx.is-bridges * { transition: none !important; animation: none !important; } }

/* ---------- one level ---------- */
.bst-level.is-bridges { max-width: 1040px; }
.brg-facts { list-style: none; margin: 0 auto 28px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 680px; }
.brg-facts li { display: grid; gap: 2px; justify-items: center; align-content: start; text-align: center; padding: 12px 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.brg-facts strong { font-family: var(--display); font-size: 1.7rem; line-height: 1; color: var(--text); }
.brg-facts span { font-size: .8rem; color: var(--muted); line-height: 1.3; }
.brg-ui.is-page, .brg-sol-in { padding: 12px 14px 16px; border-radius: 22px; background: linear-gradient(180deg, #2a1c63, #17112f); color: #ede7ff; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .7); }
.brg-head { display: flex; flex-direction: column; align-items: center; margin-bottom: 4px; }
.brg-head .gx-stars { display: flex; }
.brg-head .st { color: #ffd400; transition: color .3s; }
.brg-head .st.is-lost { color: #2c2456; }
.brg-ui.is-page .brg-line { font-size: .8rem; }
.brg-ui.is-page .brg-tools { margin-top: 14px; }
.brg-ui.is-page .brg-grid { cursor: pointer; touch-action: none; }
.brg-ui.is-page .brg-b { pointer-events: auto; }
.brg-say { min-height: 3em; }
.brg-say.is-won { color: var(--text); font-weight: 700; }
.brg-sol-in .brg-ui.is-sol { --pw: 0%; }
.brg-sol-in .gx-peek { display: none; }
.brg-why { min-height: 5.6em; margin: 12px 4px 0; font-size: .92rem; line-height: 1.45; color: #ede7ff; }
.brg-sol-in .bst-player-bar { margin-top: 10px; }
.brg-sol-in .bst-play-btn:not(.is-main) { background: #241e45; color: #ede7ff; border-color: #3a3166; }
.brg-sol-in .bst-player-count, .brg-sol-in .bst-player-count strong { color: #ede7ff; }
.brg-sol-in .bst-player-count small { color: #b7aee0; }
.bst-spoiler.is-bridges { border-radius: 22px; }
.bst-spoiler.is-bridges:not(.is-open) .brg-sol-in { filter: blur(9px) saturate(.6); user-select: none; pointer-events: none; }
.bst-spoiler.is-bridges .brg-sol-in { transition: filter .35s ease; }
.bst-move-list.is-bridges li { margin-bottom: .35em; }
@media (max-width: 560px) {
	.brg-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
	.brg-facts strong { font-size: 1.4rem; }
	.brg-ui.is-page, .brg-sol-in { padding: 10px 10px 14px; }
}
.brg-sol .bst-peek-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; }
