html:has(.ground-replay[open]) { overflow: hidden; }

.ground-replay {
  position: fixed;
  width: min(1110px, calc(100vw - 32px));
  height: min(690px, calc(100dvh - 26px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: auto;
  border: 1px solid #53637a;
  border-radius: 12px;
  color: #eef4fa;
  background: #101923;
  box-shadow: 0 20px 85px #000b;
}
.ground-replay[open] { display: grid; grid-template-rows: auto minmax(144px, 1fr) auto auto; }
.ground-replay::backdrop { background: #020711df; }
.ground-replay [hidden] { display: none; }
.ground-replay-header {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, auto) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid #46566c;
}
.ground-replay-header h2 { margin: 0; font: 600 1.15rem/1.2 var(--heading); }
.ground-replay-header p { color: #adc8df; margin: 2px 0 0; font-size: .79rem; overflow-wrap: anywhere; }
.ground-replay-status { color: #c9d8e6; text-align: right; overflow-wrap: anywhere; }
.ground-replay-status strong { color: #eef3f8; display: block; font: 600 .92rem/1.2 var(--heading); }
.ground-replay-status span { font-size: .74rem; }
.ground-replay-actions { display: flex; align-items: center; gap: 7px; }
.ground-replay-field {
  --ground-descent: 0;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: #1c2633;
}
.ground-replay-field::before {
  position: absolute;
  z-index: -2;
  inset: -2px;
  content: '';
  background: var(--ground-battle-landscape, url('assets/planet-surface-temperate.jpg')) center 55% / cover no-repeat;
  transform: translateY(calc(var(--ground-descent) * 6%)) scale(calc(1 + var(--ground-descent) * .22));
}
.ground-replay-field::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: '';
  background: linear-gradient(180deg, #08152790, #0b172b3a 33%, #07111b1a 52%, #09121ac9 100%);
}
.ground-replay-field canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.ground-replay-result {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 12px;
  padding: 5px 12px;
  background: #192e3e;
}
.ground-replay-result strong { color: #e8f4fd; font: 600 .89rem/1.1 var(--heading); }
.ground-replay-result p { margin: 2px 0 0; color: #bfd0dc; font-size: .73rem; font-variant-numeric: tabular-nums; }
.ground-replay-unit-list {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  inset: 9px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px 11px 11px;
  border: 1px solid #647c91;
  border-radius: 6px;
  background: #111d2bf4;
}
.ground-replay-unit-list h3 { margin: 0 0 4px; color: #93dcf8; font: 600 .85rem/1.2 var(--heading); overflow-wrap: anywhere; }
.ground-replay-unit-list section:last-child h3 { color: #ffba9b; }
.ground-replay-unit-list ul { margin: 0; padding: 0; list-style: none; }
.ground-replay-unit-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 4px 5px;
  border-bottom: 1px solid #35495b;
  font-size: .75rem;
  overflow-wrap: anywhere;
}
.ground-replay-unit-list li span { color: #c6deef; font-variant-numeric: tabular-nums; }
.ground-replay-info { border-block: 1px solid #46566c; }
.ground-replay-sides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: #101c27;
}
.ground-replay-sides > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px 8px;
  min-width: 0;
  padding: 6px 12px;
  overflow-wrap: anywhere;
  color: #92dbf4;
  font-size: .82rem;
}
.ground-replay-sides [data-side='defender'] { color: #ffba9b; border-left: 1px solid #425569; }
.ground-replay-sides [data-count] { color: #bacadd; font-size: .72rem; }
.ground-replay-metrics {
  display: flex;
  flex-wrap: wrap;
  background: #172433;
  margin: 0;
  padding: 5px 12px 6px;
  gap: 4px 14px;
}
.ground-replay-metrics:empty { display: none; }
.ground-replay-metrics > div { flex: 1 1 85px; }
.ground-replay-metrics dt { color: #bfcedb; font-size: .70rem; line-height: 1.2; }
.ground-replay-metrics dd { color: #f0f8ff; margin: 0; font-size: .86rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ground-replay-controls { display: flex; align-items: center; gap: 8px; padding: 8px 14px 9px; }
.ground-replay button {
  min-height: 36px;
  min-width: 38px;
  padding: 4px 8px;
  border: 1px solid #54708b;
  border-radius: 6px;
  color: #eef6ff;
  background: #182b3d;
  font-size: .80rem;
}
.ground-replay button:hover:not(:disabled) { background: #28485e; }
.ground-replay button:disabled { opacity: .46; }
.ground-replay button[aria-expanded='true'], .ground-replay button[data-report] { border-color: #9acddb; background: #204356; }
.ground-replay button[data-report] { min-height: 32px; }
.ground-replay button:is([data-close], [data-prev], [data-next]) { font-size: 1.35rem; line-height: 1; }
.ground-replay-controls [data-play] { min-width: 90px; }
.ground-replay-controls label { display: flex; flex: 1; min-width: 36px; }
.ground-replay-controls input { width: 100%; min-width: 0; min-height: 24px; accent-color: #91ddef; }
.ground-replay-controls [data-progress] { color: #bdcfe1; white-space: nowrap; font-size: .78rem; font-variant-numeric: tabular-nums; }

@media (max-height: 500px) and (orientation: landscape) {
  .ground-replay { width: calc(100vw - 14px); height: calc(100dvh - 12px); border-radius: 8px; }
  .ground-replay-header { padding: 4px 10px; gap: 7px; }
  .ground-replay-header h2 { font-size: .99rem; }
  .ground-replay-header p, .ground-replay-status span { font-size: .71rem; }
  .ground-replay-status strong { font-size: .86rem; }
  .ground-replay-sides > div { padding: 4px 9px; }
  .ground-replay-metrics { gap: 3px 9px; padding: 4px 9px; }
  .ground-replay-controls { padding: 4px 9px; }
  .ground-replay-unit-list { inset: 5px; }
}

@media (max-width: 575px) {
  .ground-replay-header { grid-template-columns: minmax(98px, 1fr) minmax(84px, auto) auto; }
  .ground-replay-status span { display: none; }
}

@media (orientation: portrait) {
  [data-mobile-device] .ground-replay[open] { display: none !important; }
  [data-mobile-device] .ground-replay::backdrop { display: none; }
}
