:root {
  --ink: #27201b;
  --muted: #75685f;
  --paper: #fffaf1;
  --line: #ded1be;
  --green: #6aa66a;
  --yellow: #e8b14d;
  --rose: #df7d86;
  --blue: #5d93ba;
  --floor: #d7e0c4;
  --wall: #f4dccd;
  --pet-render-scale: 4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(#f8eadc 0 62%, #cfdcb8 62% 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid #8b735d;
  border-radius: 8px;
  color: var(--ink);
  background: #fff6e8;
  box-shadow: 0 3px 0 #8b735d;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible {
  transform: translateY(-1px);
  background: #ffffff;
}

button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #8b735d;
}

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

.hidden {
  display: none !important;
}

.app-shell,
.game-screen {
  min-height: 100vh;
  min-height: 100dvh;
}

.start-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.start-panel {
  width: min(980px, 100%);
  padding: 26px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
  box-shadow: 0 24px 70px rgba(77, 54, 35, 0.18);
}

.start-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 0.95;
}

.name-form {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.name-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.name-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
}

.name-row button,
.actions button {
  min-width: 112px;
  padding: 12px 18px;
  font-weight: 900;
}

.pet-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 12px;
}

.pet-card {
  display: grid;
  place-items: center;
  min-height: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.pet-card[aria-pressed="true"] {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.pet-card img {
  width: 96px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
}

.pet-card span {
  margin-top: 8px;
  font-weight: 800;
}

.load-row {
  display: flex;
  justify-content: end;
  margin-top: 16px;
}

.game-screen {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.hud {
  position: relative;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding: 18px;
  pointer-events: none;
}

.stats-panel,
.file-actions,
.mode-toggle,
.decorate-panel,
.actions {
  pointer-events: auto;
}

.stats-panel {
  width: min(420px, calc(100vw - 36px));
  padding: 14px;
  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.9);
}

.pet-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.pet-title h2 {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.35rem;
}

#levelBadge {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 900;
}

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

.stat-meter {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
}

.stat-meter span {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.circle-meter {
  --stat-color: var(--yellow);
  --stat-fill: 20%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fffdf8 0 52%, transparent 54%),
    conic-gradient(var(--stat-color) var(--stat-fill), rgba(39, 32, 27, 0.12) 0);
  box-shadow: inset 0 0 0 1px rgba(39, 32, 27, 0.16);
}

.stat-meter.happiness .circle-meter {
  --stat-color: var(--yellow);
}

.stat-meter.hunger .circle-meter {
  --stat-color: var(--green);
}

.stat-meter.love .circle-meter {
  --stat-color: var(--rose);
}

.tier-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(39, 32, 27, 0.28);
  border-radius: 50%;
  color: var(--ink);
  background: #fffdf8;
  font-size: 0.95rem;
  font-style: normal;
  font-weight: 900;
}

.file-actions {
  position: relative;
  display: grid;
  justify-items: end;
  margin-left: auto;
}

.mode-toggle {
  position: absolute;
  top: 18px;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 210px;
  overflow: hidden;
  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.92);
  transform: translateX(-50%);
}

.mode-toggle.decorate-active {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 270px;
}

.mode-button {
  min-width: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-weight: 900;
}

.mode-button.active {
  background: rgba(106, 166, 106, 0.26);
}

.mode-button.remove-mode {
  color: #8f3d34;
}

.mode-button.remove-mode.active {
  background: rgba(209, 91, 80, 0.24);
}

.menu-button {
  display: grid;
  gap: 4px;
  place-items: center;
  width: 42px;
  height: 38px;
  padding: 8px;
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.file-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 12;
  display: grid;
  gap: 8px;
  width: 210px;
  padding: 10px;
  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.97);
  box-shadow: 0 14px 32px rgba(39, 32, 27, 0.18);
}

.file-menu .subtle-button {
  width: 100%;
  text-align: left;
}

.code-form {
  display: grid;
  gap: 5px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(139, 115, 93, 0.22);
}

.code-form label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr 54px;
  gap: 6px;
}

.code-row input {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.code-row .subtle-button {
  padding-inline: 8px;
  text-align: center;
}

.subtle-button {
  padding: 8px 11px;
  font-size: 0.85rem;
  font-weight: 800;
}

.danger {
  color: #8c2e2e;
}

.room {
  position: relative;
  overflow: hidden;
  min-height: 0;
  touch-action: none;
  user-select: none;
  --wall-color: #f3ddce;
  --ground-color: #cad8b2;
  --ground-start: 60%;
  background: var(--wall-color);
}

.room::before,
.room::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(96px, 24vw);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 14;
}

.room::before {
  left: 0;
  background: linear-gradient(90deg, rgba(36, 28, 22, 0.28), rgba(36, 28, 22, 0));
}

.room::after {
  right: 0;
  background: linear-gradient(270deg, rgba(36, 28, 22, 0.28), rgba(36, 28, 22, 0));
}

.room.edge-left::before,
.room.edge-right::after {
  opacity: 1;
}

.room-pan {
  display: none;
}

.pan-left {
  left: 10px;
}

.pan-right {
  right: 10px;
}

.pet-indicator {
  position: absolute;
  z-index: 11;
  display: flex;
  gap: 4px;
  align-items: center;
  color: var(--ink);
  font-weight: 900;
  pointer-events: none;
}

.pet-indicator.left {
  left: 10px;
}

.pet-indicator.right {
  right: 10px;
  flex-direction: row-reverse;
}

.pet-indicator i {
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(139, 115, 93, 0.75);
  border-radius: 50%;
  background: rgba(255, 250, 241, 0.88);
}

.placement-grid {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: var(--grid-w, 24px) var(--grid-h, 18px);
}

.placement-cell {
  position: absolute;
  border: 2px solid rgba(39, 32, 27, 0.28);
  border-radius: 4px;
}

.placement-cell.valid {
  background: rgba(106, 166, 106, 0.45);
}

.placement-cell.invalid {
  background: rgba(223, 125, 134, 0.48);
}

.furniture-ghost {
  position: absolute;
  z-index: 12;
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0.82;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

.furniture-ghost.invalid {
  filter: saturate(0.8) sepia(0.25) hue-rotate(310deg);
  opacity: 0.58;
}

.decorate-mode .actions {
  display: none;
}

.decorate-panel {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 10px;
  width: min(680px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 0 0 max(20px, calc(env(safe-area-inset-bottom, 0px) + 14px));
}

.decorate-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.furniture-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.96);
}

.floor-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.96);
}

.floor-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.floor-solid-palette {
  grid-column: 1 / -1;
  position: relative;
}

.floor-solid-scroll {
  display: grid;
  grid-auto-columns: calc((100% - 56px) / 8);
  grid-auto-flow: column;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 0 1px 2px;
  scrollbar-width: none;
  touch-action: none;
  cursor: grab;
}

.floor-solid-scroll::-webkit-scrollbar {
  display: none;
}

.floor-solid-scroll.dragging {
  cursor: grabbing;
}

.floor-scroll-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 12px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 140ms ease;
}

.floor-scroll-left {
  left: -4px;
}

.floor-scroll-right {
  right: -4px;
}

.floor-scroll-left::before,
.floor-scroll-right::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.floor-scroll-left::before {
  border-right: 10px solid rgba(90, 74, 61, 0.72);
}

.floor-scroll-right::before {
  border-left: 10px solid rgba(90, 74, 61, 0.72);
}

.floor-solid-palette.can-scroll-left .floor-scroll-left,
.floor-solid-palette.can-scroll-right .floor-scroll-right {
  opacity: 1;
}

.floor-choice {
  display: grid;
  gap: 5px;
  place-items: center;
  min-height: 76px;
  padding: 7px;
  border: 1px solid rgba(139, 115, 93, 0.26);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
}

.floor-choice img,
.floor-choice i {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(139, 115, 93, 0.28);
  border-radius: 6px;
}

.floor-choice img {
  object-fit: cover;
  image-rendering: pixelated;
}

.floor-choice i {
  background: var(--floor-swatch, var(--ground-color));
}

.floor-choice.active {
  border-color: rgba(73, 139, 99, 0.72);
  background: rgba(218, 239, 220, 0.92);
}

.floor-solid-swatch {
  min-width: 0;
  min-height: 76px;
}

.furniture-categories,
.furniture-items {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.furniture-categories button,
.furniture-items button {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 8px;
  font-weight: 900;
}

.furniture-categories button.active,
.furniture-items button.active {
  background: rgba(106, 166, 106, 0.26);
}

.furniture-items button {
  display: grid;
  gap: 4px;
  place-items: center;
}

.furniture-items small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.furniture-items img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
}

.empty-furniture {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.decorate-tools button {
  min-width: 0;
  min-height: 46px;
  padding: 8px;
  font-weight: 900;
}

.color-editor {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.96);
}

.color-editor-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  min-width: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  font-weight: 900;
}

.color-wheel {
  width: 76px;
  height: 38px;
  padding: 2px;
}

.room.pet-hand {
  cursor: grab;
}

.room.pet-holding {
  cursor: grabbing;
}

.room-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
}

.room-zone {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  display: none;
}

.wall-zone {
  top: 0;
  bottom: calc(100% - var(--ground-start));
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px) 0 0 / 92px 92px,
    var(--wall-color);
}

.ground-zone {
  top: var(--ground-start);
  bottom: 0;
  background: var(--ground-color);
  border-top: 2px solid rgba(139, 115, 93, 0.22);
}

.pet-sprite {
  position: absolute;
  left: 50%;
  top: 76%;
  --foot-offset: 64px;
  width: clamp(184px, 28vw, 312px);
  height: clamp(144px, 22vw, 240px);
  object-fit: contain;
  image-rendering: pixelated;
  transform: translate(-50%, calc(-100% + var(--foot-offset)));
  transition: filter 180ms ease;
  user-select: none;
  display: none;
}

.pet-sprite.boost {
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.92));
}

.power-triangle {
  position: absolute;
  z-index: 6;
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: var(--power-length, 80px) solid var(--power-color, #6aa66a);
  opacity: 0.82;
  pointer-events: none;
  transform-origin: left center;
  filter: drop-shadow(0 4px 8px rgba(39, 32, 27, 0.22));
  display: none;
}

.play-ball {
  position: absolute;
  z-index: 7;
  width: 24px;
  height: 24px;
  border: 2px solid #8b735d;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #fff8b8 0 18%, transparent 19%),
    linear-gradient(135deg, #f05a55 0 48%, #ffffff 49% 56%, #5d93ba 57% 100%);
  box-shadow: 0 8px 16px rgba(39, 32, 27, 0.22);
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
}

.play-ball.thrown {
  z-index: 2;
  transform: translate(-50%, -50%);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 128px;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 8px;
  color: #fff;
  background: rgba(39, 32, 27, 0.78);
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.xp-popup,
.stat-popup,
.purr-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  color: #fff8e8;
  font-size: 1rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 0 #8b735d, 0 4px 12px rgba(39, 32, 27, 0.32);
  transform: translate(-50%, -50%);
}

.pet-hold-progress {
  position: absolute;
  z-index: 9;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 250, 241, 0.95) 0 48%, transparent 50%),
    conic-gradient(#ffffff var(--hold-progress, 0%), rgba(139, 115, 93, 0.22) 0);
  border: 2px solid rgba(139, 115, 93, 0.45);
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(39, 32, 27, 0.18);
}

.heart-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.heart {
  position: absolute;
  color: #ff6f91;
  font-size: 18px;
  font-weight: 900;
  opacity: 0;
  text-shadow: 0 2px 0 #fff8e8, 0 5px 12px rgba(39, 32, 27, 0.24);
  animation: heart-rise 900ms ease-out forwards;
}

@keyframes heart-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.75) rotate(var(--heart-angle, 0deg));
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -54px) scale(1.12) rotate(var(--heart-angle, 0deg));
  }
}

.purr-popup,
.stat-popup {
  color: #ffffff;
}

.xp-popup.visible,
.stat-popup.visible,
.purr-popup.visible {
  animation: xp-rise 900ms ease-out forwards;
}

@keyframes xp-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-40% + var(--pop-offset-y, 0px))) rotate(var(--pop-angle, 0deg));
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-150% + var(--pop-offset-y, 0px))) rotate(var(--pop-angle, 0deg));
  }
}

.actions {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: min(560px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 0 0 max(20px, calc(env(safe-area-inset-bottom, 0px) + 14px));
}

.toy-menu {
  position: absolute;
  left: var(--toy-menu-left, 50%);
  bottom: calc(100% + 8px);
  z-index: 8;

  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* exactly 2 columns */
  gap: 6px;

  width: min(320px, calc(100vw - 24px));
  max-height: 220px;
  padding: 8px;

  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;

  border: 2px solid rgba(139, 115, 93, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.96);
  box-shadow: 0 12px 26px rgba(68, 50, 38, 0.18);

  transform: translateX(-50%);
}

.toy-choice {
  display: grid;
  gap: 2px;
  place-items: center;
  min-width: 0;
  min-height: 54px;
  padding: 5px;
}

.toy-choice img,
.toy-random {
  width: 28px;
  height: 28px;
}

.toy-choice img {
  object-fit: contain;
  image-rendering: pixelated;
}

.toy-random {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
}

.toy-choice.active {
  border-color: rgba(73, 139, 99, 0.72);
  background: rgba(218, 239, 220, 0.92);
}

.actions button {
  position: relative;
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 58px;
  overflow: hidden;
}

.actions button > * {
  position: relative;
  z-index: 1;
}

.actions button.action-active {
  opacity: 1;
}

.actions button.action-active::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(106, 166, 106, 0.28);
  pointer-events: none;
}

.actions small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.confirm-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(39, 32, 27, 0.28);
}

.confirm-card {
  width: min(420px, 100%);
  padding: 18px;
  border: 2px solid rgba(139, 115, 93, 0.55);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.97);
  box-shadow: 0 18px 50px rgba(39, 32, 27, 0.2);
}

.confirm-card h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.confirm-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
  margin-top: 16px;
}

.recharge {
  position: absolute;
  top: 7px;
  left: 10px;
  right: 10px;
  z-index: 2;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(139, 115, 93, 0.18);
}

.recharge b {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 220ms linear;
}

@media (max-width: 720px) {
  :root {
    --pet-render-scale: 4;
  }

  body {
    overflow: hidden;
  }

  .start-screen {
    align-items: start;
    height: 100svh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-shell,
  .game-screen {
    height: 100svh;
    min-height: 100svh;
  }

  .start-panel {
    padding: 18px;
    margin-block: 12px;
  }

  .pet-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-bottom: 12px;
  }

  .pet-card {
    min-height: 112px;
  }

  .pet-card img {
    width: 84px;
    height: 64px;
  }

  .start-header,
  .hud {
    display: grid;
  }

  .hud {
    gap: 8px;
    padding: 10px 12px 8px;
  }

  .stats-panel {
    width: min(420px, calc(100vw - 24px));
    padding: 10px;
  }

  .mode-toggle {
    position: static;
    width: min(250px, 100%);
    transform: none;
  }

  .mode-toggle.decorate-active {
    width: min(310px, 100%);
  }

  .name-row {
    grid-template-columns: 1fr;
  }

  .name-row button {
    width: 100%;
  }

  .file-actions {
    justify-self: end;
  }

  .stat-meters {
    gap: 8px;
  }

  .circle-meter {
    width: 54px;
    height: 54px;
  }

  .tier-badge {
    width: 30px;
    height: 30px;
    font-size: 0.86rem;
  }

  .stat-meter span {
    font-size: 0.7rem;
  }

  .actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: min(420px, calc(100vw - 24px));
    padding-bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 14px));
  }

  .decorate-panel {
    width: min(420px, calc(100vw - 24px));
    padding-bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 14px));
  }

  .decorate-tools {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .decorate-tools button {
    min-height: 44px;
    padding: 7px 4px;
    font-size: 0.78rem;
  }

  .color-editor {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .color-wheel {
    width: 100%;
  }

  .actions button {
    min-width: 0;
    min-height: 46px;
    padding: 7px 4px;
    font-size: 0.86rem;
  }

  .actions small {
    font-size: 0.68rem;
  }

  .recharge {
    top: 2px;
    left: 6px;
    right: 6px;
  }
}
