/* The hosted page (server/client/hosted.js): the game fills the frame, and
   none of upstream's shell chrome shows. */

html.halo-hosted,
html.halo-hosted body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: #e6f2fb;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
html.halo-hosted body::before,
html.halo-hosted body::after,
html.halo-hosted main::after { display: none !important; }

html.halo-hosted header,
html.halo-hosted #game-frame > footer,
html.halo-hosted #duke-legend,
html.halo-hosted #player-sidebar,
html.halo-hosted #online-dialog,
html.halo-hosted #about-dialog,
html.halo-hosted #campaign-loading { display: none !important; }

html.halo-hosted main#game-area {
  position: fixed;
  inset: 0;
  display: block;
  background: #000;
}
html.halo-hosted #game-frame {
  position: absolute;
  inset: 0;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  transform: none;
  display: block;
}
html.halo-hosted #game-frame::before { display: none; }
/* The canvas keeps its 16:9 backing store; the frame letterboxes it. */
html.halo-hosted #game-frame canvas.emscripten,
html.halo-hosted #game-frame canvas.emscripten.ready {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
  border: 0;
  box-shadow: none;
  clip-path: none;
  background: #000;
}

/* the shell's start-up screen, as the page's loading screen */
html.halo-hosted #loading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, #0b2742, #02070f 70%);
}
html.halo-hosted #loading[hidden] { display: none; }
html.halo-hosted #loading::before,
html.halo-hosted #loading::after { display: none; }

#hosted-ui button {
  min-height: 2.25rem;
  padding: .4rem .9rem;
  border: 1px solid rgba(110, 190, 240, .55);
  border-radius: .35rem;
  color: #e6f2fb;
  background: rgba(10, 40, 66, .9);
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
}
#hosted-ui button:hover,
#hosted-ui button:focus-visible { border-color: #8fd3ff; background: rgba(18, 66, 104, .95); outline: none; }
#hosted-ui button.primary { border-color: #6cc6ff; background: #0d6fb3; font-weight: 600; }
#hosted-ui button.primary:hover,
#hosted-ui button.primary:focus-visible { background: #1689d6; }
#hosted-ui [hidden] { display: none !important; }

/* the lobby: a panel over the game, scrolling in a short frame */
#hosted-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  overflow-y: auto;
  padding: clamp(.75rem, 3vh, 2rem) clamp(.75rem, 3vw, 2rem);
  background: rgba(2, 8, 16, .88);
  text-align: center;
}
#hosted-panel.picking { justify-content: flex-start; }
#hosted-title { margin: 0 0 .35rem; font-size: clamp(1.2rem, 3.2vh, 1.8rem); font-weight: 600; }
#hosted-text { margin: 0 0 .75rem; color: #a9c4d8; }
#hosted-notice { margin: 0 auto .75rem; max-width: 36rem; color: #ffb4a8; }
#hosted-picker { max-width: 64rem; margin: 0 auto; }
/* the server-wide lobby: matches in the server's other voice channels */
#hosted-guild { max-width: 48rem; margin: 0 auto .9rem; text-align: left; }
#hosted-guild-title { margin: 0 0 .4rem; font-size: 1rem; font-weight: 600; color: #a9c4d8; }
#hosted-guild-list { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.hosted-guild-room {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) auto auto 7.5rem;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem;
  border: 1px solid rgba(143, 211, 255, .25);
  border-radius: .3rem;
  background: rgba(10, 30, 50, .7);
}
.hosted-guild-host, .hosted-guild-what { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hosted-guild-what, .hosted-guild-state { color: #a9c4d8; font-size: .9rem; }
.hosted-guild-players { font-variant-numeric: tabular-nums; }
#hosted-ui .hosted-guild-join:disabled { opacity: .6; cursor: default; }
.hosted-maps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: .5rem;
  margin-bottom: .75rem;
}
.hosted-modes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
  margin-bottom: .75rem;
}
#hosted-ui .hosted-map,
#hosted-ui .hosted-mode {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .25rem;
  padding: .3rem;
  overflow: hidden;
}
#hosted-ui .hosted-mode { flex-direction: row; align-items: center; padding: .25rem .6rem .25rem .3rem; }
.hosted-map img { width: 100%; aspect-ratio: 140 / 114; object-fit: cover; border-radius: .2rem; }
.hosted-mode img { width: 2.6rem; aspect-ratio: 140 / 114; object-fit: cover; border-radius: .15rem; }
.hosted-card-label { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hosted-ui .selected { border-color: #8fd3ff; background: #0d4f80; box-shadow: 0 0 0 2px rgba(143, 211, 255, .45); }
.hosted-actions { position: sticky; bottom: 0; padding: .4rem 0; background: rgba(2, 8, 16, .9); }
#hosted-host { min-width: 10rem; }
#hosted-ui .hosted-link { align-self: center; margin-top: .75rem; background: transparent; }

/* in Halo's own lobby: a bar along the top */
#hosted-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 16;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .4rem .75rem;
  background: rgba(2, 8, 16, .8);
}
#hosted-bar-text { margin-right: .5rem; }

/* Team games: red and blue, in the lobby and (read-only) during a match. */
#hosted-teams {
  position: fixed;
  z-index: 16;
  top: .45rem;
  left: 50%;
  translate: -50% 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
  width: min(34rem, calc(100% - 1rem));
  pointer-events: none;
}
#hosted-teams .hosted-team {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
  padding: .3rem .4rem .4rem;
  border-radius: .35rem;
  text-align: left;
}
#hosted-teams .hosted-team.red {
  background: rgba(92, 18, 22, .9);
  border: 1px solid rgba(255, 140, 140, .55);
}
#hosted-teams .hosted-team.blue {
  background: rgba(14, 42, 110, .9);
  border: 1px solid rgba(140, 180, 255, .55);
}
/* (up to 64 players, 32 a side) names in columns as wide allows, the list
   scrolling past a third of the height; this player's name comes first */
#hosted-teams .hosted-team-players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: .15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 1.2rem;
  max-height: 33vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#hosted-teams .hosted-team-players > li { min-width: 0; }
#hosted-ui #hosted-teams .hosted-team-header,
#hosted-ui #hosted-teams .hosted-team-player {
  background: transparent;
  border-color: transparent;
  text-align: left;
  padding: .1rem .25rem;
}
#hosted-ui #hosted-teams .hosted-team-header {
  font-weight: 700;
  letter-spacing: .04em;
}
#hosted-teams .hosted-team.red .hosted-team-header { color: #ffc2c2; }
#hosted-teams .hosted-team.blue .hosted-team-header { color: #c9dcff; }
#hosted-ui #hosted-teams .hosted-team-player {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .92rem;
  font-weight: 400;
  color: #e6f2fb;
}
#hosted-ui #hosted-teams .hosted-team-player.self { font-weight: 700; }
#hosted-teams[data-interactive="true"] { pointer-events: auto; }
#hosted-teams[data-interactive="true"] .hosted-team-header,
#hosted-teams[data-interactive="true"] .hosted-team-player.self {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: .15rem;
}
#hosted-ui #hosted-teams button:disabled,
#hosted-ui #hosted-teams button:disabled:hover,
#hosted-ui #hosted-teams button:disabled:focus-visible {
  border-color: transparent;
  background: transparent;
  cursor: default;
  opacity: 1;
}
#hosted-bar > #hosted-teams,
#hosted-panel > #hosted-teams,
#hosted-overlay-main > #hosted-teams {
  position: static;
  translate: none;
  width: min(34rem, 100%);
  margin: .35rem auto 0;
  pointer-events: auto;
}
@media (max-width: 30rem) {
  #hosted-teams { width: calc(100% - .75rem); }
}

/* the mouse is free: click to play, or the paused menu */
#hosted-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(0, 0, 0, .55);
}
.hosted-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .6rem;
  min-width: min(18rem, 90vw);
  padding: 1rem 1.25rem;
  border: 1px solid rgba(110, 190, 240, .35);
  border-radius: .5rem;
  background: rgba(4, 16, 30, .94);
}
#hosted-overlay-title { margin: 0; text-align: center; font-size: 1.3rem; }
#hosted-resume { min-height: 2.75rem; font-size: 1.1rem; }
.hosted-audio { display: flex; align-items: center; gap: .6rem; }
.hosted-audio input { flex: 1; accent-color: #6cc6ff; }
.hosted-overlay-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.hosted-overlay-actions button { flex: 1 1 6.5rem; }
.hosted-hint { margin: 0; color: #7f9db3; font-size: .78rem; text-align: center; }
#hosted-end-confirm { display: flex; flex-direction: column; gap: .45rem; }
#hosted-end-confirm-text { margin: 0; color: #ffcf8a; text-align: center; }

/* Settings, in the overlay: the mouse and the controls */
.hosted-settings { width: min(34rem, 92vw); max-height: 92vh; overflow-y: auto; box-sizing: border-box; }
.hosted-settings h3 { margin: .4rem 0 0; font-size: .95rem; color: #a9c4d8; }
.hosted-sensitivity { display: flex; align-items: center; gap: .6rem; }
.hosted-sensitivity input { flex: 1; accent-color: #6cc6ff; }
.hosted-sensitivity output { min-width: 3.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.hosted-capture-notice { margin: 0; min-height: 1.2em; color: #a9c4d8; font-size: .85rem; }
.hosted-capture-notice.warning { color: #ffcf8a; }
.hosted-controls { display: grid; gap: .25rem; }
.hosted-control { display: grid; grid-template-columns: 9rem 1fr auto; align-items: center; gap: .4rem; }
.hosted-control-label { font-size: .9rem; }
.hosted-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
#hosted-ui .hosted-chip,
#hosted-ui .hosted-add { min-height: 1.8rem; padding: .15rem .5rem; font-size: .82rem; }
#hosted-ui .hosted-chip.conflict { border-color: #ffb45c; color: #ffd9a8; }
#hosted-ui .hosted-add { min-width: 2.2rem; }
#hosted-ui .hosted-add.capturing { border-color: #8fd3ff; background: #0d4f80; }
.hosted-unbound { color: #7f9db3; font-size: .82rem; font-style: italic; }
@media (max-width: 30rem) {
  .hosted-control { grid-template-columns: 1fr auto; }
  .hosted-chips { grid-column: 1 / -1; order: 3; }
}

/* the browser refused the mouse: playing on, with a way back */
#hosted-lock-notice {
  position: fixed;
  left: .75rem;
  bottom: .75rem;
  z-index: 17;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  max-width: min(36rem, calc(100% - 1.5rem));
  padding: .5rem .75rem;
  border: 1px solid rgba(255, 190, 120, .5);
  border-radius: .4rem;
  background: rgba(30, 16, 4, .9);
  font-size: .85rem;
}
#hosted-lock-notice span { flex: 1 1 18rem; }

#hosted-map-loading {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 12;
  display: grid;
  gap: .3rem;
  width: min(22rem, calc(100% - 2rem));
  padding: .5rem .75rem;
  border-radius: .35rem;
  background: rgba(0, 0, 0, .8);
  font-size: .85rem;
  pointer-events: none;
  translate: -50% 0;
}
#hosted-map-loading progress { width: 100%; height: 4px; accent-color: #6cc6ff; }

/* (a spectator) whom it watches, over the top of the game; clicks pass
   through to the game area, which picks the next player */
#hosted-spectate {
  position: fixed;
  left: 50%;
  top: .75rem;
  z-index: 12;
  display: grid;
  gap: .15rem;
  padding: .4rem .9rem;
  border-radius: .35rem;
  background: rgba(0, 0, 0, .7);
  text-align: center;
  pointer-events: none;
  translate: -50% 0;
}
#hosted-spectate-name { font-weight: 600; }
#hosted-overlay-text { margin: 0; color: #a9c4d8; text-align: center; }

@media (max-width: 40rem) {
  .hosted-guild-room { grid-template-columns: minmax(0, 1fr) auto 6.5rem; }
  .hosted-guild-what { grid-column: 1; grid-row: 2; }
  .hosted-guild-state { grid-column: 2; grid-row: 2; }
}

@media (max-height: 420px) {
  .hosted-maps { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); }
  .hosted-map img { aspect-ratio: 2 / 1; }
  #hosted-title { font-size: 1.1rem; }
}
