:root {
  --cream: #fffaf1;
  --pink: #f39abb;
  --pink-dark: #c85e87;
  --purple: #7e5aa5;
  --green: #72a96b;
  --green-dark: #477c45;
  --gold: #f2c35c;
  --ink: #493b4b;
  --panel: rgba(255, 255, 255, 0.9);
  --shadow: 0 14px 30px rgba(91, 52, 78, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,.75) 0 3%, transparent 3.2%),
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.55) 0 4%, transparent 4.2%),
    linear-gradient(145deg, #fde7ef 0%, #f8d6e5 42%, #d9edcc 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .28;
  pointer-events: none;
}
body::before { left: -80px; bottom: -70px; background: #87c77f; }
body::after { right: -95px; top: 75px; background: #f095bc; }

button { font: inherit; }
button:focus-visible { outline: 4px solid rgba(126,90,165,.35); outline-offset: 2px; }

#app { min-height: 100vh; padding: 12px 16px 22px; position: relative; z-index: 1; }

.topbar {
  max-width: 1180px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-flower { font-size: clamp(36px, 5vw, 58px); filter: drop-shadow(0 5px 4px rgba(126,90,165,.18)); }
h1 { margin: 0; font-size: clamp(24px, 4vw, 42px); line-height: 1; color: #9b416b; text-shadow: 0 2px white; }
.brand p { margin: 5px 0 0; font-size: 13px; color: #6d5b6e; }

.top-actions { display: flex; gap: 8px; }
.round-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  background: rgba(255,255,255,.78);
  box-shadow: 0 7px 15px rgba(98,55,82,.14);
  cursor: pointer;
  font-size: 21px;
  transition: transform .15s ease, background .15s ease;
}
.round-button:hover { transform: translateY(-2px) scale(1.04); background: white; }

.game-layout {
  max-width: 1180px;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(410px, 650px) minmax(180px, 230px);
  gap: 14px;
  align-items: start;
}

.side-panel {
  background: var(--panel);
  border: 3px solid rgba(255,255,255,.75);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 17px;
  backdrop-filter: blur(6px);
}

.level-heading { display: flex; align-items: baseline; justify-content: space-between; color: var(--pink-dark); text-transform: uppercase; letter-spacing: .08em; }
.level-heading strong { font-size: 34px; }
.garden-name { margin: 3px 0 14px; font-weight: 800; color: var(--purple); }
.stat-card { border-radius: 16px; padding: 12px; margin: 10px 0; box-shadow: inset 0 -3px rgba(0,0,0,.05); }
.stat-card span { display: block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.stat-card strong { display: block; font-size: 28px; line-height: 1.15; }
.moves-card { background: #fce59d; }
.score-card { background: #dceccf; }
.score-track { height: 9px; background: rgba(255,255,255,.7); border-radius: 99px; overflow: hidden; margin: 8px 0 5px; }
.score-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #f3a6c2, #b46fc5); border-radius: inherit; transition: width .3s ease; }
.score-card small { font-weight: 700; }
.objectives-box h2, .booster-card h2 { font-size: 18px; margin: 16px 0 10px; color: #825077; }
.objective {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px dashed rgba(73,59,75,.16);
  font-size: 13px;
}
.objective:last-child { border-bottom: 0; }
.objective-icon { font-size: 24px; text-align: center; }
.objective-count { font-weight: 900; color: #8c4470; }
.objective.complete { opacity: .5; text-decoration: line-through; }

.board-section { min-width: 0; }
.board-shell {
  position: relative;
  width: min(100%, 650px);
  margin: auto;
  padding: 10px;
  border-radius: 30px;
  background: linear-gradient(160deg, rgba(255,255,255,.96), rgba(248,215,228,.88));
  box-shadow: 0 18px 40px rgba(88,48,75,.2), inset 0 0 0 3px rgba(255,255,255,.72);
}
.board {
  --gap: 5px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--gap);
  padding: 8px;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  background:
    linear-gradient(45deg, rgba(103,155,88,.16) 25%, transparent 25% 75%, rgba(103,155,88,.16) 75%),
    linear-gradient(45deg, rgba(103,155,88,.16) 25%, #edf5e7 25% 75%, rgba(103,155,88,.16) 75%);
  background-position: 0 0, 9px 9px;
  background-size: 18px 18px;
  overflow: hidden;
  touch-action: none;
}

.tile {
  position: relative;
  border: 0;
  border-radius: 14px;
  background: rgba(255,255,255,.62);
  box-shadow: inset 0 -4px rgba(107,73,91,.08), 0 2px 4px rgba(92,61,78,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .13s ease, box-shadow .13s ease, background .13s ease;
  overflow: hidden;
}
.tile:hover { transform: scale(1.05); z-index: 3; }
.tile.selected { transform: scale(.9); background: #fff3ad; box-shadow: 0 0 0 4px rgba(242,195,92,.65), inset 0 -4px rgba(107,73,91,.08); z-index: 4; }
.tile.hint { animation: hintPulse 1s ease-in-out infinite; }
.flower { font-size: clamp(28px, 5.5vw, 51px); line-height: 1; filter: drop-shadow(0 4px 2px rgba(84,47,68,.2)); transform-origin: center; }
.tile.clearing .flower { animation: clearPop .26s ease forwards; }
.tile.spawned .flower { animation: dropIn .25s cubic-bezier(.22,.8,.27,1.2); }
.tile.special-line::after, .tile.special-bomb::after, .tile.special-rainbow::after {
  content: "";
  position: absolute;
  inset: 7%;
  border: 4px solid rgba(255,255,255,.9);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(134,75,126,.35);
  pointer-events: none;
}
.tile.special-line.horizontal::before { content: "↔"; position: absolute; z-index: 2; font-size: 28px; color: white; text-shadow: 0 2px 4px #8a3c68; }
.tile.special-line.vertical::before { content: "↕"; position: absolute; z-index: 2; font-size: 28px; color: white; text-shadow: 0 2px 4px #8a3c68; }
.tile.special-bomb::before { content: "✹"; position: absolute; z-index: 2; font-size: 31px; color: white; text-shadow: 0 2px 4px #784263; }
.tile.special-rainbow { background: radial-gradient(circle, #fff 5%, #f7a7bd 22%, #ffd36e 40%, #9ad689 58%, #9ec7ff 76%, #c796e0 95%); }
.tile.special-rainbow .flower { font-size: clamp(27px, 5vw, 46px); }
.tile.special-rainbow::before { content: "✨"; position: absolute; z-index: 2; font-size: 30px; }

.tile.dirt::after,
.tile.ice::after,
.tile.pot::after,
.tile.weed::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  border-radius: 12px;
}
.tile.dirt::after { content: ""; background: rgba(126,79,47,.45); box-shadow: inset 0 0 0 4px rgba(100,62,37,.26); }
.tile.ice::after { content: "❄"; color: rgba(255,255,255,.92); font-size: 27px; background: rgba(161,220,240,.42); box-shadow: inset 0 0 0 4px rgba(224,249,255,.55); }
.tile.pot::after { content: "🪴"; font-size: clamp(25px, 4.7vw, 44px); background: rgba(155,102,60,.18); }
.tile.weed::after { content: "🌿"; font-size: clamp(24px, 4.4vw, 42px); background: rgba(59,123,57,.2); }
.tile.blocked { cursor: default; }
.tile.blocked .flower { opacity: .2; }

.combo-text {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%) scale(.7);
  font-size: clamp(32px, 7vw, 66px);
  font-weight: 1000;
  color: white;
  text-shadow: 0 4px 0 #c15384, 0 7px 12px rgba(85,45,72,.3);
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}
.combo-text.show { animation: comboPop .7s ease; }
.hint-text { margin: 11px 0 0; text-align: center; font-weight: 800; color: #75516d; font-size: 14px; min-height: 20px; }

.special-guide > div { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed rgba(73,59,75,.15); }
.special-guide > div:last-child { border-bottom: 0; }
.special-guide p { margin: 0; font-size: 12px; line-height: 1.35; }
.mini-special { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: grid; place-items: center; font-size: 25px; box-shadow: inset 0 0 0 3px white, 0 3px 6px rgba(0,0,0,.12); }
.mini-special.row { background: #f8c1d4; }
.mini-special.bomb { background: #f7dc8a; }
.mini-special.rainbow { background: conic-gradient(#f5a5b8,#f4d35e,#94cf86,#8ec5ef,#bf91dc,#f5a5b8); }
.save-note { margin-top: 15px; border-radius: 14px; padding: 11px; background: #eee4f7; font-size: 12px; font-weight: 700; text-align: center; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(74,46,66,.48);
  backdrop-filter: blur(5px);
  opacity: 1;
  transition: opacity .2s ease;
}
.overlay.hidden { display: none; }
.modal {
  width: min(92vw, 480px);
  border-radius: 28px;
  padding: 25px;
  background: #fffaf5;
  border: 4px solid white;
  box-shadow: 0 25px 65px rgba(62,37,54,.35);
  text-align: center;
  animation: modalIn .25s cubic-bezier(.2,.8,.2,1.15);
}
.result-icon { font-size: 68px; }
.modal h2 { color: #99486f; font-size: 29px; margin: 6px 0; }
.modal p { margin: 8px 0 18px; color: #695269; }
.result-score { display: flex; justify-content: center; align-items: baseline; gap: 10px; padding: 12px; border-radius: 15px; background: #f8e6ad; margin: 12px 0 18px; }
.result-score strong { font-size: 27px; }
.modal-actions { display: flex; gap: 10px; }
.button { flex: 1; border: 0; border-radius: 15px; padding: 13px 15px; font-weight: 900; cursor: pointer; box-shadow: inset 0 -4px rgba(0,0,0,.09); }
.button.primary { background: #e979a5; color: white; }
.button.secondary { background: #e9dff1; color: #6e537b; }
.button:hover { transform: translateY(-1px); filter: brightness(1.03); }
.level-modal { width: min(94vw, 720px); text-align: left; max-height: 88vh; overflow: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.modal-header h2 { margin-top: 0; }
.modal-header p { margin: 0; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 20px; }
.level-button {
  aspect-ratio: 1;
  border: 3px solid white;
  border-radius: 18px;
  background: #f6d4e1;
  box-shadow: 0 6px 12px rgba(98,55,83,.12), inset 0 -5px rgba(0,0,0,.06);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #7d3c62;
  font-weight: 900;
}
.level-button strong { font-size: 24px; }
.level-button small { font-size: 10px; margin-top: 3px; }
.level-button.current { background: #f6c35f; }
.level-button.complete { background: #b9dda9; }
.level-button.locked { background: #ded8df; color: #928894; cursor: not-allowed; filter: grayscale(.5); }

@keyframes clearPop { to { transform: scale(1.55) rotate(18deg); opacity: 0; } }
@keyframes dropIn { from { transform: translateY(-70%) scale(.55); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes comboPop { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.5); } 30% { opacity: 1; transform: translate(-50%,-50%) scale(1.12); } 75% { opacity: 1; transform: translate(-50%,-58%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-75%) scale(.92); } }
@keyframes modalIn { from { transform: scale(.78); opacity: 0; } }
@keyframes hintPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(242,195,92,.1); } 50% { box-shadow: 0 0 0 6px rgba(242,195,92,.75); transform: scale(1.05); } }

@media (max-width: 930px) {
  #app { padding: 8px; }
  .game-layout { grid-template-columns: minmax(150px, 190px) minmax(390px, 1fr); }
  .booster-card { display: none; }
}

@media (max-width: 650px) {
  .topbar { margin-bottom: 6px; }
  .brand p { display: none; }
  .round-button { width: 39px; height: 39px; font-size: 18px; }
  .game-layout { display: flex; flex-direction: column; }
  .level-card { width: 100%; padding: 9px 12px; display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center; border-radius: 18px; }
  .level-heading { display: block; }
  .level-heading strong { font-size: 25px; margin-left: 5px; }
  .garden-name { display: none; }
  .stat-card { margin: 0; padding: 7px 10px; min-width: 84px; }
  .stat-card strong { font-size: 22px; }
  .score-track, .score-card small { display: none; }
  .objectives-box { grid-column: 1 / -1; }
  .objectives-box h2 { display: none; }
  #objectives { display: flex; flex-wrap: wrap; gap: 4px 10px; }
  .objective { border: 0; padding: 2px; grid-template-columns: 26px auto auto; }
  .objective-icon { font-size: 20px; }
  .board-shell { padding: 6px; border-radius: 20px; }
  .board { --gap: 3px; padding: 5px; border-radius: 16px; }
  .tile { border-radius: 10px; }
  .tile.special-line::after, .tile.special-bomb::after, .tile.special-rainbow::after { border-width: 3px; }
  .hint-text { font-size: 12px; margin-top: 7px; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 700px) and (min-width: 651px) {
  #app { padding-top: 6px; }
  .topbar { margin-bottom: 5px; }
  .brand-flower { font-size: 38px; }
  h1 { font-size: 29px; }
  .brand p { display: none; }
  .game-layout { max-width: 1000px; grid-template-columns: 190px minmax(400px, 560px) 190px; }
  .side-panel { padding: 11px; }
  .special-guide p { font-size: 10px; }
}
