.deck-map { align-items: stretch; }
.map-frame {
  position: relative;
  inset: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  min-width: 0;
  min-height: 0;
}
.map-heading { align-items: center; gap: 4px; min-height: 16px; padding: 0; }
.map-heading > span { font-weight: 700; white-space: nowrap; }
.map-heading > small { margin-left: auto; white-space: nowrap; }
.map-canvas-holder {
  align-self: center;
  justify-self: center;
  width: min(100%, 160px);
  max-height: 100%;
  min-height: 0;
  aspect-ratio: 7200 / 5050;
}
#minimap { width: 100%; height: 100%; aspect-ratio: auto; }

.camera-menu-toggle { display: none; }
.camera-controls {
  position: static;
  inset: auto;
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: none;
  color: var(--ink);
}
.camera-places { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.camera-utilities { display: flex; align-items: stretch; justify-content: space-between; gap: 4px; }
.camera-build, .camera-zoom { display: flex; align-items: center; gap: 3px; }
.camera-build { min-width: 0; }
.camera-build > span { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.camera-controls button, .camera-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 32px;
  padding: 0 4px;
  border: 1px solid #9fb2cf;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.camera-menu-toggle { display: none; }
.camera-controls button:hover, .camera-menu-toggle:hover { color: var(--cobalt-deep); background: #e3edfc; }
.camera-controls button:active, .camera-menu-toggle:active { background: #d4e2f8; }
.camera-controls svg, .camera-menu-toggle svg { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.camera-build button, .camera-zoom button { min-width: 30px; }
.camera-zoom { padding-left: 4px; border-left: 1px solid var(--line); }
.result-shortcut {
  position: absolute;
  bottom: 12px;
  left: 14px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--cobalt-deep);
  border-radius: 7px;
  color: #fff;
  background: var(--cobalt);
  font-size: 12px;
  font-weight: 700;
}
.result-shortcut:hover { background: var(--cobalt-deep); }

@media (min-width: 951px) {
  .command-deck { grid-template-columns: 240px minmax(0, 1fr); }
  .deck-map { padding: 8px; }
}

@media (max-width: 950px), (max-height: 500px), (pointer: coarse) {
  .deck-map { align-items: center; }
  .map-frame { grid-template-rows: auto auto; height: auto; overflow: visible; }
  .map-heading > small { display: none; }
  .map-canvas-holder { width: 100%; max-height: none; }
  .camera-menu-toggle { display: inline-flex; min-width: 42px; margin-left: auto; }
  .camera-controls {
    position: absolute;
    right: auto;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 5;
    display: none;
    width: 250px;
    max-width: calc(100vw - 16px);
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 4px 12px #00000033;
  }
  .camera-controls.is-open { display: grid; }
  .camera-controls button { min-height: 36px; }
}

@media (pointer: coarse) {
  .camera-menu-toggle, .camera-controls button { min-height: 44px; }
  .camera-build button, .camera-zoom button { min-width: 44px; }
}

@media (max-width: 650px) {
  .map-frame { position: fixed; right: 7px; bottom: calc(38dvh + 7px); width: 122px; }
  .result-shortcut { bottom: 7px; left: 7px; min-height: 44px; }
}

@media (max-width: 650px) and (orientation: portrait) {
  .camera-controls { right: 0; left: auto; }
}

@media (max-width: 650px) and (max-height: 600px) and (orientation: landscape) {
  .command-deck { grid-template-columns: 122px minmax(0, 1fr); }
  .deck-map { display: flex; padding: 4px; }
  .map-frame { position: relative; right: auto; bottom: auto; width: 100%; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .game-shell.is-placing .map-frame { position: fixed; right: 8px; bottom: 8px; width: 122px; visibility: visible; }
  .game-shell.is-placing .camera-controls { right: calc(100% + 6px); bottom: 0; left: auto; }
}
