/* Worker panel scrolling and minimal account-control layout. */
/* Keep expanded account tools reachable inside the sticky worker panel. */
@media (min-width: 901px) {
  .accounts-panel {
    max-height: calc(100dvh - 130px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scroll-padding-bottom: 18px;
  }

  .accounts-panel > .panel-heading {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(17, 24, 39, .98);
    backdrop-filter: blur(14px);
  }

  .accounts-panel .account-list {
    max-height: none;
    overflow: visible;
  }

  .accounts-panel > :last-child {
    margin-bottom: 12px;
  }
}

@media (max-width: 900px) {
  .accounts-panel {
    overflow: visible;
  }
}

/* Modern browsers can return the expanded tool to normal page flow. */
@supports selector(.accounts-panel:has(> details[open])) {
  @media (min-width: 901px) {
    .accounts-panel:has(> details.portal-tool[open]) {
      position: static;
      max-height: none;
      overflow: visible;
      scrollbar-gutter: auto;
    }

    .accounts-panel:has(> details.portal-tool[open]) > .panel-heading {
      position: static;
      backdrop-filter: none;
    }

    .accounts-panel:has(> details.portal-tool[open]) .account-list {
      max-height: 300px;
      overflow-y: auto;
      overscroll-behavior: contain;
    }
  }
}

/* Keep the active-turn ring centered when motion is disabled. */
@media (prefers-reduced-motion: reduce) {
  .battle-map-marker.turn-active .battle-map-symbol::before {
    animation: none !important;
    transform: scale(1);
    opacity: .58;
  }
}

/* Minimal account controls and compact portal overview. */
.summary {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  margin-bottom: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 24, 39, .78);
  scrollbar-width: none;
}
.summary::-webkit-scrollbar { display: none; }
.metric {
  flex: 0 0 auto;
  min-width: 112px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 13px;
  background: transparent;
}
.metric:last-child {
  flex: 1 1 auto;
  justify-content: flex-end;
  border-right: 0;
}
.metric span {
  display: inline;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}
.metric strong {
  display: inline;
  margin: 0;
  font-size: 15px;
  line-height: 1;
}

.layout { padding-top: 16px; }
.workspace { gap: 12px; }

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 18px;
  padding: 14px 16px;
}
.account-identity { min-width: 0; }
.account-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.detail-header .account-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
}
.account-message {
  max-width: 760px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.reward-menu-toggle {
  min-height: 34px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0 6px;
  border-radius: 9px;
  padding: 5px 9px;
  font-size: 10px;
  line-height: 1.15;
}
.reward-menu-toggle > span,
.reward-menu-toggle > strong { font-size: 10px; }
.reward-menu-toggle > small { display: none; }

.revive-toolbar {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 0;
  border: 0;
  background: transparent;
}
.revive-toggle {
  min-height: 30px;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}
.revive-toggle:hover { color: var(--text); }
.revive-toggle-track {
  width: 30px;
  height: 17px;
  background: var(--surface-map);
}
.revive-toggle-track span {
  left: 2px;
  top: 2px;
  width: 11px;
  height: 11px;
}
.revive-toggle input:checked + .revive-toggle-track span { transform: translateX(13px); }
.revive-toggle-label { white-space: nowrap; }
.revive-status {
  max-width: 130px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.revive-status::before {
  content: '·';
  margin-right: 5px;
  color: var(--line);
}
.revive-meta { display: none; }
.revive-feedback {
  flex: 1 0 100%;
  min-height: 0;
  font-size: 9px;
  line-height: 1.3;
}

.test-room-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 9px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: transparent;
}
.test-room-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.test-room-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.test-room-state {
  max-width: 260px;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.test-room-actions {
  justify-content: flex-start;
  gap: 6px;
}
.test-room-button {
  min-height: 30px;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 10px;
  line-height: 1.2;
}
.test-room-lobby,
.test-room-feedback { flex: 1 0 100%; }
.test-room-lobby {
  margin-top: 2px;
  padding-top: 0;
}
.test-room-lobby-head { padding-top: 7px; }

@media (max-width: 900px) {
  .summary { display: flex; }
  .metric:last-child {
    flex: 0 0 auto;
    justify-content: center;
  }
  .detail-header { grid-template-columns: minmax(0, 1fr); }
  .account-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .layout { padding-top: 9px; }
  .summary { margin-bottom: 9px; }
  .metric {
    min-width: 102px;
    padding: 8px 10px;
  }
  .metric span { font-size: 9px; }
  .metric strong { font-size: 14px; }
  .detail-header { padding: 12px; }
  .detail-header .account-title { font-size: 18px; }
  .account-title-row { align-items: center; }
  .account-actions { align-items: flex-start; }
  .revive-toggle { min-height: 36px; }
  .test-room-toolbar { align-items: flex-start; }
  .test-room-button { min-height: 36px; }
}

@media (max-width: 430px) {
  .account-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .reward-menu-toggle { width: auto; }
  .test-room-copy {
    width: 100%;
    justify-content: space-between;
  }
  .test-room-actions { width: 100%; }
  .test-room-button { flex: 1 1 auto; }
}

@media (max-width: 640px) {
  .metric {
    min-width: 88px;
    gap: 5px;
    padding-left: 7px;
    padding-right: 7px;
  }
}
