:root {
  color-scheme: light;
  --bg: #f7eadf;
  --bg-deep: #efc3a4;
  --ink: #2d1d17;
  --accent: #d95d39;
  --accent-deep: #a83f22;
  --gold: #f3b94f;
  --teal: #2f7f79;
  --card: rgba(255, 247, 238, 0.82);
  --line: rgba(72, 31, 19, 0.14);
  --shadow: 0 20px 50px rgba(102, 49, 21, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.65), transparent 35%),
    linear-gradient(180deg, #f8efe4 0%, #f3d7c2 45%, #e9b593 100%);
}

body[data-ui-mode="game"] {
  overflow: hidden;
  touch-action: none;
}

body[data-ui-mode="menu"] {
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
}

body[data-health-open="true"] {
  overflow: hidden;
  touch-action: none;
}

.loading-screen,
.health-dialog,
.share-fallback-dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  z-index: 80;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 241, 215, 0.92), transparent 34%),
    linear-gradient(180deg, rgba(71, 34, 22, 0.26), rgba(71, 34, 22, 0.62));
}

.loading-screen {
  transition:
    opacity 220ms ease,
    visibility 220ms ease;
}

.loading-screen.is-hidden,
.health-dialog[aria-hidden="true"],
.share-fallback-dialog[aria-hidden="true"] {
  display: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-card,
.health-card,
.share-fallback-card {
  width: min(420px, 100%);
  border: 1px solid rgba(72, 31, 19, 0.12);
  border-radius: 24px;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(255, 185, 88, 0.26), transparent 32%),
    rgba(255, 248, 239, 0.96);
  box-shadow: 0 24px 60px rgba(72, 31, 19, 0.26);
  text-align: center;
}

.loading-kicker,
.health-kicker {
  margin: 0 0 10px;
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.loading-card h1 {
  margin-bottom: 18px;
  font-size: clamp(42px, 13vw, 64px);
}

.loading-bar {
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(72, 31, 19, 0.12);
  overflow: hidden;
}

.loading-bar span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  animation: loadingSweep 1.1s ease-in-out infinite alternate;
}

.loading-text,
.health-card p,
.share-fallback-card p {
  margin: 14px 0 0;
  color: rgba(45, 29, 23, 0.76);
  font-size: 14px;
  line-height: 1.65;
}

.age-tip {
  display: inline-block;
  margin: 14px 0 0;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(217, 93, 57, 0.12);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 800;
}

.health-card {
  text-align: left;
}

.health-card h2,
.share-fallback-card h2 {
  font-family: inherit;
  font-size: 22px;
  line-height: 1.25;
  color: rgba(45, 29, 23, 0.94);
}

.age-notice {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(217, 93, 57, 0.22);
  border-radius: 16px;
  background: rgba(255, 238, 222, 0.76);
}

.age-notice strong {
  color: var(--accent-deep);
  font-size: 15px;
}

.age-notice span {
  color: rgba(45, 29, 23, 0.78);
  font-size: 13px;
  line-height: 1.55;
}

.health-actions {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 10px;
  margin-top: 18px;
}

.health-secondary-btn {
  background: linear-gradient(180deg, rgba(255, 241, 228, 0.96), rgba(229, 205, 186, 0.96));
  color: rgba(76, 37, 22, 0.9);
}

.share-fallback-card {
  text-align: left;
}

.share-fallback-card textarea {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(72, 31, 19, 0.14);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font: inherit;
  line-height: 1.45;
  resize: none;
}

.share-fallback-card button {
  margin-top: 14px;
}

@keyframes loadingSweep {
  from {
    width: 18%;
  }

  to {
    width: 100%;
  }
}

.app-shell {
  width: min(1320px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  margin: 0 auto;
  padding:
    calc(12px + env(safe-area-inset-top))
    0
    calc(18px + env(safe-area-inset-bottom));
}

.app-shell[data-ui-mode="menu"] {
  width: min(1180px, calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));
}

.app-shell[data-ui-mode="game"] {
  width: min(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right), 560px);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.stage-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.app-shell[data-ui-mode="game"] .stage-layout {
  grid-template-columns: 1fr;
}

.app-shell[data-ui-mode="menu"] .stage-layout {
  grid-template-columns: minmax(430px, 1.05fr) minmax(360px, 0.95fr);
  gap: 18px;
}

.hero-copy,
.control-card,
.side-panel {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 24px 26px 22px;
  border-radius: 28px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, var(--hero-glow, rgba(255, 172, 67, 0.35)), transparent 34%),
    linear-gradient(155deg, var(--hero-top, rgba(255, 248, 238, 0.92)) 0%, var(--hero-bottom, rgba(247, 224, 200, 0.9)) 100%);
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 172, 67, 0.38), transparent 70%);
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.26;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 42%);
}

.hero-copy[data-scene="harbor"]::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 42%),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0 2px, transparent 2px 18px);
}

.hero-copy[data-scene="lanterns"]::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 42%),
    radial-gradient(circle at 18% 18%, rgba(255, 196, 116, 0.3) 0 10px, transparent 10px 100%),
    radial-gradient(circle at 82% 22%, rgba(255, 196, 116, 0.24) 0 12px, transparent 12px 100%);
}

.hero-copy[data-scene="neon"]::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent 42%),
    repeating-linear-gradient(135deg, rgba(255, 237, 204, 0.18) 0 8px, transparent 8px 18px);
}

.hero-copy[data-scene="courtyard"]::before,
.hero-copy[data-scene="alley"]::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent 42%),
    repeating-linear-gradient(90deg, rgba(109, 63, 42, 0.12) 0 24px, transparent 24px 52px);
}

.hero-city-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.hero-city-pill,
.hero-scene-pill {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.hero-city-pill {
  background: rgba(92, 45, 26, 0.12);
  color: rgba(69, 33, 20, 0.88);
}

.hero-scene-pill {
  background: rgba(255, 248, 238, 0.78);
  color: rgba(115, 62, 36, 0.9);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(45, 29, 23, 0.7);
}

h1,
h2 {
  margin: 0;
  font-family: inherit;
  font-weight: 800;
}

h1 {
  font-size: clamp(42px, 7vw, 74px);
  line-height: 0.95;
  margin-bottom: 12px;
}

.tagline {
  max-width: 640px;
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
}

.hero-market-line {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(45, 29, 23, 0.78);
}

.hero-ingredient-strip {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.ingredient-mini {
  padding: 10px 8px 9px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-align: center;
}

.ingredient-mini-emoji {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.ingredient-mini-name {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 700;
}

.control-card {
  border-radius: 28px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at top right, var(--control-glow, rgba(255, 189, 98, 0.26)), transparent 28%),
    linear-gradient(180deg, var(--control-top, rgba(255, 248, 239, 0.94)) 0%, var(--control-bottom, rgba(250, 234, 219, 0.9)) 100%);
}

.control-card label,
.panel-block h2 {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(45, 29, 23, 0.72);
}

select,
button {
  width: 100%;
  border: 0;
  border-radius: 18px;
  font: inherit;
}

select {
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(72, 31, 19, 0.12);
}

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

button {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  color: #fff8f1;
  touch-action: manipulation;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 14px 30px rgba(183, 83, 47, 0.28);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(183, 83, 47, 0.32);
}

button:active {
  transform: translateY(1px);
}

button[disabled] {
  cursor: default;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.status-line {
  margin: 2px 2px 0;
  min-height: 42px;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(45, 29, 23, 0.78);
}

.city-preview-card {
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 252, 247, 0.76);
  border: 1px solid rgba(72, 31, 19, 0.08);
  display: grid;
  gap: 12px;
}

.city-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.city-preview-title,
.city-preview-subtitle {
  margin: 0;
}

.city-preview-title {
  font-size: 15px;
  font-weight: 800;
  color: rgba(45, 29, 23, 0.9);
}

.city-preview-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(45, 29, 23, 0.7);
}

.city-preview-scene {
  flex-shrink: 0;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(217, 93, 57, 0.12);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}

.city-preview-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.city-preview-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.city-preview-icon {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  color: rgba(53, 27, 18, 0.84);
  background: rgba(255, 255, 255, 0.42);
}

.city-preview-text {
  display: grid;
  gap: 2px;
}

.city-preview-name,
.city-preview-note {
  margin: 0;
}

.city-preview-name {
  font-size: 13px;
  font-weight: 700;
  color: rgba(45, 29, 23, 0.86);
}

.city-preview-note {
  font-size: 11px;
  color: rgba(45, 29, 23, 0.62);
}

.canvas-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 36px);
  min-height: calc(100svh - 36px);
}

.app-shell[data-ui-mode="menu"] .canvas-frame {
  width: 0;
  height: 0;
  min-height: 0;
  overflow: visible;
  justify-self: stretch;
  place-items: start end;
}

.app-shell[data-ui-mode="menu"] canvas,
.app-shell[data-ui-mode="menu"] .canvas-hud {
  display: none;
}

.app-shell[data-ui-mode="menu"] .floating-audio-panel {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  right: auto;
  width: min(420px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  z-index: 30;
  transform: translate(-50%, -8px) scale(0.98);
}

.app-shell[data-ui-mode="menu"] #canvas-frame[data-audio-open="true"] .floating-audio-panel {
  transform: translate(-50%, 0) scale(1);
}

.app-shell[data-ui-mode="game"] .canvas-frame {
  width: fit-content;
  max-width: 100%;
  justify-self: center;
  place-items: center;
  align-content: start;
  min-height: calc(100vh - 20px);
  min-height: calc(100svh - 20px);
}

.canvas-hud {
  position: absolute;
  inset: 18px 18px auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  z-index: 4;
  pointer-events: none;
}

.app-shell[data-ui-mode="menu"] .canvas-hud {
  display: none;
}

.hud-right {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.hud-btn {
  width: auto;
  min-width: 88px;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  pointer-events: auto;
  box-shadow: 0 14px 28px rgba(69, 33, 20, 0.18);
}

.hud-btn-left {
  min-width: 92px;
}

.hud-btn-audio {
  background: linear-gradient(180deg, rgba(255, 247, 238, 0.96), rgba(242, 222, 206, 0.94));
  color: rgba(76, 37, 22, 0.9);
}

.hud-btn-audio[data-open="true"] {
  background: linear-gradient(180deg, #7f4c37, #5d3424);
  color: #fff7ef;
}

.hud-btn-menu {
  background: linear-gradient(180deg, rgba(255, 241, 228, 0.96), rgba(238, 209, 185, 0.94));
  color: rgba(76, 37, 22, 0.9);
}

.floating-audio-panel {
  position: absolute;
  top: 74px;
  right: 18px;
  width: min(320px, calc(100% - 36px));
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 249, 242, 0.95);
  border: 1px solid rgba(72, 31, 19, 0.1);
  box-shadow: 0 22px 46px rgba(72, 31, 19, 0.18);
  backdrop-filter: blur(14px);
  z-index: 5;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

#canvas-frame[data-audio-open="true"] .floating-audio-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

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

.panel-utility-btn {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
}

.revive-utility-btn {
  margin-top: 2px;
}

canvas {
  width: auto;
  max-width: 100%;
  height: min(calc(100vh - 36px), 920px);
  height: min(calc(100svh - 36px), 920px);
  aspect-ratio: 900 / 1380;
  display: block;
  border-radius: 34px;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, #fadfc7 0%, #f4be89 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.app-shell[data-ui-mode="menu"] .side-stack {
  width: 100%;
  max-width: none;
  justify-self: center;
  grid-column: 1 / -1;
  grid-template-columns: minmax(430px, 1.05fr) minmax(360px, 0.95fr);
  align-items: start;
}

.app-shell[data-ui-mode="menu"] .hero-copy {
  min-height: 0;
}

.app-shell[data-ui-mode="menu"] .control-card {
  align-self: stretch;
}

.app-shell[data-ui-mode="menu"] .side-panel {
  grid-column: 1 / -1;
}

.app-shell[data-ui-mode="game"] .side-stack {
  display: none;
}

.side-panel {
  border-radius: 28px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panel-block {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 250, 245, 0.82);
  border: 1px solid rgba(72, 31, 19, 0.08);
}

.panel-block p {
  margin: 10px 0 0;
  line-height: 1.7;
  font-size: 14px;
}

.audio-panel {
  gap: 12px;
}

.audio-preset-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-btn {
  padding: 11px 12px;
  border-radius: 14px;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(183, 83, 47, 0.12);
  background: linear-gradient(180deg, rgba(255, 241, 228, 0.92), rgba(238, 209, 185, 0.92));
  color: rgba(81, 40, 23, 0.82);
}

.preset-btn[data-active="true"] {
  color: #fff7ef;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 14px 28px rgba(183, 83, 47, 0.24);
}

.audio-preset-hint {
  margin: 0;
  min-height: 44px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(45, 29, 23, 0.76);
}

.audio-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.audio-state-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(217, 93, 57, 0.1);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}

.audio-control {
  display: grid;
  gap: 8px;
}

.audio-control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(45, 29, 23, 0.84);
}

.audio-control-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 10px;
  align-items: center;
}

.audio-control input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.mini-btn {
  width: 72px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 8px 20px rgba(183, 83, 47, 0.16);
}

.mini-btn[data-muted="true"] {
  background: linear-gradient(180deg, #bca79a, #8a7365);
}

.audio-diagnostics {
  margin-top: 2px;
  min-height: 56px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(45, 29, 23, 0.74);
}

.leaderboard {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.leaderboard li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 237, 216, 0.9), rgba(255, 249, 242, 0.9));
  font-size: 14px;
}

.leaderboard .rank {
  width: 26px;
  height: 26px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: rgba(217, 93, 57, 0.12);
  color: var(--accent-deep);
}

.leaderboard .score {
  font-weight: 700;
  color: var(--teal);
}

.legal-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 2px 0 0;
  font-size: 13px;
}

.legal-links a {
  color: rgba(45, 29, 23, 0.64);
  text-decoration: none;
}

.legal-links a:hover {
  color: var(--accent-deep);
  text-decoration: underline;
}

@media (max-width: 1024px) {
  .stage-layout {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right), 760px);
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .side-stack {
    order: -1;
  }

  .app-shell[data-ui-mode="game"] .side-stack {
    display: none;
  }

  .canvas-frame {
    min-height: auto;
  }

  canvas {
    width: 100%;
    height: auto;
  }
}

@media (max-width: 640px) {
  body {
    background:
      radial-gradient(circle at top, rgba(255, 255, 255, 0.72), transparent 32%),
      linear-gradient(180deg, #faf0e7 0%, #f1cfb7 52%, #e5b18e 100%);
  }

  .app-shell,
  .app-shell[data-ui-mode="menu"],
  .app-shell[data-ui-mode="game"] {
    width: calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .app-shell[data-ui-mode="menu"] .stage-layout,
  .app-shell[data-ui-mode="menu"] .side-stack {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .app-shell[data-ui-mode="game"] {
    width: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right));
    padding:
      calc(6px + env(safe-area-inset-top))
      0
      calc(6px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="menu"] {
    padding:
      calc(8px + env(safe-area-inset-top))
      0
      calc(12px + env(safe-area-inset-bottom));
  }

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

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

  .hero-ingredient-strip,
  .city-preview-items {
    grid-template-columns: 1fr 1fr;
  }

  .hero-copy,
  .control-card,
  .side-panel {
    border-radius: 24px;
    box-shadow: 0 16px 34px rgba(102, 49, 21, 0.14);
  }

  canvas {
    width: min(
      calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)),
      calc((100svh - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 900 / 1380)
    );
    border-radius: 24px;
    height: auto;
    max-height: none;
  }

  .app-shell[data-ui-mode="game"] .canvas-frame {
    width: 100%;
    min-height: calc(100vh - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: calc(100svh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    align-content: start;
    gap: 8px;
  }

  .canvas-hud {
    position: static;
    width: min(
      calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)),
      calc((100svh - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 900 / 1380)
    );
    gap: 8px;
    order: -1;
  }

  .hud-btn {
    min-width: 68px;
    padding: 10px 11px;
    font-size: 12px;
    box-shadow: 0 10px 18px rgba(69, 33, 20, 0.16);
  }

  .hud-right {
    gap: 8px;
    flex-wrap: wrap;
    max-width: min(72vw, 260px);
    justify-content: flex-end;
  }

  .floating-audio-panel {
    top: calc(56px + env(safe-area-inset-top));
    right: 10px;
    width: calc(100% - 20px);
    border-radius: 20px;
    max-height: calc(100vh - 82px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
  }

  .app-shell[data-ui-mode="menu"] .floating-audio-panel {
    top: calc(12px + env(safe-area-inset-top));
    left: 50%;
    right: auto;
    width: calc(100% - 12px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .side-stack {
    gap: 10px;
  }

  .app-shell[data-ui-mode="menu"] .hero-copy {
    padding: 14px 16px;
    border-radius: 20px;
  }

  .app-shell[data-ui-mode="menu"] .hero-city-head {
    margin-bottom: 8px;
  }

  .app-shell[data-ui-mode="menu"] .hero-city-pill,
  .app-shell[data-ui-mode="menu"] .hero-scene-pill {
    padding: 7px 10px;
    font-size: 11px;
  }

  .app-shell[data-ui-mode="menu"] .eyebrow {
    margin-bottom: 6px;
    font-size: 12px;
    letter-spacing: 0.14em;
  }

  .app-shell[data-ui-mode="menu"] h1 {
    margin-bottom: 8px;
    font-size: clamp(38px, 14vw, 52px);
  }

  .app-shell[data-ui-mode="menu"] .hero-market-line {
    margin-bottom: 0;
    font-size: 13px;
  }

  .app-shell[data-ui-mode="menu"] .tagline,
  .app-shell[data-ui-mode="menu"] .hero-ingredient-strip {
    display: none;
  }

  .control-card,
  .side-panel {
    padding: 16px;
  }

  .app-shell[data-ui-mode="menu"] .control-card {
    gap: 9px;
    padding: 13px;
    border-radius: 20px;
  }

  .app-shell[data-ui-mode="menu"] .city-preview-card {
    display: none;
  }

  .app-shell[data-ui-mode="menu"] .button-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .app-shell[data-ui-mode="menu"] #start-btn {
    min-height: 54px;
    border-radius: 18px;
    font-size: 17px;
  }

  .app-shell[data-ui-mode="menu"] #menu-audio-btn {
    min-height: 44px;
    padding: 11px 14px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 241, 228, 0.96), rgba(238, 209, 185, 0.94));
    color: rgba(76, 37, 22, 0.9);
  }

  .app-shell[data-ui-mode="menu"] .status-line {
    display: none;
  }

  .app-shell[data-ui-mode="menu"] .side-panel {
    padding: 12px;
    border-radius: 20px;
  }

  .app-shell[data-ui-mode="menu"] .panel-block {
    padding: 12px;
    border-radius: 16px;
  }

  .app-shell[data-ui-mode="menu"] .panel-block p {
    font-size: 13px;
    line-height: 1.55;
  }

  h1 {
    font-size: clamp(34px, 11vw, 54px);
  }

  .tagline {
    font-size: 15px;
    line-height: 1.6;
  }

  .status-line {
    min-height: 0;
    font-size: 13px;
  }

  .loading-card,
  .health-card {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .health-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .hero-copy {
    padding: 18px 14px 16px;
  }

  .control-card,
  .side-panel {
    padding: 14px;
  }

  .hud-btn {
    min-width: 58px;
    padding: 9px 9px;
    font-size: 11px;
  }

  .hud-right {
    gap: 6px;
    max-width: 230px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app-shell[data-ui-mode="game"] {
    padding:
      max(4px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .app-shell[data-ui-mode="game"] .canvas-frame {
    min-height: calc(100vh - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: calc(100svh - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    grid-template-columns: auto auto;
    justify-content: center;
    align-content: center;
  }

  canvas {
    width: auto;
    height: calc(100vh - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    height: calc(100svh - 8px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .canvas-hud {
    position: absolute;
    inset: max(6px, env(safe-area-inset-top)) 8px auto 8px;
    width: auto;
    order: initial;
  }
}
