/* Mobile lobby and dialogs share one responsive owner. Original skins remain in dialog72.css. */
.touch-layout #screen .lobby {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

.touch-layout #screen .lobby-shell {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  font-size: 14px;
}

.touch-layout #screen .lobby-heading {
  padding: 0 0 8px;
  min-height: 36px;
}

.touch-layout #screen .lobby-heading h1,
.touch-layout #screen .lobby-heading h2 {
  font-size: 21px;
  line-height: 1.3;
}

.touch-layout #screen .lobby-heading p,
.touch-layout #screen .lobby-heading span {
  font-size: 13px;
}

.touch-layout #screen .lobby-columns {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.touch-layout #screen .lobby-main {
  grid-template-rows: 48px 30px minmax(70px, 1fr) 48px;
  gap: 8px;
}

.touch-layout #screen #party .lobby-main {
  grid-template-rows: 48px 30px minmax(70px, 1fr) 28px;
}

.touch-layout #screen .lobby-shell .menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 0;
}

.touch-layout #screen .lobby-shell .menu-actions button {
  margin: 0;
}

.touch-layout #screen :is(.lobby-shell, .window, .lobby-create) :is(button, input, select) {
  min-height: 44px;
  font-size: 16px;
  padding: 6px 8px;
}

.touch-layout #screen .lobby-shell #rooms button {
  min-height: 48px;
  font-size: 15px;
}

.touch-layout #screen :is(.list-heading, .lobby-shell #rooms button) {
  grid-template-columns: minmax(0, 1fr) 40px 40px 68px;
  gap: 8px;
}

.touch-layout #screen .game-list {
  grid-template-rows: 32px minmax(0, 1fr) auto;
}

.touch-layout #screen .lobby-shell #join-selected {
  min-height: 44px;
  font-size: 15px;
}

.touch-layout #screen .room-select {
  gap: 8px;
  padding: 4px 4px 4px 10px;
}

.touch-layout #screen #room-detail {
  font-size: 14px;
}

.touch-layout #screen .lobby-shell .panel-label :is(#rooms-previous, #rooms-next) {
  width: auto;
  min-width: 56px;
  height: 44px;
  margin: 0;
}

.touch-layout #screen .overlay:not(.lobby) {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--play-height, 100dvh);
  padding: 12px;
  z-index: 12;
}

.touch-layout #screen :is(.window, .lobby-create) {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(var(--play-height, 100dvh) - 24px);
  padding: 16px;
  font-size: 14px;
  overflow: auto;
}

.touch-layout #screen .window h2 {
  font-size: 20px;
  line-height: 1.4;
}

.touch-layout #screen :is(.help-window dl, #history-lines, #unit-detail-text, .game-info-content) {
  font-size: 14px;
  line-height: 1.6;
}

.touch-layout #screen .result {
  position: fixed;
  top: calc(var(--play-height, 100dvh) / 2);
  left: 50vw;
  z-index: 12;
}

.touch-layout #screen .help-window dt {
  font-size: 14px;
}

.touch-layout #screen #error {
  position: fixed;
  left: 12px;
  bottom: 12px;
  font-size: 14px;
  max-width: calc(100vw - 24px);
  z-index: 20;
}

.touch-layout #screen .lobby-main {
  grid-template-rows: 48px 44px minmax(70px, 1fr) 48px;
}

.touch-layout #screen .lobby-shell .panel-label #browse {
  position: static;
  width: auto;
  min-width: 92px;
  height: 44px;
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
}

.touch-layout #screen .lobby-shell .menu-actions button {
  width: 100%;
}

.touch-layout #screen .lobby-shell .menu-actions :is(#lobby-settings, #invite) {
  margin-right: 0;
  width: 100%;
}

.touch-layout #screen #title small {
  font-size: 12px;
}

.touch-layout #screen :is(.window, .lobby-create) h2 {
  font-size: 20px;
  line-height: 1.4;
}

.touch-layout #screen .lobby-create .selected-map {
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 12px;
  margin: 12px 0;
}

.touch-layout #screen .lobby-create .selected-map h3 {
  font-size: 16px;
  line-height: 1.4;
}

.touch-layout #screen .lobby-create .selected-map p {
  font-size: 13px;
  line-height: 1.5;
  margin: 4px 0;
}

.touch-layout #screen :is(.window, .lobby-create) .check-row {
  min-height: 44px;
  gap: 8px;
  font-size: 16px;
}

.touch-layout #screen :is(.window, .lobby-create) input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-height: 24px;
  flex: 0 0 24px;
  background-size: 100% 100%;
}

.touch-layout.touch-landscape #screen .lobby-shell .menu-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Dialogs cover the complete play shell, including the fixed control pad. */
.touch-layout.playing #screen:has(.overlay:not(.lobby):not([hidden])),
.touch-layout.playing #screen:has(#result:not([hidden])) {
  overflow: visible;
  z-index: 10;
}
.touch-layout.playing #screen #field:has(#result:not([hidden])) {
  overflow: visible;
}
.touch-layout #screen #menu {
  align-items: center;
  padding: 12px;
}
.touch-layout #screen #menu .menu-window,
.touch-layout #screen #help-panel .window {
  width: min(440px, calc(100vw - 24px));
}
.touch-layout #screen #menu .menu-window h2 {
  font-size: 20px;
  line-height: 1.4;
}
.touch-layout #screen :is(.window, .lobby-create) {
  overflow: hidden;
}
.touch-layout #screen .settings-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}
.touch-layout #screen .settings-content > * {
  flex-shrink: 0;
}
.touch-layout #screen .settings-window > .menu-actions {
  margin-top: 8px;
}
.touch-layout #screen .window > button,
.touch-layout #screen .window .menu-actions button {
  min-width: 64px;
}
.touch-layout #screen #result {
  position: fixed;
  top: calc(var(--play-height, 100dvh) / 2);
  left: 50vw;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 24px));
}
.touch-layout #screen #game-info nav button {
  font-size: 14px;
  padding: 4px 8px;
}
.touch-layout #screen .game-info-content {
  max-height: 360px;
  min-height: 0;
  flex: 1 1 auto;
}
.touch-layout #screen #history-lines {
  height: auto;
  min-height: 64px;
  max-height: 320px;
  flex: 1 1 auto;
}
@media (max-height: 480px) {
  .touch-layout #screen #menu .menu-window {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  .touch-layout #screen #menu .menu-window h2 {
    grid-column: 1 / -1;
    margin: 0 0 8px;
  }
  .touch-layout #screen #menu #resume {
    margin: 0;
  }
}
@media (max-width: 400px) {
  .touch-layout #screen #game-info nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
}
