/* ضيّ وجسر النجوم — star-bridge.html only.
   Colours are the brand tokens from style.css or a mix of two of them; nothing
   here introduces a new hue. The character motion is the exception recorded
   in DESIGN.md (Motion) and must not be reused on other pages. */
.sb-page { overflow: hidden; background: var(--beige); overscroll-behavior: none; }
.sb-game [hidden] { display: none !important; }
.sb-game {
  --sb-tile: var(--beige); --sb-tile-alt: var(--white); --sb-tile-side: var(--border);
  --sb-leaf: var(--text-muted); --sb-leaf-light: var(--sage);
  --sb-rock: var(--border); --sb-rock-light: var(--beige); --sb-rock-line: var(--text-muted);
  --sb-fur-line: var(--text-muted); --sb-cloud-line: var(--border);
  --sb-key: clamp(44px, 14vw, 64px);
  position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh; height: 100dvh; color: var(--navy); font-family: var(--font-main);
  background: linear-gradient(var(--white), var(--beige) 70%);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
@supports (color: color-mix(in srgb, red, blue)) {
  .sb-game {
    --sb-tile: color-mix(in srgb, var(--beige), var(--gold-light) 30%);
    --sb-tile-alt: color-mix(in srgb, var(--beige), var(--gold-light) 12%);
    --sb-tile-side: color-mix(in srgb, var(--border), var(--gold-dark) 42%);
    --sb-leaf: color-mix(in srgb, var(--sage), var(--navy) 42%);
    --sb-leaf-light: color-mix(in srgb, var(--sage), var(--navy) 16%);
    --sb-rock: color-mix(in srgb, var(--border), var(--navy) 26%);
    --sb-rock-light: color-mix(in srgb, var(--border), var(--white) 30%);
    --sb-rock-line: color-mix(in srgb, var(--border), var(--navy) 50%);
    --sb-fur-line: color-mix(in srgb, var(--border), var(--navy) 38%);
  }
}
.sb-game button, .sb-game a { font-family: inherit; touch-action: manipulation; }
.sb-game button:focus-visible, .sb-game a:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.sb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── top bar ── */
.sb-hud { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(4px + env(safe-area-inset-top, 0px)) 12px 4px; }
.sb-title { font-size: 1rem; font-weight: 700; line-height: 1.45; color: var(--navy); text-align: center; }
.sb-title span { font-weight: 600; }
.sb-hud-tools { display: flex; gap: 8px; }
.sb-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--navy); background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.sb-icon-btn svg, .sb-tool svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-icon-btn[aria-pressed="true"] .sb-off, .sb-icon-btn[aria-pressed="false"] .sb-on { display: none; }
#sbCalm[aria-pressed="true"] { background: var(--sage); border-color: var(--navy); }

/* ── scene ── */
.sb-scene { position: relative; display: flex; flex-direction: column; min-height: 0; }
.sb-sky { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sb-sun { fill: var(--gold-light); opacity: .22; }
.sb-cloud path { fill: var(--white); stroke: var(--sb-cloud-line); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sb-islet-earth { fill: var(--border); }
.sb-islet-top { fill: var(--sage); }
.sb-islet-leaf { fill: var(--sb-leaf-light); }
.sb-twinkles path { fill: var(--gold-light); }
.sb-levels { position: relative; z-index: 1; display: flex; justify-content: center; gap: 4px; list-style: none; padding: 0 12px; }
.sb-level { display: flex; align-items: center; justify-content: center; width: 40px; height: 44px; }
.sb-level span { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--white); border: 1px solid var(--border); color: var(--navy); font-size: .95rem; font-weight: 700; line-height: 1; transition: var(--transition); }
.sb-level.is-done span { background: var(--gold-light); border-color: var(--gold-dark); color: var(--navy-dark); }
.sb-level.is-current span { background: var(--navy); border-color: var(--navy); color: var(--white); box-shadow: var(--shadow-md); }
.sb-stage { position: relative; z-index: 1; flex: 1; min-height: 0; margin: 4px 16px 8px; }
.sb-board { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* board pieces */
.sb-island-shadow { fill: var(--navy); opacity: .08; }
.sb-tile-side { fill: var(--sb-tile-side); }
.sb-tile-top { fill: var(--sb-tile); stroke: var(--sb-tile-side); stroke-width: 1.5; }
.sb-tile.is-alt .sb-tile-top { fill: var(--sb-tile-alt); }
.sb-tile-shine { fill: none; stroke: var(--white); stroke-width: 4; stroke-linecap: round; opacity: .8; }
.sb-tuft { fill: none; stroke: var(--sb-leaf); stroke-width: 2.5; stroke-linecap: round; opacity: .7; }
.sb-petal { fill: var(--white); stroke: var(--sb-tile-side); stroke-width: 1; }
.sb-pollen { fill: var(--gold); }
.sb-goal-ring { fill: none; stroke: var(--gold-dark); stroke-width: 3; stroke-dasharray: 3 9; stroke-linecap: round; }
.sb-start-ring { fill: none; stroke: var(--navy); stroke-width: 2; stroke-dasharray: 2 8; stroke-linecap: round; opacity: .45; }
.sb-shadow { fill: var(--navy); opacity: .14; }
.sb-rock { fill: var(--sb-rock); stroke: var(--sb-rock-line); stroke-width: 2.5; stroke-linejoin: round; }
.sb-rock-light { fill: var(--sb-rock-light); }
.sb-rock-line { fill: none; stroke: var(--sb-rock-line); stroke-width: 2.5; stroke-linecap: round; }
.sb-moss, .sb-leaf-light { stroke: var(--sb-leaf-light); }
.sb-moss { fill: var(--sb-leaf-light); }
.sb-leaf { fill: var(--sb-leaf); }
.sb-leaf-light { fill: none; stroke-width: 3; stroke-linecap: round; }
.sb-berry { fill: var(--gold-light); stroke: var(--gold-dark); stroke-width: 1.5; }
.sb-bridge { fill: none; stroke: var(--gold); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 1 13; }
.sb-trail-star, .sb-spark, .sb-star, .sb-dai-spark { fill: var(--gold-light); stroke: var(--gold-dark); stroke-width: 1.5; stroke-linejoin: round; }
.sb-board-hint path { fill: var(--navy); stroke: var(--white); stroke-width: 3; stroke-linejoin: round; }

/* characters */
.sb-ink { fill: var(--navy-dark); }
.sb-glint { fill: var(--white); }
.sb-line { fill: none; stroke: var(--navy-dark); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.sb-line.sb-thin { stroke-width: 1.8; }
.sb-glow-in { stop-color: var(--gold-light); stop-opacity: .6; }
.sb-glow-out { stop-color: var(--gold-light); stop-opacity: 0; }
.sb-skin-top { stop-color: var(--gold-light); }
.sb-skin-bottom { stop-color: var(--gold); }
.sb-dai-halo { fill: url(#sbGlow); }
.sb-dai-skin { fill: url(#sbSkin); stroke: var(--gold-dark); stroke-width: 2.5; }
.sb-dai-shine { fill: var(--white); opacity: .45; }
.sb-dai-foot { fill: var(--gold-dark); }
.sb-dai-arm, .sb-dai-antenna { fill: none; stroke: var(--gold-dark); stroke-width: 6; stroke-linecap: round; }
.sb-dai-antenna { stroke-width: 3; }
.sb-dai .sb-cheek { fill: var(--white); opacity: .5; }
.sb-fur { fill: var(--white); stroke: var(--sb-fur-line); stroke-width: 2.2; }
.sb-ear-in, .sb-bunny .sb-cheek { fill: var(--gold-light); opacity: .65; }
.sb-paw { fill: none; stroke: var(--white); stroke-width: 8; stroke-linecap: round; paint-order: stroke; filter: drop-shadow(0 0 .8px var(--navy)); }
.sb-scarf { fill: var(--navy); stroke: var(--navy-dark); stroke-width: 1.5; stroke-linejoin: round; }
.sb-nose { fill: var(--gold-dark); }
.sb-question { fill: var(--navy); font-family: var(--font-main); font-size: 30px; font-weight: 800; }
.sb-eyes-happy, .sb-eyes-dizzy, .sb-mouth-o, .sb-mouth-open, .sb-dizzy, .sb-question { display: none; }
.is-happy .sb-eyes-happy, .is-bump .sb-eyes-dizzy, .is-bump .sb-dizzy, .is-puzzled .sb-question,
.is-bump .sb-mouth-o, .is-puzzled .sb-mouth-o, .is-happy .sb-mouth-open { display: inline; }
.is-happy .sb-eyes-open, .is-bump .sb-eyes-open, .is-happy .sb-mouth-smile, .is-bump .sb-mouth-smile, .is-puzzled .sb-mouth-smile { display: none; }
.sb-dai-face { transition: transform .2s; }
.look-side .sb-dai-face { transform: translate(4px, 0); }
.look-up .sb-dai-face { transform: translate(0, -5px); }
.look-down .sb-dai-face { transform: translate(0, 5px); }

/* motion — parts of the characters move, not the whole picture */
.sb-dai-body, .sb-bunny-body, .sb-eye, .sb-dai-arm, .sb-paw, .sb-ear, .sb-dai-foot, .sb-dai-spark, .sb-dai-halo,
.sb-block-in, .sb-trail-star, .sb-spark, .sb-dizzy, .sb-goal-ring, .sb-board-hint path { transform-box: fill-box; transform-origin: 50% 50%; }
.sb-dai-body, .sb-bunny-body, .sb-block-in, .sb-ear { transform-origin: 50% 100%; }
.sb-dai-body { animation: sbBreathe 3.2s ease-in-out infinite; }
.sb-bunny-body { animation: sbBreathe 3.8s ease-in-out -1s infinite; }
.sb-eye { animation: sbBlink 4.6s infinite; }
.sb-bunny .sb-eye { animation-delay: -1.7s; }
.sb-dai-halo { animation: sbGlow 2.6s ease-in-out infinite alternate; }
.sb-dai-spark { animation: sbTwinkle 2.2s ease-in-out infinite alternate; }
.sb-ear-b { animation: sbEar 5.2s ease-in-out infinite; }
.sb-paw-wave { transform-origin: 0% 100%; animation: sbWave 3.6s ease-in-out infinite; }
.sb-paw-rest { transform-origin: 100% 0%; }
.sb-dai-arm-a { transform-origin: 100% 0%; }
.sb-dai-arm-b { transform-origin: 0% 0%; }
.sb-goal-ring { animation: sbSpin 16s linear infinite; }
.sb-trail-star { animation: sbPop .3s cubic-bezier(.4, 0, .2, 1) both; }
.sb-board-hint path { animation: sbPulse 1s ease-in-out infinite; }
.is-walk .sb-dai-foot-a { animation: sbFoot .23s ease-in-out infinite alternate; }
.is-walk .sb-dai-foot-b { animation: sbFoot .23s ease-in-out -.23s infinite alternate; }
.is-walk .sb-dai-arm-a { animation: sbSwing .23s ease-in-out infinite alternate; }
.is-walk .sb-dai-arm-b { animation: sbSwing .23s ease-in-out -.23s infinite alternate; }
.is-land .sb-dai-body { animation: sbLand .2s ease-out; }
.is-pop .sb-dai-body { animation: sbPop .3s cubic-bezier(.4, 0, .2, 1), sbBreathe 3.2s ease-in-out .3s infinite; }
.is-bump .sb-dai-body { animation: sbWobble .5s ease-in-out; }
.is-bump .sb-dizzy { animation: sbSpin 1.2s linear infinite; }
.is-puzzled .sb-dai-body { transform: rotate(-6deg); animation: none; }
.is-happy .sb-dai-body, .is-happy .sb-bunny-body { animation: sbCheer .5s ease-in-out 4; }
.is-happy .sb-bunny-body { animation-delay: .12s; }
.is-happy .sb-dai-arm-a { animation: sbArmUpA .4s ease-in-out infinite alternate; }
.is-happy .sb-dai-arm-b { animation: sbArmUpB .4s ease-in-out infinite alternate; }
.is-happy .sb-paw-wave { animation: sbWaveFast .36s ease-in-out infinite alternate; }
.is-happy .sb-paw-rest { transform: rotate(118deg); }
.is-happy .sb-ear { animation: sbEar .5s ease-in-out 4; }
.sb-block.is-hit .sb-block-in { animation: sbWobble .4s ease-in-out; }
.sb-spark { animation: sbRise 1.3s cubic-bezier(.4, 0, .2, 1) both; }
[data-state="won"] .sb-trail-star { animation: sbPop .3s cubic-bezier(.4, 0, .2, 1) both, sbTwinkle .7s ease-in-out .3s 4 alternate; }
.sb-cloud-a { animation: sbDrift 22s ease-in-out infinite alternate; }
.sb-cloud-b { animation: sbDrift 28s ease-in-out -6s infinite alternate-reverse; }
.sb-cloud-c { animation: sbDrift 25s ease-in-out -11s infinite alternate; }
.sb-islet-a { animation: sbBob 7s ease-in-out infinite alternate; }
.sb-islet-b { animation: sbBob 9s ease-in-out -3s infinite alternate; }
.sb-twinkles path { animation: sbGlow 2.4s ease-in-out infinite alternate; }
.sb-twinkles path:nth-child(even) { animation-delay: -1.2s; }
@keyframes sbBreathe { 50% { transform: scale(1.03, .97); } }
@keyframes sbBlink { 0%, 93%, 100% { transform: scaleY(1); } 96.5% { transform: scaleY(.1); } }
@keyframes sbGlow { from { opacity: .55; } to { opacity: 1; } }
@keyframes sbTwinkle { from { transform: scale(.8) rotate(-12deg); } to { transform: scale(1.15) rotate(12deg); } }
@keyframes sbEar { 0%, 84%, 100% { transform: rotate(0); } 90% { transform: rotate(9deg); } 95% { transform: rotate(-3deg); } }
@keyframes sbWave { 0%, 58%, 100% { transform: rotate(0); } 66%, 82% { transform: rotate(-16deg); } 74%, 90% { transform: rotate(10deg); } }
@keyframes sbWaveFast { from { transform: rotate(-22deg); } to { transform: rotate(12deg); } }
@keyframes sbSpin { to { transform: rotate(360deg); } }
@keyframes sbPop { from { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); opacity: 1; } to { transform: scale(1); } }
@keyframes sbPulse { 50% { transform: scale(1.18); } }
@keyframes sbFoot { to { transform: translateY(-6px); } }
@keyframes sbSwing { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes sbLand { from { transform: scale(1.12, .86); } to { transform: scale(1); } }
@keyframes sbWobble { 20% { transform: rotate(-7deg); } 50% { transform: rotate(6deg); } 80% { transform: rotate(-3deg); } }
@keyframes sbCheer { 0%, 100% { transform: translateY(0) scale(1); } 45% { transform: translateY(-16px) scale(.97, 1.04); } 85% { transform: translateY(0) scale(1.06, .94); } }
@keyframes sbArmUpA { from { transform: rotate(96deg); } to { transform: rotate(122deg); } }
@keyframes sbArmUpB { from { transform: rotate(-96deg); } to { transform: rotate(-122deg); } }
@keyframes sbRise { from { transform: translate(0, 0) scale(.4); opacity: 0; } 25% { opacity: 1; } to { transform: translate(var(--sb-drift, 0), -80px) scale(1); opacity: 0; } }
@keyframes sbDrift { to { transform: translateX(16px); } }
@keyframes sbBob { to { transform: translateY(8px); } }
@keyframes sbRing { 50% { box-shadow: 0 0 0 8px var(--gold-light), var(--shadow-md); } }
@keyframes sbChipShake { 25% { transform: translateX(4px); } 75% { transform: translateX(-4px); } }

/* «حركة أهدى»: the scene holds still, steps slide instead of hopping (js), no rising stars. */
.is-calm .sb-cloud, .is-calm .sb-islet, .is-calm .sb-twinkles path, .is-calm .sb-goal-ring, .is-calm .sb-dai-halo, .is-calm .sb-dai-spark,
.is-calm .sb-dai-body, .is-calm .sb-bunny-body, .is-calm .sb-ear, .is-calm .sb-paw-wave, .is-calm .sb-block-in, .is-calm .sb-trail-star,
.is-calm .sb-dizzy, .is-calm .sb-dai-foot, .is-calm .sb-board-hint path, .is-calm .sb-hand, .is-calm .is-hint, .is-calm .sb-chip { animation: none !important; }
.is-calm .is-happy .sb-dai-arm-a { animation: none; transform: rotate(108deg); }
.is-calm .is-happy .sb-dai-arm-b { animation: none; transform: rotate(-108deg); }
.is-calm .is-walk .sb-dai-arm { animation: none; }

/* ── plan panel ── */
.sb-panel { position: relative; z-index: 2; background: var(--white); border-top: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -6px 28px rgba(27, 58, 92, .10); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.sb-panel > * { max-width: 520px; margin-inline: auto; }
.sb-status { color: var(--text-mid); font-size: .82rem; font-weight: 600; line-height: 1.7; text-align: center; margin-bottom: 8px; }
[data-state="won"] .sb-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.sb-strip { display: flex; flex-wrap: wrap; gap: 6px; min-height: 54px; padding: 6px; list-style: none; background: var(--beige); border: 1px solid var(--border); border-radius: var(--radius-md); }
.sb-strip.is-full { animation: sbChipShake .28s cubic-bezier(.4, 0, .2, 1); }
.sb-chip { position: relative; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--navy); transition: var(--transition); }
.sb-arrow { display: block; fill: currentColor; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.sb-chip-empty { background: transparent; border: 2px dashed var(--border); }
.sb-chip.is-done { background: var(--sage); border-color: var(--sage); }
.sb-chip.is-now { background: var(--navy); border-color: var(--navy); color: var(--white); transform: scale(1.1); }
.sb-chip.is-wrong { border: 2px dashed var(--navy); background: var(--white); animation: sbChipShake .28s cubic-bezier(.4, 0, .2, 1) 2; }
.sb-chip.is-fix { box-shadow: 0 0 0 3px var(--gold); }
.sb-controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: 12px; }
.sb-tools { display: flex; flex-direction: column; gap: 8px; }
.sb-tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 60px; min-height: 52px; padding: 4px; color: var(--navy); background: var(--beige); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: .66rem; font-weight: 600; line-height: 1.45; white-space: nowrap; transition: var(--transition); }
.sb-dpad { display: grid; grid-template-columns: repeat(3, var(--sb-key)); grid-template-rows: repeat(2, var(--sb-key)); gap: 8px; justify-content: center; }
.sb-dir { position: relative; display: flex; align-items: center; justify-content: center; color: var(--white); background: linear-gradient(135deg, var(--navy), var(--navy-light)); border-radius: var(--radius-md); box-shadow: var(--shadow-md); transition: var(--transition); }
.sb-dir .sb-arrow { width: 56%; height: 56%; }
.sb-dir-up { grid-column: 2; grid-row: 1; }
.sb-dir-left { grid-column: 1; grid-row: 2; }
.sb-dir-down { grid-column: 2; grid-row: 2; }
.sb-dir-right { grid-column: 3; grid-row: 2; }
.sb-go { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; width: clamp(64px, 20vw, 88px); aspect-ratio: 1; color: var(--navy-dark); background: linear-gradient(135deg, var(--gold-dark), var(--gold) 55%, var(--gold-light)); border-radius: 50%; box-shadow: var(--shadow-gold); font-size: 1rem; font-weight: 800; line-height: 1.2; transition: var(--transition); }
.sb-go svg { fill: currentColor; }
.sb-game button:disabled { opacity: .45; box-shadow: none; cursor: default; }
.sb-dir:active, .sb-go:active, .sb-tool:active { transform: scale(.96); }
.is-hint { box-shadow: 0 0 0 4px var(--gold), var(--shadow-md); animation: sbRing 1s ease-in-out infinite; z-index: 1; }
.sb-tool.is-hint { background: var(--white); }
.sb-hand { position: absolute; right: -8px; bottom: -14px; z-index: 3; pointer-events: none; animation: sbBob .5s ease-in-out infinite alternate; }
.sb-hand svg { display: block; }
.sb-hand path { fill: var(--white); stroke: var(--navy); stroke-width: 2.5; stroke-linejoin: round; }
.sb-win { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.sb-win-stars path { fill: var(--gold-light); stroke: var(--gold-dark); stroke-width: 1.5; stroke-linejoin: round; }
.sb-win h2 { color: var(--navy); font-size: 1.2rem; font-weight: 700; line-height: 1.45; }
.sb-next { width: 100%; justify-content: center; min-height: 56px; }
.sb-text-btn { min-height: 44px; padding: 0 16px; color: var(--navy); font-size: .9rem; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
.sb-noscript { position: absolute; inset: auto 16px 50%; padding: 16px; text-align: center; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); }

@media (min-width: 768px) {
  .sb-title { font-size: 1.2rem; }
  .sb-status { font-size: .95rem; }
}
/* A phone turned sideways: the garden beside the plan instead of above it. */
@media (orientation: landscape) and (max-height: 560px) {
  .sb-game { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); grid-template-rows: auto minmax(0, 1fr); }
  .sb-hud { grid-column: 1 / -1; }
  .sb-panel { align-self: stretch; display: flex; flex-direction: column; justify-content: center; border-radius: var(--radius-lg) 0 0 0; border-inline-start: 1px solid var(--border); padding: 8px 12px; }
  .sb-panel > * { width: 100%; }
  .sb-game { --sb-key: 48px; }
  .sb-go { width: 68px; }
  .sb-strip { min-height: 46px; }
  .sb-chip { width: 32px; height: 32px; }
}
/* Short phones: a smaller plan strip leaves the garden its room. */
@media (orientation: portrait) and (max-height: 640px) {
  .sb-status { margin-bottom: 4px; }
  .sb-strip { gap: 4px; min-height: 44px; }
  .sb-game .sb-chip { width: 30px; height: 30px; }
  .sb-chip .sb-arrow { width: 20px; height: 20px; }
  .sb-controls { margin-top: 8px; }
}
@media (max-width: 360px) {
  .sb-panel { padding-inline: 12px; }
  .sb-controls { gap: 8px; }
  .sb-tool { width: 54px; }
  .sb-chip { width: 36px; height: 36px; }
}
