/* Applied only to the Life, Forest Fire and Pathfinding phone layouts. */
body.mobile-layout {
  height: auto;
  min-height: 100svh;
  overflow: auto;
  background: var(--theme-bg);
  line-height: 1.5;
}
.mobile-layout header {
  position: static;
  width: 100%;
  height: 56px;
  padding: 0 16px;
  background: var(--theme-bg);
  box-shadow: none;
  pointer-events: auto;
}
.mobile-layout main {
  position: static;
  display: block;
  max-width: 700px;
  margin: 0 auto;
  padding: 16px 16px 28px;
  overflow: visible;
  pointer-events: auto;
}
.mobile-layout main > :not(.mobile-simulation) { display: none !important; }
.mobile-layout .mobile-simulation {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mobile-layout .mobile-info { display: grid; gap: 12px; }
.mobile-layout .intro {
  position: static;
  margin: 0;
  max-width: none;
  pointer-events: auto;
  text-shadow: none;
}
.mobile-layout .intro h1 {
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: -.6px;
}
.mobile-layout .intro .eyebrow,
.mobile-layout .intro p:last-child,
.mobile-layout .intro-tag { display: none; }
.mobile-layout .mobile-meta,
.mobile-layout .world-heading,
.mobile-layout .mobile-meta > .panel-top {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  pointer-events: auto;
}
.mobile-layout .mobile-meta .section-label { display: none; }
.mobile-layout .mobile-meta .legend {
  order: 0;
  width: auto;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  gap: 12px;
  font: 11px ui-monospace, monospace;
  background: none;
  border: none;
  color: var(--theme-muted);
}
.mobile-layout .legend > span { display: flex; align-items: center; gap: 6px; }
.mobile-layout .legend i { width: 8px; height: 8px; border-radius: 2px; }
.mobile-layout .mobile-meta .status {
  font-size: 10px;
  letter-spacing: .5px;
  line-height: 1.5;
  padding: 4px 7px;
  margin: 0;
  color: var(--theme-text);
}
.mobile-layout .mobile-stage { display: grid; gap: 8px; min-width: 0; }
.mobile-layout .canvas-wrap {
  position: relative;
  inset: auto;
  width: 100%;
  height: clamp(280px, 55svh, 520px);
  margin: 0;
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--theme-deep);
}
.mobile-layout #grid {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: auto;
  touch-action: none;
}
.mobile-layout #canvas-hint {
  position: static;
  display: block;
  font: 12px/1.5 ui-sans-serif, system-ui, sans-serif;
  padding: 0 2px;
  color: var(--theme-muted);
  border: none;
  background: none;
  pointer-events: none;
}
.mobile-layout .floating-play,
.mobile-layout .control-drawer,
.mobile-layout .code-drawer,
.mobile-layout .stats,
.mobile-layout .explanation {
  position: static;
  inset: auto;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  margin: 0;
  flex-shrink: 0;
  pointer-events: auto;
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  background: linear-gradient(135deg, rgb(255 255 255 / 5%), transparent 60%), var(--theme-panel);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 8%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.mobile-layout .control-drawer:not([open]),
.mobile-layout .code-drawer:not([open]) { width: 100%; max-height: none; }
.mobile-layout .control-drawer[open],
.mobile-layout .code-drawer[open] { max-height: none; overflow: visible; }
.mobile-layout .floating-play { padding: 8px; }
.mobile-layout .floating-play .play-controls {
  display: flex;
  width: 100%;
  gap: 8px;
  margin: 0;
}
.mobile-layout .floating-play button { flex: 1; min-width: 44px; min-height: 44px; }
.mobile-layout .floating-play .primary { flex: 2; font-size: 14px; min-width: 100px; }
.mobile-layout details > summary {
  min-height: 48px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--theme-text);
}
.mobile-layout .control-drawer .toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
  gap: 18px 16px;
  border: none;
  background: none;
  margin: 0;
}
.mobile-layout .control-drawer .toolbar label {
  color: var(--theme-text);
  font-size: 13px;
  line-height: 1.5;
  gap: 8px;
  min-width: 0;
  width: auto;
  max-width: none;
}
.mobile-layout .control-drawer .preset-label,
.mobile-layout .control-drawer .algorithm-control { grid-column: 1 / -1; }
.mobile-layout .control-drawer .slider-label,
.mobile-layout .control-drawer .range-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}
.mobile-layout .control-drawer .toolbar output {
  position: static;
  font: 12px/1.625 ui-monospace, monospace;
  color: var(--theme-accent);
  white-space: nowrap;
}
.mobile-layout .control-drawer .toolbar input {
  grid-column: 1 / -1;
  width: 100%;
  height: 36px;
  margin: 0;
}
.mobile-layout .control-drawer .toolbar select {
  width: 100%;
  font-size: 14px;
  min-height: 44px;
  color: var(--theme-text);
}
.mobile-layout .world-tools,
.mobile-layout .grid-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 16px 16px;
  width: auto;
  position: static;
}
.mobile-layout .brushes { display: flex; width: 100%; flex-wrap: wrap; gap: 6px; }
.mobile-layout .brushes button {
  flex: 1;
  min-height: 44px;
  font-size: 13px;
  padding: 9px;
  color: var(--theme-text);
}
.mobile-layout .grid-tools > button { min-height: 44px; font-size: 13px; }
.mobile-layout .view-options { flex-wrap: wrap; font-size: 13px; color: var(--theme-muted); gap: 18px; }
.mobile-layout .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 14px;
  gap: 12px;
}
.mobile-layout .stats > div { min-width: 0; }
.mobile-layout .stats > div > span {
  display: block;
  font: 10px/1.5 ui-monospace, monospace;
  letter-spacing: 0;
  color: var(--theme-muted);
}
.mobile-layout .stats strong {
  display: block;
  font: 18px/1.5 ui-monospace, monospace;
  margin-top: 4px;
  color: var(--theme-text);
  overflow-wrap: anywhere;
}
.mobile-layout .stats strong span { font-size: 10px; color: var(--theme-muted); margin-left: 2px; }
.mobile-layout .explanation {
  display: block;
  padding: 16px;
  min-height: 0;
}
.mobile-layout .explanation .rules-title { display: block; font-size: 11px; margin-bottom: 8px; }
.mobile-layout .explanation p { font-size: 13px; line-height: 1.65; min-width: 0; color: var(--theme-muted); }
.mobile-layout .explanation a { display: inline-block; font-size: 12px; margin: 10px 0 0; }
.mobile-layout .code-drawer .code { background: none; }
.mobile-layout .code-drawer h2 { font-size: 20px; padding: 16px; }
.mobile-layout .code-drawer #code-lines li { font-size: 12px; gap: 12px; }
.mobile-layout .code-drawer #algorithm-note { font-size: 13px; line-height: 1.65; }
.mobile-layout .code-drawer .code-footer { font-size: 11px; }
@media (max-width: 380px) {
  .mobile-layout .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-layout .stats > div > span { font-size: 11px; }
  .mobile-layout .control-drawer .toolbar { grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 550px) and (min-width: 600px) {
  .mobile-layout .canvas-wrap { height: 64svh; min-height: 220px; }
}
