:root {
  color-scheme: dark;
  --bg: #061512;
  --panel: rgba(12, 38, 32, 0.86);
  --panel-strong: #0f3028;
  --soil: #173b31;
  --soil-dark: #0c2821;
  --line-off: #49695f;
  --line-on: #9ff4a9;
  --gold: #ffd477;
  --mint: #6ee7b7;
  --text: #effbf4;
  --muted: #9bbcaf;
  --danger: #ff987a;
  --radius: 24px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(72, 177, 125, 0.18), transparent 42%),
    linear-gradient(180deg, #081d18 0%, var(--bg) 70%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.18;
  pointer-events: none;
}

.ambient-one {
  top: 5%;
  left: -160px;
  background: #3ad095;
}

.ambient-two {
  right: -170px;
  bottom: 5%;
  background: #d9b45e;
}

.app-shell {
  width: min(100%, 580px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow,
.modal-kicker {
  margin: 0 0 3px;
  color: var(--mint);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 7vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
}

h1 span {
  color: var(--gold);
  font-style: italic;
}

.icon-button {
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.25rem;
  cursor: pointer;
}

.status-card {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 8px;
  padding: 13px 15px;
  border: 1px solid rgba(159, 244, 169, 0.11);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(14px);
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-item span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.status-item strong {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 1.06rem;
}

.status-item b {
  font-weight: 800;
}

.status-item small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.status-center {
  align-items: center;
  border-inline: 1px solid rgba(255, 255, 255, 0.08);
}

.status-right {
  align-items: flex-end;
}

.seed-dot {
  width: 9px;
  height: 13px;
  margin-right: 2px;
  border-radius: 70% 30% 70% 30%;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(255, 212, 119, 0.5);
  transform: rotate(40deg);
}

.coach {
  min-height: 42px;
  margin: 12px 0 6px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(110, 231, 183, 0.08);
  color: #cdebdc;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
  transition: opacity 180ms ease;
}

.coach:empty {
  display: none;
}

.garden-frame {
  position: relative;
  width: 100%;
  padding: clamp(10px, 3.5vw, 18px);
  overflow: hidden;
  border: 1px solid rgba(255, 212, 119, 0.16);
  border-radius: 30px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    #0a241e;
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.06);
}

.frame-glow {
  position: absolute;
  top: -50%;
  left: 25%;
  width: 50%;
  height: 80%;
  border-radius: 50%;
  background: rgba(255, 212, 119, 0.12);
  filter: blur(40px);
  pointer-events: none;
}

.board {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  gap: clamp(4px, 1.5vw, 8px);
}

.tile {
  --line: clamp(5px, 1.6vw, 9px);
  --hub: clamp(6px, 1.9vw, 11px);
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: clamp(10px, 3vw, 18px);
  background-color: var(--soil);
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.14);
  color: var(--line-off);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 180ms ease, color 180ms ease, transform 120ms ease, box-shadow 180ms ease;
}

.tile:active {
  transform: scale(0.93);
}

.tile.powered {
  color: var(--line-on);
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.1), 0 0 20px rgba(103, 238, 155, 0.06);
}

.tile.recent {
  animation: turn-pop 170ms ease-out;
}

.tile.hinted {
  animation: hint-ring 600ms ease-out;
}

.tile.empty {
  border-color: transparent;
  background:
    radial-gradient(circle, rgba(110, 231, 183, 0.07) 0 2px, transparent 3px) 0 0 / 14px 14px,
    var(--soil-dark);
  opacity: 0.48;
  box-shadow: none;
  cursor: default;
}

.tile[data-marker]::after {
  content: attr(data-marker);
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: clamp(27px, 8vw, 42px);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1rem, 5vw, 1.55rem);
  line-height: 1;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 240ms ease;
}

.tile.source::after {
  border: 2px solid rgba(255, 212, 119, 0.72);
  background: #624e23;
  color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 212, 119, 0.32);
}

.tile.flower::after {
  border: 2px solid #6c837a;
  background: #2c4940;
  color: #91a9a0;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 240ms ease;
}

.tile.powered.flower::after {
  border-color: rgba(255, 212, 119, 0.75);
  background: #5e3b5a;
  color: #ffc1e8;
  box-shadow: 0 0 18px rgba(255, 161, 216, 0.3);
  transform: translate(-50%, -50%) scale(1.08) rotate(8deg);
}

.legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.legend i {
  margin-right: 4px;
  font-style: normal;
}

.legend-source {
  color: var(--gold);
}

.legend-flower {
  color: #ffc1e8;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 9px;
}

.controls button {
  min-height: 54px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.controls button span {
  display: inline-block;
  margin-right: 5px;
  color: var(--mint);
  font-size: 1.1rem;
  vertical-align: -1px;
}

.controls .primary-control {
  border-color: rgba(255, 212, 119, 0.25);
  background: linear-gradient(145deg, #735d2d, #4c411f);
  color: #fff5d7;
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.text-button,
.wide-text-button {
  display: block;
  margin: 13px auto 0;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.modal {
  width: min(calc(100% - 36px), 460px);
  max-height: calc(100svh - 40px);
  padding: 24px;
  overflow: auto;
  border: 1px solid rgba(255, 212, 119, 0.18);
  border-radius: 28px;
  background: #0d2b24;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}

.modal::backdrop {
  background: rgba(2, 10, 8, 0.78);
  backdrop-filter: blur(6px);
}

.modal h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 600;
}

.modal p,
.modal li {
  color: #c3dacf;
  font-size: 0.88rem;
  line-height: 1.65;
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-primary {
  width: 100%;
  min-height: 54px;
  margin-top: 12px;
  border: 1px solid rgba(255, 212, 119, 0.35);
  border-radius: 16px;
  background: linear-gradient(135deg, #c29a47, #806628);
  color: #fff9e9;
  font-weight: 900;
  cursor: pointer;
}

.complete-modal {
  text-align: center;
}

.bloom-emblem {
  display: grid;
  width: 78px;
  aspect-ratio: 1;
  margin: 0 auto 18px;
  place-items: center;
  border: 1px solid rgba(255, 193, 232, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle, #74496e, #2a463d 70%);
  color: #ffc1e8;
  box-shadow: 0 0 36px rgba(255, 193, 232, 0.18);
  font-size: 2.4rem;
  animation: bloom-in 480ms cubic-bezier(0.2, 0.9, 0.25, 1.25);
}

.reward-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 4px;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 0.82rem;
}

.reward-line strong {
  color: var(--gold);
  font-size: 1.1rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.setting-row span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setting-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.setting-row input {
  width: 23px;
  height: 23px;
  accent-color: var(--mint);
}

.wide-text-button {
  width: 100%;
  margin-top: 20px;
}

.help-modal ol {
  padding-left: 22px;
}

@keyframes turn-pop {
  45% { transform: scale(0.88) rotate(4deg); }
}

@keyframes hint-ring {
  0% { box-shadow: 0 0 0 0 rgba(255, 212, 119, 0.8); }
  100% { box-shadow: 0 0 0 18px rgba(255, 212, 119, 0); }
}

@keyframes bloom-in {
  from { opacity: 0; transform: scale(0.45) rotate(-35deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@media (max-width: 370px) {
  .app-shell {
    padding-inline: 12px;
  }

  .status-card {
    padding-inline: 10px;
  }

  .controls {
    gap: 6px;
  }

  .controls button {
    font-size: 0.72rem;
  }
}

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

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

/* 2026 pastel garden refresh */
:root {
  color-scheme: light;
  --bg: #f7f5ff;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --soil: #e7f8ef;
  --soil-dark: #e9e5f8;
  --line-off: #93b5aa;
  --line-on: #24d1a0;
  --gold: #ffb53f;
  --mint: #14bfa0;
  --text: #29243f;
  --muted: #746e8c;
  --danger: #ff6f91;
  --shadow: 0 22px 55px rgba(88, 73, 150, 0.16);
}

html {
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 153, 204, 0.28), transparent 32%),
    radial-gradient(circle at 92% 15%, rgba(102, 224, 213, 0.34), transparent 34%),
    linear-gradient(155deg, #fff9fc 0%, #f3f0ff 48%, #edfff8 100%);
}

.ambient {
  opacity: 0.3;
  filter: blur(76px);
}

.ambient-one { background: #68e8cf; }
.ambient-two { background: #ff9bc8; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-button,
.icon-button {
  border: 1px solid rgba(117, 91, 187, 0.14);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 24px rgba(92, 74, 152, 0.1);
}

.record-button {
  display: flex;
  min-width: 58px;
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 13px;
  border-radius: 16px;
  color: #6d52d9;
  cursor: pointer;
}

.record-button span {
  color: #ffb53f;
  filter: drop-shadow(0 3px 5px rgba(255, 181, 63, 0.3));
}

.eyebrow,
.modal-kicker { color: #7659dc; }

h1,
.modal h2 {
  font-family: inherit;
  font-weight: 900;
  letter-spacing: -0.055em;
}

h1 span {
  color: #ff659f;
  font-style: normal;
}

.status-card {
  border-color: rgba(114, 88, 194, 0.12);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 14px 36px rgba(99, 79, 163, 0.11);
}

.status-center { border-color: rgba(110, 92, 166, 0.12); }
.status-item small { color: #8d83a7; }
#bestStarsLabel { color: #ffad32; letter-spacing: 0.02em; }

.coach {
  background: rgba(255, 255, 255, 0.68);
  color: #5e5875;
  box-shadow: 0 8px 24px rgba(95, 77, 153, 0.07);
}

.garden-frame {
  border: 1px solid rgba(122, 91, 204, 0.15);
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 159, 203, 0.24), transparent 32%),
    radial-gradient(circle at 88% 90%, rgba(69, 219, 190, 0.25), transparent 34%),
    rgba(255, 255, 255, 0.68);
  box-shadow: 0 24px 55px rgba(94, 72, 157, 0.16), inset 0 1px rgba(255, 255, 255, 0.9);
}

.frame-glow {
  background: rgba(255, 190, 95, 0.2);
}

.tile {
  border-color: rgba(62, 167, 139, 0.12);
  box-shadow: inset 0 -7px 16px rgba(58, 125, 102, 0.06), 0 7px 15px rgba(71, 123, 106, 0.08);
}

.tile.powered {
  box-shadow: inset 0 -6px 15px rgba(35, 184, 145, 0.05), 0 0 22px rgba(36, 209, 160, 0.18);
}

.tile.powered::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(105deg, #29cfa1 5%, #9bffe2 38%, #ffffff 50%, #63e9c5 62%, #29cfa1 95%) 0 0 / 220% 100%;
  -webkit-mask: var(--path-mask);
  mask: var(--path-mask);
  pointer-events: none;
  animation:
    flow-grow 520ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--flow-delay) both,
    flow-shimmer 1450ms linear calc(var(--flow-delay) + 520ms) infinite;
}

.tile.source::after {
  border-color: rgba(255, 174, 55, 0.78);
  background: linear-gradient(145deg, #fff5c7, #ffd56f);
  color: #ef8e00;
  box-shadow: 0 0 22px rgba(255, 178, 59, 0.42);
}

.tile.flower::after {
  border-color: #b7c8c3;
  background: #f6fffb;
  color: #9bb8af;
}

.tile.powered.flower::after {
  border-color: rgba(255, 104, 167, 0.55);
  background: linear-gradient(145deg, #fff1f8, #ffd0e5);
  color: #ff5a9c;
  box-shadow: 0 0 23px rgba(255, 99, 161, 0.34);
}

.tile.empty {
  background:
    radial-gradient(circle, rgba(126, 103, 190, 0.1) 0 2px, transparent 3px) 0 0 / 14px 14px,
    var(--soil-dark);
}

.legend { color: #77708d; }
.legend-flower { color: #ff5a9c; }

.controls button {
  border-color: rgba(117, 91, 187, 0.13);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 9px 22px rgba(83, 65, 139, 0.08);
}

.controls .primary-control,
.modal-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #7959e8, #a66cf0 52%, #ff6da9);
  color: #fff;
  box-shadow: 0 12px 27px rgba(119, 81, 218, 0.25);
}

.modal {
  border-color: rgba(119, 91, 197, 0.15);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(65, 48, 116, 0.28);
}

.modal::backdrop {
  background: rgba(51, 40, 83, 0.34);
  backdrop-filter: blur(8px);
}

.modal p,
.modal li { color: #625c77; }
.setting-row { border-color: rgba(112, 92, 168, 0.11); }
.setting-row input { accent-color: #7959e8; }

.bloom-emblem {
  border-color: rgba(255, 99, 161, 0.32);
  background: radial-gradient(circle at 35% 30%, #ffffff, #ffd3e5 55%, #c9b9ff);
  color: #ff599b;
  box-shadow: 0 0 45px rgba(255, 104, 166, 0.23);
}

.reward-line {
  background: linear-gradient(110deg, #fff7da, #fff2f8);
  color: #756b86;
}

.result-stars {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 8px 0 4px;
  font-size: 2.7rem;
}

.result-stars span {
  display: inline-block;
  animation: star-pop 560ms cubic-bezier(0.2, 1.3, 0.25, 1) var(--star-delay) both;
}

.result-stars .earned {
  color: #ffb229;
  filter: drop-shadow(0 7px 9px rgba(255, 174, 41, 0.32));
}

.result-stars .empty { color: #ded9e9; }

.best-record {
  min-height: 20px;
  color: #7a58df !important;
  font-size: 0.78rem !important;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.record-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 15px 17px;
  border-radius: 18px;
  background: linear-gradient(110deg, #fff3c7, #ffeaf4);
  color: #6f6683;
}

.record-summary strong { color: #7555d8; font-size: 1.25rem; }
.record-summary i { color: #ffad2e; font-style: normal; }

.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  max-height: 48svh;
  overflow: auto;
}

.stage-record {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid rgba(114, 90, 184, 0.12);
  border-radius: 16px;
  background: #faf9ff;
}

.stage-record b { color: #6a6380; font-size: 0.68rem; }
.stage-record span { color: #ffb12d; font-size: 1rem; letter-spacing: 0.02em; }
.stage-record.current {
  border-color: rgba(121, 89, 232, 0.4);
  background: linear-gradient(145deg, #f1ecff, #fff2f8);
  box-shadow: inset 0 0 0 2px rgba(121, 89, 232, 0.08);
}

.celebration-layer {
  position: fixed;
  z-index: 30;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.celebration-layer i {
  position: absolute;
  top: -24px;
  left: var(--x);
  width: 11px;
  height: 18px;
  border-radius: 70% 30% 70% 30%;
  background: var(--petal);
  opacity: 0;
}

.celebration-layer.active i {
  animation: petal-fall 1450ms cubic-bezier(0.15, 0.7, 0.3, 1) var(--delay) both;
}

.board.cleared {
  animation: board-celebrate 700ms cubic-bezier(0.2, 1.1, 0.25, 1);
}

@keyframes flow-grow {
  from { opacity: 0; clip-path: circle(0 at 50% 50%); }
  to { opacity: 1; clip-path: circle(74% at 50% 50%); }
}

@keyframes flow-shimmer {
  from { background-position: 110% 0; }
  to { background-position: -110% 0; }
}

@keyframes star-pop {
  from { opacity: 0; transform: scale(0.2) rotate(-35deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes petal-fall {
  0% { opacity: 0; transform: translate3d(0, -20px, 0) rotate(0); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift), 105vh, 0) rotate(560deg); }
}

@keyframes board-celebrate {
  0% { transform: scale(1); }
  45% { transform: scale(1.025); filter: saturate(1.35) brightness(1.08); }
  100% { transform: scale(1); }
}
