.aa-room {
  --line: #344761;
  --ink: #e8eef7;
  --dim: #a3b3c7;
  --gold: #efd092;
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 24px 26px;
  color: var(--ink);
}

.aa-room :is(h1,h2,h3,h4,p),.aa-order h3,.aa-round h4 {
  margin: 0;
}

.aa-nav,.aa-actions,.aa-team-foot,.aa-squad header,.aa-squad header > div,.aa-wait-actions,.aa-round-title,.aa-order div,.aa-player-stats > div,.aa-fight,.aa-fight > div,.aa-record header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aa-nav {
  margin-bottom: 10px;
  color: var(--dim);
  font-size: 13px;
}

.aa-nav > div {
  margin-left: auto;
  display: flex;
  gap: 5px;
}

.aa-nav button,.aa-team-foot button,.aa-actions button,.aa-order button,.aa-fight button {
  padding: 5px 12px;
  min-height: 30px;
}

.aa-wait {
  max-width: 980px;
  margin: 30px auto;
  border: 1px solid var(--line);
  background: linear-gradient(110deg,#122846e8,#121b2ee8),url('/assets/battlefield.jpg') center/cover;
  border-radius: 10px;
  padding: clamp(16px,4vw,54px);
}

.aa-wait header > span,.aa-record header > span,.aa-score > div:first-child span {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .07em;
}

.aa-wait h1 {
  margin: 9px 0;
  font-size: clamp(24px,4vw,40px);
}

.aa-wait header p,.aa-seat span,.aa-team-foot,.aa-actions,.aa-round small {
  color: var(--dim);
}

.aa-side.blue,.aa-squad.blue {
  --accent: #79bcf2;
  --tint: #223c59;
}

.aa-side.red,.aa-squad.red {
  --accent: #ef9a90;
  --tint: #493037;
}

.aa-wait-grid,.aa-locked,.aa-player-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.aa-wait-grid {
  margin: 26px 0;
}

.aa-side {
  min-width: 0;
}

.aa-side h2 {
  color: var(--accent);
  font-size: 16px;
  letter-spacing: .12em;
}

.aa-seat {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: linear-gradient(105deg,var(--tint),#101c2c);
}

.aa-seat > div {
  flex: 1;
  display: grid;
  gap: 4px;
}

.aa-seat > span,.aa-seat button:not(.player-link) {
  font-size: 12px;
}

.aa-seat small {
  color: var(--accent);
}

.aa-wait-actions {
  flex-wrap: wrap;
}

.aa-wait-actions .primary {
  margin-left: auto;
}

.aa-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 15px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-top: 2px solid #bc9b66;
  background: linear-gradient(100deg,#162d48,#111d2e 60%,#342630);
  border-radius: 5px;
}

.aa-score > div:first-child {
  display: grid;
  gap: 3px;
}

.aa-score small,.aa-score > div:first-child b {
  font-size: 13px;
  color: var(--dim);
}

.aa-score strong {
  font: 700 32px/1.1 Georgia,serif;
  white-space: nowrap;
}

.aa-score i,.aa-score em {
  font: 600 13px/1 sans-serif;
  color: #8bbce5;
}

.aa-score i:last-child {
  color: #e4a099;
}

.aa-score em {
  color: #b8a581;
  font-size: 26px;
}

.aa-instruction {
  text-align: right;
}

.aa-clock {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  color: #efcf91;
  margin-top: 3px;
}

.aa-clock b,.aa-army,.aa-team-foot [data-aa-deadline] {
  font-variant-numeric: tabular-nums;
}

.aa-room progress {
  height: 5px;
  max-width: 90px;
  accent-color: #d5ad6b;
}

.aa-bans {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  background: #111c2d;
  border-bottom: 1px solid var(--line);
}

.aa-bans > div {
  display: flex;
  align-items: center;
  gap: 5px;
}

.aa-bans b {
  font-size: 12px;
  color: #b1c1d5;
}

.aa-bans span {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 30px;
  border: 1px solid #465368;
  background: #1c283a;
  border-radius: 3px;
  overflow: hidden;
}

.aa-bans img,.aa-history img,.aa-locked img,.aa-public img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.aa-bans small {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: #08111d9e;
  text-align: center;
  font-size: 9px;
}

.aa-field {
  display: grid;
  grid-template-columns: minmax(0,1fr) 26px minmax(0,1fr);
  gap: 9px;
  padding: 10px 0;
}

.aa-field .aa-side {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.aa-vs {
  align-self: center;
  text-align: center;
  font: bold italic 17px/1 Georgia,serif;
  color: #ac976f;
}

.aa-squad {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: linear-gradient(100deg,var(--tint),#152234 50%,#121c2c);
  padding: 6px 9px;
  border-radius: 5px;
}

.aa-squad header {
  justify-content: space-between;
  color: var(--accent);
  font-size: 12px;
  margin-bottom: 5px;
}

.aa-squad .player-avatar {
  width: 25px;
  height: 25px;
}

.aa-squad .player-link {
  max-width: 170px;
}

.aa-cards {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 5px;
}

.aa-hero {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(78px,13vh,138px);
  padding: 0;
  background: #142238;
  border: 1px solid #586175;
  overflow: hidden;
  isolation: isolate;
}

.aa-hero > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 19%;
}

.aa-hero .slot-name {
  position: absolute;
  inset: auto 0 0;
  padding: 13px 3px 3px;
  background: linear-gradient(transparent,#08111ee8);
  font-weight: bold;
  color: #fff;
}

.aa-hero .card-faction,.aa-position {
  position: absolute;
  top: 3px;
  left: 4px;
  padding: 1px 4px;
  border-radius: 2px;
  background: #0b1526c9;
  color: #eee6cd;
  font-size: 10px;
}

.aa-position {
  left: auto;
  right: 3px;
}

.aa-hero .card-stars {
  position: absolute;
  bottom: 4px;
  left: 4px;
  color: #ebbd6b;
  font-size: 8px;
  z-index: 1;
}

.aa-hero.empty {
  display: grid;
  place-content: center;
  border-style: dashed;
  color: #8295ae;
  font-size: 12px;
  background: linear-gradient(140deg,#182940,#111d30);
}

.aa-team-foot {
  justify-content: space-between;
  min-height: 18px;
  font-size: 12px;
}

.aa-team-foot button {
  margin: 0;
  border: 0;
  background: none;
  color: #b7c9dc;
  min-height: 20px;
  padding: 0 3px;
  font-size: 11px;
}

.aa-team-foot span:first-child {
  margin-right: auto;
}

.aa-loadout {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 5px;
  font-size: 10px;
  color: #b9c8da;
}

.aa-loadout span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aa-history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 26px;
}

.aa-history > div {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.aa-history > div > b {
  max-width: 20%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  font-size: 12px;
}

.aa-history button {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  font-size: 10px;
}

.aa-history button img {
  width: 16%;
  max-width: 20px;
  height: 22px;
}

.aa-history button em {
  font-style: normal;
  color: #ebcf90;
}

.aa-actions {
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  margin-top: 6px;
  border-top: 1px solid var(--line);
  background: #0f1929;
}

.aa-actions .primary {
  min-width: 120px;
}

.aa-order {
  margin: 10px 0;
  padding: 12px;
  background: #16263a;
  border: 1px solid #47576c;
  border-radius: 5px;
}

.aa-order > div {
  padding: 6px 0;
}

.aa-order > div > b {
  color: #eed097;
}

.aa-order small {
  color: #b0c0d2;
}

.aa-field:has(.active-leg) .aa-squad.active-leg {
  order: 1;
}

.aa-field:has(.active-leg) .aa-squad.reserve {
  order: 2;
}

.aa-squad.reserve .aa-hero {
  height: 45px;
}

.aa-squad.active-leg .aa-hero {
  height: clamp(120px,20vh,200px);
}

.aa-squad.active-leg {
  border-color: var(--accent);
}

.aa-troops {
  position: absolute;
  left: 4px;
  bottom: 26px;
  background: #0c1728df;
  padding: 2px;
  font-size: 11px;
}

.aa-army {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}

.aa-army progress {
  flex: 1;
  max-width: none;
  accent-color: var(--accent);
}

.aa-record header {
  padding: 15px;
  flex-wrap: wrap;
  background: linear-gradient(105deg,#25384e,#1a2337);
  border-top: 2px solid #bc9c68;
}

.aa-record header h2 {
  font-size: 23px;
}

.aa-record header strong {
  color: #f1d399;
  font-size: 30px;
}

.aa-player-stats {
  margin: 8px 0;
}

.aa-player-stats > div {
  background: #182638;
  padding: 6px;
  flex-wrap: wrap;
  font-size: 12px;
}

.aa-player-stats small {
  color: #a5b7c9;
}

.aa-record > details,.aa-round {
  padding: 10px;
  border: 1px solid #34455a;
  background: #121e2f;
}

.aa-record summary {
  cursor: pointer;
}

.aa-round-title {
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 16px;
}

.aa-locked > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.aa-locked button {
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 6px;
  font-size: 12px;
}

.aa-locked img {
  width: 27px;
  height: 34px;
  margin-right: 2px;
}

.aa-round h4 {
  margin: 8px 0 2px;
}

.aa-fight {
  padding: 7px 0;
  border-bottom: 1px solid #34455a;
  flex-wrap: wrap;
  font-size: 13px;
}

.aa-fight > div {
  flex: 1;
  flex-wrap: wrap;
}

.aa-sweep {
  display: inline-block;
  color: #ffdb91;
  padding: 4px 9px;
  border: 1px solid #ae8549;
  background: #473a26;
  border-radius: 4px;
  animation: aa-gold 1s ease-out;
}

@keyframes aa-gold {
  from {
    box-shadow: 0 0 16px #e7b353;
    transform: scale(1.04);
  }
  to {
    box-shadow: none;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion:reduce) {
  .aa-sweep {
    animation: none;
  }
}

.aa-history-dialog[open] {
  width: min(960px,96vw);
  max-height: 92dvh;
  overflow: auto;
  padding: 14px;
}

.aa-history-dialog header,.aa-history-dialog nav {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin: 5px 0;
}

.aa-history-dialog header button {
  margin-left: auto;
}

.aa-history-dialog h2 {
  margin: 0;
}

.aa-history-dialog button[aria-pressed=true] {
  color: #f4d99f;
  border-color: #c7a361;
}

.aa-public img {
  width: 48px;
  height: 60px;
  vertical-align: middle;
}

.aa-detail-points {
  font-size: 12px;
  color: #b6c7d9;
}

.aa-order-shortcut {
  margin-left: 4px;
  font-size: 12px;
  padding: 4px;
}

.chat-channels:not([hidden]) {
  display: flex;
  gap: 8px;
  padding: 2px 8px;
}

.chat-channels label {
  font-size: 11px;
}

.chat-channels select {
  margin-left: 3px;
  padding: 2px;
  font-size: 12px;
}

.aa-clock[data-warning=urgent] {
  color: #ff9b88;
}

@media (max-width:1024px) and (max-height:550px),(max-width:640px) {
  .aa-room {
    padding: 4px;
  }
  .aa-room .aa-nav {
    gap: 5px;
  }
  .aa-playing {
    height: var(--arena-height);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  body:has(.aa-playing) #app > .topbar,.aa-playing .aa-nav {
    display: none;
  }
  .aa-score {
    flex: none;
    gap: 5px;
    padding: 3px 8px;
  }
  .aa-score > div:first-child span {
    font-size: 12px;
  }
  .aa-score strong {
    font-size: 22px;
  }
  .aa-score > div:first-child b,.aa-instruction b {
    font-size: 12px;
  }
  .aa-instruction .aa-clock {
    margin: 0;
  }
  .aa-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
  .aa-actions {
    flex: none;
    position: relative;
    z-index: 1;
    margin: 0;
    padding: 3px 0 max(3px,env(safe-area-inset-bottom));
  }
  .aa-bans {
    padding: 2px 4px;
  }
  .aa-bans span {
    height: 19px;
    width: 25px;
  }
  .aa-bans b,.aa-team-foot,.aa-squad header {
    font-size: 10px;
  }
  .aa-bans small {
    font-size: 8px;
  }
  .aa-field {
    gap: 2px;
    grid-template-columns: minmax(0,1fr) 18px minmax(0,1fr);
    padding: 2px 0;
  }
  .aa-field .aa-side {
    gap: 2px;
  }
  .aa-field h2 {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .aa-squad {
    padding: 2px 4px;
  }
  .aa-squad header {
    margin-bottom: 2px;
    gap: 3px;
  }
  .aa-squad header > div {
    gap: 3px;
  }
  .aa-squad .player-avatar {
    width: 18px;
    height: 18px;
  }
  .aa-squad .player-link {
    font-size: 12px;
  }
  .aa-hero {
    height: clamp(32px,calc((var(--arena-height) - 304px)/2),90px);
  }
  .aa-team-foot {
    min-height: 14px;
  }
  .aa-team-foot button {
    font-size: 9px;
    min-height: 13px;
  }
  .aa-squad .aa-hero .slot-name {
    font-size: 12px;
  }
  .aa-hero .card-stars {
    display: none;
  }
  .aa-loadout {
    font-size: 9px;
  }
  .aa-history {
    gap: 1px 16px;
  }
  .aa-history button {
    height: 17px;
    font-size: 9px;
  }
  .aa-history button img {
    height: 15px;
  }
  .aa-history > div > b {
    font-size: 10px;
  }
  .aa-squad.active-leg .aa-hero {
    height: clamp(56px,18vh,90px);
  }
  .aa-squad.reserve .aa-hero {
    height: 28px;
  }
  .aa-actions button {
    min-height: 30px;
    font-size: 12px;
  }
  .aa-history-dialog[open] {
    padding: 6px;
  }
  .aa-order-shortcut {
    font-size: 10px;
  }
  .aa-nav button {
    font-size: 11px;
    padding: 3px;
  }
  .aa-wait {
    margin: 10px auto;
  }
}

.board-portrait .aa-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.board-portrait .aa-vs {
  display: none;
}

.board-portrait .aa-field h2 {
  position: static;
  clip-path: none;
  width: auto;
  height: auto;
  font-size: 13px;
}

.board-portrait .aa-squad {
  display: grid;
  grid-template-columns: minmax(85px,28%) minmax(0,1fr);
  align-items: center;
  gap: 2px;
  padding: 3px;
}

.board-portrait .aa-squad header,.board-portrait .aa-squad header > div {
  display: grid;
  justify-content: start;
  min-width: 0;
}

.board-portrait .aa-squad .player-link {
  max-width: 100%;
}

.board-portrait .aa-squad .aa-cards {
  gap: 3px;
}

.board-portrait .aa-hero,.board-portrait .aa-squad.active-leg .aa-hero {
  height: clamp(56px,15vw,75px);
}

.board-portrait .aa-team-foot {
  grid-column: 1/3;
}

.board-portrait .aa-loadout {
  display: none;
}

.board-portrait .aa-history {
  grid-template-columns: 1fr;
  gap: 3px;
  margin-top: 6px;
}

.board-portrait .aa-history > div:nth-child(2) {
  order: 3;
}

.board-portrait .aa-history > div:nth-child(3) {
  order: 2;
}

.board-portrait .aa-history > div:nth-child(4) {
  order: 4;
}

.board-portrait .aa-history button {
  height: 23px;
}

.board-portrait .aa-history > div > b {
  width: 22%;
}

.board-portrait .aa-score {
  grid-template-columns: 1fr auto;
}

.board-portrait .aa-instruction {
  grid-column: 1/3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 2px;
  border-top: 1px solid #415069;
}

.board-portrait .aa-wait-grid,.board-portrait .aa-locked,.board-portrait .aa-player-stats {
  grid-template-columns: 1fr;
}

.board-portrait .aa-round-title {
  align-items: start;
  flex-direction: column;
  gap: 3px;
}

.board-portrait .aa-hero .aa-position {
  font-size: 8px;
}

.board-portrait .aa-army {
  grid-column: 1/3;
}

