@font-face {
  font-family: Rubik;
  src: url("assets/Rubik.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: Rubik, system-ui, sans-serif;
  color: #f5f0df;
  background: #03121c;
  --cream: #f5f0df;
  --muted: #b5cfcc;
  --gold: #ffcc76;
  --gold-soft: #f7ae55;
  --panel: #0b242d;
  --jade: #77d5b2;
  --jade-dark: #226b62;
}

* { box-sizing: border-box; }

body {
  display: grid;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  place-items: center;
  background: radial-gradient(ellipse at center, #163741, #03121c 73%);
}

button { font: inherit; color: inherit; }

button:enabled { cursor: pointer; }

button:focus-visible {
  outline: 2px solid #fff0b3;
  outline-offset: 3px;
  z-index: 2;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.game-shell {
  position: relative;
  isolation: isolate;
  width: min(100%, 460px);
  height: clamp(560px, 100vh, 995px);
  height: clamp(560px, 100dvh, 995px);
  overflow: hidden;
  background: #0a2935;
  box-shadow: 0 0 76px #01080bcf;
}

.scene {
  position: absolute;
  inset: 0;
  container-type: size;
  isolation: isolate;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  user-select: none;
  -webkit-user-select: none;
}

.map-scene {
  background-image: linear-gradient(180deg, #00132188, transparent 33%, transparent 75%, #03131c 100%),
    url("../Design/LanternIslands/mist-islands-world-map.webp");
}

.map-scene[data-chapter="lagoon"] {
  background-image: linear-gradient(180deg, #00132188, transparent 33%, transparent 75%, #03131c 100%),
    url("../Design/LanternIslands/lagoon-world-map.webp");
}

.map-scene[data-chapter="shore"] {
  background-image: linear-gradient(180deg, #00132188, transparent 33%, transparent 75%, #03131c 100%),
    url("../Design/LanternIslands/far-shore-world-map.webp");
}

.map-scene[data-chapter="caves"] {
  background-image: linear-gradient(180deg, #06101b88, transparent 33%, transparent 75%, #03131c 100%),
    url("../Design/LanternIslands/tidal-caves-map.webp");
}

.pier-flight {
  position: absolute;
  z-index: 6;
  inset: 0;
  overflow: hidden;
  background: #0a2935;
  animation: pier-flight-reveal 135ms ease-out both;
}

.pier-flight-camera {
  animation: pier-flight-approach var(--flight-time) cubic-bezier(.35, 0, .23, 1) both;
}

.pier-flight-route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
}

.pier-flight-trail {
  stroke: #ffd58e;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  filter: drop-shadow(0 0 4px #ffbd64);
}

.pier-flight-spark {
  position: absolute;
  z-index: 2;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #fff7d4;
  box-shadow: 0 0 8px 3px #ffc774, 0 0 19px 8px #ff9a3e86;
  transform: translate(-50%, -50%) rotate(45deg);
  animation: pier-flight-spark var(--flight-time) linear both;
}

.pier-flight .map-node.is-current {
  animation: map-crossing-pin 340ms 400ms ease-out both;
}

.pier-flight .map-node { z-index: 3; }

@keyframes pier-flight-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pier-flight-approach {
  from { transform: scale(1); }
  to { transform: scale(1.16); }
}

@keyframes pier-flight-spark {
  0%, 8%, 100% { opacity: 0; }
  16%, 84% { opacity: 1; }
}

.map-scene.is-crossing::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(148deg, #102b3e3d, transparent 55%);
  pointer-events: none;
  animation: map-crossing-veil 560ms ease-out both;
}

@keyframes map-crossing-veil {
  from { opacity: 1; }
  to { opacity: 0; }
}

.map-header {
  position: absolute;
  z-index: 2;
  top: max(24px, env(safe-area-inset-top));
  left: 6.2%;
  right: 6.2%;
  text-shadow: 0 3px 14px #04101d;
  pointer-events: none;
}

.map-header h1 {
  margin: 0;
  color: var(--cream);
  font-size: clamp(37px, 11cqw, 57px);
  font-weight: 670;
  letter-spacing: -.045em;
  line-height: .97;
}

#offline-status {
  position: absolute;
  top: 0;
  right: 0;
  max-width: 45%;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid #799d93a8;
  border-radius: 9px;
  background: #0b2634ec;
  color: #deeee5;
  font-size: .69rem;
  line-height: 1.2;
  text-align: center;
}

.map-region {
  margin: .62rem 0 0;
  color: #c7dbd6;
  font-size: .95rem;
  font-weight: 480;
}

.chapter-switch {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 100%;
  margin-top: 13px;
  padding: 3px;
  border: 1px solid #9cc2af60;
  border-radius: 15px;
  background: #0b2634e8;
  box-shadow: inset 0 1px #e0f4d626, 0 3px 10px #00152288;
  pointer-events: auto;
}

.chapter-tab {
  min-height: 44px;
  padding: 6px clamp(8px, 3cqw, 14px);
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #c8e0d9;
  font-size: .84rem;
  font-weight: 550;
  line-height: 1.1;
}

.chapter-tab[aria-pressed="true"] {
  border-color: #dfc48d;
  background: linear-gradient(#634f35, #383c33);
  color: #fff1c7;
  box-shadow: inset 0 1px #f7db9d30;
}

.chapter-tab:disabled { color: #a9bfbb; }

.chapter-switch:has(#chapter-shore:not([hidden])) .chapter-tab {
  padding-inline: clamp(6px, 1.8cqw, 12px);
  font-size: .76rem;
}

.chapter-switch:has(#chapter-caves:not([hidden])) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 196px);
}

#map-route,
#map-nodes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#map-route {
  color: #efc285;
  overflow: visible;
  filter: drop-shadow(0 2px 3px #051722);
}

.route-open {
  stroke: #f6bd70bb;
  stroke-width: 2px;
  stroke-dasharray: 3px 6px;
  stroke-linecap: round;
}

.route-closed {
  stroke: #9dccc880;
  stroke-width: 1.5px;
  stroke-dasharray: 2px 6px;
  stroke-linecap: round;
}

.route-ferry {
  stroke: #ffdc91;
  stroke-width: 4px;
  stroke-dasharray: 1px 10px;
  filter: drop-shadow(0 0 3px #ffc46a);
}

.map-scene.is-crossing .route-open { animation: map-crossing-route 850ms ease-out both; }

@keyframes map-crossing-route {
  0%, 100% { stroke: #f6bd70bb; }
  35% { stroke: #ffe1a3; }
}

.map-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  width: 48px;
  min-height: 48px;
  padding: 5px 4px 3px;
  place-items: center;
  border: 1px solid #789e9959;
  border-radius: 50%;
  background: linear-gradient(#19353dec, #0b222ce8);
  box-shadow: inset 0 1px #afddd119, 0 4px 9px #04121caf;
  color: #d8e6e3;
  font-size: .95rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 3px #09151a;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.map-node::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin-bottom: 1px;
  border: 1px solid currentColor;
  border-radius: 1px 4px 1px 4px;
  transform: rotate(45deg);
  opacity: .65;
}

.map-node.is-lit {
  border-color: #f7b86eaf;
  background: linear-gradient(#694727ed, #2e2c28ed);
  color: #fff1c8;
  box-shadow: inset 0 1px #ffd39c60, 0 0 24px #f9ab4e6b, 0 4px 9px #04121caa;
}

.map-node.is-lit::before {
  border-color: #fff2c0;
  background: #ffd079;
  opacity: 1;
  box-shadow: 0 0 11px #ffb45c;
}

.map-node.is-lighthouse::before {
  width: 18px;
  height: 17px;
  border: 0;
  border-radius: 0;
  background: currentColor;
  clip-path: polygon(50% 0, 80% 28%, 68% 28%, 68% 48%, 62% 48%, 76% 100%,
    24% 100%, 38% 48%, 32% 48%, 32% 28%, 20% 28%);
  transform: none;
}

.map-node.is-lighthouse.is-lit::before { background: #ffd079; }

.map-node.has-star-goal::after {
  content: "☆";
  position: absolute;
  top: -4px;
  right: -5px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid #bb985e;
  border-radius: 50%;
  background: #102b36;
  color: #ffe0a6;
  font-size: 14px;
  text-shadow: none;
  pointer-events: none;
}

.map-node.is-starred::after {
  content: "★";
  border-color: #ffe0a6;
  background: #ffce7d;
  color: #452a12;
  box-shadow: 0 0 8px #ffc267a1;
}

.map-node.is-current {
  width: 52px;
  min-height: 52px;
  border: 2px solid #ffe1a3;
  box-shadow: 0 0 0 4px #ffd39127, 0 0 24px #ffd3886a, 0 5px 14px #011017cc;
  color: #fff1c8;
  z-index: 1;
}

.map-scene.is-crossing .map-node.is-current {
  animation: map-crossing-pin 860ms 120ms ease-out both;
}

@keyframes map-crossing-pin {
  0%, 100% { box-shadow: 0 0 0 4px #ffd39127, 0 0 24px #ffd3886a, 0 5px 14px #011017cc; }
  46% { box-shadow: 0 0 0 7px #ffd3913d, 0 0 28px #ffd388aa, 0 5px 14px #011017cc; }
}

.map-node:disabled { opacity: .71; }

.map-node:enabled:active { transform: translate(-50%, -50%) scale(.95); }

.map-footer {
  position: absolute;
  z-index: 2;
  left: 6.2%;
  right: 6.2%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  display: grid;
  gap: 9px;
  justify-items: stretch;
  text-align: center;
  color: #d7e3df;
  font-size: .9rem;
  text-shadow: 0 1px 5px #000;
}

.map-footer p { margin: 0; }

.map-footer #map-attempt {
  color: #ffe4aa;
  font-size: .82rem;
  font-weight: 520;
  line-height: 1.16;
}

.primary,
.secondary {
  min-height: 46px;
  padding: .75rem 1rem;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: .94rem;
  font-weight: 650;
  line-height: 1.2;
  text-shadow: none;
  transition: filter 140ms ease, transform 140ms ease;
}

.primary {
  border-color: #ffe5a9;
  background: linear-gradient(#ffe19c, #eeb362 83%);
  color: #2b211a;
  box-shadow: inset 0 1px #fff9dc, 0 4px 0 #9b693b, 0 6px 17px #061721bb;
}

.secondary {
  border-color: #5f898b;
  background: linear-gradient(#21414a, #142e38);
  color: var(--cream);
  box-shadow: inset 0 1px #cae5d823, 0 3px 0 #081c26;
}

.primary:active,
.secondary:active { transform: translateY(2px); }

.play-scene {
  background-image: linear-gradient(180deg, #0415214a, transparent 29%, transparent 75%, #03162180),
    url("../Design/LanternIslands/fog-pier-11.webp");
}

.play-scene[data-chapter="lagoon"] {
  background-image: linear-gradient(180deg, #0415214a, transparent 29%, transparent 75%, #03162180),
    url("../Design/LanternIslands/lagoon-background.webp");
}

.play-scene[data-chapter="caves"] {
  background-image: linear-gradient(180deg, #080d23a8, #0919293d 46%, #0611219c),
    url("../Design/LanternIslands/tidal-caves-map.webp");
  background-size: cover;
  background-position: center;
}

.play-header {
  position: absolute;
  z-index: 3;
  top: max(15px, env(safe-area-inset-top));
  left: 5%;
  right: 5%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  text-shadow: 0 2px 8px #031723;
}

.play-header h2 {
  margin: 0;
  color: #fff4d9;
  font-size: clamp(21px, 6.2cqw, 31px);
  font-weight: 660;
  letter-spacing: -.035em;
  line-height: 1.07;
}

.play-header .region {
  margin: 0;
  color: #deede3;
  line-height: 1.12;
}

.level-name {
  display: block;
  margin: 5px 0 0;
  color: #c7ded7;
  font-size: clamp(12px, 3.7cqw, 16px);
  font-weight: 520;
  line-height: 1.15;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid #9cc2af91;
  border-radius: 50%;
  background: #0b2634c9;
  color: #fbefcf;
  box-shadow: inset 0 1px #e0f4d635, 0 3px 10px #00152288;
}

.icon-button svg { width: 19px; height: 19px; }

.score {
  position: absolute;
  z-index: 2;
  top: max(73px, 12%);
  right: 6.2%;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #a0c5b45e;
  border-radius: 100px;
  background: #0a2936d9;
  color: #fff0cc;
  box-shadow: 0 2px 9px #0310196b;
  font-size: clamp(15px, 5cqw, 23px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.score::before {
  content: "";
  width: 11px;
  height: 15px;
  background: conic-gradient(from 45deg, #ffcf71 0 25%, #e99439 0 50%, #ffc45d 0 75%, #fff0ad 0);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.lantern {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 78%;
  width: clamp(26px, 9cqw, 43px);
  height: clamp(45px, 9cqh, 85px);
  transform: translateX(-50%);
  border: 2px solid #b4a67a;
  border-radius: 26% 26% 18% 18% / 21% 21% 13% 13%;
  background: linear-gradient(90deg, #0b252e, #245250 46%, #6d7255 50%, #164044 54%, #0a202a);
  box-shadow: inset 0 0 0 2px #15333b, 0 0 0 3px #15282b, 0 4px 0 3px #092332;
  pointer-events: none;
}

.lantern::before,
.lantern::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
}

.lantern::before {
  bottom: 88%;
  width: 149%;
  height: 39%;
  background: linear-gradient(120deg, #bcaa78, #716b50 53%, #a0966f 55%, #5e5947);
  clip-path: polygon(50% 0, 84% 40%, 100% 92%, 92% 100%, 8% 100%, 0 92%, 16% 40%);
}

.lantern::after {
  top: 94%;
  width: 144%;
  height: 13%;
  border: 1px solid #9a9b74;
  border-radius: 18% / 52%;
  background: linear-gradient(#707957, #273f42);
  box-shadow: 0 4px 0 #142d35;
}

.lantern-flame {
  position: absolute;
  inset: 18% 7% 9%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff4b6 4%, #ffc35c 29%, #ff9c3988 58%, transparent 77%);
  opacity: var(--charge, 0);
  filter: blur(2px);
  transition: opacity 320ms ease;
}

.lantern.is-lit .lantern-flame {
  opacity: 1;
  box-shadow: 0 0 20px 11px #ffb85d77, 0 4px 45px 14px #ffad526b;
}

.lantern-pips {
  position: absolute;
  z-index: 3;
  inset: auto 6% 10%;
  display: flex;
  justify-content: center;
  gap: 2px;
}

.lantern-pips i {
  width: 4px;
  height: 4px;
  border-radius: 100%;
  background: #87937a;
}

.lantern-pips i.is-lit,
.lantern-pips i.lit,
.lantern.is-lit .lantern-pips i { background: #ffdaa0; }

.board {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 23.4%;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  width: min(calc(100cqw - 30px), 38.1cqh);
  aspect-ratio: 1;
  padding: clamp(6px, 2.1cqw, 10px);
  gap: clamp(2px, .78cqw, 4px);
  border: 1px solid #a7c5a2b0;
  border-radius: clamp(12px, 4cqw, 20px);
  background: linear-gradient(155deg, #133b40, #09252f 62%, #14353b);
  box-shadow: inset 0 0 0 3px #36575a, inset 0 0 0 5px #071d26, 0 5px 0 #1b3c40,
    0 8px 0 #0a252d, 0 11px 20px #011019be;
  transform: translateX(-50%);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 1px solid #49757a9e;
  border-radius: 19%;
  background: linear-gradient(160deg, #23515a, #163a45);
  box-shadow: inset 0 1px 2px #041d2560;
  touch-action: none;
}

.glass,
.piece-shape i {
  border-color: #95e3c5;
  background: linear-gradient(148deg, #81dcbc 0%, #57b79c 34%, #2c847b 72%, #226a63 100%);
  box-shadow: inset 0 1px 0 #c4f5d9c9, inset 0 -2px 0 #0d4d4c93, inset 1px 0 #a6eac064,
    0 2px 1px #09272bda;
}

.cell.stone {
  border-color: #a3adb4;
  background:
    linear-gradient(132deg, transparent 49%, #36434b 50%, #bdc3bf8c 52%, transparent 54%),
    linear-gradient(22deg, transparent 57%, #35444a99 58%, transparent 61%),
    linear-gradient(145deg, #969fa3, #68777b 40%, #48555e 80%, #343f4a);
  border-radius: 16% 22% 15% 20%;
  box-shadow: inset 0 1px 0 #d6dfd6a9, inset 0 -2px 0 #152a34ab, 0 2px 1px #05242ad9;
}

.cell.gate {
  border-color: #d5b780;
  background: #173943;
}

.cell.gate::before,
.moving-gate::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px solid #d9bc83;
  border-radius: 12%;
  background: repeating-linear-gradient(90deg, transparent 0 17%, #d9bc83 17% 26%);
  box-shadow: 0 2px 3px #071a23;
}

.moving-gate {
  position: absolute;
  translate: -50% -50%;
}

.cell.gate.will-open,
.cell.gate-slot.will-block {
  outline: 2px solid #ffd892;
  outline-offset: -2px;
}

.cell.gate-slot::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px dashed #d9bc83;
  border-radius: 12%;
}

.cell.gate-slot.will-block::before {
  border-style: solid;
  background: repeating-linear-gradient(90deg, transparent 0 17%, #d9bc8390 17% 26%);
}

.gate-circle::after,
.gate-diamond::after {
  content: "";
  position: absolute;
  top: 7%;
  right: 7%;
  z-index: 1;
  width: 20%;
  height: 20%;
  min-width: 6px;
  min-height: 6px;
  border: 1px solid #172b39;
  background: #85e8fa;
  border-radius: 50%;
  pointer-events: none;
}

.gate-diamond::after {
  border-radius: 1px;
  background: #e5b5f8;
  transform: rotate(45deg) scale(.86);
}

.cell.open-gate { border: 1px dashed #d9bc83; }

.spark,
.flying-spark {
  display: block;
  width: 38%;
  height: 52%;
  background: conic-gradient(from 45deg, #ffcf71 0 25%, #e99439 0 50%, #ffc45d 0 75%, #fff0ad 0);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  pointer-events: none;
}

.cell.has-spark {
  border-color: #a987568f;
  background: radial-gradient(ellipse, #8c713d80, #3d5249 48%, #1f4750 78%);
  filter: drop-shadow(0 0 3px #ffc36946);
}

.cell:not(.has-spark) .spark { display: none; }

.cell.is-escape-origin {
  border-color: #a6eeff;
  box-shadow: inset 0 0 0 1px #a6eeff, 0 0 9px #76d6f18c;
}

.cell.star-spark {
  box-shadow: inset 0 0 0 2px #ffdc91, 0 0 10px #ffc97870;
}

.cell:is(.tee-space, .star-point):not(.preview, .invalid)::before,
.cell.will-free-tee::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px dashed #ffdc91;
  border-radius: inherit;
  pointer-events: none;
}

.cell.will-free-tee::before {
  border-style: solid;
  box-shadow: inset 0 0 7px #ffd38b8c;
}

.cell.tutorial-target:not(.preview):not(.invalid):not(.glass):not(.stone) {
  border: 2px dashed #ffdc91;
  background: radial-gradient(ellipse, #8b74454f, #2b5354);
  box-shadow: inset 0 0 0 2px #f8ce6b22, 0 0 9px #ffcc7755;
}

.cell.tutorial-target:not(.is-retry-target):not(.preview):not(.invalid):not(.glass):not(.stone) {
  animation: tutorial-target 1300ms ease-in-out 3 alternate;
}

.cell.tutorial-target.is-retry-target.glass {
  border: 2px dashed #ffdc91;
  box-shadow: inset 0 0 0 2px #f8ce6b22, 0 0 9px #ffcc7755;
  animation: none;
}

.cell.preview {
  border: 2px solid #bdf5c4;
  background: linear-gradient(148deg, #589b889c, #36766f92);
  box-shadow: inset 0 0 0 2px #92d6ba25, 0 0 6px #bcfad76d;
}

.cell.invalid {
  border: 2px dashed #ffe0c1;
  box-shadow: inset 0 0 0 999px #a7453f69;
}

.cell.will-close {
  border-color: #ffdd9b;
  box-shadow: inset 0 0 0 2px #fbbf7380, inset 0 0 15px #ffb64f62, 0 0 12px #ffc97880;
}

.cell.will-break::after {
  position: absolute;
  inset: 2px;
  border: 2px dashed #ffda91;
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.cell.placed { animation: settle-cell 180ms ease both; }
.cell.shatter { animation: fade-tile 290ms ease-out both; }

.cell.piece-space:not(.preview, .invalid)::before,
.cell.piece-space.will-cover-space::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px dashed #ffdc91;
  border-radius: inherit;
  pointer-events: none;
}

.cell:is(.will-cover-space, .piece-space-blocked)::before {
  border-color: #ffccae;
  background:
    linear-gradient(45deg, transparent 46%, #ffccae 46% 54%, transparent 54%) center / 12px 12px no-repeat,
    linear-gradient(-45deg, transparent 46%, #ffccae 46% 54%, transparent 54%) center / 12px 12px no-repeat;
}

.cell:is(.contour-side, .contour-corner):not(.preview, .invalid)::before {
  content: "";
  position: absolute;
  pointer-events: none;
}

.cell.contour-side::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #b1ebed;
}

.cell.contour-corner::before {
  width: 8px;
  height: 8px;
  border-left: 2px solid #ffd392;
  border-bottom: 2px solid #ffd392;
  border-radius: 0 0 0 2px;
}

.cell.shared-wall.glass:not(.invalid)::before {
  content: "";
  position: absolute;
  inset: 21% 30%;
  border-inline: 2px solid #ffe4a8;
  border-radius: 2px;
  pointer-events: none;
}

.cell.cleared-glass:not(.preview):not(.invalid)::before {
  content: "";
  position: absolute;
  bottom: 17%;
  left: 17%;
  width: 25%;
  height: 25%;
  border-left: 2px solid #ffd392;
  border-bottom: 2px solid #ffd392;
  border-radius: 0 0 0 3px;
  pointer-events: none;
}

.cell.roof-gap:not(.preview, .invalid)::before,
.cell:is(.roof-block, .surviving-glass, .will-survive)::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  pointer-events: none;
}

.cell.roof-gap::before { border: 1px dashed #ffdc91; }

.cell:is(.roof-block, .surviving-glass, .will-survive)::before {
  border: 2px solid #ffe5a5;
  box-shadow: inset 0 0 5px #ffd38b8c;
}

@keyframes settle-cell {
  0% { transform: translateY(-4px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes fade-tile {
  0%, 20% { filter: brightness(1.43); }
  100% { filter: brightness(.88); }
}

@keyframes tutorial-target {
  from { box-shadow: inset 0 0 0 2px #f8ce6b22, 0 0 7px #ffcc773e; }
  to { box-shadow: inset 0 0 0 2px #f8ce6b49, 0 0 12px #ffcc7785; }
}

.hint {
  position: absolute;
  z-index: 2;
  top: 64.2%;
  left: 6%;
  right: 6%;
  margin: 0;
  text-align: center;
  color: #e4eee4;
  font-size: clamp(12px, 3.7cqw, 15px);
  font-weight: 530;
  line-height: 1.32;
  text-shadow: 0 1px 2px #001019, 0 1px 7px #001019, 0 1px 10px #001019;
}

.hint.is-invalid { color: #ffe0c1; }
.capture-forecast { color: #ffedc2; }
.capture-forecast:not([hidden]) + .hint { visibility: hidden; }

.shelf {
  position: absolute;
  z-index: 2;
  top: 71%;
  left: 50%;
  display: flex;
  width: 88%;
  min-height: 75px;
  align-items: stretch;
  justify-content: center;
  gap: clamp(4px, 2.1cqw, 10px);
  padding: clamp(6px, 2.1cqw, 10px);
  border: 1px solid #b5a77f;
  border-radius: 16px;
  background: repeating-linear-gradient(178deg, #f5dd9830 0 1px, transparent 1px 14px),
    linear-gradient(120deg, #64674e, #464b3d 62%, #3c5147);
  box-shadow: inset 0 1px #ded3a7ac, inset 0 -2px #ae9c7955, 0 6px 0 #263d39,
    0 9px 0 #152e30, 0 14px 16px #011218a0;
  transform: translateX(-50%);
}

.piece {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  padding: 6px 1px;
  border: 1px solid #929774;
  border-radius: 11px;
  background: #1a3739b3;
  box-shadow: inset 0 2px 4px #0b292cb8;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.piece.active {
  flex-grow: 1.3;
  border-color: #c6d3a7;
  background: radial-gradient(ellipse, #305a4b, #1d3938 78%);
  box-shadow: inset 0 1px 4px #b4d69b54;
}

.piece.active[aria-pressed="true"] {
  border-color: #ffe3a7;
  box-shadow: inset 0 0 0 1px #ffe3a771, inset 0 1px 4px #b4d69b54, 0 0 9px #ffc97d3d;
}

.piece.pending { opacity: .76; }
.piece.active:active { filter: brightness(1.12); }
.piece.is-dragging .piece-shape { opacity: .23; }

.piece-shape {
  --unit: min(4.7cqw, 20px);
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), var(--unit));
  grid-template-rows: repeat(var(--rows, 1), var(--unit));
  gap: 2px;
  width: max-content;
  pointer-events: none;
}

.piece.active .piece-shape { --unit: min(5.4cqw, 23px); }

.piece-shape i {
  display: block;
  min-width: 0;
  min-height: 0;
  border-width: 1px;
  border-style: solid;
  border-radius: 20%;
}

.drag-figure {
  position: fixed;
  z-index: 9;
  pointer-events: none;
  filter: drop-shadow(0 6px 9px #03131dbb);
}

.drag-figure .piece-shape {
  --unit: var(--drag-cell, 34px);
  gap: var(--drag-gap, 3px);
}

.drag-figure.is-forecasting .piece-shape { opacity: .32; }

.game-fx {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}

.capture-effect { position: absolute; inset: 0; }

.game-fx .glass-echo {
  position: absolute;
  border: 1px solid #95e3c5;
  border-radius: 19%;
  translate: -50% -50%;
}

.game-fx .flying-spark,
.game-fx .shard {
  position: absolute;
  display: block;
  pointer-events: none;
}

.game-fx .flying-spark {
  width: 14px;
  height: 19px;
  filter: drop-shadow(0 0 5px #ffd080);
}

.game-fx .shard {
  width: 5px;
  height: 7px;
  border-radius: 1px;
  background: #9de8c3;
  box-shadow: 0 0 4px #8bd1a99e;
}

.game-fx .contour-stroke { color: #ffce79; }

.game-fx .contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: #ffce79;
  pointer-events: none;
}

.escape-route {
  position: absolute;
  z-index: 3;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  fill: none;
  stroke: #a6eeff;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px #072432);
  pointer-events: none;
}

.escape-trace { stroke-width: 2.5; stroke-dasharray: 5 6; }
.escape-diagonal { stroke: #e0fbff; stroke-width: 3.5; }
.escape-end { stroke-width: 2; }

.star-goal,
.escape-switch {
  position: absolute;
  z-index: 3;
  bottom: 79%;
  left: 6.2%;
}

.star-goal {
  margin: 0;
  padding: 5px 8px;
  border: 1px solid #b1925f;
  border-radius: 10px;
  background: #0a2936e8;
  color: #ffe4ae;
  font-size: .75rem;
  font-weight: 620;
}

.escape-switch {
  display: grid;
  min-width: 94px;
  min-height: 44px;
  place-content: center;
  gap: 1px;
  padding: 4px 8px;
  border: 1px solid #83c0ce;
  border-radius: 11px;
  font-size: .73rem;
  font-weight: 590;
  line-height: 1.12;
}

#escape-count { color: #a6eeff; }

.show-escape {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 44px;
  padding: 6px 15px;
  translate: -50%;
  border-color: #75a9b6;
  border-radius: 100px;
  background: #0a2936e8;
  font-size: .83rem;
  -webkit-tap-highlight-color: transparent;
}

.show-escape[aria-pressed="true"] {
  border-color: #a6eeff;
  color: #d8f9ff;
  background: #174352;
  box-shadow: 0 0 14px #73d9ff44;
}

.result {
  position: absolute;
  z-index: 4;
  top: 64.2%;
  left: 5.5%;
  right: 5.5%;
  display: grid;
  gap: 5px;
  padding: clamp(11px, 4cqw, 18px);
  border: 1px solid #789c8b;
  border-radius: 17px;
  background: linear-gradient(153deg, #1f4246fc, #0b2631fc 82%);
  box-shadow: inset 0 1px #e0eec137, 0 10px 24px #00121bcf;
  animation: show-panel 250ms ease-out both;
}

.result .eyebrow {
  color: #ffd68e;
  font-size: .75rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.result h3 {
  margin: 0;
  color: #fff0d0;
  font-size: clamp(21px, 6cqw, 27px);
  font-weight: 650;
  letter-spacing: -.04em;
  line-height: 1.1;
}

.result p {
  margin: 0;
  color: #cee0da;
  font-size: .88rem;
  line-height: 1.32;
}

.blocked-piece {
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid #789c8b78;
  border-radius: 8px;
  background: #0a2632;
  color: #e4eee4;
  font-size: .8rem;
}

.blocked-piece .piece-shape { --unit: 11px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.actions button { flex: 1 1 auto; }

.actions.has-three-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.12fr) minmax(0, .9fr);
  gap: 6px;
}

.actions.trial-actions {
  grid-template-columns: minmax(0, 1.16fr) minmax(0, .85fr) minmax(0, 1.07fr);
}

.result .actions.has-three-actions button {
  min-width: 0;
  padding: 5px 4px;
  font-size: clamp(.83rem, 3.7cqw, .94rem);
}

.pause-dialog {
  width: min(calc(100% - 32px), 358px);
  padding: 23px;
  border: 1px solid #8cae9b;
  border-radius: 19px;
  background: linear-gradient(155deg, #204245, #0c2530 82%);
  box-shadow: inset 0 1px #cbddaa51, 0 15px 52px #00121bcb;
  color: var(--cream);
}

.pause-dialog::backdrop { background: #03121bbd; }

.pause-dialog h2 {
  margin: 0 0 15px;
  color: #fff0d0;
  font-size: 1.5rem;
  letter-spacing: -.04em;
}

.pause-dialog .actions { flex-direction: column; }

@keyframes show-panel {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 350px), (max-height: 660px) {
  .map-footer { bottom: max(17px, env(safe-area-inset-bottom)); }
  .chapter-switch { margin-top: 9px; }
  .map-node { width: 44px; min-height: 44px; }
  .map-node.is-current { width: 48px; min-height: 48px; }
  .shelf { min-height: 66px; }
  .piece { min-height: 52px; }
  .result { gap: 4px; padding: 9px 11px; }
  .result p { font-size: .8rem; }
  .result .actions button { padding-inline: .65rem; font-size: .83rem; }
}

@media (max-height: 660px) {
  .map-scene[data-chapter="mist"] .chapter-switch:has(#chapter-shore:not([hidden])):has(#chapter-caves[hidden]) {
    display: grid;
    grid-template-columns: max-content max-content;
  }

  .map-scene[data-chapter="mist"] .chapter-switch:has(#chapter-caves[hidden]) #chapter-shore {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-scene.is-crossing::before,
  .map-scene.is-crossing .route-open,
  .map-scene.is-crossing .map-node.is-current { animation: none; }

  .map-scene.is-crossing::before { opacity: 0; }

  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
