@font-face {
  font-family: Frost Pixel;
  src: url("frost-pixel.ttf") format("truetype");
  font-display: swap;
}
:root {
  color-scheme: dark;
  --cream: #fff1d8;
  --gold: #f4d18a;
  --mint: #a7ddc0;
  --ink: #172034;
  --pixel: "Frost Pixel","Lucida Console",monospace;
  --text: "Trebuchet MS",system-ui,sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  display: grid;
  place-items: center;
  background: #171f34;
  background-image: radial-gradient(ellipse at center,#35475d 0%,#192236 62%);
  color: var(--cream);
  font: 1rem var(--text);
  overscroll-behavior: none;
}
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid #fae5a6; outline-offset: 3px; }
button:disabled { cursor: default; }
h1,h2,p { margin: 0; }
[hidden] { display: none !important; }
.sprite { display: block; width: 100%; height: 100%; image-rendering: pixelated; object-fit: contain; }
[data-icon] { display: inline-grid; place-items: center; flex: none; width: 1.2rem; height: 1.2rem; }
#stage {
  position: relative;
  isolation: isolate;
  height: 100%;
  height: 100dvh;
  width: min(100vw, max(31rem, 66dvh));
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background: #a2b6c9;
  box-shadow: 0 0 0 1px #718297,0 0 65px #1018299c;
}
#world { position: absolute; inset: 0; display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.hud {
  position: absolute; inset: max(.7rem, env(safe-area-inset-top)) .75rem auto;
  display: flex; justify-content: flex-end; align-items: flex-start;
  pointer-events: none;
}
.hud-right { display: flex; align-items: center; gap: .38rem; }
.score {
  min-height: 2.45rem; padding: 0 .48rem;
  display: flex; align-items: center; gap: .23rem;
  color: var(--cream); background: #24324bea;
  border: 2px solid #526680; box-shadow: 0 2px #23314999;
}
.score strong { font: .89rem var(--pixel); white-space: nowrap; }
.score [data-icon] { width: 1.1rem; height: 1.1rem; }
.tool {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
  padding: 0; border: 2px solid #65778e; border-radius: 3px;
  background: #25334c; box-shadow: inset 0 -3px #152436;
  pointer-events: auto;
}
.tool:hover { border-color: var(--gold); }
.tool [data-icon] { width: 1rem; height: 1rem; }
.location {
  position: absolute; top: 4.05rem; left: 50%; transform: translateX(-50%);
  pointer-events: none; color: var(--cream); background: #26354ce8;
  border: 2px solid #708098; box-shadow: 0 3px #23314965;
  padding: .42rem .65rem; font: .9rem/1.1 var(--pixel);
  text-align: center; white-space: nowrap;
}
.location:empty { display: none; }
.game-controls {
  position: absolute; bottom: max(1.4rem, calc(.6rem + env(safe-area-inset-bottom)));
  inset-inline: 1.25rem; display: flex; justify-content: space-between;
  align-items: flex-end; pointer-events: none;
}
.stick {
  position: relative; width: clamp(6rem, 26vw, 7.15rem); aspect-ratio: 1;
  flex: none; pointer-events: auto; touch-action: none;
  border: 2px solid #d4e3eb9c; border-radius: 50%;
  background: #27364d7e; box-shadow: inset 0 0 0 5px #17294144, 0 3px 0 #293a5180;
}
.stick-thumb {
  position: absolute; top: 50%; left: 50%;
  width: 50%; height: 50%; transform: translate(-50%,-50%);
  background: #d6e6e6c9; border: 2px solid #eef4efda; border-radius: 50%;
  box-shadow: inset 0 -5px #6f8da5a8,0 3px #1e314f9c;
  pointer-events: none;
}
.tick { position: absolute; background: #dbe7e7ad; pointer-events: none; }
.tick-up,.tick-down { left: calc(50% - 1px); width: 2px; height: 5px; }
.tick-up { top: 8px; }.tick-down { bottom: 8px; }
.tick-right,.tick-left { top: calc(50% - 1px); height: 2px; width: 5px; }
.tick-right { right: 8px; }.tick-left { left: 8px; }
#walk-tip {
  position: absolute; bottom: .3rem; left: 50%; transform: translateX(-50%);
  font-size: .82rem; background: #29374de8; padding: .27rem .47rem; white-space: nowrap;
}
.interact {
  display: grid; justify-items: center; gap: .23rem;
  min-width: 4.5rem; min-height: 4.7rem; padding: .3rem .4rem;
  background: #293951e8; border: 2px solid #c3b083; border-radius: 5px;
  box-shadow: inset 0 -4px #17273b,0 3px #293a5180;
  color: var(--gold); pointer-events: auto;
  font: .84rem/1 var(--pixel); text-transform: uppercase;
}
.interact b {
  display: grid; place-items: center; width: 2.35rem; height: 2.35rem;
  border: 2px solid #eac88a; border-radius: 50%; background: #bd9c6e;
  box-shadow: inset 0 -4px #a37c55;
  color: #22293b; font: 1.4rem var(--pixel);
}
.interact:hover { background: #48536a; }
noscript { position: absolute; background: #26354c; padding: 1rem; }

dialog {
  width: min(100% - 1.5rem, 26rem);
  max-height: calc(100% - 1.5rem);
  max-height: calc(100dvh - 1.5rem);
  padding: .25rem; border: 2px solid #d3b588; border-radius: 3px;
  background: #694f52; color: var(--cream); box-shadow: 0 6px #172033,0 15px 50px #111926ce;
}
dialog::backdrop { background: #11192bb7; }
body:has(.is-indoors) dialog::backdrop { background: #18162679; }
.dialog-inner { position: relative; background: #28354a; border: 2px solid #826962; padding: 1.4rem 1.1rem 1.2rem; }
.close { position: absolute; top: .42rem; right: .42rem; }
.dialog-kicker { color: var(--gold); font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin: 0 3rem .6rem 0; }
#dialog-title { color: var(--cream); font: 1.66rem/1.12 var(--pixel); text-transform: uppercase; overflow-wrap: anywhere; }
.dialog-copy { color: #f0e4d4; line-height: 1.48; margin-top: .72rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem; margin-top: .85rem; }
.dialog-actions .primary { flex: 1; }
.primary,.secondary {
  min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .48rem .9rem; border-radius: 2px; font-weight: 800;
}
.primary { color: #292832; background: #ebc886; border: 2px solid #f9db9e; box-shadow: inset 0 -4px #bf925f; }
.primary:hover { background: #f7dda9; }
.secondary { color: var(--cream); background: #34485f; border: 2px solid #788797; box-shadow: inset 0 -3px #24364e; }
.secondary:hover { background: #425772; }
.puzzle-board { display: grid; grid-template-columns: repeat(var(--columns,3),minmax(0,1fr)); gap: .47rem; width: min(100%, 15.5rem); margin: 1rem auto .68rem; }
.cell {
  display: grid; place-items: center; aspect-ratio: 1; padding: 0; min-height: 2.75rem; min-width: 0;
  border: 2px solid #697c93; border-radius: 2px; background: #354963;
  box-shadow: 0 3px #1b273a,inset 0 -4px #29394e; font: 1.68rem var(--pixel);
}
.cell:hover { border-color: var(--mint); }
.cell:active { transform: translateY(1px); }
.cell > .sprite { width: 52%; height: 52%; }
.cell.light-off > .sprite { filter: saturate(.35) brightness(.53); opacity: .76; }
.cell.light-on { background: #654d45; border-color: #c8966a; }
.cell.light-on > .sprite { filter: drop-shadow(0 0 8px #eab06294); }
.cell.card-hidden { background: #35486c; }
.cell.card-hidden > .sprite { opacity: .48; }
.cell.card-match { border-color: #86b69e; background: #34555b; }
.cell.empty { background: #1c293d; border-style: dashed; box-shadow: none; }
.cell.slide-ready { color: #f7db9d; }
.puzzle-board.pattern { --columns: 2; width: min(100%, 11.5rem); }
.cell.pattern-tile { background: var(--tile-bg); border-color: var(--tile-border); }
.cell.pattern-tile.glow { background: var(--tile-border); border-color: #fff4d6; box-shadow: 0 0 14px var(--tile-border); }
.cell.pattern-tile:disabled { opacity: 1; }
.puzzle-board.ice {
  width: min(100%, 15.1rem);
  gap: 2px;
  border: 3px solid #8cb1c5;
  background: #3f607c;
  padding: 2px;
}
.ice-tile {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #6e9fbb;
  box-shadow: inset 1px 1px #acc9d8, inset -1px -1px #618ca9;
}
.ice-tile:nth-child(3n) { background: #7ba8c1; }
.ice-tile.snowbank {
  background: #becfdc;
  box-shadow: inset 3px 3px #e4edf2, inset -3px -3px #89a5bd;
}
.ice-tile.ice-goal { background: #53778f; box-shadow: inset 0 0 0 2px #d8b573; }
.ice-tile.ice-player { background: #b0d4dd; }
.ice-tile .sprite { width: 70%; height: 70%; }
.ice-controls { display: flex; justify-content: center; gap: .34rem; }
.ice-arrow { min-width: 2.75rem; padding-inline: .2rem; font-size: 1.35rem; }
.hinted, .cell.hinted:hover { border-color: #ffdf8d; box-shadow: 0 0 0 2px #efbc70, inset 0 -3px #24364e; }
.dialog-actions .secondary:disabled { opacity: .55; }
.puzzle-status { text-align: center; min-height: 2.5em; line-height: 1.3; display: grid; place-items: center; color: var(--gold); font-size: .96rem; }
.dialog-art { width: 3.25rem; height: 3.25rem; margin: .9rem auto .1rem; }
.win-stars { display: flex; justify-content: center; align-items: center; gap: .45rem; margin: .95rem 0; }
.win-stars .sprite { width: 1.75rem; height: 1.75rem; }
.win-stars .sprite:nth-child(2) { width: 3.2rem; height: 3.2rem; }
.help-list { display: grid; gap: .65rem; color: #f0e4d4; line-height: 1.45; padding-left: 1.3rem; margin: .9rem 0 1rem; }
@media (min-width: 560px) { .game-controls { inset-inline: 1.6rem; } }
@media (max-width: 365px) { .hud { inset-inline: .5rem; } .game-controls { inset-inline: .85rem; } .score strong { font-size: .8rem; } }
