:root {
  --ink: #25302c;
  --muted: #6b766f;
  --paper: rgba(255, 253, 244, 0.78);
  --line: rgba(62, 74, 67, 0.18);
  --accent: #6fa886;
  --accent-strong: #3f7f65;
  --sun-a: #dff4fb;
  --sun-b: #f8eec9;
  --sun-c: #efb083;
  --phase: #6fa886;
  --phase-bright: #cfe9d8;
  --phase-soft: rgba(111, 168, 134, 0.22);
  --sun-x: 22%;
  --sun-y: 18%;
  --plant-bottom: clamp(12px, 2.4vh, 30px);
  --soil-bottom: clamp(8px, 1.8vh, 24px);
  --biome-scale: 1;
  --biome-position: left bottom;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #dff4fb;
  transition: background 900ms linear;
  user-select: none;
  touch-action: manipulation;
}

.game-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 430px);
  align-items: stretch;
}

.garden-stage {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  padding: 0;
}

.sky-layer {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent 50%);
  pointer-events: none;
}

.biome-layer {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--biome-position);
  image-rendering: pixelated;
  filter: saturate(0.96) brightness(1);
  transform: scale(var(--biome-scale));
  transition: opacity 420ms ease, filter 900ms linear;
}

.sun-sprite {
  position: absolute;
  left: var(--sun-x);
  top: var(--sun-y);
  z-index: 0;
  width: clamp(148px, 22vw, 260px);
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 42px rgba(246, 172, 54, 0.38));
  transform: translate(-50%, -50%);
  transition: left 900ms linear, top 900ms linear, filter 900ms linear, opacity 900ms linear;
  pointer-events: none;
}

.hills {
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: 16vh;
  height: 24vh;
  min-height: 120px;
  background: linear-gradient(180deg, transparent, rgba(43, 65, 42, 0.14));
  pointer-events: none;
}

#plantCanvas,
#finalCanvas {
  position: relative;
  z-index: 1;
  width: min(52vmin, 360px);
  height: min(52vmin, 360px);
  image-rendering: pixelated;
  transform-origin: 50% 84%;
  filter: saturate(0.96);
}

#plantCanvas {
  position: absolute;
  left: 50%;
  bottom: var(--plant-bottom);
  transform: translateX(-50%);
}

#plantCanvas.inhaling {
  filter: brightness(1.12) saturate(1.1) drop-shadow(0 0 24px rgba(255, 238, 154, 0.36));
}

#plantCanvas.exhaling {
  filter: saturate(1.02) drop-shadow(0 10px 20px rgba(70, 78, 65, 0.16));
}

.soil {
  position: absolute;
  left: 50%;
  bottom: var(--soil-bottom);
  width: min(22vw, 220px);
  height: 26px;
  background:
    radial-gradient(ellipse at center, rgba(31, 22, 17, 0.2), rgba(31, 22, 17, 0.03) 58%, transparent 72%);
  border-radius: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.control-panel {
  display: flex;
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  min-height: 100vh;
  padding: clamp(22px, 5vw, 48px);
  background: var(--paper);
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(18px);
}

.top-bar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.header-tools {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.language-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: 86px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.38);
}

.language-choice {
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.language-choice.active {
  color: #f7fff9;
  background: var(--accent-strong);
}

.audio-toggle {
  min-height: 28px;
  width: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 900;
  cursor: pointer;
}

.audio-toggle.active {
  color: #f7fff9;
  background: linear-gradient(180deg, #6f9f83, #3f7f65);
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(51, 119, 87, 0.18);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.timer {
  flex: 0 0 auto;
  min-width: 86px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
  font-size: 1.22rem;
  font-weight: 800;
  text-align: center;
}

.breath-area {
  display: grid;
  place-items: center;
  min-height: 220px;
}

.breath-orb {
  --orb-scale: 0.74;
  width: 190px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 50%;
  color: #244337;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.94), transparent 27%),
    radial-gradient(circle, var(--phase-bright), var(--phase-soft) 62%, rgba(99, 156, 127, 0.1));
  box-shadow:
    0 0 0 1px rgba(73, 117, 94, 0.12),
    0 0 0 14px var(--phase-soft),
    0 24px 80px rgba(58, 99, 78, 0.22);
  cursor: default;
  transform: scale(var(--orb-scale));
  transition: filter 180ms ease;
}

.breath-orb::before {
  content: "";
  position: absolute;
  inset: -18px;
  border: 2px solid var(--phase);
  border-radius: 50%;
  opacity: 0.36;
  transform: scale(calc(var(--orb-scale) * 0.98));
}

.phase-kicker,
.phase-main,
.phase-time {
  position: relative;
  z-index: 1;
  width: 104px;
  text-align: center;
  pointer-events: none;
}

.phase-kicker {
  color: rgba(36, 67, 55, 0.72);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.phase-main {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.16;
}

.phase-time {
  font-size: 1.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.breath-orb:active {
  filter: none;
}

.is-holding .breath-orb::before {
  opacity: 0.52;
  border-style: dashed;
}

.is-holding .breath-orb {
  box-shadow:
    0 0 0 1px rgba(73, 117, 94, 0.12),
    0 0 0 10px var(--phase-soft),
    0 24px 70px rgba(58, 73, 99, 0.18);
}

.start-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #f7fff9;
  background: linear-gradient(180deg, #4f946f, #347759);
  box-shadow: 0 14px 34px rgba(52, 119, 89, 0.22);
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}

.start-button[hidden] {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.43);
}

.stats-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.stats-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
}

.progress-wrap {
  display: grid;
  gap: 10px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(78, 88, 80, 0.14);
}

#progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #87b878, #e8c45b, #cc8b79);
  transition: width 220ms ease;
}

.stage-dots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.stage-dots span {
  height: 8px;
  border-radius: 99px;
  background: rgba(58, 76, 66, 0.16);
}

.stage-dots span.active {
  background: var(--accent-strong);
}

.plant-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.plant-choice,
#restartButton {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.4);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.plant-choice.active,
#restartButton {
  color: #f7fff9;
  background: var(--accent-strong);
  border-color: transparent;
}

.finish-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 24px;
  color: var(--ink);
  background: rgba(255, 248, 226, 0.9);
  text-align: center;
  backdrop-filter: blur(12px);
}

.finish-screen[hidden] {
  display: none;
}

.finish-screen h2 {
  max-width: 520px;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.finish-screen p {
  color: var(--muted);
  font-weight: 800;
}

#restartButton {
  padding: 0 20px;
}

@media (max-width: 820px) {
  html,
  body {
    height: 100%;
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 55svh) minmax(0, 45svh);
    height: 100svh;
    min-height: 100svh;
  }

  .garden-stage {
    min-height: 0;
    height: 55svh;
  }

  .biome-layer {
    object-position: var(--biome-position);
    transform: scale(var(--biome-scale));
  }

  .sun-sprite {
    width: clamp(110px, 34vw, 190px);
  }

  #plantCanvas {
    width: min(44vmin, 212px);
    height: min(44vmin, 212px);
    bottom: var(--plant-bottom);
  }

  .soil {
    bottom: var(--soil-bottom);
    width: min(26vw, 150px);
    height: 18px;
  }

  .control-panel {
    min-height: 0;
    height: 45svh;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    justify-content: start;
    gap: 8px;
    padding: 12px 14px;
    overflow: visible;
  }

  .top-bar {
    align-items: center;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  h1 {
    font-size: clamp(1.5rem, 7vw, 2.3rem);
  }

  .timer {
    min-width: 76px;
    padding: 7px 9px;
    font-size: 1rem;
  }

  .breath-area {
    min-height: 96px;
  }

  .breath-orb {
    width: 102px;
  }

  .breath-orb::before {
    inset: -10px;
  }

  .phase-kicker {
    font-size: 0.62rem;
  }

  .phase-main {
    font-size: 0.84rem;
  }

  .phase-time {
    font-size: 1.15rem;
  }

  .start-button,
  .plant-choice,
  #restartButton {
    min-height: 32px;
    font-size: 0.82rem;
  }

  .stats-grid {
    gap: 6px;
  }

  .stats-grid div {
    padding: 7px;
  }

  .stats-grid span {
    margin-bottom: 2px;
    font-size: 0.66rem;
  }

  .stats-grid strong {
    font-size: 0.92rem;
  }

  .progress-wrap {
    gap: 5px;
  }

  .progress-track {
    height: 8px;
  }

  .stage-dots {
    gap: 4px;
  }

  .stage-dots span {
    height: 6px;
  }

  .plant-picker {
    gap: 6px;
  }

  .plant-choice {
    padding: 0 6px;
    white-space: nowrap;
  }
}

@media (max-width: 430px) {
  .game-shell {
    grid-template-rows: minmax(0, 52svh) minmax(0, 48svh);
  }

  .garden-stage {
    height: 52svh;
  }

  .control-panel {
    height: 48svh;
    gap: 7px;
    padding: 8px 10px 10px;
  }

  .biome-layer {
    object-position: var(--biome-position);
    transform: scale(var(--biome-scale));
  }

  .sun-sprite {
    width: clamp(96px, 32vw, 150px);
  }

  #plantCanvas {
    width: min(38vmin, 170px);
    height: min(38vmin, 170px);
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(1.25rem, 6vw, 1.75rem);
  }

  .language-choice {
    min-height: 22px;
    font-size: 0.66rem;
  }

  .audio-toggle {
    width: 100%;
    min-height: 24px;
    font-size: 0.64rem;
  }

  .timer {
    min-width: 70px;
    padding: 6px 7px;
    font-size: 0.92rem;
  }

  .breath-area {
    min-height: 82px;
  }

  .breath-orb {
    width: 88px;
  }

  .breath-orb::before {
    inset: -8px;
  }

  .phase-main {
    font-size: 0.78rem;
  }

  .phase-time {
    font-size: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .stats-grid div {
    padding: 6px 5px;
  }

  .stats-grid span {
    font-size: 0.6rem;
  }

  .stats-grid strong {
    font-size: 0.82rem;
  }

  .plant-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .top-bar {
    align-items: center;
    flex-direction: row;
  }

  .header-tools {
    justify-items: stretch;
  }

  .language-picker {
    width: 100%;
  }

  .timer {
    width: auto;
  }

  .start-button,
  .plant-choice {
    min-height: 30px;
    padding: 0 4px;
    font-size: 0.74rem;
  }

  .progress-track {
    height: 7px;
  }

  .stage-dots span {
    height: 5px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .game-shell {
    height: 100svh;
    min-height: 100svh;
    grid-template-columns: minmax(0, 1fr) clamp(286px, 36vw, 360px);
  }

  .garden-stage {
    min-height: 100svh;
  }

  .biome-layer {
    object-position: var(--biome-position);
    transform: scale(var(--biome-scale));
  }

  .sun-sprite {
    width: clamp(112px, 18vw, 170px);
  }

  #plantCanvas {
    width: min(54vmin, 232px);
    height: min(54vmin, 232px);
    bottom: var(--plant-bottom);
  }

  .soil {
    bottom: var(--soil-bottom);
    width: min(20vw, 160px);
    height: 18px;
  }

  .control-panel {
    min-height: 100svh;
    gap: 8px;
    padding: 10px 12px;
    overflow: hidden;
  }

  .top-bar {
    gap: 10px;
  }

  .eyebrow {
    font-size: 0.66rem;
  }

  h1 {
    font-size: clamp(1.35rem, 4vw, 1.9rem);
  }

  .header-tools {
    gap: 5px;
  }

  .language-picker {
    width: 74px;
    padding: 2px;
  }

  .language-choice {
    min-height: 23px;
    font-size: 0.68rem;
  }

  .audio-toggle {
    width: 74px;
    min-height: 24px;
    font-size: 0.62rem;
  }

  .timer {
    min-width: 74px;
    padding: 7px 8px;
    font-size: 0.98rem;
  }

  .breath-area {
    min-height: 108px;
  }

  .breath-orb {
    width: 112px;
  }

  .breath-orb::before {
    inset: -10px;
  }

  .phase-kicker {
    font-size: 0.62rem;
  }

  .phase-main {
    font-size: 0.82rem;
  }

  .phase-time {
    font-size: 1.1rem;
  }

  .start-button,
  .plant-choice,
  #restartButton {
    min-height: 34px;
    font-size: 0.82rem;
  }

  .stats-grid {
    gap: 6px;
  }

  .stats-grid div {
    padding: 7px;
  }

  .stats-grid span {
    margin-bottom: 2px;
    font-size: 0.66rem;
  }

  .stats-grid strong {
    font-size: 0.92rem;
  }

  .progress-wrap {
    gap: 6px;
  }

  .progress-track {
    height: 8px;
  }

  .stage-dots {
    gap: 4px;
  }

  .stage-dots span {
    height: 6px;
  }

  .plant-picker {
    gap: 6px;
  }
}
