#play-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--play-height, 100dvh);
  width: 100vw;
}

#control-guide {
  position: absolute;
  left: 30%;
  bottom: 28%;
  width: 66%;
  z-index: 2;
  white-space: pre-line;
  color: #e5d48f;
  font-size: 1.3cqw;
  line-height: 1.55;
  text-shadow:
    1px 1px #000,
    -1px -1px #000;
  pointer-events: none;
}

.chat-action {
  display: none;
}

body.touch-layout {
  display: block;
  overflow: hidden;
  overscroll-behavior: none;
}

.touch-layout #play-shell {
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
}

.touch-layout #screen {
  width: 100vw;
  aspect-ratio: auto;
  height: var(--play-height, 100dvh);
  overflow: visible;
  z-index: 2;
}

.touch-layout.playing #screen {
  height: calc(100% - var(--touch-pad-height));
}

.touch-layout.playing #screen #field {
  height: 100%;
  bottom: 0;
}

.touch-layout.playing #native-console-art,
.touch-layout.playing #native-console-shield,
.touch-layout.playing .console-counter,
.touch-layout.playing #leaderboard {
  display: none;
}

.touch-layout.playing #screen #hud {
  visibility: hidden;
  pointer-events: none;
}

.touch-layout.playing #screen #map-panel {
  visibility: visible;
  pointer-events: auto;
  position: absolute;
  left: 8px;
  top: auto;
  bottom: 8px;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid #837943;
  background: #020405;
}

.touch-layout.playing #screen #minimap {
  width: 100%;
  height: 100%;
}

.touch-layout.playing #screen #minimap-controls {
  display: none;
}

.touch-layout.playing #screen #order-prompt {
  font-size: 14px;
  bottom: 8px;
  left: 80px;
  max-width: calc(100% - 88px);
}

#touch-dock {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 4px;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  grid-template-rows: 44px 188px 44px;
  gap: 4px;
  flex: 0 0 var(--touch-pad-height);
  height: var(--touch-pad-height);
  overflow: clip;
  color: #d8d8bd;
  font:
    14px/1.4 "Malgun Gothic",
    "Apple SD Gothic Neo",
    Arial,
    sans-serif;
  background: #070b10 url("./dialog-weave72.svg") repeat;
  border-top: 1px solid #29318a;
}

#touch-dock button {
  min-width: 0;
  min-height: 44px;
  padding: 2px;
  font: inherit;
  color: #e2dc69;
  border: 1px solid #30388d;
  border-radius: 0;
  background: #050b13c9;
  box-shadow: inset 0 0 0 2px #111638;
}

#touch-dock button:disabled {
  color: #797b79;
  opacity: 0.65;
}

#touch-dock button[aria-pressed="true"] {
  color: #fff6a0;
  border-color: #86c8c5;
  background: #173035;
}

.touch-nav,
.touch-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 4px;
}

#view-0 {
  color: #ed7065 !important;
}

#view-1 {
  color: #83afff !important;
}

#view-2 {
  color: #7ed8b8 !important;
}

#view-3 {
  color: #d7a8f4 !important;
}

#touch-selection {
  display: flex;
  align-items: center;
  height: 188px;
  min-height: 0;
  overflow: clip;
  flex-direction: column;
  gap: 2px;
}

#touch-dock #portrait-frame {
  position: relative;
  width: 44px;
  height: 40px;
  flex: 0 0 40px;
  margin: 0;
  padding: 0;
  border: 1px solid #47615c;
  background: #000;
}

#touch-dock #portrait {
  width: 100%;
  height: 100%;
}

#touch-dock #portrait-label,
#touch-dock #selection-unit-art {
  display: none;
}

#touch-dock #selection-panel {
  position: static;
  flex: 1;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#touch-dock #selection-title {
  font-size: 13px;
  line-height: 1.3;
  margin: 0;
  text-align: left;
}

#touch-dock #selection-stats,
#touch-dock #selection-extra {
  font-size: 12px;
  line-height: 1.3;
  margin: 0;
  text-align: left;
  white-space: pre-line;
}

#touch-dock #selection-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(4, 44px);
  gap: 4px;
  height: 188px;
  overflow: clip;
}

#touch-dock #selection-grid:empty {
  display: none;
}

#touch-dock #selection-grid button {
  width: 100%;
  height: 44px;
  min-height: 44px;
}

#touch-dock #selection-grid canvas {
  width: 32px;
  height: 32px;
}

#touch-dock #selection-detail {
  position: absolute;
  right: 0;
  bottom: 0;
  min-height: 44px;
  font-size: 12px;
  padding: 2px 4px;
}

#touch-dock #commands {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
}

#touch-dock #commands button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  width: auto;
  height: auto;
}

#touch-dock #commands canvas {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  image-rendering: pixelated;
}

#touch-dock #commands .command-icon {
  font-size: 16px;
  line-height: 1;
}

#touch-dock #commands .command-name {
  position: static;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
#touch-dock #commands button[data-command-kind] {
  gap: 1px;
}
#touch-dock #commands button[data-command-kind] .command-name {
  display: grid;
  line-height: 1;
}
#touch-dock #commands button[data-command-kind] .command-icon {
  height: 14px;
  font-size: 14px;
}
#touch-dock #commands button[data-command-kind] canvas {
  width: 21px;
  height: 14px;
  flex-basis: 14px;
}

#touch-dock #commands kbd {
  display: none;
}

#touch-dock #commands .command-empty {
  min-height: 44px;
  border: 1px solid #1b2532;
}

.touch-layout #screen .map-brief {
  display: none;
}

.touch-layout #screen .identity-row {
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
}

.touch-layout #screen .join-row {
  grid-template-columns: 64px minmax(0, 1fr) 96px;
  gap: 8px;
  font-size: 14px;
}

.touch-layout
  #screen
  :is(.panel-label, .list-heading, .member, .member-name, .member-status, #party-status, #rooms-empty) {
  font-size: 14px;
  line-height: 1.4;
}

.touch-layout #screen .member {
  min-height: 48px;
  padding: 8px 0;
}

.touch-layout #screen .panel-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#touch-dock {
  align-content: start;
}

.touch-nav button,
.touch-actions button {
  word-break: keep-all;
  font-size: 13px !important;
  padding: 2px !important;
}

/* The play pad has a fixed budget; informational text never changes its rows. */
.touch-layout.playing {
  --touch-pad-height: 300px;
}

.touch-layout.playing #play-shell {
  position: fixed;
  top: var(--play-top, 0px);
  left: 0;
  height: var(--play-height, 100dvh);
  min-height: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: clip;
}

.touch-layout.playing #screen {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

#touch-dock #portrait-frame {
  inset: auto;
}

#touch-dock #selection-panel {
  position: relative;
  inset: auto;
}

#touch-dock #selection-panel:has(#selection-detail:not([hidden])) {
  padding-bottom: 44px;
}

#touch-dock #selection-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#touch-dock #selection-stats {
  max-height: 48px;
  overflow: hidden;
}

#touch-dock #touch-selection:has(#selection-grid:not(:empty)) #portrait-frame,
#touch-dock #selection-panel:has(#selection-grid:not(:empty)) > :not(#selection-grid) {
  display: none;
}

#touch-dock #selection-panel:has(#selection-grid:not(:empty)) {
  padding: 0;
}

.touch-layout.playing #screen #topbar {
  top: 4px;
  left: 8px;
  right: 8px;
  height: 22px;
  padding: 0;
  background: none;
  border: 0;
  font-size: 14px;
  pointer-events: none;
}

.touch-layout.playing #screen :is(#timer, .resources) {
  font-size: 14px;
  gap: 8px;
}

.touch-layout.playing #screen #stage {
  top: 28px;
  left: 8px;
  right: 8px;
  bottom: auto;
  width: auto;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.touch-layout.playing #screen #control-guide {
  top: 52px;
  left: 8px;
  bottom: auto;
  width: calc(100% - 16px);
  font-size: 13px;
  line-height: 1.45;
}

.touch-layout.playing #screen #announcements {
  left: 80px;
  bottom: 8px;
  width: calc(100% - 88px);
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
}

.touch-layout.playing #screen #announcements .match-line:nth-last-child(n + 3) {
  display: none;
}

.touch-layout.playing #screen #announcements .match-line {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.touch-layout.playing #screen #announcements button {
  pointer-events: auto;
  min-height: 44px;
}

.touch-layout.playing:has(#match-chat.expanded) #touch-dock {
  display: none;
}

.touch-layout.playing:has(#match-chat.expanded) #screen {
  width: 100%;
  height: 100%;
}

.touch-layout.touch-landscape.playing #play-shell {
  flex-direction: row;
}

.touch-layout.touch-landscape.playing #screen {
  height: 100%;
  width: calc(100% - 300px);
}

.touch-layout.touch-landscape.playing #touch-dock {
  flex: 0 0 300px;
  width: 300px;
  height: 100%;
  border-top: 0;
  border-left: 1px solid #29318a;
  align-content: center;
}

#touch-dock .touch-nav,
#touch-dock .touch-actions {
  grid-column: 1 / -1;
}

#touch-dock #touch-selection {
  grid-column: 1;
  grid-row: 2;
}

#touch-dock #touch-commands {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
}

#touch-dock #selection-panel:has(#selection-grid:not(:empty)) {
  flex: 0 0 188px;
}

.touch-layout.playing #screen .console-counter {
  display: none;
}

.touch-layout.playing #screen #timer {
  position: relative;
  inset: auto;
  font-size: 14px;
}

.touch-layout.playing #screen #topbar {
  display: flex;
}

.touch-layout.playing #screen .resources {
  position: static;
  display: flex;
  margin-left: auto;
  width: auto;
}

.touch-layout.playing #screen .resources > span {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.touch-layout.playing #screen :is(#minerals, #gas, #supply) {
  font-size: 14px;
}

.touch-layout.playing #screen.resource-art72 .resource-symbol {
  width: 14px;
  height: 14px;
  background-size: 156px 42px;
}

.touch-layout.playing #screen.resource-art72 .gas .resource-symbol {
  background-position: -28px 0;
}

.touch-layout.playing #screen.resource-art72 .supply .resource-symbol {
  background-position: -70px 0;
}

/* Lobby information follows the full-height scene; the battlefield never scrolls. */
html:has(#lobby:not([hidden])),
body:has(#lobby:not([hidden])) {
  height: auto;
  min-height: 100dvh;
  overflow-y: auto;
}
body:has(#lobby:not([hidden])) {
  display: block;
}
.site-footer {
  display: none;
}
body:has(#lobby:not([hidden])) .site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid #28363b;
  padding: 18px 24px;
  color: #9aaba5;
  font:
    12px/1.5 "Malgun Gothic",
    "Apple SD Gothic Neo",
    sans-serif;
}
.site-footer a {
  color: inherit;
  text-underline-offset: 3px;
}
.site-footer .guide-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
