/* css/modes/knots.css — knot tying mini-game (dom mode) */
.knots-root {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px);
}
.knots-top { display: flex; align-items: center; gap: 10px; padding-right: 58px; flex: none; }
.knots-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 16px;
  background: rgba(13, 19, 33, .66); border: 1px solid var(--glass-border); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.knots-ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; color: #3a1d0b; background: linear-gradient(180deg, var(--primary-hi), var(--primary-2)); }
.knots-ico .ico { width: 26px; height: 26px; }
.knots-title > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.knots-name { font-size: 1.15rem; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.knots-sub { font-size: .75rem; font-weight: 800; color: var(--text-dim); letter-spacing: .04em; }
.knots-stats { display: flex; gap: 6px; }
.knots-stat { display: flex; flex-direction: column; line-height: 1.05; padding: 6px 12px; border-radius: 14px; background: rgba(13, 19, 33, .66); border: 1px solid var(--glass-border); }
.knots-stat span { font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.knots-stat b { font-size: 1.1rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.knots-stat-m b { color: #ffb3bb; }
.knots-stat.bump { animation: knBump .45s var(--ease-pop); }
@keyframes knBump { 40% { transform: scale(1.15); background: rgba(255, 77, 94, .35); } }

/* the board: weathered pier planks */
.knots-board {
  position: relative; flex: 1; min-height: 0; border-radius: 22px; overflow: hidden; touch-action: none;
  border: 1px solid rgba(255,255,255,.14); box-shadow: inset 0 0 60px rgba(5, 10, 25, .55), var(--shadow);
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(255, 230, 190, .1), transparent 60%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.0) 0 2px, rgba(255,255,255,.035) 2px 3px, rgba(0,0,0,0) 3px 17px),
    repeating-linear-gradient(180deg, #4a5b78 0 62px, #22304a 62px 66px),
    #3d4f6b;
}
.knots-board::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(180deg, transparent 0 20px, rgba(255,255,255,.025) 20px 21px, transparent 21px 41px, rgba(0,0,0,.05) 41px 42px, transparent 42px 66px); }
.knots-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.knots-svg:active { cursor: grabbing; }
.kn-guide-dash { animation: knDash .8s linear infinite; }
@keyframes knDash { to { stroke-dashoffset: -16; } }
.kn-target { animation: knPulse 1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; fill: rgba(62,224,143,.15); }
@keyframes knPulse { 50% { transform: scale(1.3); opacity: .6; } }
.kn-tip-ring { fill: rgba(255, 214, 120, .22); stroke: #ffd25e; stroke-width: 3.5; transform-box: fill-box; transform-origin: center; animation: knTip 1.1s ease-in-out infinite; }
.kn-tip-ring.grab { animation: none; fill: rgba(62, 224, 143, .25); stroke: var(--good); transform: scale(1.15); }
.kn-tip-ring.off { stroke: var(--bad); fill: rgba(255, 77, 94, .3); animation: knShake .3s linear infinite; }
@keyframes knTip { 50% { transform: scale(1.25); opacity: .75; } }
@keyframes knShake { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.kn-badge rect { fill: rgba(13, 19, 33, .82); stroke: rgba(255,255,255,.4); stroke-width: 1.2; }
.kn-badge text { font-size: 10.5px; font-weight: 900; fill: #fff; letter-spacing: .04em; }
.kn-badge-o rect, .kn-badge-f rect { stroke: #3ee08f; }
.kn-badge-o text, .kn-badge-f text { fill: #9ff0c4; }
.kn-badge-u rect, .kn-badge-b rect { stroke: #49c6f2; }
.kn-badge-u text, .kn-badge-b text { fill: #bfeaff; }
.kn-badge.next .kn-badge-in { animation: knBadge .9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.kn-badge:not(.next) { opacity: .6; }
@keyframes knBadge { 50% { transform: scale(1.18); } }
.kn-hand { pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0,0,0,.4)); }
.knots-bunny { pointer-events: none; animation: knHop .6s ease-in-out infinite alternate; }
@keyframes knHop { to { transform: translateY(-3px); } }
.kn-label { pointer-events: none; }

/* instructions */
.knots-instr { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 10px 14px 12px; border-radius: 18px;
  background: rgba(13, 19, 33, .72); border: 1px solid var(--glass-border); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.knots-steps { display: flex; gap: 6px; }
.knots-steps i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: .8rem; background: rgba(255,255,255,.1); color: var(--text-dim); transition: background .3s, transform .3s var(--ease-pop); }
.knots-steps i.cur { background: var(--primary); color: #3a1d0b; transform: scale(1.12); }
.knots-steps i.done { background: var(--good); color: #05341c; }
.knots-text { font-size: 1.12rem; font-weight: 900; line-height: 1.25; }
.knots-text.pop { animation: knTxt .45s var(--ease-pop); }
@keyframes knTxt { from { transform: translateY(6px); opacity: 0; } }
.knots-hint { font-size: .78rem; font-weight: 700; color: var(--text-dim); }

/* overlay cards */
.knots-overlay { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; padding: calc(var(--safe-t) + 60px) 16px calc(var(--safe-b) + 16px); background: rgba(5, 9, 20, .45); }
.knots-card { width: min(100%, 640px); display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; padding: 20px; border-radius: var(--radius-lg);
  background: rgba(16, 24, 42, .9); border: 1px solid var(--glass-border); box-shadow: var(--shadow); animation: knIn .45s var(--ease-pop) both; }
.knots-card-sm { grid-template-columns: 1fr; width: min(100%, 420px); text-align: center; }
@keyframes knIn { from { transform: scale(.9) translateY(20px); opacity: 0; } }
.knots-preview { aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: repeating-linear-gradient(180deg, #4a5b78 0 40px, #22304a 40px 43px); box-shadow: inset 0 0 30px rgba(0,0,0,.5); }
.knots-preview svg { width: 100%; height: 100%; display: block; animation: knSpin 6s ease-in-out infinite alternate; }
@keyframes knSpin { from { transform: rotate(-2deg) scale(.96); } to { transform: rotate(2deg) scale(1.02); } }
.knots-card-txt { display: flex; flex-direction: column; gap: 10px; }
.knots-card h2 { font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 900; line-height: 1.05; background: linear-gradient(180deg, #fffaf0, #ffd38a 55%, #ff9b4a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(90,40,20,.6)); }
.knots-card p { font-weight: 700; color: rgba(240,244,255,.85); }
.knots-kicker { font-size: .75rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); }

/* juice */
.knots-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.knots-float { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 1.05rem; white-space: nowrap; text-shadow: 0 2px 0 rgba(0,0,0,.45); animation: knFloat 1s ease-out both; }
.knots-float-good { color: var(--good); font-size: 1.3rem; }
.knots-float-cross { color: #fff6d8; font-size: .95rem; }
.knots-float-bad { color: #ff8f9b; }
.knots-float-big { font-size: 2.6rem; color: #ffd25e; text-shadow: 0 4px 0 #7a4a32, 0 8px 18px rgba(0,0,0,.4); animation-duration: 1.4s; }
@keyframes knFloat { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
.knots-spark { position: absolute; width: 9px; height: 9px; border-radius: 3px; animation: knSpark .75s ease-out both; }
@keyframes knSpark { from { transform: translate(-50%, -50%); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(200deg) scale(.3); opacity: 0; } }

@media (max-width: 640px) {
  .knots-root { gap: 6px; }
  .knots-name { font-size: 1rem; }
  .knots-stat { padding: 4px 9px; }
  .knots-ico { width: 34px; height: 34px; }
  .knots-text { font-size: 1rem; }
  .knots-card { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .knots-preview { max-height: 34vh; justify-self: stretch; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .knots-root { display: grid; grid-template-columns: 1fr minmax(200px, 32%); grid-template-rows: auto 1fr; padding-top: calc(var(--safe-t) + 6px); }
  .knots-top { grid-column: 1 / -1; }
  .knots-board { grid-row: 2; }
  .knots-instr { grid-row: 2; align-self: end; }
  .knots-card { grid-template-columns: 1fr 1fr; padding: 14px; }
  .knots-overlay { padding-top: 16px; }
}
