/* The panel paints the scene and the stage stays see-through; the script sets --sf-horizon to the foot of the wall. */
.game-root[data-game="snug-fit"] {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #dcecf4 0, #e8f3f6 var(--sf-horizon, 60%), #f1e6d0 calc(var(--sf-horizon, 60%) + 14px), #efe2c8 100%);
}
.sf { container-type: inline-size; position: relative; display: flex; flex-direction: column; gap: 10px; width: 100%; }
.sf-hud { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sf-rule { margin: 0; padding: 3px 12px; border-radius: 999px; background: #f6ecd8; color: #7a5a2e; font-size: .9rem; font-weight: 700; text-align: center; }
.sf-trail { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.sf-dot { width: 12px; height: 12px; border-radius: 3px; background: rgba(60, 90, 110, .18); transition: background .3s; }
.sf-dot.is-hit { background: #7cc58a; }
.sf-dot.is-miss { background: #c9ccd8; }
.sf-dot.is-now { background: #fff; box-shadow: inset 0 0 0 2px #7cc58a; }
/* min-height: 0, or the aspect-ratio box grows by the stage's rounding and the fit loops. */
.sf-fit { display: grid; place-items: center; width: 100%; max-width: 520px; min-height: 0; margin: 0 auto; aspect-ratio: 560 / 720; }
.sf-stage { position: relative; }
.sf-world { position: absolute; left: 0; top: 0; width: 560px; height: 720px; transform-origin: 0 0; }
.sf-world > * { position: absolute; }
.sf-snd { position: absolute; top: 8px; right: 8px; z-index: 3; display: grid; place-items: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 2px 6px rgba(60, 80, 100, .15); color: #7a5a2e; font-size: 19px; line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sf-snd[hidden] { display: none; }
.sf-snd.is-off { color: #a9a39a; }
.sf-snd.is-off::after { content: ""; position: absolute; width: 22px; height: 2px; border-radius: 1px; background: #a9a39a; transform: rotate(-45deg); }
.sf-walls, .sf-tray, .sf-pieces, .sf-fx { inset: 0; }
.sf-pieces, .sf-fx { pointer-events: none; }
.sf-clock { left: 0; top: 0; width: 0; height: 0; }

.sf-wall { position: absolute; overflow: hidden; border-radius: 10px; background: #b8976a; box-shadow: 0 6px 0 rgba(96, 70, 38, .22); }
/* The cells here are the script's C (46px): stones sit 2px inside theirs, holes fill theirs. */
.sf-stone, .sf-hole { position: absolute; }
.sf-stone { width: 42px; height: 42px; margin: 2px; border-radius: 6px; background: var(--tone); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4), inset 0 -3px 0 rgba(120, 88, 50, .22); }
.sf-hole { width: 46px; height: 46px; background: #4d3d30; transition: background .2s; }
.sf-hole.is-top { box-shadow: inset 0 9px 7px -6px rgba(0, 0, 0, .55); }
.sf-hole.is-bare { animation: sf-bare .55s ease-in-out 2; }
@keyframes sf-bare { 50% { background: #8a6f58; } }
.sf-shine { position: absolute; top: 0; bottom: 0; left: 0; width: 80px; background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .6), rgba(255, 255, 255, 0)); transform: translateX(-120px); pointer-events: none; }

.sf-slot { position: absolute; margin: 0; padding: 0; border: 0; border-radius: 18px; background: #fffdf7; box-shadow: 0 4px 0 #e2d4b8, 0 8px 16px rgba(120, 96, 50, .1); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: opacity .25s, transform .12s; }
.sf-slot:disabled { cursor: default; }
.sf-slot:not(:disabled):active { transform: translateY(2px); }
@media (hover: hover) {
  .sf-slot:not(:disabled):hover { transform: translateY(-2px); }
}
.sf-slot.is-out { opacity: .45; }
.sf-halo { position: absolute; inset: -7px; border: 3px solid #5fb870; border-radius: 22px; pointer-events: none; animation: sf-breathe 1.6s ease-in-out infinite; }
@keyframes sf-breathe { 0%, 100% { transform: scale(.97); opacity: .3; } 50% { transform: scale(1.03); opacity: .95; } }

.sf-holder { position: absolute; left: 0; top: 0; transition: opacity .25s; }
.sf-holder.is-out { opacity: .4; }
.sf-piece { position: absolute; inset: 0; filter: drop-shadow(0 4px 0 rgba(60, 40, 20, .16)); }
.sf-wall .sf-piece { filter: none; }
/* 44px plus a 1px margin each side fills the script's 46px cell. */
.sf-cell { position: absolute; width: 44px; height: 44px; margin: 1px; border-radius: 7px; background: var(--pc); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .42), inset 0 -4px 0 rgba(0, 0, 0, .16); transition: background .15s; }
.sf-cell.is-set { animation: sf-set .5s ease-out; }
@keyframes sf-set { 0% { filter: brightness(1.7); } 100% { filter: brightness(1); } }
.sf-cell.is-out { background: repeating-linear-gradient(135deg, #e5574b 0 7px, #c9463c 7px 14px); }
.sf-puff { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #f3e8d2; }

.sf-foot { display: grid; justify-items: center; }
.sf-cap { min-height: 1.5em; margin: 0; font-weight: 700; color: var(--c-text); text-align: center; }
@container (max-width: 480px) {
  .sf-cap { min-height: 3em; }
}
.sf-go { background: #3fae5a; color: #fff; box-shadow: var(--shadow); }
.sf-go:hover { background: #36994e; }
.sf-end { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 12px; background: rgba(34, 52, 72, .22); }
.sf-end:empty { display: none; }
.sf-end .result-card { width: min(100%, 340px); padding: 18px 20px 20px; border-radius: 20px; background: #fff; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); animation: sf-pop .34s cubic-bezier(.3, 1.4, .5, 1); }
.sf-end .result-card .result-done { font-size: 1.8rem; margin: 0 0 6px; }
.sf-end .result-card .btn { margin-top: 12px; }
@keyframes sf-pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

html.fills-window .game-root[data-game="snug-fit"] .sf { height: 100%; }
html.fills-window .game-root[data-game="snug-fit"] .sf-fit { flex: 1 1 0; max-width: none; aspect-ratio: auto; }
html.fills-window .game-root[data-game="snug-fit"] .sf-hud,
html.fills-window .game-root[data-game="snug-fit"] .sf-foot { flex: none; }
