:root {
  color-scheme: dark;
  --bg: #070b1b;
  --panel: #0c1228;
  --text: #eeeefa;
  --muted: #a4abc9;
  --mint: #c8bcf4;
  --gold: #f2d8ad;
  --line: #323957;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  color: var(--text);
  font:
    13px "PingFang SC",
    "Microsoft Yahei",
    system-ui,
    sans-serif;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  border: 0;
  background: none;
}
button:hover {
  color: white;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}
button[hidden],
[hidden] {
  display: none !important;
}
button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app {
  height: 100dvh;
  max-width: 1800px;
  margin: auto;
  padding: 0 20px;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #ffffff0c;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 20px;
  letter-spacing: 4px;
  flex-shrink: 0;
}
.brand svg {
  width: 31px;
  height: 31px;
  color: var(--mint);
}
.brand small {
  display: block;
  color: #99b5a0;
  font-size: 7px;
  letter-spacing: 2px;
  margin-top: 1px;
}
.header-tools {
  display: flex;
  align-items: center;
  gap: 18px;
}
nav {
  display: flex;
  align-items: center;
  gap: 18px;
}
.text-button {
  font-size: 11px;
  color: #bfd1be;
  display: flex;
  gap: 6px;
  align-items: center;
}
.circle {
  border: 1px solid #668272;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  font-size: 9px;
  display: inline-grid;
  place-items: center;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid #354b3c;
  border-radius: 50%;
  color: #b4c9b3;
}
.choose-level {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #4b6143;
  background: #212a49;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 11px;
  color: #d3e1c5;
}
.choose-level strong {
  font-family: Georgia, serif;
  font-weight: 400;
  color: #dbd1f1;
}
.progress-mini {
  font-size: 9px;
  color: #819e88;
  white-space: nowrap;
}
main {
  min-height: 0;
  padding: 10px 0 5px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 27px;
}
.game {
  border: 1px solid #3a523d;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  display: grid;
  min-height: 0;
}
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  border-bottom: 1px solid #ffffff08;
  background: #11182f;
}
.stage {
  display: flex;
  gap: 13px;
  align-items: center;
}
.stage > span {
  font:
    italic 29px Georgia,
    serif;
  color: #b0c7a5;
  opacity: 0.8;
  line-height: 1;
}
.stage h2 {
  font-weight: 500;
  margin: 0 0 5px;
}
.stage p {
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.5px;
}
.stats {
  display: flex;
  gap: 21px;
  align-items: center;
}
.target-stat {
  display: flex;
  gap: 13px;
  align-items: center;
}
.target-stat > span,
.stat-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.target-stat strong {
  font:
    23px Georgia,
    serif;
  color: #dce5cc;
}
.target-stat b {
  font-weight: 400;
}
.target-stat small {
  font-size: 14px;
  color: #91a78d;
}
.stat-divider {
  width: 1px;
  height: 25px;
  background: #35405e;
}
.shots {
  display: flex;
  gap: 8px;
  margin-top: 7px;
}
.shots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 7px #d8b66d44;
}
.shots i.spent {
  background: #33483a;
  box-shadow: none;
}
.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  contain: layout paint;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.board-caption {
  position: absolute;
  top: 12px;
  left: 21px;
  font-size: 10px;
  color: #95b49b;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.5px;
}
.tiny-spark {
  font-size: 17px;
  color: #bed5ac;
}
.coordinates {
  position: absolute;
  bottom: 13px;
  right: 21px;
  font-size: 9px;
  color: #77947c;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.coordinates > span:first-child {
  font: 10px monospace;
  color: #a8bda3;
}
.game-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid #ffffff09;
  background: #11182f;
  gap: 14px;
}
#status {
  font-size: 10px;
  color: #c0d1bc;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-light {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint);
  flex-shrink: 0;
}
.game-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.game-actions button {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #b4c7ae;
  white-space: nowrap;
}
.game-actions button svg {
  width: 15px;
  height: 15px;
}
.game-actions kbd {
  font: 9px system-ui;
  border: 1px solid #476047;
  padding: 1px 4px;
  border-radius: 3px;
  color: #89a088;
}
.below {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px;
}
.legend {
  display: flex;
  gap: 18px;
  font-size: 9px;
  color: #93ac98;
}
.legend > span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-source {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}
.legend-emitter {
  font-style: normal;
  color: var(--mint);
  font-size: 16px;
  line-height: 0.5;
}
.legend-target {
  width: 6px;
  height: 6px;
  border: 1px solid #a1b99e;
  transform: rotate(45deg);
}
.legend-mirror {
  width: 13px;
  height: 3px;
  border-radius: 2px;
  background: #c9f1ec;
  transform: rotate(-30deg);
}
.micro-note {
  font-size: 9px;
  color: #7f9b86;
}
.primary {
  padding: 11px 21px;
  border-radius: 6px;
  font-size: 12px;
  min-width: 175px;
  display: inline-flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
.primary:hover {
  background: #eee7fc;
}
.result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #080e23ed;
  animation: appear 0.45s;
}
.result-inner {
  text-align: center;
  padding: 25px;
  max-width: 90%;
}
.result-flower {
  font-size: 40px;
  color: var(--gold);
  margin-bottom: 10px;
}
.result-inner > span {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--mint);
}
.result h2 {
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 1px;
  margin: 15px 0 10px;
}
.result p {
  font-size: 11px;
  color: #aec4ad;
  line-height: 1.8;
  margin-bottom: 22px;
}
.result-replay {
  display: block;
  font-size: 10px;
  color: #afc3ac;
  margin: 13px auto 0;
}
.result.is-win {
  inset: auto 18px 18px auto;
  width: 250px;
  border: 1px solid #6a89634d;
  border-radius: 10px;
  background: #10152bed;
  place-items: stretch;
}
.result.is-win .result-inner {
  padding: 16px;
  max-width: none;
}
.result.is-win .result-flower {
  font-size: 20px;
  margin-bottom: 8px;
}
.result.is-win .result-inner > span {
  font-size: 7px;
  letter-spacing: 2px;
}
.result.is-win h2 {
  font-size: 17px;
  margin: 11px 0 8px;
}
.result.is-win p {
  font-size: 10px;
  margin: 0 0 12px;
}
.result.is-win .primary {
  padding: 9px 13px;
  font-size: 10px;
  min-width: 160px;
}
dialog {
  border: 1px solid #4c6650;
  border-radius: 13px;
  background: #131b35;
  color: var(--text);
  max-width: 480px;
  width: calc(100% - 30px);
  max-height: 90dvh;
  padding: 29px;
  overflow: auto;
}
dialog::backdrop {
  background: #050819df;
}
.eyebrow {
  font-size: 8px;
  letter-spacing: 2px;
  color: #9bb7a3;
}
dialog h2 {
  font-size: 25px;
  font-weight: 400;
  margin: 15px 0 24px;
}
dialog ol {
  padding-left: 20px;
}
dialog li {
  padding-left: 6px;
  color: #d5dfcb;
  margin-bottom: 18px;
  font-size: 12px;
}
dialog p {
  font-size: 11px;
  color: #a2b8a6;
  line-height: 1.9;
  margin: 7px 0;
}
dialog .primary {
  width: 100%;
  margin-top: 6px;
}
.close-help {
  position: absolute;
  right: 13px;
  top: 7px;
  font-size: 25px;
  color: #aec9ac;
}
#level-map {
  max-width: 820px;
  padding: 28px;
  width: calc(100% - 30px);
}
#level-map h2 {
  margin-bottom: 7px;
}
.map-note {
  margin: 0 0 20px;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 11px;
}
.level-card {
  border: 1px solid #36523f;
  border-radius: 8px;
  padding: 12px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background: #121831;
}
.level-card:hover:enabled {
  background: #272d50;
}
.level-card:disabled {
  opacity: 0.38;
}
.level-card.current {
  border-color: #c5d8b1;
  background: #242d50;
}
.level-card.complete {
  border-color: #769b72;
}
.level-card svg {
  width: 100%;
  height: 78px;
  max-width: 110px;
  opacity: 0.85;
}
.level-card-num {
  position: absolute;
  left: 9px;
  top: 8px;
  font:
    italic 12px Georgia,
    serif;
  color: #b7c9a8;
}
.level-card strong {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
  margin: 6px 0;
}
.level-card-badge {
  font-size: 8px;
  line-height: 1.8;
  color: #9db79e;
  white-space: nowrap;
}
@keyframes appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (max-width: 850px) {
  .progress-mini {
    display: none;
  }
  .app {
    padding: 0 12px;
  }
  .header-tools,
  nav {
    gap: 12px;
  }
  .stage p {
    max-width: 270px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

@media (max-height: 540px) and (min-width: 601px) {
  .app {
    grid-template-rows: 44px minmax(0, 1fr);
  }
  .game-top {
    padding: 5px 15px;
  }
  .stage p {
    font-size: 9px;
  }
  .brand svg {
    width: 26px;
    height: 26px;
  }
  .brand {
    font-size: 18px;
  }
  main {
    padding-top: 6px;
    grid-template-rows: minmax(0, 1fr) 22px;
  }
  .result.is-win {
    width: 220px;
  }
  .result.is-win .result-inner {
    padding: 11px;
  }
  .result.is-win .result-flower {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}
.mode-links a {
  text-decoration: none;
  font-size: 11px;
}
.game-actions {
  gap: 16px;
}
.share-dialog {
  max-width: 760px;
}
.share-dialog h2 {
  margin: 12px 0;
}
#share-preview {
  width: 100%;
  max-height: 53dvh;
  object-fit: contain;
  border: 1px solid #385341;
  background: #081713;
}
.share-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  margin-top: 12px;
}
.share-actions .primary {
  width: auto;
  margin: 0;
}
#share-url {
  display: block;
  margin-top: 16px;
  color: #8fae9c;
  font-size: 10px;
  overflow-wrap: anywhere;
}
.volume-control {
  display: flex;
  gap: 15px;
  align-items: center;
  font-size: 12px;
}
.volume-control input {
  accent-color: #b6d5b7;
  flex: 1;
}
@media (max-width: 850px) {
  .mode-links a {
    padding: 5px 8px;
    font-size: 10px;
  }
  .game-actions {
    gap: 12px;
  }
}

.game {
  grid-template-rows: 62px minmax(0, 1fr) 46px;
}
@media (max-height: 540px) and (min-width: 601px) {
  .game {
    grid-template-rows: 49px minmax(0, 1fr) 39px;
  }
}

body {
  font-size: 15px;
}
.stage h2 {
  font-size: 20px;
  letter-spacing: 1px;
}
.stage p {
  font-size: 13px;
}
.text-button,
.choose-level,
.game-actions button,
.mode-links a {
  font-size: 13px;
}
.choose-level strong,
.target-stat strong {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.choose-level strong {
  font-size: 15px;
}
.target-stat > span,
.stat-label,
.progress-mini,
.legend,
.micro-note {
  font-size: 12px;
}
.game-bottom #status,
.board-caption {
  font-size: 13px;
}
.coordinates,
.brand small {
  font-size: 10px;
}

.app {
  grid-template-columns: minmax(0, 1fr);
}
header,
main,
.game,
.stage,
.stage > div {
  min-width: 0;
}

@media (max-height: 540px) {
  .app {
    grid-template-rows: 45px minmax(0, 1fr);
  }
  main {
    padding: 4px 0;
    grid-template-rows: minmax(0, 1fr);
  }
  .below {
    display: none;
  }
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 48px minmax(0, 1fr) 42px;
    grid-template-areas: "top" "board" "bottom";
  }
  .game-top {
    grid-area: top;
  }
  .canvas-wrap {
    grid-area: board;
  }
  .game-bottom {
    grid-area: bottom;
    flex-direction: row;
    padding: 4px 12px;
  }
  .stage p,
  .progress-mini,
  .brand small {
    display: none;
  }
  .stage h2 {
    margin: 0;
    font-size: 17px;
  }
  .mode-links {
    display: none;
  }
  .game-actions button {
    font-size: 12px;
    min-height: 36px;
  }
}
#field {
  touch-action: none;
}
body {
  background:
    radial-gradient(ellipse at 20% 10%, #24234970, transparent 55%),
    radial-gradient(ellipse at 85% 80%, #25224c60, transparent 60%), #070b1b;
}
.game {
  border-color: #41456588;
  box-shadow: 0 16px 70px #00000038;
}
.canvas-wrap {
  background:
    radial-gradient(ellipse at 28% 32%, #39245135, transparent 50%),
    radial-gradient(ellipse at 74% 65%, #19335740, transparent 55%),
    radial-gradient(ellipse at center, #10192e, #070c1e 85%);
}
header {
  border-color: #ffffff0d;
}
.game-top,
.game-bottom {
  background: #10162bd0;
}
.brand {
  color: #e0d7f4;
}
.mode-links {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid #5e63833d;
  border-radius: 99px;
  background: #090e2077;
}
.mode-links a {
  border: 0;
  border-radius: 99px;
  padding: 8px 15px;
  white-space: nowrap;
  color: #a9abc8;
}
.mode-links a[aria-current="page"] {
  color: #f0e6ff;
  background: #35304c;
  box-shadow: inset 0 0 0 1px #c8b3ef33;
}
.primary {
  background: linear-gradient(120deg, #e5d8f4, #c4c7ee);
  color: #1d2039;
}
.legend,
.micro-note,
.stage p,
#status {
  color: #acb2ca;
}

@media (max-height: 540px) and (min-width: 601px) {
  .mode-links {
    display: flex;
    padding: 2px;
  }
  .mode-links a {
    padding: 5px 10px;
    font-size: 12px;
  }
}
#stage-number img {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 0 22px #ad7aff25;
}
.art-credit {
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.7;
}
.art-credit a {
  color: #d4b5ff;
}

.gift-finished .board-caption,
.gift-finished .coordinates {
  opacity: 0;
  pointer-events: none;
}
.mode-links .secret-link {
  color: #efc8d9;
}

/* One compact phone layout. Chapter, level and sound controls live in the map sheet. */
.primary:hover,
.primary:focus-visible {
  color: #1d2039;
}
#compact-title,
.mobile-result,
.mobile-stats {
  display: none;
}
.map-mode-slot:empty,
.map-settings:empty {
  display: none;
}
@media (max-width: 600px), (max-height: 500px) and (max-width: 1000px) {
  .app {
    padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right))
      env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
    grid-template-rows: 48px minmax(0, 1fr);
  }
  header {
    display: flex;
    gap: 8px;
    padding: 0 6px;
  }
  .brand {
    font-size: 17px;
    letter-spacing: 2px;
    gap: 6px;
  }
  .brand svg {
    width: 22px;
    height: 22px;
  }
  .brand small,
  header .mode-links,
  header nav,
  .progress-mini,
  #current-shape {
    display: none;
  }
  .header-tools {
    min-width: 0;
    gap: 0;
  }
  .choose-level {
    min-height: 44px;
    padding: 0 8px;
    gap: 8px;
    background: none;
    border-color: transparent;
  }
  #compact-title {
    display: inline;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }
  .choose-level strong {
    font-size: 12px;
    white-space: nowrap;
    color: var(--muted);
  }
  main {
    padding: 0 0 3px;
    grid-template-rows: minmax(0, 1fr);
  }
  .below,
  .game-top {
    display: none;
  }
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 48px;
    grid-template-areas: "board" "bottom";
    border-radius: 9px;
    position: relative;
  }
  .canvas-wrap {
    grid-area: board;
  }
  .game-bottom {
    grid-area: bottom;
    padding: 0 10px;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
  }
  #status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .mobile-stats {
    display: block;
  }
  .stats {
    gap: 9px;
    margin: 0;
  }
  .target-stat {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .target-stat > span {
    font-size: 10px;
    white-space: nowrap;
  }
  .target-stat strong {
    display: inline;
    margin: 0;
    font-size: 15px;
    white-space: nowrap;
  }
  .target-stat small {
    font-size: 11px;
  }
  .stat-divider,
  .stat-label {
    display: none;
  }
  .shots {
    gap: 5px;
  }
  .shots i {
    width: 5px;
    height: 5px;
  }
  .game-actions {
    gap: 3px;
    flex-shrink: 0;
  }
  .game-actions button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 0;
    border-radius: 10px;
  }
  .game-actions button span,
  .game-actions kbd {
    display: none;
  }
  .game-actions button svg {
    display: block;
    width: 20px;
    height: 20px;
  }
  .board-caption {
    top: 12px;
    left: 12px;
    right: 12px;
    font-size: 12px;
    line-height: 1.5;
    align-items: flex-start;
    white-space: pre-line;
    pointer-events: none;
  }
  .coordinates {
    bottom: 9px;
    right: 12px;
    font-size: 10px;
    pointer-events: none;
  }
  .coordinates > span:last-child {
    display: none;
  }
  #level-map {
    width: 100%;
    max-width: 600px;
    max-height: 85dvh;
    margin: auto auto 0;
    padding: 22px 16px max(20px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  #level-map h2 {
    font-size: 21px;
    margin: 8px 0;
  }
  .map-note {
    font-size: 12px;
  }
  .map-mode-slot .mode-links {
    display: flex;
    margin: 14px 0 10px;
    width: fit-content;
    flex-wrap: wrap;
    border-radius: 12px;
  }
  .map-mode-slot .mode-links a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 13px;
  }
  .map-settings nav {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-bottom: 12px;
  }
  .map-settings .text-button {
    font-size: 13px;
    min-height: 44px;
  }
  .map-settings .circle {
    display: inline-grid;
  }
  .icon-button {
    width: 44px;
    height: 44px;
  }
  .level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .level-card {
    min-width: 0;
    padding: 10px 5px;
  }
  .level-card svg {
    height: 56px;
  }
  .level-card strong {
    font-size: 12px;
    letter-spacing: 0;
  }
  .level-card-badge {
    font-size: 10px;
    white-space: normal;
    line-height: 1.5;
  }
  .mobile-result {
    display: contents;
  }
  .game-bottom.has-result .mobile-stats,
  .game-bottom.has-result #hint,
  .game-bottom.has-result #reset {
    display: none;
  }
  .game-bottom.has-result .mobile-result {
    display: block;
    flex: 1;
    min-width: 0;
  }
  .mobile-result .result {
    position: static;
    inset: auto;
    transform: none;
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    padding: 0;
    box-shadow: none;
    background: transparent;
    animation: none;
  }
  .mobile-result .result .result-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
  }
  .mobile-result .result .result-flower,
  .mobile-result #result-label,
  .mobile-result h2,
  .mobile-result #result-desc {
    display: none;
  }
  .mobile-result #next {
    flex: 1;
    margin: 0;
    padding: 8px;
    min-height: 44px;
    font-size: 14px;
  }
  .mobile-result #replay {
    margin: 0;
    padding: 8px;
    min-height: 44px;
    font-size: 12px;
  }
  .share-actions {
    gap: 12px;
  }
}
