/* Phone is the default play surface; Wide preserves the desktop workspace. */
.display-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--site-line);
  border-radius: 4px;
}
.display-switch button {
  border: 0;
  background: transparent;
  color: var(--site-ink);
  min-height: 44px;
  padding: 7px 12px;
  font-size: var(--type-body);
  font-weight: 700;
  border-radius: 2px;
}
.display-switch [aria-pressed='true'] {
  background: var(--site-ink);
  color: var(--paper);
}
.site-tools {
  gap: 10px;
}
.site-header {
  min-height: 56px;
}
#main {
  min-width: 0;
}
#game-frame {
  container: game / size;
  contain: layout style size;
  position: relative;
  width: 100%;
  height: min(1040px, calc(100svh - 100px));
  min-height: 0;
  margin-inline: auto;
}
:root[data-display-mode='phone'] #game-frame {
  width: min(100%, 430px);
  height: min(932px, calc(100svh - 100px));
  min-height: 0;
}
#game-frame > .game-shell {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  border-radius: 4px;
}
#game-frame .game-shell #app {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: auto;
}
#game-frame .game-shell[data-screen='title'] #app {
  overflow: hidden;
}
#game-frame #navigation {
  position: relative;
  bottom: auto;
  flex: 0 0 auto;
}
:root[data-display-mode='phone'] .page > footer {
  max-width: 430px;
  margin-inline: auto;
  min-height: 40px;
}
#main:fullscreen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--night);
  overflow: auto;
}
#main:fullscreen #game-frame {
  height: 100svh;
  max-height: none;
  min-height: 0;
}
:root[data-display-mode='phone'] #main:fullscreen #game-frame {
  max-height: 932px;
}
/* Native dialogs keep modal semantics, with geometry aligned to the visible game. */
#game-frame dialog {
  position: fixed;
  left: var(--dialog-left, 0px);
  right: calc(100% - var(--dialog-left, 0px) - var(--dialog-width, 100vw));
  top: var(--dialog-top, 0px);
  bottom: calc(100% - var(--dialog-top, 0px) - var(--dialog-height, 100svh));
  margin: auto;
  transform: none;
  max-width: calc(var(--dialog-width, 100vw) - 16px);
  max-height: calc(var(--dialog-height, 100svh) - 16px);
  overflow: auto;
}
#game-frame dialog::backdrop {
  background: #07151cc9;
}
@container game (max-width:700px) {
  #game-frame .game-shell {
    border-radius: 3px;
  }
  .match-player-dialog,
  .bowling-planner-dialog {
    height: auto;
    min-height: 0;
  }
  #game-frame .tactical-controls,
  #game-frame .batting-target-sheet {
    left: 10px;
    right: 10px;
    bottom: 12px;
    width: auto;
    max-width: none;
    max-height: calc(100cqh - 28px);
  }
  #game-frame .field-inspector {
    left: 10px;
    right: 10px;
    bottom: 12px;
    max-height: calc(100cqh - 28px);
  }
}
@media (max-width: 700px) {
  .page {
    padding: 0 6px;
  }
  .site-header {
    padding: 0;
    min-height: 52px;
    height: 52px;
  }
  .wordmark {
    font-size: var(--type-name);
  }
  .site-tools {
    gap: 5px;
  }
  .theme-toggle {
    min-height: 44px;
    padding: 5px;
  }
  .theme-toggle svg {
    width: 16px;
    height: 16px;
  }
  .display-switch {
    gap: 0;
    padding: 1px;
  }
  .display-switch button {
    padding: 6px 8px;
    font-size: var(--type-caption);
    min-height: 44px;
  }
  #game-frame,
  :root[data-display-mode='phone'] #game-frame {
    height: calc(100svh - 92px);
    min-height: 0;
  }
  .page > footer,
  :root[data-display-mode='phone'] .page > footer {
    min-height: 40px;
    font-size: var(--type-caption);
  }
}
