:root {
  color-scheme: light;
  --bg: #fbf5e9;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #294139;
  --muted: #76867f;
  --line: rgba(54, 78, 67, .12);
  --shadow: 0 18px 50px rgba(58, 72, 61, .13);
  --green: #65b86c;
  --yellow: #f2c95c;
  --red: #ed806f;
  --blue: #6eb6dc;
  --accent: #477d58;
  --cell-gap: clamp(4px, 1.4vw, 9px);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { min-width: 320px; color: var(--ink); overscroll-behavior: none; touch-action: manipulation; }
body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}
@media (min-width: 960px) {
  body {
    display: grid;
    place-items: center;
    padding: 20px;
    background:
      linear-gradient(rgba(245,239,223,.08), rgba(242,231,207,.08)),
      url("../assets/art/desktop-background.png?v=1.3.1") center / cover no-repeat fixed,
      linear-gradient(180deg, #f5efdf 0%, #f2e7cf 100%);
  }
  body::before {
    background:
      radial-gradient(circle at 6% 50%, rgba(255,255,255,.20) 0 16%, transparent 17%),
      radial-gradient(circle at 93% 42%, rgba(255,255,255,.16) 0 15%, transparent 16%),
      radial-gradient(circle at 22% 18%, rgba(101,184,108,.15) 0 10%, transparent 11%),
      radial-gradient(circle at 76% 83%, rgba(110,182,220,.14) 0 11%, transparent 12%);
  }
  body::after {
    inset: auto 0 0;
    height: 35vh;
    background:
      radial-gradient(circle at 20% 30%, rgba(98,155,84,.18), transparent 28%),
      radial-gradient(circle at 76% 18%, rgba(102,163,88,.14), transparent 22%),
      linear-gradient(180deg, transparent 0%, rgba(120,165,101,.12) 28%, rgba(120,165,101,.18) 100%);
  }
  .app-shell {
    width: min(100%, 470px);
    height: min(calc(100dvh - 40px), 920px);
    min-height: 620px;
    border-radius: 36px;
    border: 1px solid rgba(87, 112, 91, .12);
    box-shadow: 0 38px 90px rgba(45, 57, 48, .2), 0 10px 18px rgba(255,255,255,.4) inset;
    overflow: hidden;
  }
}
html[data-embedded="true"] body {
  padding: 10px;
}
@media (min-width: 960px) {
  html[data-embedded="true"] body {
    padding: 10px;
  }
  html[data-embedded="true"] .app-shell {
    width: min(100%, 460px);
    height: min(calc(100dvh - 20px), 900px);
  }
}
button { font: inherit; color: inherit; }
button, [role="button"] { -webkit-user-select: none; user-select: none; }
button:focus-visible { outline: 3px solid rgba(71, 125, 88, .28); outline-offset: 3px; }
svg, img, canvas { display: block; }

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
  background:
    radial-gradient(circle at 11% 10%, rgba(242, 201, 92, .14), transparent 23%),
    radial-gradient(circle at 88% 78%, rgba(101, 184, 108, .12), transparent 29%),
    linear-gradient(180deg, #fffaf0 0%, var(--bg) 48%, #f9f2e5 100%);
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.screen.is-active { opacity: 1; transform: none; pointer-events: auto; }
.screen[hidden] { display: flex !important; visibility: hidden; }

.art-icon-button {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
}
.art-icon-button img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 8px rgba(52, 68, 59, .13)); }
.art-icon-button:active { transform: scale(.91); }
.close-button { width: 46px; height: 46px; }

.home-screen { justify-content: center; }
.home-settings { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 2; }
.home-stars {
  position: absolute;
  top: max(15px, env(safe-area-inset-top));
  left: max(17px, env(safe-area-inset-left));
  height: 42px;
  padding: 0 13px 0 7px;
  border-radius: 21px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 7px 20px rgba(63, 79, 68, .07);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.home-stars img { width: 34px; height: 34px; object-fit: contain; }
.home-content {
  width: min(100%, 410px);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.4vh, 21px);
  text-align: center;
}
.brand-mark {
  position: relative;
  width: clamp(205px, 58vw, 272px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin-inline: auto;
  margin-bottom: clamp(5px, 1vh, 10px);
}
.home-chameleon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
  animation: homeFloat 3.6s ease-in-out infinite;
  filter: drop-shadow(0 13px 16px rgba(47, 72, 57, .17));
}
@keyframes homeFloat {
  0%,100% { transform: translateY(1px); }
  50% { transform: translateY(-6px); }
}
.title-group { display: grid; gap: 3px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(41px, 12.5vw, 62px); line-height: .98; letter-spacing: -.055em; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.home-actions { width: min(100%, 310px); display: grid; gap: 9px; }
.primary-button, .secondary-button {
  height: 59px;
  border: 0;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-button { background: var(--accent); color: #fff; box-shadow: 0 13px 28px rgba(71,125,88,.24); }
.secondary-button { background: rgba(255,255,255,.84); color: var(--ink); box-shadow: 0 9px 24px rgba(58,72,61,.09); }
.primary-button:active, .secondary-button:active { transform: translateY(2px) scale(.985); }
.art-action img { width: 48px; height: 48px; object-fit: contain; margin-left: -13px; }
.art-action span { margin-right: 18px; }
.version-label { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); left: 0; right: 0; margin: 0; text-align: center; color: rgba(41,65,57,.34); font-size: 11px; }

.topbar { min-height: 56px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; flex: 0 0 auto; }
.topbar-title, .game-status { text-align: center; }
.topbar h2, .game-status h2 { margin: 0; font-size: 18px; line-height: 1.1; letter-spacing: -.02em; }
.topbar p, .game-status p { margin: 3px 0 0; color: var(--muted); font-size: 12px; font-weight: 650; }
.topbar-stars { display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.topbar-stars img { width: 20px; height: 20px; object-fit: contain; }
.topbar-spacer { width: 48px; }
.levels-screen { gap: 8px; }
.level-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 10px 3px calc(24px + env(safe-area-inset-bottom)); }
.level-scroll::-webkit-scrollbar { display: none; }
.level-grid { width: min(100%, 520px); margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: clamp(8px, 2.7vw, 14px); }
.level-button {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 20px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 8px 20px rgba(58,72,61,.08);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .14s ease, box-shadow .14s ease;
}
.level-button:active:not(:disabled) { transform: scale(.94); }
.level-button.current { box-shadow: 0 0 0 2px rgba(71,125,88,.28), 0 9px 22px rgba(58,72,61,.1); }
.level-number { font-size: clamp(16px, 5vw, 22px); font-weight: 850; transform: translateY(-3px); }
.level-stars { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; justify-content: center; gap: 0; }
.level-stars img { width: 15px; height: 15px; object-fit: contain; opacity: .16; filter: grayscale(1); }
.level-stars img.earned { opacity: 1; filter: none; }
.level-button.locked { background: rgba(232,229,218,.72); color: rgba(41,65,57,.33); box-shadow: none; }
.level-lock { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.game-screen { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
.game-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(5px, 1.3vh, 10px); }
.objective-strip { height: 29px; display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 750; }
.objective-fruit { width: 24px; height: 24px; object-fit: contain; }
.board-wrap { width: min(94vw, calc(100svh - 205px), 540px); min-width: 278px; max-width: 100%; padding: clamp(5px, 1.2vw, 8px); border-radius: clamp(22px, 6vw, 34px); background: rgba(255,255,255,.72); box-shadow: var(--shadow); }
.board { --size: 4; --gap: var(--cell-gap); --cell: calc((100% - (var(--size) - 1) * var(--gap)) / var(--size)); position: relative; display: grid; grid-template-columns: repeat(var(--size), 1fr); gap: var(--gap); width: 100%; aspect-ratio: 1; touch-action: none; }
.cell { position: relative; aspect-ratio: 1; border: 0; border-radius: clamp(10px, 3vw, 19px); overflow: hidden; background: var(--cell-color); box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 4px 9px rgba(48,64,54,.08); transition: background-color .22s ease, transform .18s ease, filter .18s ease; }
.cell::before { content: ""; position: absolute; inset: 0; opacity: .12; pointer-events: none; }
.cell[data-color="green"] { --cell-color: var(--green); }
.cell[data-color="green"]::before { background-image: radial-gradient(circle, rgba(30,80,42,.62) 1.1px, transparent 1.4px); background-size: 13px 13px; }
.cell[data-color="yellow"] { --cell-color: var(--yellow); }
.cell[data-color="yellow"]::before { background: repeating-linear-gradient(135deg, rgba(101,78,18,.58) 0 1.5px, transparent 1.5px 10px); }
.cell[data-color="red"] { --cell-color: var(--red); }
.cell[data-color="red"]::before { background-image: linear-gradient(90deg, transparent 46%, rgba(109,41,32,.52) 46% 54%, transparent 54%), linear-gradient(transparent 46%, rgba(109,41,32,.52) 46% 54%, transparent 54%); background-size: 18px 18px; }
.cell[data-color="blue"] { --cell-color: var(--blue); }
.cell[data-color="blue"]::before { background-image: radial-gradient(circle at center, transparent 4px, rgba(33,82,109,.55) 4.5px 5.5px, transparent 6px); background-size: 18px 18px; }
.cell.live::after { content: ""; position: absolute; inset: 22%; border: 2px solid rgba(255,255,255,.55); border-radius: 50% 15% 50% 15%; transform: rotate(45deg); animation: livePulse 2.4s ease-in-out infinite; z-index: 1; }
@keyframes livePulse { 0%,100% { opacity: .55; transform: rotate(45deg) scale(.88); } 50% { opacity: .95; transform: rotate(45deg) scale(1); } }
.cell.rock { background: #e3e1da; box-shadow: inset 0 1px 0 rgba(255,255,255,.58), 0 4px 9px rgba(48,64,54,.06); }
.cell.rock::before { display: none; }
.cell-asset { position: absolute; inset: 5%; width: 90%; height: 90%; object-fit: contain; pointer-events: none; z-index: 2; filter: drop-shadow(0 5px 4px rgba(40, 51, 45, .15)); }
.rock-asset { inset: 5%; width: 90%; height: 90%; }
.tree-asset { inset: -8%; width: 116%; height: 116%; transform-origin: 50% 90%; transition: transform .25s ease, filter .25s ease, opacity .16s ease; }
.cell.tree-ready .tree-asset { animation: treeWake 1.8s ease-in-out infinite; filter: saturate(1.08) drop-shadow(0 5px 4px rgba(40,51,45,.17)); }
@keyframes treeWake { 0%,100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg) scale(1.025); } }
.fruit-asset { inset: 15%; width: 70%; height: 70%; animation: fruitBob 1.8s ease-in-out infinite; transition: transform .22s ease, opacity .18s ease; }
@keyframes fruitBob { 0%,100% { transform: translateY(1px) rotate(-2deg); } 50% { transform: translateY(-4px) rotate(2deg); } }
.cell.fruit-collected .fruit-asset { animation: fruitCollect .25s ease forwards; }
@keyframes fruitCollect { to { transform: translateY(-20%) scale(1.45) rotate(12deg); opacity: 0; } }
.cell.invalid { animation: cellWobble .26s ease; }
@keyframes cellWobble { 0%,100% { transform: none; } 30% { transform: rotate(-3deg) scale(.98); } 65% { transform: rotate(3deg) scale(.98); } }
.cell.hint-target { animation: hintGlow .8s ease-in-out 2; z-index: 3; }
@keyframes hintGlow { 50% { transform: scale(.93); filter: brightness(1.13); box-shadow: 0 0 0 5px rgba(255,255,255,.8), 0 0 0 8px rgba(71,125,88,.2); } }

.effect-layer { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: visible; }
.board-effect { position: absolute; left: calc(var(--col) * (var(--cell) + var(--gap))); top: calc(var(--row) * (var(--cell) + var(--gap))); width: var(--cell); height: var(--cell); pointer-events: none; }
.effect-wave { width: 190%; height: 190%; object-fit: contain; transform: translate(-24%, -24%) scale(.35); opacity: 0; animation: waveBurst .42s ease-out forwards; filter: drop-shadow(0 0 6px rgba(255,255,255,.65)); }
@keyframes waveBurst { 35% { opacity: .95; } 100% { opacity: 0; transform: translate(-24%, -24%) scale(1.18) rotate(18deg); } }
.effect-cloud { z-index: 1; }
.effect-cloud img { width: 90%; height: 90%; object-fit: contain; transform: translate(5%, 18%) scale(.62); opacity: .9; animation: cloudPuff .38s ease-out forwards; }
@keyframes cloudPuff { to { transform: translate(5%, 34%) scale(1.08); opacity: 0; } }
.leaf-particle { position: absolute; z-index: 10; width: 28%; height: 28%; object-fit: contain; left: 36%; top: 34%; animation: leafFly .68s cubic-bezier(.15,.72,.2,1) forwards; animation-delay: var(--delay, 0ms); filter: drop-shadow(0 2px 2px rgba(44,72,50,.18)); }
@keyframes leafFly { to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.55); } }
.spark-dot { position: absolute; z-index: 11; left: 47%; top: 47%; width: var(--spark-size, 7px); height: var(--spark-size, 7px); border-radius: 50%; background: #fff7ac; box-shadow: 0 0 8px rgba(255,242,112,.95); animation: dotFly .48s ease-out forwards; animation-delay: var(--delay, 0ms); }
@keyframes dotFly { to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); } }

.chameleon-piece { --row: 0; --col: 0; --chameleon-inset: clamp(5px, 1.8vw, 8px); position: absolute; z-index: 8; left: calc(var(--col) * (var(--cell) + var(--gap)) + var(--chameleon-inset)); top: calc(var(--row) * (var(--cell) + var(--gap)) + var(--chameleon-inset)); width: calc(var(--cell) - var(--chameleon-inset) - var(--chameleon-inset)); height: calc(var(--cell) - var(--chameleon-inset) - var(--chameleon-inset)); padding: 0; border: 0; background: transparent; cursor: pointer; transition: left .22s cubic-bezier(.2,.8,.2,1), top .22s cubic-bezier(.2,.8,.2,1), filter .2s ease; touch-action: none; }
.chameleon-canvas { width: 112%; height: 112%; transform: translate(-6%, -9%); overflow: visible; pointer-events: none; filter: drop-shadow(0 7px 5px rgba(39,61,48,.19)); }
.chameleon-piece.jumping .chameleon-canvas { animation: chameleonJump .24s ease; }
@keyframes chameleonJump { 0% { transform: translate(-6%,-9%) scale(1); } 48% { transform: translate(-6%,-27%) scale(1.06,.95); } 100% { transform: translate(-6%,-9%) scale(1); } }
.chameleon-piece.color-shift { animation: colorBloom .3s ease; }
@keyframes colorBloom { 50% { transform: scale(1.08) rotate(2deg); filter: brightness(1.1); } }
.chameleon-piece.hint-color { animation: hintColor .7s ease-in-out 2; }
@keyframes hintColor { 50% { transform: scale(1.09); filter: drop-shadow(0 0 10px rgba(255,255,255,.9)); } }
.chameleon-piece.celebrating .chameleon-canvas { animation: celebrate .58s ease-in-out 2; }
@keyframes celebrate { 0%,100% { transform: translate(-6%,-9%) rotate(0); } 50% { transform: translate(-6%,-20%) rotate(-5deg) scale(1.08); } }

.tutorial-bubble { max-width: min(92vw, 430px); min-height: 38px; padding: 9px 15px; border-radius: 16px; background: rgba(255,255,255,.88); box-shadow: 0 8px 22px rgba(58,72,61,.1); color: var(--ink); font-size: 13px; font-weight: 700; text-align: center; }
.game-controls { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; gap: clamp(19px, 8vw, 40px); padding-top: 7px; }
.control-button { width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; cursor: pointer; transition: transform .14s ease, opacity .14s ease; }
.control-button:active:not(:disabled) { transform: scale(.9); }
.control-button:disabled { opacity: .34; }
.code-control { background: rgba(255,255,255,.85); box-shadow: 0 8px 22px rgba(58,72,61,.1); color: #4c77c8; }
.code-control svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.art-control img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(58,72,61,.12)); }
.hint-button { width: 59px; height: 59px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: end center; padding: 18px max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); background: rgba(33,50,43,.25); backdrop-filter: blur(5px); animation: fadeIn .18s ease; }
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card { width: min(100%, 430px); border-radius: 28px; background: var(--surface); box-shadow: 0 24px 70px rgba(37,50,43,.24); padding: 20px; animation: modalIn .25s cubic-bezier(.2,.8,.2,1); }
@keyframes modalIn { from { transform: translateY(24px) scale(.98); opacity: 0; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 22px; }
.setting-row { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.setting-row > div { display: grid; gap: 4px; }
.setting-row strong { font-size: 15px; }
.setting-row span { color: var(--muted); font-size: 12px; }
.sound-toggle { width: 58px; height: 58px; padding: 0; border: 0; background: transparent; cursor: pointer; transition: transform .16s ease, opacity .16s ease; }
.sound-toggle img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 7px rgba(58,72,61,.12)); }
.sound-toggle:active { transform: scale(.91); }
.sound-toggle[aria-checked="false"] { opacity: .88; }
.legend-block { padding-top: 17px; }
.legend-block p { margin: 0 0 11px; color: var(--muted); font-size: 12px; font-weight: 750; }
.legend-colors { display: flex; gap: 12px; }
.legend-dot { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: rgba(31,54,45,.45); font-weight: 900; }
.legend-dot.green { background: var(--green); }
.legend-dot.yellow { background: var(--yellow); }
.legend-dot.red { background: var(--red); }
.legend-dot.blue { background: var(--blue); }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.result-backdrop {
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden;
  background: rgba(12, 28, 22, .82);
  backdrop-filter: blur(9px) saturate(.82) brightness(.74);
}
.result-backdrop::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 40%, rgba(145, 224, 111, .18), transparent 36%),
    radial-gradient(circle at 18% 88%, rgba(251, 209, 99, .11), transparent 31%),
    radial-gradient(circle at 86% 18%, rgba(113, 192, 229, .1), transparent 28%);
}
.victory-stage {
  position: relative;
  isolation: isolate;
  width: min(100%, 410px);
  min-width: 0;
  min-height: min(94svh, 700px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 18px 22px;
  color: #fffdf3;
  text-align: center;
}
.victory-levels-button {
  position: absolute;
  z-index: 8;
  top: 4px;
  left: 4px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 10px 24px rgba(0,0,0,.16);
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease;
}
.victory-levels-button:active { transform: scale(.9); background: rgba(255,255,255,.18); }
.victory-levels-button img { width: 100%; height: 100%; object-fit: contain; }
.victory-effects { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.victory-aura {
  position: absolute;
  left: 50%;
  top: 43%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  background: radial-gradient(circle, rgba(230,255,181,.24) 0 28%, rgba(138,216,99,.12) 48%, transparent 72%);
  filter: blur(2px);
  animation: victoryAura 2.3s ease-in-out infinite;
}
@keyframes victoryAura { 50% { transform: translate(-50%,-50%) scale(1.08); opacity: .8; } }
.victory-leaf { position: absolute; width: 29px; height: 29px; object-fit: contain; opacity: 0; filter: drop-shadow(0 3px 4px rgba(0,0,0,.18)); }
.result-backdrop.is-opening .victory-leaf { animation: victoryLeafFloat 2.8s ease-in-out infinite; animation-delay: var(--leaf-delay); }
.leaf-one { --leaf-delay: .1s; left: 7%; top: 25%; transform: rotate(-32deg); }
.leaf-two { --leaf-delay: .45s; right: 7%; top: 23%; transform: rotate(44deg) scale(.85); }
.leaf-three { --leaf-delay: .75s; left: 14%; top: 57%; transform: rotate(18deg) scale(.7); }
.leaf-four { --leaf-delay: 1.05s; right: 12%; top: 59%; transform: rotate(-55deg) scale(.72); }
.leaf-five { --leaf-delay: 1.35s; left: 25%; top: 78%; transform: rotate(70deg) scale(.62); }
.leaf-six { --leaf-delay: 1.65s; right: 24%; top: 76%; transform: rotate(-12deg) scale(.65); }
@keyframes victoryLeafFloat {
  0% { opacity: 0; translate: 0 14px; }
  18%, 75% { opacity: .8; }
  50% { translate: 8px -10px; rotate: 16deg; }
  100% { opacity: 0; translate: -6px -34px; rotate: 38deg; }
}
.victory-spark { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #fff5a9; box-shadow: 0 0 12px rgba(255,244,154,.95); opacity: .25; animation: victorySpark 1.8s ease-in-out infinite; animation-delay: var(--spark-delay); }
.spark-one { --spark-delay: .1s; left: 24%; top: 29%; }
.spark-two { --spark-delay: .45s; right: 23%; top: 32%; width: 5px; height: 5px; }
.spark-three { --spark-delay: .8s; left: 18%; top: 48%; width: 4px; height: 4px; }
.spark-four { --spark-delay: 1.05s; right: 17%; top: 48%; }
.spark-five { --spark-delay: 1.35s; left: 31%; top: 63%; width: 5px; height: 5px; }
.spark-six { --spark-delay: 1.6s; right: 30%; top: 65%; width: 4px; height: 4px; }
@keyframes victorySpark { 50% { opacity: 1; transform: scale(1.55); } }
.result-arc-title {
  position: relative;
  z-index: 3;
  width: min(100%, 340px);
  height: 98px;
  margin: 0 0 -27px;
  overflow: visible;
  filter: drop-shadow(0 5px 12px rgba(0,0,0,.24));
}
.result-arc-title text { fill: #fffdf3; font-size: 27px; font-weight: 900; letter-spacing: .018em; }
.result-backdrop.is-opening .result-arc-title { animation: victoryTitleIn .46s cubic-bezier(.2,.9,.25,1) both; }
@keyframes victoryTitleIn { from { opacity: 0; transform: translateY(-14px) scale(.94); } }
.result-character-shell {
  position: relative;
  z-index: 3;
  width: clamp(176px, 52vw, 216px);
  height: clamp(176px, 52vw, 216px);
  display: grid;
  place-items: center;
  margin: 0 auto -4px;
}
.result-backdrop.is-opening .result-character-shell { animation: victoryCharacterIn .58s cubic-bezier(.18,1.28,.35,1) both; }
@keyframes victoryCharacterIn { from { opacity: 0; transform: translateY(24px) scale(.72) rotate(-7deg); } }
.result-character-glow {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,250,185,.38), rgba(159,227,112,.14) 48%, transparent 72%);
  filter: blur(5px);
}
.result-chameleon-canvas {
  position: relative;
  z-index: 2;
  width: 112%;
  height: 112%;
  object-fit: contain;
  filter: drop-shadow(0 15px 12px rgba(0,0,0,.28));
  animation: victoryCharacterFloat 2.15s .58s ease-in-out infinite;
}
@keyframes victoryCharacterFloat { 50% { transform: translateY(-7px) rotate(1.5deg); } }
.result-stars { position: relative; z-index: 4; min-height: 72px; display: flex; justify-content: center; align-items: center; gap: 3px; margin-top: -2px; }
.result-stars img { width: 60px; height: 60px; object-fit: contain; opacity: .2; filter: grayscale(1) brightness(1.45) drop-shadow(0 7px 8px rgba(0,0,0,.2)); }
.result-stars img.earned { opacity: 1; filter: drop-shadow(0 7px 8px rgba(0,0,0,.28)); animation: starPop .42s cubic-bezier(.2,1.35,.4,1) both; }
@keyframes starPop { from { opacity: 0; transform: translateY(14px) scale(.28) rotate(-20deg); } }
.result-summary { position: relative; z-index: 4; min-height: 47px; margin: 2px 0 17px; display: grid; place-items: center; gap: 3px; }
.result-summary strong { color: #fffdf3; font-size: 18px; line-height: 1.15; font-weight: 900; }
.result-summary span { color: rgba(255,255,255,.74); font-size: 13px; line-height: 1.3; font-weight: 700; }
.result-actions {
  position: relative;
  z-index: 5;
  width: min(100%, 304px);
  display: grid;
  gap: 9px;
}
.result-next {
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  border: 0;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: linear-gradient(180deg, #8bcf62, #62ac48);
  color: white;
  box-shadow: 0 13px 25px rgba(14,42,27,.34), inset 0 1px rgba(255,255,255,.3);
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .14s ease, filter .14s ease;
}
.result-next:active { transform: scale(.96); filter: brightness(.97); }
.result-next svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.result-next[data-action="levels"] svg { fill: currentColor; stroke: none; width: 21px; height: 21px; }
.result-retry {
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,.1);
  color: #fffdf3;
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 9px 20px rgba(0,0,0,.14);
  backdrop-filter: blur(4px);
  font: inherit;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .14s ease, background .14s ease;
}
.result-retry[hidden] { display: none; }
.result-retry:active { transform: scale(.96); background: rgba(255,255,255,.16); }
.result-retry svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); padding: 10px 15px; border-radius: 15px; background: rgba(41,65,57,.93); color: white; box-shadow: 0 10px 28px rgba(31,48,41,.23); font-size: 13px; font-weight: 700; text-align: center; animation: toastIn .2s ease; }
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%,8px); } }

@media (max-width: 360px) {
  .screen { padding-left: 10px; padding-right: 10px; }
  .level-grid { gap: 7px; }
  .level-button { border-radius: 16px; }
  .board-wrap { min-width: 272px; }
  .game-controls { gap: 25px; }
  .control-button { width: 51px; height: 51px; }
  .hint-button { width: 54px; height: 54px; }
  .brand-mark { width: 188px; margin-bottom: 7px; }
  .home-actions { width: min(100%, 292px); }
}
@media (max-height: 610px) {
  .game-main { gap: 2px; }
  .objective-strip { height: 22px; }
  .objective-fruit { width: 19px; height: 19px; }
  .board-wrap { width: min(88vw, calc(100svh - 176px), 500px); }
  .game-controls { padding-top: 3px; }
  .control-button { width: 48px; height: 48px; }
  .hint-button { width: 51px; height: 51px; }
  .tutorial-bubble { min-height: 30px; padding: 6px 11px; }
  .brand-mark { width: 158px; margin-bottom: 4px; }
  .home-content { gap: 8px; }
  .primary-button, .secondary-button { height: 53px; }
  .art-action img { width: 44px; height: 44px; }
}
@media (max-height: 650px) {
  .victory-stage { min-height: 96svh; padding-top: 18px; padding-bottom: 12px; }
  .result-arc-title { width: 300px; height: 82px; margin-bottom: -29px; }
  .result-arc-title text { font-size: 25px; }
  .result-character-shell { width: 154px; height: 154px; }
  .result-stars { min-height: 62px; }
  .result-stars img { width: 52px; height: 52px; }
  .result-summary { margin-bottom: 11px; min-height: 42px; }
  .result-next { min-height: 51px; }
  .result-actions { gap: 7px; }
  .result-retry { min-height: 44px; }
}
@media (max-width: 340px) {
  .victory-stage { padding-left: 10px; padding-right: 10px; }
  .result-arc-title { width: 292px; }
  .result-arc-title text { font-size: 25px; }
  .result-character-shell { width: 150px; height: 150px; }
  .result-stars img { width: 51px; height: 51px; }
  .victory-levels-button { width: 44px; height: 44px; }
}
@media (min-width: 700px) {
  .level-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}

/* v1.2 island progression */
.topbar-stars {
  min-width: 48px;
  min-height: 42px;
  padding: 0 7px;
  border-radius: 15px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 6px 18px rgba(58,72,61,.08);
  font-size: 13px;
  font-weight: 900;
}
.topbar-title p#levels-subtitle { margin-top: 3px; }
.island-map-view, .island-levels-view { width: min(100%, 520px); margin: 0 auto; }
.island-map-heading { display: grid; gap: 3px; padding: 7px 14px 0; text-align: center; }
.island-map-heading strong { font-size: 15px; }
.island-map-heading span { color: var(--muted); font-size: 12px; font-weight: 650; }
.island-map {
  position: relative;
  width: 100%;
  height: 1085px;
  margin: 10px auto 18px;
  overflow: hidden;
}
.island-route { position: absolute; inset: 30px 0 12px; width: 100%; height: calc(100% - 42px); overflow: visible; }
.island-route polyline {
  fill: none;
  stroke: rgba(88,126,101,.22);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2.2 2.1;
  vector-effect: non-scaling-stroke;
}
.island-step {
  position: absolute;
  left: var(--island-x);
  top: var(--island-y);
  width: 148px;
  min-height: 116px;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  gap: 3px;
  text-align: center;
  z-index: 2;
}
.island-node {
  --node-color: #7fc76f;
  position: relative;
  width: 78px;
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 34% 27%, rgba(255,255,255,.9) 0 5%, transparent 6%),
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--node-color) 74%, white), var(--node-color));
  box-shadow: inset 0 -8px 16px rgba(37,68,43,.1), 0 13px 24px rgba(48,73,57,.17);
  cursor: pointer;
  animation: islandBob 3.4s ease-in-out infinite;
  animation-delay: calc(var(--island-index) * -180ms);
  transition: filter .16s ease, scale .16s ease;
}
.island-step[data-color="green"] .island-node { --node-color: #79c968; }
.island-step[data-color="yellow"] .island-node { --node-color: #efd063; }
.island-step[data-color="red"] .island-node { --node-color: #ec826f; }
.island-step[data-color="blue"] .island-node { --node-color: #73bee3; }
.island-node:active { scale: .94; }
.island-step.current .island-node { box-shadow: inset 0 -8px 16px rgba(37,68,43,.1), 0 0 0 5px rgba(255,255,255,.8), 0 16px 28px rgba(48,73,57,.23); }
.island-step.locked .island-node { --node-color: #d8d8cf; filter: saturate(.45); }
@keyframes islandBob { 0%,100% { translate: 0 1px; } 50% { translate: 0 -5px; } }
.island-chameleon { width: 94px; height: 94px; object-fit: contain; translate: 0 -9px; pointer-events: none; filter: drop-shadow(0 5px 4px rgba(37,58,44,.16)); }
.island-number {
  position: absolute;
  right: -5px;
  bottom: -4px;
  min-width: 27px;
  height: 27px;
  padding: 0 6px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 5px 12px rgba(50,70,58,.15);
  font-size: 12px;
  font-weight: 950;
}
.island-lock-icon { width: 30px; height: 30px; fill: none; stroke: rgba(55,72,62,.52); stroke-width: 2; stroke-linejoin: round; }
.island-caption { max-width: 148px; display: grid; gap: 1px; padding: 4px 8px 6px; border-radius: 12px; background: rgba(251,247,238,.76); backdrop-filter: blur(3px); }
.island-caption strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.island-caption span { color: var(--muted); font-size: 10px; font-weight: 650; }
.island-caption em { min-height: 19px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; color: var(--accent); font-size: 10px; font-style: normal; font-weight: 900; }
.island-caption em img { width: 18px; height: 18px; object-fit: contain; }
.island-intro {
  margin: 7px 4px 13px;
  min-height: 59px;
  padding: 10px 16px;
  border-radius: 20px;
  display: grid;
  place-content: center;
  gap: 2px;
  text-align: center;
  background: rgba(255,255,255,.76);
  box-shadow: 0 8px 22px rgba(58,72,61,.08);
}
.island-intro strong { font-size: 13px; }
.island-intro span { color: var(--muted); font-size: 11px; font-weight: 650; }

/* Game plates float independently without interfering with click or wobble transforms. */
.cell { animation: plateFloat 3.15s ease-in-out infinite; animation-delay: calc((var(--row-index, 0) + var(--col-index, 0)) * -95ms); }
.cell:nth-child(4n + 1) { animation-delay: -.2s; }
.cell:nth-child(4n + 2) { animation-delay: -.75s; }
.cell:nth-child(4n + 3) { animation-delay: -1.3s; }
.cell:nth-child(4n) { animation-delay: -1.85s; }
@keyframes plateFloat { 0%,100% { translate: 0 1px; } 50% { translate: 0 -2px; } }
.cell.live { animation-duration: 2.55s; }

.purchase-backdrop { place-items: center; }
.purchase-card { position: relative; width: min(100%, 360px); padding: 25px 20px 20px; text-align: center; overflow: hidden; }
.purchase-card::before { content: ''; position: absolute; inset: -45% -30% auto; height: 230px; background: radial-gradient(circle, rgba(126,201,104,.22), transparent 67%); pointer-events: none; }
.purchase-backdrop[data-color="yellow"] .purchase-card::before { background: radial-gradient(circle, rgba(239,208,99,.3), transparent 67%); }
.purchase-backdrop[data-color="red"] .purchase-card::before { background: radial-gradient(circle, rgba(236,130,111,.25), transparent 67%); }
.purchase-backdrop[data-color="blue"] .purchase-card::before { background: radial-gradient(circle, rgba(115,190,227,.25), transparent 67%); }
.purchase-close { position: absolute; z-index: 2; top: 9px; right: 9px; }
.purchase-island-orb { position: relative; width: 76px; height: 76px; margin: 0 auto 7px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #a5dc87, #6eb45d); box-shadow: inset 0 2px rgba(255,255,255,.45), 0 12px 24px rgba(65,111,73,.2); }
.purchase-island-orb svg { width: 31px; height: 31px; fill: none; stroke: white; stroke-width: 2; stroke-linejoin: round; }
.purchase-kicker { position: relative; margin: 0 0 3px; color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.purchase-card h2 { position: relative; margin: 0; font-size: 24px; }
.purchase-theme { position: relative; margin: 5px auto 17px; max-width: 270px; color: var(--muted); font-size: 12px; font-weight: 650; }
.purchase-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.purchase-stats > div { padding: 10px; border-radius: 17px; background: #f6f1e7; display: grid; gap: 3px; }
.purchase-stats span { color: var(--muted); font-size: 10px; font-weight: 700; }
.purchase-stats strong { display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 17px; }
.purchase-stats img { width: 24px; height: 24px; object-fit: contain; }
.purchase-stats b { font: inherit; }
.purchase-hint { min-height: 18px; margin: 11px 0 12px; color: var(--muted); font-size: 11px; font-weight: 700; }
.purchase-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 8px; }
.purchase-actions button { min-height: 51px; border: 0; border-radius: 17px; font: inherit; font-size: 13px; font-weight: 900; cursor: pointer; }
.purchase-cancel { background: #eeeae1; color: var(--ink); }
.purchase-confirm { background: var(--accent); color: white; box-shadow: 0 10px 20px rgba(71,125,88,.22); }
.purchase-confirm:disabled { background: #c9cec7; box-shadow: none; cursor: default; }
.result-next[data-action="islands"] svg { fill: currentColor; stroke: none; width: 21px; height: 21px; }

@media (max-width: 360px) {
  .island-map { height: 1000px; }
  .island-step { width: 132px; }
  .island-caption { max-width: 132px; }
  .island-node { width: 72px; height: 72px; }
  .island-chameleon { width: 88px; height: 88px; }
}

/* v1.2 mixed board sizes: 4x4 through 9x9 */
.level-size {
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  color: rgba(41,65,57,.42);
  font-size: 8px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: .01em;
}
.level-button.locked .level-size { color: rgba(41,65,57,.24); }
.level-number.locked-number { color: rgba(41,65,57,.25); transform: translateY(-4px); }
.level-button.locked .level-lock {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 15px;
  height: 15px;
}

.board[data-size="6"] .cell,
.board[data-size="7"] .cell { border-radius: 11px; }
.board[data-size="8"] .cell,
.board[data-size="9"] .cell { border-radius: 8px; }
.board[data-size="6"] .chameleon-piece,
.board[data-size="7"] .chameleon-piece { --chameleon-inset: 3px; }
.board[data-size="8"] .chameleon-piece,
.board[data-size="9"] .chameleon-piece { --chameleon-inset: 2px; }
.board[data-size="8"] .cell.live::after,
.board[data-size="9"] .cell.live::after { inset: 19%; border-width: 1px; }
.board[data-size="8"] .cell-asset,
.board[data-size="9"] .cell-asset { inset: 1%; width: 98%; height: 98%; }
.board[data-size="8"] .cell,
.board[data-size="9"] .cell { animation-name: plateFloatSmall; }
@keyframes plateFloatSmall { 0%,100% { translate: 0 .4px; } 50% { translate: 0 -1px; } }

/* The route is made from compact floating island circles. */
.island-node { width: 70px; height: 70px; }
.island-chameleon { width: 84px; height: 84px; translate: 0 -8px; }
.island-step { min-height: 108px; }
.island-caption { padding-top: 3px; }

@media (max-width: 360px) {
  .island-node { width: 64px; height: 64px; }
  .island-chameleon { width: 78px; height: 78px; }
  .level-size { top: 4px; font-size: 7px; }
  .board[data-size="8"] .cell,
  .board[data-size="9"] .cell { border-radius: 7px; }
}
