:root {
  --ink: #18352d;
  --muted: #647b73;
  --cream: #fffaf0;
  --paper: rgba(255, 253, 244, 0.92);
  --leaf: #2e6b58;
  --leaf-dark: #204d41;
  --gold: #e5ae4d;
  --shadow: 0 18px 50px rgba(37, 71, 58, 0.15);
  --shell-gutter: clamp(10px, 4.3vw, 20px);
  --board-gap: clamp(3px, 1.25vw, 5px);
  --board-padding: clamp(8px, 2.75vw, 11px);
}

* { box-sizing: border-box; }

html { min-height: 100%; max-width: 100%; background: #e8eee3; }

body {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,.95), transparent 32%),
    radial-gradient(circle at 90% 24%, rgba(235,205,227,.8), transparent 28%),
    linear-gradient(155deg, #edf4e9 0%, #e2ebdf 48%, #f4eadf 100%);
  overflow-x: hidden;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(229, 174, 77, .72); outline-offset: 3px; }

.game-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  min-width: 0;
  padding: max(16px, env(safe-area-inset-top)) var(--shell-gutter) max(28px, env(safe-area-inset-bottom));
  isolation: isolate;
}

.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(2px); opacity: .75; }
.ambient-one { width: 190px; height: 190px; top: -65px; right: -65px; background: rgba(248, 193, 198, .42); }
.ambient-two { width: 240px; height: 240px; bottom: 10%; left: -150px; background: rgba(161, 205, 177, .38); }

.game-header, .section-title-row, .power-label, .stage-card, .booster { display: flex; align-items: center; }
.game-header { justify-content: space-between; margin-bottom: 16px; padding: 0 4px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(46,107,88,.25); border-radius: 50%; color: #bd6e78; background: rgba(255,255,255,.58); font-size: 24px; box-shadow: 0 8px 20px rgba(48,86,69,.09); }
.brand-lockup p, .brand-lockup h1 { margin: 0; }
.brand-lockup p { color: var(--muted); font-size: 11px; letter-spacing: .24em; }
.brand-lockup h1 { margin-top: 2px; font-size: 18px; letter-spacing: .06em; }
.round-button { width: 40px; height: 40px; border: 1px solid rgba(46,107,88,.15); border-radius: 50%; color: var(--leaf); background: rgba(255,255,255,.6); cursor: pointer; letter-spacing: 2px; }

.stage-card, .spirit-book, .board-frame, .boosters {
  border: 1px solid rgba(255,255,255,.78);
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.stage-card { position: relative; flex-wrap: wrap; gap: clamp(9px, 3vw, 12px); padding: clamp(14px, 4vw, 18px); border-radius: 24px; overflow: hidden; }
.stage-card::after { content: ""; position: absolute; width: 110px; height: 110px; right: 48px; top: -66px; border: 24px solid rgba(207, 226, 202, .36); border-radius: 50%; }
.stage-copy { flex: 1; min-width: 0; }
.eyebrow { display: block; color: #9a7860; font-family: system-ui, sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.stage-copy h2, .section-title-row h2 { margin: 4px 0 0; font-size: clamp(18px, 5.4vw, 20px); }
.stage-copy p { margin: 5px 0 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: 11px; }
.moves-orb { position: relative; z-index: 1; display: grid; place-items: center; width: 61px; height: 61px; border-radius: 50%; color: white; background: linear-gradient(145deg, #3f7b67, #204f42); box-shadow: 0 8px 18px rgba(37,91,72,.25), inset 0 0 0 4px rgba(255,255,255,.13); }
.moves-orb strong { margin-bottom: -8px; font-family: system-ui, sans-serif; font-size: 23px; }
.moves-orb span { font-family: system-ui, sans-serif; font-size: 9px; opacity: .82; }
.power-wrap { width: 100%; }
.power-label { justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-family: system-ui, sans-serif; font-size: 11px; }
.power-label strong { color: var(--leaf); font-size: 14px; }
.power-label small { font-size: 10px; font-weight: 500; }
.power-track { position: relative; height: 8px; border-radius: 8px; background: #dfe8dd; overflow: visible; }
.power-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #73a985, #e0b454, #d885a2); box-shadow: 0 0 11px rgba(224,180,84,.35); transition: width .45s ease; }
.milestone { position: absolute; top: 50%; width: 5px; height: 12px; border-radius: 4px; background: #fffaf0; transform: translate(-50%,-50%); box-shadow: 0 0 0 1px rgba(46,107,88,.15); }
.milestone-one { left: 28.4%; }.milestone-two { left: 62.5%; }

.spirit-book { min-width: 0; margin-top: 12px; padding: clamp(12px, 3.8vw, 15px) clamp(11px, 3.6vw, 14px) clamp(10px, 3.3vw, 13px); border-radius: 22px; }
.section-title-row { justify-content: space-between; }
.section-title-row h2 { font-size: 17px; }
.collection-count { color: var(--muted); font-family: system-ui, sans-serif; font-size: 11px; }
.collection-count strong { color: var(--leaf); font-size: 18px; }
.spirit-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(4px, 1.8vw, 7px); margin-top: 12px; }
.spirit { min-width: 0; text-align: center; }
.spirit-avatar { position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 1px dashed rgba(63,90,80,.18); border-radius: 50% 50% 46% 54%; background: rgba(229,234,225,.72); filter: grayscale(1); opacity: .36; transition: .35s ease; }
.spirit-avatar::after { content: ""; position: absolute; bottom: 5%; width: 30%; height: 16%; border-radius: 50%; background: currentColor; opacity: .28; }
.spirit-avatar span { font-family: system-ui, sans-serif; font-size: clamp(14px, 5vw, 23px); }
.spirit-avatar img { position: relative; z-index: 1; width: 145%; height: 145%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(37,68,56,.16)); transform: translateY(-4%); }
.spirit-name { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-family: system-ui, sans-serif; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.spirit.is-collected .spirit-avatar { border-style: solid; filter: none; opacity: 1; background: color-mix(in srgb, currentColor 15%, white); box-shadow: 0 6px 14px color-mix(in srgb, currentColor 25%, transparent); animation: spiritWake .55s ease both; }
.spirit.is-collected .spirit-name { color: var(--ink); font-weight: 700; }

.board-section { position: relative; min-width: 0; margin-top: 12px; }
.board-frame { position: relative; width: 100%; min-width: 0; padding: var(--board-padding); border-radius: 26px; overflow: hidden; }
.board-frame::before { content: ""; position: absolute; inset: 5px; z-index: 0; border: 1px solid rgba(46,107,88,.08); border-radius: 22px; pointer-events: none; }
.board { position: relative; z-index: 1; display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--board-gap); touch-action: none; user-select: none; }
.tile { position: relative; display: grid; min-width: 0; min-height: 0; place-items: center; aspect-ratio: 1; padding: 0; border: 0; border-radius: 18px 18px 16px 16px; color: var(--flower-color); background: linear-gradient(145deg, rgba(255,255,255,.9), color-mix(in srgb, var(--flower-color) 16%, white)); box-shadow: inset 0 -3px 7px rgba(62,82,72,.08), 0 3px 7px rgba(53,77,66,.07); cursor: pointer; transition: transform .16s ease, opacity .2s ease, box-shadow .16s ease; will-change: transform, opacity; }
.tile::after { content: ""; position: absolute; inset: 10%; border-radius: 50%; background: radial-gradient(circle, transparent 56%, color-mix(in srgb, var(--flower-color) 16%, transparent)); opacity: .7; }
.tile .flower-art { position: relative; z-index: 1; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(43,54,48,.16)); transform: translateY(-1%); }
.tile.is-selected { z-index: 2; transform: scale(.9); box-shadow: inset 0 0 0 3px var(--gold), 0 4px 14px rgba(197,149,58,.26); }
.tile.is-matched { animation: bloomOut .35s ease forwards; }
.tile.is-new { animation: fallIn .3s cubic-bezier(.18,.8,.3,1.2) both; }
.tile.is-hint { animation: tileHint 1s ease infinite; }
.board.is-locked .tile { pointer-events: none; transition: none; }
.board-mist { position: absolute; z-index: 3; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(230,239,230,.25), rgba(82,105,97,.68)); backdrop-filter: blur(2px); transition: opacity .28s ease; }
.board-mist.is-active { opacity: 1; animation: mistPass .8s ease; }
.board-tip { margin: 8px 0 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: 10px; text-align: center; }
.combo-toast { position: absolute; z-index: 8; top: 45%; left: 50%; padding: 7px 13px; border-radius: 999px; color: #fff; background: rgba(37,91,72,.92); font-family: system-ui, sans-serif; font-size: 13px; font-weight: 800; opacity: 0; pointer-events: none; transform: translate(-50%, 10px) scale(.9); }
.combo-toast.is-visible { animation: toastPop 1s ease; }
.mist-warning { margin: 0 12px 7px; padding: 7px 10px; border-radius: 10px; color: #694f64; background: rgba(238,219,231,.82); font-family: system-ui, sans-serif; font-size: 10px; text-align: center; }

.boosters { display: grid; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(5px, 1.8vw, 7px); margin-top: 12px; padding: clamp(7px, 2.4vw, 9px); border-radius: 22px; }
.booster { position: relative; min-width: 0; min-height: 58px; gap: 7px; padding: 7px; border: 0; border-radius: 16px; color: var(--ink); background: rgba(241,244,234,.8); cursor: pointer; text-align: left; transition: transform .16s ease, opacity .2s; }
.booster:active { transform: scale(.96); }
.booster:disabled { cursor: not-allowed; filter: grayscale(1); opacity: .4; }
.booster-icon { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; font-family: system-ui, sans-serif; font-size: 18px; }
.sun-icon { color: #a76d17; background: #fde7a6; }.dew-icon { color: #337690; background: #cbe8ed; }.wind-icon { color: #42735f; background: #cfe5d7; }
.booster-copy { min-width: 0; }
.booster-copy strong, .booster-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.booster-copy strong { font-size: 10px; }.booster-copy small { margin-top: 3px; color: var(--muted); font-family: system-ui, sans-serif; font-size: 7px; }
.booster-count { position: absolute; top: -4px; right: -2px; display: grid; place-items: center; width: 19px; height: 19px; border: 2px solid var(--cream); border-radius: 50%; color: white; background: var(--leaf); font-family: system-ui, sans-serif; font-size: 9px; font-weight: 800; }

.overlay { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(20,43,37,.55); backdrop-filter: blur(10px); opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s; }
.overlay.is-visible { opacity: 1; visibility: visible; }
.story-card { width: min(100%, 410px); padding: 30px 26px 25px; border: 1px solid rgba(255,255,255,.75); border-radius: 30px; background: linear-gradient(160deg, rgba(255,253,245,.98), rgba(238,243,230,.98)); box-shadow: 0 32px 90px rgba(13,37,29,.32); text-align: center; transform: translateY(14px); transition: transform .35s ease; }
.overlay.is-visible .story-card { transform: translateY(0); }
.story-card h2 { margin: 9px 0 12px; font-size: clamp(25px, 7vw, 32px); line-height: 1.38; }
.story-card p { margin: 0 auto 22px; color: var(--muted); font-family: system-ui, sans-serif; font-size: 13px; line-height: 1.8; }
.primary-button, .secondary-button { width: 100%; min-height: 49px; border-radius: 999px; cursor: pointer; }
.primary-button { border: 0; color: white; background: linear-gradient(135deg, #39745f, #224f43); box-shadow: 0 10px 24px rgba(36,81,66,.22); font-weight: 700; letter-spacing: .08em; }
.primary-button span { margin-left: 8px; }
.secondary-button { border: 1px solid rgba(46,107,88,.22); color: var(--leaf); background: rgba(255,255,255,.6); }
.text-button { margin-top: 14px; border: 0; color: var(--leaf); background: transparent; cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.sleeping-flower { position: relative; width: 88px; height: 88px; margin: 0 auto 18px; transform: rotate(-8deg); }
.sleeping-flower i { position: absolute; z-index: 3; width: 29px; height: 29px; top: 30px; left: 30px; border-radius: 50%; background: #d9a446; box-shadow: inset 0 -5px 8px rgba(120,70,10,.13); }
.petal { position: absolute; left: 31px; top: 4px; width: 29px; height: 45px; border-radius: 60% 60% 50% 50%; background: linear-gradient(#f4b8c3, #ca7586); transform-origin: 50% 40px; }
.p2 { transform: rotate(72deg); }.p3 { transform: rotate(144deg); }.p4 { transform: rotate(216deg); }.p5 { transform: rotate(288deg); }
.compact-card { padding-top: 25px; }
.compact-card h2 { font-size: 27px; }
.modal-symbol { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 50%; color: #b98429; background: #f7e7b8; font-size: 29px; }
.modal-actions { display: grid; gap: 10px; }
.modal-actions .secondary-button { min-height: 44px; }
.vertical-actions { margin-top: 8px; }

.victory-overlay { overflow: hidden; background: linear-gradient(to bottom, rgba(20,38,32,.08) 40%, rgba(21,50,40,.78) 100%), url("assets/art/fairy-awakening.webp") center 32% / cover no-repeat; }
.victory-overlay::after { content: ""; position: absolute; z-index: 1; inset: 55% 0 0; background: linear-gradient(to bottom, transparent, rgba(18,48,39,.9)); pointer-events: none; }
.victory-rays { position: absolute; width: 620px; height: 620px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.22) 0deg 9deg, transparent 9deg 24deg); animation: raysSpin 30s linear infinite; }
.fairy-awake { display: none; }
.wing { position: absolute; top: 55px; width: 82px; height: 118px; border: 2px solid rgba(255,255,255,.72); background: linear-gradient(145deg, rgba(255,255,255,.68), rgba(213,183,237,.2)); }
.left-wing { left: 2px; border-radius: 90% 18% 75% 25%; transform: rotate(-18deg); }.right-wing { right: 2px; border-radius: 18% 90% 25% 75%; transform: rotate(18deg); }
.fairy-head { position: absolute; z-index: 2; top: 38px; left: 68px; display: grid; place-items: center; width: 45px; height: 45px; border-radius: 50%; color: #fff; background: #e8b886; box-shadow: 0 -8px 0 #79563f; }
.fairy-body { position: absolute; z-index: 2; top: 78px; left: 61px; width: 58px; height: 110px; border-radius: 45% 45% 16% 16%; background: linear-gradient(#f7d5df, #8970ad); clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%); }
.victory-copy { position: absolute; z-index: 2; width: 100%; bottom: max(42px, env(safe-area-inset-bottom)); padding: 0 24px; text-align: center; }
.victory-copy .eyebrow { color: #f1d89e; }
.victory-copy h2 { margin: 8px 0; color: #fffaf0; font-size: 35px; text-shadow: 0 3px 14px rgba(0,0,0,.35); }
.victory-copy p { color: rgba(255,255,255,.86); font-family: system-ui, sans-serif; line-height: 1.8; }
.victory-copy .primary-button { max-width: 330px; margin-top: 12px; }

@keyframes bloomOut { 45% { transform: scale(1.16) rotate(5deg); filter: brightness(1.25); } 100% { transform: scale(.1) rotate(22deg); opacity: 0; } }
@keyframes fallIn { from { opacity: 0; transform: translateY(-45%); } }
@keyframes spiritWake { 0% { transform: scale(.45) rotate(-12deg); } 70% { transform: scale(1.12) rotate(3deg); } }
@keyframes tileHint { 50% { transform: scale(.9); box-shadow: inset 0 0 0 3px rgba(229,174,77,.7); } }
@keyframes mistPass { 0%,100% { opacity: 0; } 40%,65% { opacity: 1; } }
@keyframes toastPop { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.8); } 18%,68% { opacity: 1; transform: translate(-50%, -8px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -20px) scale(.95); } }
@keyframes raysSpin { to { transform: rotate(360deg); } }
@keyframes fairyFloat { 50% { transform: translateY(-12px); } }

@media (min-width: 700px) {
  body { padding: 25px 0; }
  .game-shell { min-height: calc(100vh - 50px); border: 1px solid rgba(255,255,255,.62); border-radius: 36px; background: rgba(238,245,235,.38); box-shadow: 0 30px 80px rgba(36,70,57,.15); }
}

@media (max-width: 359px) {
  .game-shell { padding-inline: 10px; }
  .board { gap: 3px; }.board-frame { padding: 8px; }.tile { border-radius: 14px; }
  .booster { justify-content: center; min-height: 52px; }.booster-copy { display: none; }.booster-icon { flex-basis: 29px; width: 29px; height: 29px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
