/* Floe / Témpano: three penguins sliding on an ice floe. The frame (bar, tries, dialogs) comes from game.css.
   The floe keeps its own light colours in dark mode too: it is an object on the page, like a board on a table. */
.game.floe { --accent: #3d8bff; --ice-ink: #1f2038; }

/* ---------- the floe ---------- */
.fl-area { width: 100%; display: grid; justify-items: center; gap: 10px; }
.fl-floe { position: relative; width: min(100%, 470px, 64vh); padding: 3.4%; border-radius: 32px;
  background: linear-gradient(170deg, #ffffff 0%, #f1f7fb 60%, #e3eef6 100%);
  box-shadow: inset 0 -7px 0 #c6d9e8, inset 0 2px 0 #ffffff, 0 2px 0 rgba(31, 32, 56, .05), 0 28px 44px -30px rgba(16, 48, 92, .7); }
@media (min-width: 900px) { .fl-floe { width: min(100%, 520px, 70vh); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fl-floe { background: linear-gradient(170deg, #f1f6fa 0%, #e2ecf3 100%); } }
:root[data-theme="dark"] .fl-floe { background: linear-gradient(170deg, #f1f6fa 0%, #e2ecf3 100%); }
.fl-ice { position: relative; aspect-ratio: 1; border-radius: 22px; isolation: isolate;
  background:
    linear-gradient(to right, rgba(61, 139, 255, .13) 1.5px, transparent 1.5px) 0 0 / calc(100% / 7) calc(100% / 7),
    linear-gradient(to bottom, rgba(61, 139, 255, .13) 1.5px, transparent 1.5px) 0 0 / calc(100% / 7) calc(100% / 7),
    radial-gradient(130% 95% at 28% 12%, #f6fcff 0%, #dcedf8 52%, #c6e0f2 100%);
  box-shadow: inset 0 3px 12px rgba(36, 92, 148, .2), inset 0 0 0 1px rgba(36, 92, 148, .08);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/* with a penguin chosen, a swipe anywhere on the ice slides it, so the page shouldn't scroll under the finger */
.fl-ice.has-sel { touch-action: none; }
.fl-cracks, .fl-guides, #trails { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fl-cracks { z-index: 1; border-radius: 22px; }
.fl-cracks path { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#trails { z-index: 5; }
.fl-guides { z-index: 8; }
.fl-guides line { stroke: var(--c); stroke-width: 6; stroke-linecap: round; stroke-dasharray: .1 16; opacity: .75; animation: fl-march 1s linear infinite; }
@keyframes fl-march { to { stroke-dashoffset: -16.1; } }

/* every piece sits in its cell; pieces lower on the floe are drawn in front */
.fl-rock, .fl-spot, .fl-peng, .fl-ghost { position: absolute; left: calc(var(--x) * 100% / 7); top: calc(var(--y) * 100% / 7); width: calc(100% / 7); height: calc(100% / 7); }

.fl-rock { pointer-events: none; }
.fl-rock svg { position: absolute; left: 1%; top: -10%; width: 98%; height: 106%; overflow: visible; }
.fl-rock.flip svg { transform: scaleX(-1); }
.rb { fill: #7d8da2; } .rd { fill: #5f6f86; } .rc { fill: #f3f8fc; } .rs { fill: rgba(20, 48, 86, .2); }

.fl-spot { pointer-events: none; }
.fl-spot::before { content: ""; position: absolute; left: 9%; right: 9%; top: 42%; bottom: 5%; border-radius: 50%; border: 3.5px solid var(--c);
  background: color-mix(in srgb, var(--c) 28%, transparent); box-shadow: inset 0 2px 4px rgba(20, 48, 86, .12); transition: box-shadow .4s, border-width .3s; }
.fl-spot b { position: absolute; left: 50%; top: 69%; transform: translate(-50%, -50%); font: 800 clamp(.82rem, 3.5vw, 1.1rem)/1 var(--display); color: var(--ice-ink); }
.fl-spot.taken::before { border-width: 4.5px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent), 0 0 20px 2px var(--c); }
.fl-spot.ping::after { content: ""; position: absolute; left: 9%; right: 9%; top: 42%; bottom: 5%; border-radius: 50%; border: 3px solid var(--c); animation: fl-ping .7s ease-out forwards; }
@keyframes fl-ping { from { transform: scale(.9); opacity: 1; } to { transform: scale(2.1); opacity: 0; } }

/* ---------- penguins ---------- */
.fl-peng { border: 0; background: none; padding: 0; margin: 0; cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent; touch-action: none; border-radius: 14px; }
.fl-peng:focus-visible { outline: 3px solid var(--ice-ink); outline-offset: -1px; }
.fl-shadow { position: absolute; left: 17%; right: 17%; bottom: 2%; height: 17%; border-radius: 50%; background: rgba(20, 48, 86, .24); transition: background-color .25s, box-shadow .25s, transform .25s; }
.fl-body { position: absolute; left: 5%; width: 90%; bottom: 3%; height: 114%; transform-origin: 50% 92%; transition: transform .22s var(--spring); display: block; }
.fl-body svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pb { fill: #262a40; } .pw { fill: #fbfbf8; } .pe { fill: #1b1d2c; } .pk, .pf { fill: #ff9a1f; } .ps { fill: var(--c); }
.pn { font: 800 20px/1 var(--display); text-anchor: middle; fill: var(--ice-ink); }
.fl-eyes { transform-box: fill-box; transform-origin: center; animation: fl-idle 6s infinite; }
.fl-peng[data-k="1"] .fl-eyes { animation-delay: -2.1s; }
.fl-peng[data-k="2"] .fl-eyes { animation-delay: -4.3s; }
@keyframes fl-idle { 0%, 95%, 100% { transform: none; } 97% { transform: scaleY(.12); } }
.fl-peng.blink .fl-eyes { animation: fl-blink .32s; }
@keyframes fl-blink { 50% { transform: scaleY(.1); } }
.fl-peng:hover .fl-body { transform: translateY(-4%); }
.fl-peng.sel .fl-body { transform: translateY(-9%) scale(1.04); }
.fl-peng.sel .fl-shadow { background: color-mix(in srgb, var(--c) 45%, transparent); box-shadow: 0 0 0 3px var(--c); transform: scale(1.1); animation: fl-sel 1.3s ease-in-out infinite; }
@keyframes fl-sel { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 40%, transparent); } }
.fl-peng.home .fl-shadow { background: transparent; }
.fl-peng.hop .fl-body { animation: fl-hop .6s var(--ease-out); }
@keyframes fl-hop { 0% { transform: none; } 30% { transform: translateY(-30%) scale(.95, 1.06); } 58% { transform: translateY(0) scale(1.1, .88); } 78% { transform: scale(.97, 1.03); } 100% { transform: none; } }
.fl-peng.hop .fl-flip.l { animation: fl-flap-l .6s; transform-box: fill-box; transform-origin: 90% 10%; }
.fl-peng.hop .fl-flip.r { animation: fl-flap-r .6s; transform-box: fill-box; transform-origin: 10% 10%; }
@keyframes fl-flap-l { 30% { transform: rotate(38deg); } }
@keyframes fl-flap-r { 30% { transform: rotate(-38deg); } }

/* ---------- where the chosen penguin would stop ---------- */
.fl-ghost { border: 0; background: none; padding: 0; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; border-radius: 14px; color: var(--ice-ink); }
.fl-ghost:focus-visible { outline: 3px solid var(--ice-ink); outline-offset: -1px; }
.fl-ring { position: absolute; left: 11%; right: 11%; top: 40%; bottom: 6%; border-radius: 50%; border: 3px dashed var(--c); background: color-mix(in srgb, var(--c) 16%, rgba(255, 255, 255, .55)); animation: fl-ghost-in .28s var(--spring) both; }
.fl-arrow { position: absolute; left: 50%; top: 67%; width: 44%; aspect-ratio: 1; translate: -50% -50%; rotate: var(--r); display: grid; place-items: center; border-radius: 50%; background: var(--c); box-shadow: 0 3px 8px -3px rgba(16, 32, 64, .5), inset 0 -2px 0 rgba(0, 0, 0, .14); transition: scale .15s var(--spring); animation: fl-ghost-in .28s .05s var(--spring) both; }
.fl-arrow svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.fl-ghost:hover .fl-arrow, .fl-ghost:focus-visible .fl-arrow { scale: 1.14; }
.fl-ghost.spot .fl-ring { border-style: solid; border-width: 4px; box-shadow: 0 0 16px 1px var(--c); }
@keyframes fl-ghost-in { from { opacity: 0; scale: .4; } }

.fl-ice.won::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 3px color-mix(in srgb, #1d7a4c 65%, transparent); pointer-events: none; z-index: 70; }

/* ---------- moves ---------- */
.fl-hint { margin: 0; text-align: center; color: var(--muted); font-size: .96rem; }
.fl-moves { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; justify-content: space-between; min-height: 30px; }
.fl-pips { list-style: none; margin: 0; padding: 0; display: flex; gap: 5px; flex-wrap: wrap; }
.fl-pips li { width: 27px; height: 27px; border-radius: 9px; display: grid; place-items: center; position: relative; color: var(--ice-ink); }
.fl-pips li.free { border: 2px dashed var(--line); }
.fl-pips li.used { background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .16); }
.fl-pips li.sol { background: color-mix(in srgb, var(--c) 32%, var(--paper)); box-shadow: inset 0 0 0 2px var(--c); color: var(--ink); }
.fl-pips li.in { animation: fl-pip-in .38s var(--spring); }
@keyframes fl-pip-in { from { transform: scale(0) rotate(-30deg); } }
.fl-pip-n { position: absolute; left: 3px; top: 2px; font: 800 .6rem/1 var(--display); }
.fl-pip-a { width: 15px; height: 15px; display: grid; rotate: var(--r); margin: 3px 0 0 3px; }
.fl-pip-a svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.fl-count { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.fl-count.last { color: var(--danger); }
#restart { flex: 1; }
#restart.armed { border-color: var(--danger); color: var(--danger); animation: fl-armed .4s; }
@keyframes fl-armed { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- tries ---------- */
.fl-replay { margin: -4px 0 10px; color: var(--muted); font-size: .92rem; }
.fl-mvs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.fl-mv { width: 27px; height: 27px; border-radius: 8px; border: 0; padding: 0; background: var(--c); color: var(--ice-ink); display: grid; place-items: center; position: relative; font: inherit; flex: none; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14); }
button.fl-mv { cursor: pointer; transition: transform .15s var(--spring), box-shadow .15s; }
button.fl-mv:hover, button.fl-mv:focus-visible { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--ink); }
.tries li.new .fl-mv { animation: fl-pip-in .35s var(--spring) both; }
.fl-res { display: flex; align-items: center; gap: 8px; flex: none; }
.fl-heads { display: flex; gap: 3px; }
.fl-head { width: 21px; height: 21px; border-radius: 50%; border: 2px solid var(--line); font: 800 .7rem/17px var(--display); text-align: center; color: var(--muted); }
.fl-head.on { background: var(--c); border-color: var(--c); color: var(--ice-ink); }
.tries li.new .fl-head { animation: fl-pip-in .35s var(--spring) both; }
.tries li.new .fl-head:nth-child(2) { animation-delay: .11s; }
.tries li.new .fl-head:nth-child(3) { animation-delay: .22s; }
.fl-n { font: 800 1.1rem/1 var(--display); font-variant-numeric: tabular-nums; min-width: 2.4ch; text-align: right; }
.fl-n.full { color: var(--ok); }

/* ---------- results dialog ---------- */
.res-floe { background: var(--wall); border-radius: 20px; padding: 14px 16px; display: grid; gap: 10px; }
.res-floe p { margin: 0; font-weight: 700; }
.fl-sol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- help demos ---------- */
.dm-ice { position: relative; width: 70px; height: 46px; border-radius: 12px; background: linear-gradient(160deg, #f4fbff, #cfe5f4); box-shadow: inset 0 0 0 2px #ffffff, 0 2px 0 #c6d9e8; }
.dm-pg { position: absolute; bottom: 9px; width: 15px; height: 20px; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%; background: #262a40; }
.dm-pg::before { content: ""; position: absolute; left: 3px; right: 3px; top: 7px; bottom: 2px; border-radius: 50%; background: #fbfbf8; }
.dm-pg::after { content: ""; position: absolute; left: 1px; right: 1px; top: 8px; height: 3px; border-radius: 2px; background: var(--c); }
.dm-rk { position: absolute; bottom: 8px; width: 16px; height: 14px; border-radius: 48% 52% 40% 40%; background: #7d8da2; box-shadow: inset 0 4px 0 #f3f8fc; }
.hstep-0 .dm-pg { left: 6px; --c: #ffc531; animation: dm-glide 3s cubic-bezier(.3, .05, .25, 1) infinite; }
.hstep-0 .dm-rk { right: 5px; }
@keyframes dm-glide { 0%, 18% { transform: none; } 48%, 82% { transform: translateX(32px); } 84% { transform: translateX(32px) scale(.85, 1.1); } 100% { transform: none; } }
.hstep-1 .dm-pg.a { left: 6px; --c: #ffc531; animation: dm-stop 3s cubic-bezier(.3, .05, .25, 1) infinite; }
.hstep-1 .dm-pg.b { right: 10px; --c: #ff5d4f; animation: dm-bonk 3s infinite; }
@keyframes dm-stop { 0%, 18% { transform: none; } 46%, 84% { transform: translateX(24px); } 100% { transform: none; } }
@keyframes dm-bonk { 0%, 45% { transform: none; } 50% { transform: translateX(3px) rotate(8deg); } 58%, 100% { transform: none; } }
.dm-spots { display: flex; gap: 4px; }
.dm-spot { position: relative; width: 22px; height: 34px; }
.dm-spot::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; border-radius: 50%; border: 2.5px solid var(--c); background: color-mix(in srgb, var(--c) 28%, transparent); }
.dm-spot .dm-pg { left: 3.5px; bottom: 4px; animation: dm-home 3.6s var(--spring) infinite both; }
.dm-spot:nth-child(2) .dm-pg { animation-delay: .3s; }
.dm-spot:nth-child(3) .dm-pg { animation-delay: .6s; }
@keyframes dm-home { 0%, 8% { opacity: 0; transform: translateY(-14px); } 22%, 86% { opacity: 1; transform: none; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .fl-guides line, .fl-eyes, .fl-peng.sel .fl-shadow { animation: none; }
  .fl-ring, .fl-arrow { animation: none; }
  .hstep-0 .dm-pg, .hstep-1 .dm-pg.a, .hstep-1 .dm-pg.b, .dm-spot .dm-pg { animation: none; }
  .hstep-0 .dm-pg { transform: translateX(32px); }
  .hstep-1 .dm-pg.a { transform: translateX(24px); }
}
