:root {
  color-scheme: light;
  --bg: #ece7dc;
  --surface: #f8f2e7;
  --panel: #fffaf0;
  --line: #d7cbb8;
  --line-strong: #b9a98d;
  --text: #1d2a24;
  --muted: #667064;
  --accent: #2f6f66;
  --accent-strong: #1f554e;
  --danger: #a23d34;
  --map-bg: #d9e5d2;
  --shadow: 0 14px 36px rgba(49, 44, 33, 0.14);
  --app-vh: 1vh;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.app-shell {
  min-height: 100vh;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.topbar-left,
.topbar-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-left {
  min-width: 0;
}

.topbar-left,
.topbar-actions {
  flex: 0 0 auto;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.school-button,
.primary-button,
.secondary-button,
.icon-button,
.tool-button,
.shape-toggle,
.brush-shape-toggle,
.color-slot {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.school-button {
  min-height: 40px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  padding: 0 12px;
  font-weight: 800;
  font-size: 13px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fffaf0;
}

.primary-button.compact {
  min-height: 36px;
}

.secondary-button {
  background: #fffdf6;
}

.secondary-button.danger {
  border-color: color-mix(in srgb, var(--danger), var(--line) 35%);
  color: var(--danger);
}

.school-button:hover,
.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.tool-button:hover,
.shape-toggle:hover,
.brush-shape-toggle:hover,
.color-slot:hover {
  border-color: var(--accent);
}

.current-school {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  max-width: min(68%, 360px);
  padding: 6px 9px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line-strong), transparent 18%);
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel), transparent 8%);
  box-shadow: 0 8px 20px rgba(49, 44, 33, 0.1);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

body.game-info-open {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.game-info-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 10px;
  overflow: hidden;
  background: rgba(29, 42, 36, 0.28);
  overscroll-behavior: none;
  touch-action: none;
}

.game-info-dialog {
  width: min(560px, calc(100vw - 20px));
  max-height: min(680px, calc(100dvh - 20px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-strong), #fffaf0 88%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.game-info-head strong {
  color: var(--accent-strong);
  font-size: 16px;
}

.game-info-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.game-info-tab {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: #fffdf6;
  color: var(--accent-strong);
  font-weight: 900;
  cursor: pointer;
}

.game-info-tab.active {
  background: var(--accent);
  color: #fffaf0;
}

.game-info-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-right: 2px;
}

.game-info-page {
  display: grid;
  gap: 10px;
}

.game-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px;
}

.game-info-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 58%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), transparent 2%);
}

.game-info-card p {
  margin: 6px 0;
  line-height: 1.55;
}

.game-info-card a {
  color: #1670b7;
  font-weight: 900;
}

.project-card a {
  text-decoration: none;
}

.project-card a span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-card a em {
  text-decoration: none;
}

.game-info-card em {
  margin-left: 4px;
  color: var(--text);
  font-style: normal;
  font-weight: 800;
}

.author-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-weight: 900;
}

.album-card {
  display: grid;
  gap: 10px;
}

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

.album-card h2 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 16px;
}

.album-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rules-card {
  display: grid;
  gap: 8px;
}

.rules-card h2 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 16px;
}

.rules-card details {
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--line), transparent 25%);
}

.rules-card summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.rules-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.album-status {
  min-width: 58px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1eadf;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.album-status[data-status="connected"] {
  background: #dfeee4;
  color: #22623b;
}

.album-status[data-status="needs-permission"] {
  background: #fff1d7;
  color: #956216;
}

.album-status[data-status="unsupported"] {
  background: #f4e1df;
  color: #a03f35;
}

.album-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 6px;
}

.library-browser {
  max-height: min(280px, 38vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 72%);
  border-radius: 7px;
  background: #fffaf0;
}

.library-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.library-browser-head strong {
  min-width: 0;
  color: var(--accent-strong);
  font-size: 13px;
}

.library-browser p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.45;
}

.library-browser ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-browser li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  padding: 5px 6px;
  border-radius: 6px;
  background: #f7efe1;
}

.library-browser li strong,
.library-browser li small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-browser li strong {
  color: var(--ink);
  font-size: 12px;
}

.library-browser li small {
  color: var(--muted);
  font-size: 11px;
}

.stats-card {
  grid-column: auto;
}

.stats-card h2,
.stat-group h3 {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 16px;
}

.stats-panel {
  display: grid;
  gap: 10px;
}

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

.stat-card {
  min-height: 74px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 68%);
  border-radius: 7px;
  background: #f8f2e7;
}

.stat-card span,
.stat-card em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.stat-card strong {
  display: block;
  margin: 2px 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.stats-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
}

.map-panel,
.info-panel {
  min-width: 0;
}

.map-panel {
  position: relative;
}

.map-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.map-frame {
  position: relative;
  height: calc(100vh - 138px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--map-bg);
  box-shadow: var(--shadow);
}

.map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
  background: var(--map-bg);
}

.map-zoom-readout {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  min-width: 54px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--line-strong), transparent 20%);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel), transparent 8%);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.exploration-progress {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--line-strong), transparent 22%);
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel), transparent 7%);
  box-shadow: 0 8px 20px rgba(49, 44, 33, 0.1);
  color: inherit;
  cursor: pointer;
  appearance: none;
  text-align: left;
}

.exploration-progress.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), #fffaf0 86%);
}

.exploration-progress-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  white-space: nowrap;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.exploration-progress-row strong {
  font-size: 13px;
}

.exploration-progress-track {
  height: 6px;
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line), #fff 54%);
}

.exploration-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5d984b, #c8a746);
  transition: width 180ms ease;
}

.map-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100% - 84px);
  gap: 7px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--line-strong), transparent 16%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), transparent 6%);
  box-shadow: 0 10px 24px rgba(49, 44, 33, 0.12);
}

.map-action-button,
.map-action-toggle {
  min-height: 30px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fffdf6;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.map-action-button {
  cursor: pointer;
}

.map-action-button.active,
.map-action-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fffaf0;
}

.map-action-button.emoji-button {
  min-width: 42px;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.map-action-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 18px;
  text-align: center;
  pointer-events: none;
}

.info-panel {
  height: calc(100vh - 86px);
  min-height: 560px;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.info-heading {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.info-panel h1 {
  margin: 7px 0 12px;
  font-size: 24px;
  line-height: 1.2;
}

.info-body {
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-line;
}

.missing-map-actions {
  margin-top: 12px;
}

.game-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.game-panel.inside-building {
  overflow: hidden;
}

.game-panel.inside-building .campus-card {
  display: none;
}

.game-panel.inside-building .photo-card {
  min-height: 0;
  overflow: auto;
}

.game-panel.inside-building .photo-stage {
  min-height: clamp(260px, 52vh, 620px);
}

.game-card {
  min-width: 0;
  min-height: 0;
  padding: 10px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf6;
}

.campus-card {
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.game-card-head {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.game-card-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interior-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.interior-title small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.game-card-head-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.photo-card {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.guide-card {
  display: grid;
  align-content: start;
  gap: 14px;
}

.guide-hero {
  display: grid;
  gap: 6px;
}

.guide-hero strong {
  color: var(--ink);
  font-size: 18px;
}

.guide-hero span,
.rule-notes p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.guide-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.guide-stats span {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 18%);
  border-radius: 7px;
  background: #fffdf6;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.guide-steps {
  display: grid;
  gap: 8px;
}

.guide-steps div {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.guide-steps b {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fffaf0;
  font-size: 12px;
}

.guide-steps span {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.rule-notes {
  display: grid;
  gap: 5px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--line), transparent 20%);
}

.rule-notes strong {
  font-size: 13px;
}

.photo-card.entrance-card {
  display: flex;
}

.spot-fields,
.building-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(118px, 0.75fr);
  gap: 8px;
}

.interior-spot-fields {
  grid-template-columns: minmax(0, 1.1fr) minmax(118px, 0.75fr) minmax(96px, 0.55fr);
}

.photo-stage {
  min-height: clamp(260px, 48vh, 620px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line), transparent 20%);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(215, 203, 184, 0.34) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(215, 203, 184, 0.34) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(215, 203, 184, 0.34) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(215, 203, 184, 0.34) 75%),
    #f8f2e7;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-size: 18px 18px;
}

.photo-stage img,
.mini-photo img,
.person-photo img,
.item-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.photo-list {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px 6px 12px 2px;
}

.photo-tile {
  box-sizing: border-box;
  display: block;
  position: relative;
  --photo-ratio: 1.333333;
  --photo-natural-width: 9999px;
  --photo-max-height: min(68vh, 680px);
  width: min(100%, var(--photo-natural-width), calc(var(--photo-max-height) * var(--photo-ratio)));
  max-width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--line), transparent 10%);
  border-radius: 8px;
  background: #f8f2e7;
  cursor: pointer;
  line-height: 0;
  flex: 0 0 auto;
}

.photo-tile:hover {
  border-color: color-mix(in srgb, var(--accent), var(--line) 35%);
}

.photo-tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(47, 111, 102, 0.13);
}

.photo-tile.selected {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(47, 111, 102, 0.22);
}

.photo-tile img {
  width: 100%;
  height: auto;
  display: block;
}

.photo-tile-index {
  position: absolute;
  left: 8px;
  top: 8px;
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(31, 85, 78, 0.88);
  color: #fffaf0;
  font-size: 12px;
  font-weight: 900;
}

.photo-tile-date {
  position: absolute;
  right: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(31, 85, 78, 0.82);
  color: #fffaf0;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.list-empty {
  min-width: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--line), transparent 10%);
  border-radius: 8px;
  background: #fffdf6;
}

.game-actions {
  display: grid;
  gap: 7px;
  align-items: stretch;
}

.game-actions.dense {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.game-actions.photo-actions {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.game-actions.photo-actions [data-game-action="linkPhotoSpotEntrance"],
.game-actions.photo-actions [data-game-action="enterFromPhotoSpot"],
.game-actions.photo-actions [data-game-action="captureSpotPhoto"],
.game-actions.photo-actions [data-game-action="captureInteriorSpotPhoto"],
.game-actions.photo-actions [data-game-action="captureBuildingPhoto"],
.game-actions.photo-actions [data-game-action="uploadSpotPhoto"],
.game-actions.photo-actions [data-game-action="uploadInteriorSpotPhoto"],
.game-actions.photo-actions [data-game-action="uploadBuildingPhoto"] {
  grid-column: span 2;
  order: 1;
}

.game-actions.photo-actions [data-game-action="moveSpotPhotoBackward"],
.game-actions.photo-actions [data-game-action="moveInteriorSpotPhotoBackward"],
.game-actions.photo-actions [data-game-action="moveBuildingPhotoBackward"] {
  grid-column: span 2;
  order: 2;
}

.game-actions.photo-actions [data-game-action="moveSpotPhotoForward"],
.game-actions.photo-actions [data-game-action="moveInteriorSpotPhotoForward"],
.game-actions.photo-actions [data-game-action="moveBuildingPhotoForward"] {
  grid-column: span 2;
  order: 3;
}

.game-actions.photo-actions [data-game-action="deletePhotoSpotSelected"],
.game-actions.photo-actions [data-game-action="deleteInteriorSpotSelected"],
.game-actions.photo-actions [data-game-action="deleteBuildingPhoto"] {
  grid-column: span 2;
  order: 4;
}

.game-actions.interior-spot-actions [data-game-action="captureInteriorSpotPhoto"],
.game-actions.interior-spot-actions [data-game-action="uploadInteriorSpotPhoto"] {
  grid-column: span 3;
  order: 1;
}

.game-actions.interior-spot-actions [data-game-action="moveInteriorSpotPhotoBackward"],
.game-actions.interior-spot-actions [data-game-action="moveInteriorSpotPhotoForward"],
.game-actions.interior-spot-actions [data-game-action="deleteInteriorSpotSelected"] {
  grid-column: span 2;
}

.game-actions.interior-spot-actions [data-game-action="moveInteriorSpotPhotoBackward"] {
  order: 2;
}

.game-actions.interior-spot-actions [data-game-action="moveInteriorSpotPhotoForward"] {
  order: 3;
}

.game-actions.interior-spot-actions [data-game-action="deleteInteriorSpotSelected"] {
  order: 4;
}

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

.game-actions .secondary-button,
.game-actions .primary-button,
.compact {
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
  align-self: stretch;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.game-notice {
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #e8f0e7;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.building-chip-row,
.interaction-chip-row,
.room-chip-row,
.item-chip-row,
.person-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.building-chip,
.interaction-chip,
.room-chip,
.item-chip,
.person-chip,
.entrance-row {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.entrance-row {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  cursor: default;
}

.entrance-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.building-chip.active,
.interaction-chip.active,
.room-chip.active,
.item-chip.active,
.person-chip.active {
  border-color: var(--accent);
  background: #e8f0e7;
  color: var(--accent-strong);
}

.building-editor,
.room-fields,
.room-detail,
.item-detail,
.person-detail {
  display: grid;
  gap: 8px;
}

.building-editor {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.building-photo-list {
  min-height: 0;
}

.building-photo-list .list-empty {
  min-height: 42px;
}

.game-input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

textarea.game-input {
  min-height: 54px;
  resize: vertical;
}

.mini-photo {
  min-height: clamp(220px, 38vh, 520px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f2e7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-photo.has-photo,
.item-photo.has-photo,
.person-photo.has-photo {
  min-height: 0;
  align-items: center;
  justify-items: center;
}

.mini-photo.wide {
  min-height: clamp(280px, 50vh, 680px);
}

.mini-photo.wide.has-photo {
  height: clamp(300px, 58vh, 720px);
  min-height: 0;
}

.player-portrait-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.player-portrait-status {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entrance-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 0 auto;
  align-items: flex-start;
  max-height: 92px;
  overflow: auto;
}

.interior-card {
  overflow: auto;
  min-height: 0;
  align-content: start;
}

.venue-chip-row {
  max-height: 72px;
  overflow: auto;
}

.interior-add-row {
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 18%);
}

.room-add-row,
.item-add-row,
.person-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) auto;
  gap: 7px;
}

.room-fields {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.item-add-row,
.person-add-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.legacy-entity-row:empty {
  display: none;
}

.person-add-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.item-top,
.person-top {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(0, 0.9fr);
  gap: 10px;
}

.item-photo,
.person-photo {
  width: 100%;
  min-height: clamp(220px, 34vh, 500px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f2e7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.item-photo.has-photo,
.person-photo.has-photo {
  height: clamp(260px, 42vh, 560px);
}

.item-fields,
.person-fields {
  display: grid;
  gap: 7px;
}

.interior-photo-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.interior-photo-list {
  min-height: 220px;
  max-height: min(56vh, 560px);
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 18%);
  padding-bottom: 12px;
}

.item-detail .interior-photo-list {
  max-height: min(44vh, 440px);
}

.interior-photo-list.compact-list {
  min-height: 150px;
  max-height: min(42vh, 420px);
}

.player-portrait-card {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf6;
}

.player-portrait-status {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-log {
  max-height: 104px;
  overflow: auto;
  display: grid;
  gap: 5px;
}

.chat-line {
  padding: 6px 8px;
  border-radius: 6px;
  background: #f8f2e7;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.chat-line.me {
  background: #e8f0e7;
  color: var(--accent-strong);
}

.muted-inline {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.editor-panel {
  margin-top: 0;
  display: grid;
  gap: 10px;
}

.editor-section,
.dialog-section {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf6;
}

.section-title {
  margin-bottom: 8px;
  font-weight: 800;
}

.editor-layer-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.layer-toggle,
.mode-tab {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fffdf6;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.layer-toggle.active,
.mode-tab.active {
  border-color: var(--accent);
  background: #e8f0e7;
  color: var(--accent-strong);
}

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

.editor-mode-tabs .mode-tab {
  min-width: 0;
  padding: 0 8px;
  white-space: normal;
}

.editor-workspace {
  display: grid;
  gap: 7px;
}

.editor-status {
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--accent), var(--line) 55%);
  border-radius: 6px;
  background: #eef4ec;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.editor-status.warning {
  border-color: color-mix(in srgb, var(--danger), var(--line) 45%);
  background: #fff6f0;
  color: var(--danger);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--muted);
}

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

.tool-grid.single-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-button {
  min-height: 36px;
  padding: 0 8px;
  background: #fffaf0;
  font-weight: 800;
  text-align: center;
}

.tool-button.icon-tool,
.shape-toggle.icon-tool,
.primary-button.icon-tool,
.secondary-button.icon-tool {
  min-width: 64px;
  min-height: 36px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

.tool-button.icon-tool::after,
.shape-toggle.icon-tool::after,
.primary-button.icon-tool::after,
.secondary-button.icon-tool::after {
  content: attr(data-label);
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.tool-svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.tool-label {
  display: block;
  min-width: 0;
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
}

.tool-svg .tool-soft {
  fill: color-mix(in srgb, currentColor, transparent 82%);
}

.tool-svg .tool-fill {
  fill: currentColor;
  stroke: none;
}

.tool-svg .tool-dash {
  stroke-dasharray: 2 2;
}

.tool-button.active {
  border-color: var(--accent);
  background: #e8f0e7;
  color: var(--accent-strong);
}

.segmented-row,
.color-slot-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented-row.two-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.brush-shape-toggle,
.shape-toggle,
.color-slot {
  min-height: 34px;
  padding: 0 8px;
  font-weight: 800;
}

.brush-shape-toggle.active,
.shape-toggle.active,
.color-slot.active {
  border-color: var(--accent);
  background: #e8f0e7;
  color: var(--accent-strong);
}

.color-panel {
  display: grid;
  gap: 8px;
}

.editor-color-field {
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 900;
}

.editor-color-input {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #fffdf7;
  overflow: hidden;
  cursor: pointer;
}

.editor-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.editor-color-input::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

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

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

.color-slot i {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--slot-color, #f5e9bd);
}

.palette-block {
  display: grid;
  gap: 6px;
}

.palette-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-row input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
}

.field-row input[type="range"] {
  width: 100%;
}

.compact-number {
  width: 56px;
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  text-align: center;
}

.rotate-angle-row {
  grid-template-columns: 44px minmax(0, 1fr) 64px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatches button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
}

.swatches button.active {
  outline: 3px solid rgba(47, 111, 102, 0.24);
  outline-offset: 2px;
}

.field {
  display: grid;
  gap: 4px;
}

.compact-field {
  margin-bottom: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--text);
}

.structure-object-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, 0.72fr) 30px;
  gap: 8px;
}

.structure-object-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.structure-object-form input,
.structure-object-form select {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--text);
}

.structure-object-form input[type="text"] {
  padding: 6px 9px;
}

.structure-object-form input[type="color"] {
  width: 28px;
  height: 28px;
  min-height: 28px;
  align-self: center;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
}

.structure-object-form input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.structure-object-form input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.structure-object-list {
  display: grid;
  gap: 5px;
  overflow: hidden;
}

.structure-object-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf6;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.structure-object-item.active {
  border-color: var(--accent);
  background: #edf5ed;
  color: var(--text);
}

.structure-object-item.hidden-object {
  opacity: 0.58;
}

.structure-object-swatch {
  width: 14px;
  height: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--object-color);
}

.structure-object-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.structure-object-copy strong {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.structure-object-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.structure-list-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.structure-list-pager .secondary-button {
  min-height: 32px;
}

.structure-list-pager output {
  min-width: 46px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.compact-check {
  min-height: 24px;
}

.school-dialog {
  width: min(860px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  margin: 10px auto auto 10px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(27, 31, 24, 0.28);
}

.school-dialog::backdrop {
  background: rgba(29, 35, 28, 0.38);
}

.dialog-shell {
  padding: 12px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.icon-button {
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
}

.dialog-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.82fr) 1.18fr;
  gap: 10px;
}

.school-picker {
  display: grid;
  grid-template-rows: minmax(160px, 1fr) auto;
  gap: 8px;
  min-height: 280px;
}

.school-list,
.school-picker-actions,
.new-school {
  display: grid;
  gap: 8px;
}

.school-list {
  align-content: start;
  grid-auto-rows: min-content;
}

.new-school {
  gap: 8px;
}

.school-card {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf6;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.school-card:hover,
.school-card.active {
  border-color: var(--accent);
  background: #edf5ed;
}

.create-card {
  font-weight: 800;
}

.school-card.dragging {
  opacity: 0.55;
}

.campus-form-panel {
  display: grid;
  gap: 8px;
}

.bulk-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.resource-hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.resource-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 30%);
}

.name-row {
  padding-top: 0;
}

.resource-row.disabled {
  color: color-mix(in srgb, var(--muted), transparent 25%);
}

.resource-label {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.resource-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.resource-info span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-check {
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
}

.resource-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.resource-check input:disabled {
  visibility: hidden;
}

.map-thumb-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.map-thumb {
  width: 48px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  object-fit: cover;
  background: var(--map-bg);
}

.map-thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.download-panel {
  display: grid;
  align-content: start;
}

.download-list {
  display: grid;
  gap: 8px;
}

.download-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 30%);
}

.download-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.download-copy strong,
.download-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-copy span {
  color: var(--muted);
  font-size: 12px;
}

.download-progress {
  display: grid;
  gap: 4px;
  padding-top: 4px;
}

.download-progress[hidden] {
  display: none;
}

.download-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line), transparent 18%);
}

.download-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.18s ease-out;
}

.download-progress-text {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

.download-copy .download-progress-text {
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

.download-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.download-actions .secondary-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.form-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 4px;
}

.empty-school {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
}

.field input:focus-visible,
.field select:focus-visible,
.school-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.icon-button:focus-visible,
.tool-button:focus-visible,
.shape-toggle:focus-visible,
.brush-shape-toggle:focus-visible,
.color-slot:focus-visible,
.editor-color-input:focus-visible,
.layer-toggle:focus-visible,
.mode-tab:focus-visible,
.school-card:focus-visible,
.swatches button:focus-visible {
  outline: 3px solid rgba(47, 111, 102, 0.25);
  outline-offset: 2px;
}

.form-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-note.error {
  color: var(--danger);
}

@media (max-width: 980px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    min-height: 36px;
    display: flex;
    align-items: stretch;
    gap: 6px;
  }

  .topbar-left,
  .topbar-actions {
    min-width: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
  }

  .topbar-left {
    flex: 2 1 0;
  }

  .topbar-actions {
    flex: 1 1 0;
    justify-content: stretch;
  }

  .school-button,
  .topbar .secondary-button,
  .topbar .primary-button {
    width: 100%;
    min-height: 34px;
    padding: 0 6px;
    font-size: 12px;
    white-space: nowrap;
  }

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

  .stat-card {
    min-height: 62px;
    padding: 7px 8px;
  }

  .stat-card strong {
    font-size: 19px;
  }

  .game-info-panel {
    padding: 8px;
  }

  .game-info-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .map-toolbar {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 6px;
  }

  .map-frame {
    height: clamp(330px, calc(var(--app-vh) * 56), 560px);
    min-height: 330px;
    border-radius: 8px;
  }

  .map-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    display: flex;
    justify-content: flex-end;
    max-width: none;
    gap: 5px;
    padding: 5px;
  }

  .map-action-button,
  .map-action-toggle {
    min-height: 34px;
    padding: 0 8px;
    font-size: 12px;
  }

  .map-action-toggle input {
    width: 16px;
    height: 16px;
  }

  .map-zoom-readout {
    top: 8px;
    left: 8px;
    min-width: 56px;
    min-height: 34px;
    display: inline-grid;
    place-items: center;
  }

  .exploration-progress {
    min-width: 0;
    padding: 5px 7px;
  }

  .info-panel {
    height: auto;
    min-height: 260px;
    padding: 8px;
    overflow: visible;
  }

  .current-school {
    right: 8px;
    bottom: 8px;
    max-width: min(42%, 180px);
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    font-size: 12px;
  }

  .game-panel {
    height: auto;
    grid-template-rows: auto;
    overflow: visible;
  }

  .photo-stage {
    min-height: clamp(260px, 54vh, 520px);
    max-height: none;
  }

  .spot-fields,
  .building-fields {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 6px;
  }

  .interior-spot-fields {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }

  .interior-spot-fields select {
    grid-column: 1 / -1;
  }

  .photo-list {
    min-height: 220px;
    max-height: 52vh;
  }

  .photo-tile {
    --photo-max-height: min(46vh, 420px);
  }

  .game-actions.dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-actions.photo-actions {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .room-add-row,
  .room-fields,
  .person-add-row {
    grid-template-columns: 1fr;
  }

  .item-top,
  .person-top {
    grid-template-columns: 1fr;
  }

  .item-photo,
  .person-photo {
    min-height: 260px;
  }

  .dialog-grid {
    grid-template-columns: 1fr;
  }

  .school-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: 8px auto auto 8px;
    overflow: hidden;
  }

  .school-dialog[open] {
    display: grid;
  }

  .dialog-shell {
    max-height: calc(100dvh - 16px);
    overflow: auto;
  }

  .dialog-shell {
    padding: 8px;
  }

  .dialog-section {
    padding: 8px;
  }

  .school-list {
    max-height: 30vh;
    overflow: auto;
  }

  .resource-row {
    grid-template-columns: 76px minmax(0, 1fr) 34px;
  }

  .editor-mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-row,
  .segmented-row.two-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-grid {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }

  .tool-grid.single-row {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }

  .structure-object-form {
    grid-template-columns: 1fr 1fr;
  }

  .map-thumb {
    width: 42px;
    height: 30px;
  }

  .download-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .download-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .download-actions .secondary-button {
    min-width: 0;
    padding: 0 6px;
  }

  .download-progress-text {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .form-footer {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 980px) and (max-height: 760px) {
  .map-frame {
    height: clamp(330px, calc(var(--app-vh) * 64), 520px);
    min-height: 360px;
  }

  .map-action-button,
  .map-action-toggle {
    min-height: 32px;
  }
}
