:root{font-family:system-ui,-apple-system,'Hiragino Kaku Gothic ProN',sans-serif;color:#2a2328;background:#fff;color-scheme:light}*{box-sizing:border-box}body{margin:0;height:100svh;height:100dvh;min-height:540px;display:flex;flex-direction:column}button,select{font:inherit;color:inherit;touch-action:manipulation}button{min-height:44px;border:0;border-radius:8px;background:#f3f4f6;padding:8px 12px}button:disabled{opacity:.45}[hidden]{display:none!important}body>.game-nav-header{flex-shrink:0}main{width:100%;max-width:450px;margin:auto;flex:1;min-height:0;display:flex;flex-direction:column;gap:5px;padding:3px 8px max(8px,env(safe-area-inset-bottom))}.companion{display:flex;align-items:center;gap:7px;flex-shrink:0}.companion img{width:56px;height:56px;object-fit:contain}.companion p{flex:1;margin:0;font-size:13px;line-height:1.4}.companion small{font-size:11px;color:#6e626a;display:block}.companion span{display:block}.companion button{width:44px;padding:0}.toolbar{display:flex;align-items:center;justify-content:space-between;gap:5px;font-size:12px;flex-shrink:0}.toolbar label{display:flex;align-items:center;gap:5px;min-width:0}.toolbar select{max-width:190px;min-height:44px;border:0;border-radius:8px;background:#f3f4f6}#stats{white-space:nowrap}#rule{font-size:12px;margin:0;text-align:center;color:#6e626a;flex-shrink:0}#board{position:relative;flex:1;min-height:270px;border-radius:16px;overflow:hidden;background:radial-gradient(ellipse at 50% 70%,#304d68,#14263f);touch-action:none;user-select:none}#threads,#nodes{position:absolute;inset:0;width:100%;height:100%}#threads{pointer-events:none}.thread{stroke:#b8e5e2;stroke-width:.65;stroke-linecap:round}.thread.crossed{stroke:#ffd18e;stroke-width:.9}.crossing{fill:#fff4cf;stroke:#f2b16a;stroke-width:.6}.rail{stroke:#adc7d0;stroke-width:.4;stroke-dasharray:1 1.4;opacity:.7}.node{position:absolute;transform:translate(-50%,-50%);width:44px;height:44px;border:1px solid #b8e5e2;border-radius:50%;background:radial-gradient(circle at 35% 30%,#f5ffff,#b7dedd 45%,#6a9baf);color:#14263f;font-size:14px;font-weight:700;box-shadow:0 0 9px #c8f2ee50;padding:0;touch-action:none}.node.fixed{background:#354861;color:#fff;border:2px solid #adc7d0;box-shadow:none}.node.horizontal{border:2px solid #ffe3a0}.node.dragging{outline:2px solid #fff;outline-offset:3px}.node:disabled{opacity:1}.panel{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;background:#14263feF;color:#fff;padding:20px;text-align:center}.panel h2{font-size:23px;margin:0}.panel p{font-size:14px;line-height:1.8;margin:0}.panel button{min-width:160px;background:#e2eeee}#feedback{font-size:12px;line-height:17px;min-height:34px;text-align:center;margin:0;flex-shrink:0}.controls{display:flex;gap:6px;flex-shrink:0}.controls button{flex:1;font-size:13px}#result{padding:8px;border-radius:8px;background:#eef0f3;flex-shrink:0}#result strong{display:block;font-size:13px;margin-bottom:6px}#next{background:#304d68;color:#fff}#save-note{margin:0;font-size:11px;color:#6e626a}dialog{max-width:410px;width:calc(100% - 32px);max-height:85dvh;overflow:auto;border:1px solid #ddd;border-radius:12px;padding:18px}dialog h2{font-size:19px;margin-top:0}dialog p{font-size:13px;line-height:1.7}dialog button{width:100%}dialog::backdrop{background:#14263f80}button:focus-visible,select:focus-visible{outline:3px solid #b94f7c;outline-offset:2px}@media(max-height:700px){.companion img{width:44px;height:44px}main{gap:3px}#feedback{min-height:17px}#board{min-height:250px}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}

/* Scene art stays behind the threads and never captures a touch. */
#board[data-scene]{--light:#b8e5e2;--ink:#14263f;isolation:isolate}
#board::before,#board::after{content:'';position:absolute;pointer-events:none;z-index:-1;opacity:.3}
#board[data-scene]:not([data-scene="classic"]) .thread:not(.crossed){stroke:var(--light)}
#board[data-scene]:not([data-scene="classic"]) .node:not(.fixed){border-color:var(--light);background:radial-gradient(circle at 35% 30%,#fff,var(--light) 60%,#7194a1);color:var(--ink)}
#board[data-scene="christmas-tree"]{--light:#c9edbc;background:radial-gradient(ellipse at bottom,#2e6551,#102c30)}
#board[data-scene="christmas-tree"]::before{inset:54% 0 0;background:#6dba86;clip-path:polygon(14% 5%,4% 48%,9% 48%,0 77%,10% 77%,10% 100%,18% 100%,18% 77%,28% 77%,19% 48%,24% 48%)}
#board[data-scene="christmas-tree"]::after{inset:0;background:radial-gradient(circle at 14% 57%,#ffde91 0 2px,transparent 3px),radial-gradient(circle at 87% 8%,#fff 0 2px,transparent 3px),radial-gradient(circle at 94% 75%,#fff 0 2px,transparent 3px),radial-gradient(circle at 6% 26%,#fff 0 1px,transparent 2px)}
#board[data-scene="christmas-ribbon"]{--light:#f8d0ca;background:repeating-linear-gradient(45deg,transparent 0 24px,#ffffff04 24px 26px),radial-gradient(ellipse at bottom,#743d54,#32233e)}
#board[data-scene="christmas-ribbon"]::before{width:58px;height:48px;bottom:12px;right:12px;border-radius:5px;background:linear-gradient(90deg,transparent 41%,#ffe6ac 41% 59%,transparent 59%),linear-gradient(transparent 37%,#ffe6ac 37% 57%,transparent 57%),#cc7189}
#board[data-scene="christmas-ribbon"]::after{width:36px;height:16px;bottom:60px;right:23px;border:4px solid #ffe6ac;border-radius:50% 50% 0 0}
#board[data-scene="christmas-bells"]{--light:#f8e1aa;background:radial-gradient(ellipse at top,#42436a,#171e3d)}
#board[data-scene="christmas-bells"]::before,#board[data-scene="christmas-bells"]::after{top:12px;width:32px;height:36px;background:#f8d884;border-radius:50% 50% 10% 10%;border-bottom:5px solid #fff0be;transform:rotate(18deg)}
#board[data-scene="christmas-bells"]::before{left:16px}#board[data-scene="christmas-bells"]::after{right:16px;transform:rotate(-18deg)}
#board[data-scene="sakura"]{--light:#ffd2e4;background:radial-gradient(ellipse at top,#674869,#302941)}
#board[data-scene="sakura"]::before{inset:0;background:radial-gradient(ellipse at 4% 9%,#ffb8d9 0 9px,transparent 10px),radial-gradient(ellipse at 8% 6%,#ffb8d9 0 9px,transparent 10px),radial-gradient(ellipse at 11% 10%,#ffb8d9 0 9px,transparent 10px),radial-gradient(ellipse at 7% 13%,#ffb8d9 0 9px,transparent 10px),radial-gradient(ellipse at 94% 90%,#ffb8d9 0 8px,transparent 9px),radial-gradient(ellipse at 92% 95%,#ffb8d9 0 8px,transparent 9px)}
#board[data-scene="tide"]{--light:#a8eceb;background:radial-gradient(ellipse at bottom,#296c81,#152e52)}
#board[data-scene="tide"]::before{inset:70% -30% -20%;border-radius:50%;background:repeating-radial-gradient(ellipse at center,transparent 0 14px,#b5f4ef 15px 16px,transparent 17px 32px)}
#board[data-scene="tide"]::after{bottom:14px;left:15px;width:36px;height:28px;border-radius:50% 50% 10% 10%;background:repeating-conic-gradient(from -60deg at 50% 100%,#edc9b5 0deg 15deg,#bfa6a1 16deg 30deg);clip-path:polygon(0 0,100% 0,100% 65%,55% 100%,45% 100%,0 65%)}
#board[data-scene="firefly"]{--light:#dceda4;background:radial-gradient(ellipse at bottom,#1f514d,#142f34)}
#board[data-scene="firefly"]::before{inset:0;opacity:.5;background:radial-gradient(circle at 7% 20%,#ecfba6 0 2px,transparent 5px),radial-gradient(circle at 92% 36%,#ecfba6 0 2px,transparent 5px),radial-gradient(circle at 14% 92%,#ecfba6 0 2px,transparent 5px),radial-gradient(circle at 90% 84%,#ecfba6 0 2px,transparent 5px)}
#board[data-scene="firefly"]::after{inset:78% -10% -20%;border-top:3px solid #90c9b7;border-radius:50%;transform:rotate(-22deg)}
#board[data-scene="maple"]{--light:#ffd4a0;background:radial-gradient(ellipse at bottom,#68423a,#302c40)}
#board[data-scene="maple"]::before{width:56px;height:58px;right:5px;bottom:4px;background:#e78f64;clip-path:polygon(50% 0,60% 27%,79% 10%,75% 39%,100% 32%,82% 60%,95% 65%,55% 80%,53% 100%,47% 100%,45% 80%,5% 65%,18% 60%,0 32%,25% 39%,21% 10%,40% 27%)}
#board[data-scene="maple"]::after{left:6px;bottom:7px;width:65px;height:30px;border-top:5px solid #dcb38e;border-radius:50%;border-bottom:2px solid #dcb38e}
#board[data-scene="aurora"]{--light:#bddbff;background:linear-gradient(115deg,transparent 10%,#7ae0be25 18%,transparent 35%,#a28df82c 55%,transparent 75%),radial-gradient(ellipse at top,#253f63,#18233b)}
#board[data-scene="aurora"]::before{inset:0;background:radial-gradient(circle at 7% 9%,#fff 0 1px,transparent 2px),radial-gradient(circle at 92% 18%,#fff 0 1px,transparent 2px),radial-gradient(circle at 8% 85%,#fff 0 2px,transparent 3px),radial-gradient(circle at 90% 94%,#fff 0 1px,transparent 2px)}
#board[data-scene="aurora"]::after{inset:0 0 85%;border-bottom:9px solid #a2eed7;filter:blur(8px);border-radius:0 0 60% 30%;transform:rotate(-12deg)}
