*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --green-950: #0a1f12;
  --green-900: #0f2918;
  --green-800: #163d24;
  --green-700: #1f5232;
  --green-600: #2a6b3f;
  --green-500: #3d8f52;
  --green-400: #5cb36a;
  --gold-700: #8a6a1a;
  --gold-500: #c9a227;
  --gold-400: #e3bc3a;
  --gold-300: #f0d060;
  --cream: #f4f1e6;
  --muted: rgba(244, 241, 230, 0.65);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --fab-clearance: 3.35rem;
}

html {
  /* Fluid type: small screens tighter, desktop readable. */
  font-size: clamp(13px, 0.7vw + 10px, 16px);
  min-height: 100%;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--green-950);
  background-image:
    radial-gradient(ellipse 140% 100% at 50% 0%, var(--green-800) 0%, transparent 55%),
    linear-gradient(180deg, var(--green-900) 0%, var(--green-950) 100%);
  color: var(--cream);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  padding-top: calc(var(--safe-top) + clamp(0.16rem, 0.35vw, 0.28rem));
  padding-right: max(clamp(0.38rem, 0.6vw, 0.85rem), var(--safe-right));
  padding-bottom: calc(var(--safe-bottom) + clamp(0.35rem, 0.7vw, 0.85rem) + var(--fab-clearance));
  padding-left: max(clamp(0.38rem, 0.6vw, 0.85rem), var(--safe-left));
}

.app {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  /* Compact centered layout on desktop, full-bleed on small screens. */
  max-width: min(1120px, 100%);
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 0.28rem;
  flex-shrink: 0;
}

.fb-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  margin-top: 0.28rem;
  padding: 0.22rem 0.2rem;
  min-width: 0;
}

.fb-auth-welcome {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--gold-300);
}

.fb-auth-logout {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.32rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(15, 41, 24, 0.75);
  color: var(--cream);
  cursor: pointer;
}

.fb-auth-logout:active {
  background: rgba(22, 61, 36, 0.85);
}

.fb-login-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--cream);
  min-height: 44px;
  padding: 0.42rem 1.2rem 0.42rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(227, 188, 58, 0.45);
  background: linear-gradient(
    165deg,
    rgba(61, 143, 82, 0.42) 0%,
    rgba(22, 61, 36, 0.88) 42%,
    rgba(10, 31, 18, 0.96) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    0 2px 12px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition:
    filter 0.15s ease,
    transform 0.08s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.fb-login-pill:hover:not(:disabled) {
  filter: brightness(1.07);
  border-color: rgba(240, 208, 96, 0.65);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 3px 14px rgba(0, 0, 0, 0.42);
}

.fb-login-pill:active:not(:disabled) {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.fb-login-pill:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 3px;
}

.fb-login-pill:disabled {
  opacity: 0.5;
  cursor: wait;
}

.fb-login-pill__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #fff;
  color: #1877f2;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.fb-login-pill__svg {
  width: 1.02rem;
  height: 1.02rem;
  display: block;
}

.fb-login-pill__text {
  line-height: 1.25;
  padding-right: 0.15rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

#fb-logged-in-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

#fb-logged-in-wrap[hidden] {
  display: none;
}

.header--compact .title {
  font-size: clamp(0.46rem, 3.35vw, 0.68rem);
}

.header--compact .tagline {
  font-size: clamp(0.3rem, 2.5vw, 0.4rem);
  margin-top: 0.25rem;
}

.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  margin-bottom: 0.28rem;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.title-block {
  flex: 1 1 auto;
  min-width: 0;
  max-width: min(100%, 19rem);
}

.title {
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: clamp(0.54rem, 4vw, 0.75rem);
  color: var(--gold-300);
  text-shadow: 2px 2px 0 var(--green-950);
  margin: 0;
  line-height: 1.55;
  letter-spacing: 0.02em;
}

.title-sub {
  margin: 0.28rem 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--green-400);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pixel-garden {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: clamp(4rem, 14vw, 5.75rem);
  flex-shrink: 0;
  padding: 4px 2px 2px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(22, 61, 36, 0.55) 0%, rgba(10, 31, 18, 0.35) 100%);
  border: 1px solid rgba(201, 162, 39, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 3px 10px rgba(0, 0, 0, 0.28);
}

.pixel-grass {
  width: 100%;
  height: 16px;
  image-rendering: pixelated;
  background: repeating-linear-gradient(
    90deg,
    #1a4d2a 0 4px,
    #2d6a3e 4px 8px,
    #245c33 8px 12px,
    #3d8f52 12px 16px
  );
  border-bottom: 3px solid #0f2918;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.06),
    0 2px 0 rgba(0, 0, 0, 0.35);
}

.pixel-flowers {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 3px 0 4px;
}

.fl {
  display: inline-block;
  width: 8px;
  height: 8px;
  image-rendering: pixelated;
  box-shadow:
    0 -5px 0 0 currentColor,
    -4px -3px 0 0 currentColor,
    4px -3px 0 0 currentColor;
  position: relative;
  top: 3px;
  color: #2d5016;
}

.fl::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 2px;
  height: 5px;
  background: #1f3d1a;
}

.fl--r {
  color: #c42d2d;
}

.fl--y {
  color: #e6c82e;
}

.fl--w {
  color: #f5f0e6;
}

.tagline {
  margin: 0 auto;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: clamp(0.36rem, 3.1vw, 0.48rem);
  color: var(--muted);
  line-height: 1.75;
  max-width: 38em;
}

.howto {
  background: rgba(15, 41, 24, 0.55);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 8px;
  padding: 0.22rem 0.35rem 0.28rem;
  margin-bottom: 0.22rem;
  flex-shrink: 0;
}

.howto-heading {
  margin: 0 0 0.22rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--gold-400);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
}

.howto-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.28rem;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.howto-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  flex: 0 0 auto;
  width: 4.35rem;
  min-width: 4.35rem;
  scroll-snap-align: start;
  font-size: 0.62rem;
  color: var(--cream);
  text-align: center;
  line-height: 1.2;
}

.howto-icon {
  width: 1.85rem;
  height: 1.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, var(--green-700) 0%, var(--green-800) 55%, #0f2918 100%);
  border-radius: 6px;
  color: var(--gold-400);
  border: 1px solid rgba(201, 162, 39, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.35);
}

.howto-icon svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  stroke: var(--gold-300);
  fill: none;
}

.howto-icon .lucide {
  width: 1rem;
  height: 1rem;
}

.howto-text strong {
  color: var(--gold-300);
  font-weight: 700;
  display: block;
  font-size: 0.62rem;
  margin-bottom: 0.04rem;
}

.game-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 0 0 0.28rem;
  position: relative;
  z-index: 0;
}

.game-stage-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  padding: 0.32rem 0.4rem;
  border-radius: 10px;
  background: rgba(22, 61, 36, 0.5);
  border: 1px solid rgba(92, 179, 106, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 10px rgba(0, 0, 0, 0.28);
  overflow: visible;
  isolation: isolate;
}

.movement-strip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.22rem 0.28rem 0.32rem;
  background: rgba(10, 31, 18, 0.35);
  border-bottom: 1px solid rgba(92, 179, 106, 0.22);
}

.movement-strip .nudge-shell {
  margin: 0 auto;
}

.bottom-chrome {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  padding-top: 0.32rem;
  padding-bottom: max(0.45rem, env(safe-area-inset-bottom, 0px));
  position: relative;
  z-index: 2;
  background-color: var(--green-950);
  background-image: linear-gradient(180deg, rgba(22, 61, 36, 0.45) 0%, var(--green-950) 50%);
  border-top: 1px solid rgba(201, 162, 39, 0.22);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
}

.controls-options {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  min-width: 0;
  width: 100%;
}

.free-estimate-btn {
  position: fixed;
  left: max(0.5rem, var(--safe-left));
  bottom: max(0.65rem, calc(var(--safe-bottom) + 0.15rem));
  z-index: 80;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: clamp(0.28rem, 2.2vw, 0.38rem);
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-align: center;
  color: var(--green-950);
  padding: 0.55rem 0.75rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: min(12.5rem, calc(100vw - var(--safe-left) - var(--safe-right) - 1rem));
  border-radius: 10px;
  border: 2px solid rgba(10, 31, 18, 0.85);
  background: linear-gradient(165deg, var(--gold-300) 0%, var(--gold-500) 45%, var(--gold-700) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 4px 14px rgba(0, 0, 0, 0.45);
  transition: filter 0.12s ease, transform 0.08s ease;
}

.free-estimate-btn:hover {
  filter: brightness(1.06);
}

.free-estimate-btn:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.mode-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.28rem 0.38rem;
  margin-bottom: 0;
  font-size: 0.78rem;
}

.mode-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
}

.mode-pill {
  background: linear-gradient(180deg, var(--gold-400) 0%, var(--gold-700) 100%);
  color: var(--green-950);
  font-weight: 800;
  font-size: 0.76rem;
  padding: 0.3rem 0.62rem;
  border-radius: 999px;
  min-width: 4.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.25);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  margin-bottom: 0;
}

.tool-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.tool-btn {
  font-family: inherit;
  min-height: 44px;
  padding: 0.38rem 0.32rem;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.25);
  background: var(--green-800);
  color: var(--cream);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.tool-btn:active {
  transform: scale(0.98);
}

.tool-btn.active {
  background: var(--green-600);
  border-color: var(--gold-500);
  box-shadow: 0 0 0 2px rgba(227, 188, 58, 0.25);
}

.tool-emoji {
  font-size: 1.2rem;
  line-height: 1;
}

.tool-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold-300);
}

.tool-btn.active .tool-name {
  color: var(--cream);
}

.progress-block {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.35rem;
}

.progress-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-400);
}

.progress-track {
  height: 11px;
  background: var(--green-950);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(201, 162, 39, 0.3);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-700) 0%, var(--gold-400) 45%, var(--gold-300) 100%);
  transition: width 0.15s ease-out;
}

.progress-pct {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--gold-300);
  min-width: 2.35rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn-icon-text {
  font-family: inherit;
  min-height: 42px;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--gold-500);
  background: transparent;
  color: var(--gold-300);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-icon-text:active {
  background: rgba(201, 162, 39, 0.12);
}

.btn-ico {
  font-size: 1.25rem;
  line-height: 1;
}

.scene-sep {
  color: var(--muted);
  font-weight: 700;
  padding: 0 0.15rem;
}

.scene-pill {
  background: rgba(61, 143, 82, 0.35);
  border: 1px solid rgba(201, 162, 39, 0.45);
  color: var(--gold-300);
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 7px;
  font-size: 0.72rem;
  min-width: 4.25rem;
  text-align: center;
}

.scene-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.32rem;
  padding: 0.08rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.scene-btn {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.38rem 0.62rem;
  min-height: 40px;
  border-radius: 10px;
  border: 2px solid rgba(201, 162, 39, 0.35);
  background: linear-gradient(180deg, rgba(31, 82, 50, 0.5) 0%, rgba(15, 41, 24, 0.85) 100%);
  color: var(--cream);
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.scene-btn:hover {
  border-color: var(--gold-500);
  color: var(--gold-300);
}

.scene-btn.active {
  background: linear-gradient(180deg, var(--gold-300) 0%, var(--gold-700) 100%);
  color: var(--green-950);
  border-color: rgba(10, 31, 18, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 0 rgba(0, 0, 0, 0.2);
}

.canvas-wrap {
  position: relative;
  z-index: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(244, 241, 230, 0.14);
  background: var(--green-950);
  line-height: 0;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  aspect-ratio: 720 / 480;
  box-sizing: border-box;
  width: auto;
  height: auto;
  max-width: min(100%, 99vw, 980px);
  max-height: min(100%, 72dvh);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  align-self: center;
  backface-visibility: hidden;
  transform: translateZ(0);
  transform-origin: center;
  will-change: transform;
}

@media (max-width: 600px) {
  .canvas-wrap {
    max-width: 100%;
    max-height: min(100%, 62dvh, 68vh);
    box-shadow:
      0 4px 14px rgba(0, 0, 0, 0.32),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
}

#game {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  vertical-align: middle;
  touch-action: none;
}

.hint {
  position: absolute;
  bottom: 0.45rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(244, 241, 230, 0.95);
  text-shadow: 0 1px 3px var(--green-950);
  pointer-events: none;
  text-align: center;
  max-width: 94%;
  padding: 0.3rem 0.55rem;
  background: rgba(10, 31, 18, 0.62);
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.2);
}

.hint.hidden {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.nudge-shell {
  width: 100%;
  max-width: 232px;
  padding: 0.38rem 0.48rem 0.42rem;
  border-radius: 16px;
  background: linear-gradient(165deg, #1a3d28 0%, #0f2918 42%, #0a1810 100%);
  border: 1px solid rgba(201, 162, 39, 0.38);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.07),
    inset 0 -3px 10px rgba(0, 0, 0, 0.35),
    0 6px 18px rgba(0, 0, 0, 0.4);
}

.nudge-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  touch-action: manipulation;
  user-select: none;
  aspect-ratio: 1;
  max-height: min(156px, 42vw, 28dvh);
  margin: 0 auto;
}

.nudge-spacer {
  pointer-events: none;
}

.nudge-center {
  border-radius: 12px;
  background: radial-gradient(ellipse at 35% 30%, rgba(61, 143, 82, 0.45) 0%, rgba(15, 41, 24, 0.95) 65%);
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nudge-center-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold-300) 0%, var(--gold-700) 70%);
  box-shadow:
    0 0 0 2px rgba(10, 31, 18, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.nudge-arrow {
  display: block;
  font-size: 0.92rem;
  line-height: 1;
  font-family: system-ui, sans-serif;
  font-weight: 800;
  color: #1a1208;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}

.nudge-btn {
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 44px;
  font-family: inherit;
  color: var(--green-950);
  background: linear-gradient(155deg, #f2e6a8 0%, var(--gold-400) 28%, var(--gold-500) 52%, var(--gold-700) 100%);
  border: 2px solid #1f140a;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18),
    0 4px 0 #0a0a0a,
    0 5px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.08s ease;
}

.nudge-btn:hover {
  filter: brightness(1.05);
}

.nudge-btn:active,
.nudge-btn.is-pressed {
  transform: translateY(3px);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.25),
    0 1px 0 #0a0a0a,
    0 2px 6px rgba(0, 0, 0, 0.3);
  filter: brightness(0.94);
}

.nudge-btn--up {
  border-radius: 12px 12px 10px 10px;
}

.nudge-btn--down {
  border-radius: 10px 10px 12px 12px;
}

.nudge-btn--side {
  border-radius: 11px;
}

.kb-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0;
}

.message {
  text-align: center;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--gold-300);
  min-height: 1.15em;
  margin: 0;
}

.celebration {
  position: fixed;
  inset: 0;
  background: rgba(10, 31, 18, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.celebration[hidden] {
  display: none;
}

.celebration-box {
  background: var(--green-800);
  border: 1px solid var(--gold-500);
  border-radius: 14px;
  padding: 1.25rem 1rem;
  text-align: center;
  max-width: 18rem;
}

.celebration-title {
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.68rem;
  color: var(--gold-300);
  margin: 0 0 0.65rem;
  line-height: 1.6;
}

.celebration-text {
  font-size: 1rem;
  color: var(--cream);
  margin: 0 0 1rem;
}

@media (min-width: 600px) {
  body {
    padding-left: max(1rem, var(--safe-left));
    padding-right: max(1rem, var(--safe-right));
  }

  .canvas-wrap {
    max-width: min(100%, 98vw, 1000px);
    max-height: min(100%, 84dvh, calc(100dvh - 9.25rem));
  }

  .howto-list {
    flex-wrap: nowrap;
    justify-content: center;
    overflow-x: visible;
  }

  .howto-item {
    width: 4.45rem;
    min-width: 4.45rem;
  }

  .nudge-shell {
    max-width: 240px;
  }
}

@media (min-width: 900px) {
  .controls-options .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 0.85rem;
  }

  .controls-options .toolbar .tool-group {
    flex: 0 0 auto;
    min-width: 11rem;
  }

  .controls-options .toolbar .progress-block {
    flex: 1 1 12rem;
    max-width: 18rem;
    min-width: 10rem;
  }

  .controls-options .toolbar .btn-icon-text {
    flex: 0 0 auto;
  }
}

/* Phones — Chrome (Android) & Safari (iOS): safe areas, no overlap with FAB, tighter chrome */
@media (max-width: 640px) {
  :root {
    --fab-clearance: 3.5rem;
  }

  .header {
    margin-bottom: 0.22rem;
  }

  .title-row {
    gap: 0.22rem;
  }

  .pixel-garden {
    width: clamp(2.85rem, 9.5vw, 3.85rem);
    padding: 2px 1px 2px;
  }

  .howto {
    padding: 0.18rem 0.28rem 0.22rem;
    margin-bottom: 0.18rem;
  }

  .howto-heading {
    font-size: 0.58rem;
    margin-bottom: 0.15rem;
  }

  .howto-item {
    width: 3.95rem;
    min-width: 3.95rem;
    font-size: 0.56rem;
    gap: 0.12rem;
  }

  .howto-icon {
    width: 1.65rem;
    height: 1.65rem;
  }

  .howto-icon svg,
  .howto-icon .lucide {
    width: 0.9rem;
    height: 0.9rem;
  }

  .howto-text strong {
    font-size: 0.56rem;
  }

  .game-stage {
    padding: 0 0 0.2rem;
  }

  .game-stage-inner {
    padding: 0.25rem 0.25rem;
  }

  .canvas-wrap {
    max-width: 100%;
    max-height: min(100%, 58dvh, 64vh);
  }

  .hint {
    font-size: 0.62rem;
    padding: 0.15rem 0.32rem;
    bottom: 0.28rem;
  }

  .movement-strip {
    padding: 0.18rem 0.18rem 0.26rem;
  }

  .nudge-shell {
    max-width: min(216px, 82vw);
    padding: 0.32rem 0.38rem 0.36rem;
  }

  .nudge-pad {
    gap: 5px;
    max-height: min(138px, 34vw, 26dvh);
  }

  .nudge-btn {
    min-height: 40px;
  }

  .bottom-chrome {
    gap: 0.28rem;
    padding-top: 0.28rem;
    padding-bottom: max(0.38rem, calc(var(--safe-bottom) + 0.18rem));
  }

  .mode-bar {
    justify-content: center;
    font-size: 0.72rem;
  }

  .mode-label {
    font-size: 0.6rem;
  }

  .mode-pill {
    font-size: 0.7rem;
    padding: 0.26rem 0.55rem;
    min-width: 4.1rem;
  }

  .scene-pill {
    font-size: 0.66rem;
    min-width: 3.85rem;
    padding: 0.24rem 0.48rem;
  }

  .scene-bar {
    justify-content: center;
    gap: 0.28rem;
  }

  .scene-btn {
    font-size: 0.68rem;
    padding: 0.32rem 0.52rem;
    min-height: 38px;
  }

  .tool-btn {
    min-height: 42px;
    padding: 0.32rem 0.22rem;
  }

  .tool-name {
    font-size: 0.72rem;
  }

  .progress-label {
    font-size: 0.62rem;
  }

  .progress-pct {
    font-size: 0.7rem;
  }

  .btn-icon-text {
    min-height: 42px;
    font-size: 0.72rem;
    width: 100%;
  }

  .kb-hint {
    font-size: 0.65rem;
    padding: 0 0.2rem;
  }

  .message {
    font-size: 0.7rem;
    padding: 0 0.2rem;
  }

  .free-estimate-btn {
    font-size: clamp(0.28rem, 2.5vw, 0.34rem);
    padding: 0.45rem 0.55rem;
    max-width: min(11.5rem, calc(100vw - var(--safe-left) - var(--safe-right) - 0.75rem));
  }
}
