:root {
  color-scheme: dark;
  --bg: #0b1020;
  --fg: #e8ecff;
  --muted: #b9c4ee;
  --ok: #4ade80;
  --warn: #facc15;
  --error: #fb7185;
  --hud-bg: rgba(11, 16, 32, 0.58);
  --hud-bg-strong: rgba(11, 16, 32, 0.8);
  --hud-border: rgba(209, 222, 255, 0.16);
  --hud-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --hud-radius: 14px;
}

* { box-sizing: border-box; }

html, body, #app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: #05070f;
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.runtime-viewport-only #chat-toggle,
.runtime-viewport-only #chat-panel,
.runtime-viewport-only #player-list,
.runtime-viewport-only #agent-log-toggle,
.runtime-viewport-only #agent-log-panel,
.runtime-viewport-only #behavior-panel,
.runtime-viewport-only #replay-panel,
.runtime-viewport-only .runtime-meta-sr {
  display: none !important;
}

#app {
  position: relative;
}

#status {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

#meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.runtime-meta-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 10%, rgba(84, 108, 190, 0.22), transparent 42%),
    radial-gradient(circle at 86% 12%, rgba(89, 181, 255, 0.14), transparent 38%),
    linear-gradient(180deg, #060913 0%, #05070f 100%);
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
}

.external-replay-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #05070f;
}

.hud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud-icon-button {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--hud-border);
  border-radius: 10px;
  background: var(--hud-bg);
  color: var(--fg);
  display: grid;
  place-items: center;
  box-shadow: var(--hud-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.hud-icon-button:hover {
  background: rgba(24, 33, 59, 0.82);
  border-color: rgba(209, 222, 255, 0.28);
  transform: translateY(-1px);
}

.hud-icon-button:active {
  transform: translateY(0);
}

.hud-icon-button:focus-visible {
  outline: 2px solid rgba(126, 211, 255, 0.9);
  outline-offset: 2px;
}

.chat-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
}

.chat-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.agent-log-toggle {
  position: absolute;
  left: 14px;
  bottom: 18px;
  z-index: 19;
}

.agent-log-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.chat-panel {
  position: absolute;
  top: 66px;
  left: 14px;
  width: min(300px, calc(100vw - 28px));
  border-radius: var(--hud-radius);
  border: 1px solid var(--hud-border);
  background: var(--hud-bg-strong);
  box-shadow: var(--hud-shadow);
  padding: 9px 10px 10px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 140ms ease, transform 140ms ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  grid-template-rows: auto minmax(72px, 1fr) auto auto;
  gap: 7px;
  height: min(340px, calc(52vh - 24px));
}

.chat-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.chat-feed {
  overflow: auto;
  min-height: 0;
  border-radius: 9px;
  border: 1px solid rgba(209, 222, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.chat-message {
  font-size: 11px;
  line-height: 1.3;
  color: #e9eeff;
  word-break: break-word;
}

.chat-message__meta {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  margin-right: 4px;
}

.chat-message__name {
  font-weight: 700;
}

.chat-message__time {
  color: rgba(185, 196, 238, 0.78);
  font-size: 9px;
}

.chat-message--system {
  color: #cfdaff;
  opacity: 0.92;
}

.chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.chat-input {
  width: 100%;
  min-width: 0;
  border-radius: 9px;
  border: 1px solid rgba(209, 222, 255, 0.14);
  background: rgba(10, 14, 27, 0.8);
  color: var(--fg);
  padding: 7px 9px;
  font: inherit;
  font-size: 11px;
}

.chat-input::placeholder {
  color: rgba(185, 196, 238, 0.62);
}

.chat-input:focus-visible {
  outline: 2px solid rgba(126, 211, 255, 0.85);
  outline-offset: 1px;
  border-color: transparent;
}

.chat-send {
  border: 1px solid rgba(209, 222, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #eef3ff;
  border-radius: 9px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.chat-send:disabled,
.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-local-status {
  font-size: 9px;
  color: rgba(185, 196, 238, 0.72);
  min-height: 1.2em;
}

.player-list {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 12;
  width: min(220px, calc(100vw - 28px));
  max-height: min(42vh, 320px);
  border-radius: 12px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  box-shadow: var(--hud-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  pointer-events: auto;
}

.player-list * {
  pointer-events: auto;
}

.player-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(209, 222, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.player-list__count {
  color: rgba(233, 238, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(209, 222, 255, 0.08);
  border-radius: 999px;
  min-width: 20px;
  padding: 1px 6px;
  text-align: center;
  font-size: 10px;
}

.player-list__body {
  min-height: 0;
  overflow: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.player-list__row {
  appearance: none;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(209, 222, 255, 0.04);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.player-list__row:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(209, 222, 255, 0.1);
}

.player-list__row:focus-visible {
  outline: 2px solid rgba(126, 211, 255, 0.85);
  outline-offset: 1px;
}

.player-list__row.is-selected {
  background: rgba(126, 211, 255, 0.12);
  border-color: rgba(126, 211, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(126, 211, 255, 0.22);
}

.player-list__name {
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  color: #eef3ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-list__hp {
  font-size: 10px;
  color: rgba(185, 196, 238, 0.88);
}

.player-list__empty {
  font-size: 10px;
  color: rgba(185, 196, 238, 0.72);
  padding: 6px 4px;
}

.agent-log-panel {
  position: absolute;
  left: 14px;
  bottom: 92px;
  z-index: 18;
  width: min(520px, calc(100vw - 28px));
  max-height: min(42vh, 360px);
  border-radius: 12px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg-strong);
  box-shadow: var(--hud-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.agent-log-panel[hidden] {
  display: none;
}

.agent-log-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.agent-log-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(209, 222, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
}

.agent-log-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(209, 222, 255, 0.06);
}

.agent-log-tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(185, 196, 238, 0.8);
  font: inherit;
  font-size: 10px;
  padding: 4px 7px;
  cursor: pointer;
}

.agent-log-tab.is-active {
  background: rgba(126, 211, 255, 0.16);
  color: rgba(236, 240, 255, 0.98);
}

.agent-log-panel__status {
  color: rgba(185, 196, 238, 0.82);
  font-size: 10px;
  font-weight: 500;
}

.agent-log-feed {
  min-height: 0;
  overflow: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
}

.workspace-feed {
  min-height: 0;
  overflow: auto;
  padding: 6px 8px;
  scrollbar-width: thin;
}

.workspace-feed[hidden],
.agent-log-feed[hidden] {
  display: none;
}

.workspace-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 3px 2px;
  border-bottom: 1px solid rgba(209, 222, 255, 0.04);
  font-size: 11px;
  line-height: 1.35;
}

.workspace-row__op {
  color: rgba(126, 211, 255, 0.88);
  font-size: 10px;
  text-align: center;
}

.workspace-row__path {
  min-width: 0;
  color: rgba(236, 240, 255, 0.94);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-row__meta {
  color: rgba(185, 196, 238, 0.68);
  font-size: 10px;
}

.agent-log-message {
  display: flex;
  gap: 6px;
  padding: 1px 0;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.agent-log-message.is-current {
  background: rgba(126, 211, 255, 0.06);
  box-shadow: inset 2px 0 0 0 rgba(126, 211, 255, 0.55);
  padding-left: 6px;
}

.agent-log-message[data-role="user"] {
  color: rgba(236, 240, 255, 0.95);
}

.agent-log-message__user-badge {
  flex-shrink: 0;
  padding-top: 2px;
  color: rgba(126, 211, 255, 0.85);
}

.agent-log-message__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agent-log-block {
  font-size: 12px;
  line-height: 1.5;
}

.agent-log-block--text {
  color: rgba(236, 240, 255, 0.95);
  white-space: pre-wrap;
}

.agent-log-block--thinking {
  color: rgba(185, 196, 238, 0.62);
  font-style: italic;
  white-space: pre-wrap;
  border-left: 2px solid rgba(185, 196, 238, 0.18);
  padding: 0 0 0 8px;
}

.agent-log-block--tool {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.agent-log-block--tool.is-error .agent-log-tool__name {
  color: rgba(255, 170, 170, 0.95);
}

.agent-log-block--tool.is-error .agent-log-tool__head svg:first-child {
  color: rgba(255, 140, 140, 0.9);
}

.agent-log-tool__head {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 6px;
  margin: 0;
  height: 18px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  color: rgba(220, 228, 255, 0.85);
  background: transparent;
  border: none;
  user-select: none;
  text-align: left;
}

.agent-log-tool__head[aria-disabled="true"] {
  cursor: default;
}

.agent-log-tool__head svg {
  flex-shrink: 0;
  color: rgba(185, 196, 238, 0.72);
}

.agent-log-tool__name {
  font-weight: 600;
  color: rgba(236, 240, 255, 0.9);
}

.agent-log-tool__detail {
  align-self: stretch;
  margin: 2px 0 2px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-log-tool__detail[hidden] {
  display: none;
}

.agent-log-tool__body {
  margin: 0;
  padding: 6px 8px;
  border: 1px solid rgba(209, 222, 255, 0.08);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: rgba(220, 228, 255, 0.9);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}

.agent-log-tool__body--result {
  border-color: rgba(126, 211, 255, 0.18);
  background: rgba(126, 211, 255, 0.04);
}

.agent-log-tool__body--result.is-error {
  border-color: rgba(255, 120, 120, 0.35);
  background: rgba(255, 120, 120, 0.06);
  color: rgba(255, 220, 220, 0.95);
}

.agent-log-empty {
  color: rgba(185, 196, 238, 0.72);
  font-size: 10px;
  padding: 2px 2px;
}

.behavior-panel {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(6px);
  z-index: 19;
  width: min(1012px, calc(100vw - 28px));
  height: min(34vh, 240px);
  border-radius: 12px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg-strong);
  box-shadow: var(--hud-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.behavior-panel[hidden] {
  display: none;
}

.behavior-panel.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.behavior-timeline-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid rgba(209, 222, 255, 0.08);
}

.behavior-ruler {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 8px 8px 0;
}

.behavior-ruler__spacer {
  height: 100%;
}

.behavior-ruler__track {
  position: relative;
  min-height: 20px;
  border-radius: 8px;
  border: 1px solid rgba(209, 222, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.behavior-ruler__tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(185, 196, 238, 0.18);
}

.behavior-ruler__label {
  position: absolute;
  top: 2px;
  transform: translateX(4px);
  font-size: 9px;
  color: rgba(185, 196, 238, 0.82);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.behavior-tracks {
  height: 100%;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.behavior-row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.behavior-row__label {
  appearance: none;
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  padding: 2px 0;
  cursor: pointer;
  display: grid;
  gap: 3px;
}

.behavior-row__label:hover,
.behavior-row__track:hover {
  background: rgba(255, 255, 255, 0.05);
}

.behavior-row__label:focus-visible,
.behavior-occurrence:focus-visible {
  outline: 2px solid rgba(126, 211, 255, 0.9);
  outline-offset: 2px;
}

.behavior-row__label.is-selected {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(126, 211, 255, 0.18);
}

.behavior-row__name {
  font-size: 11px;
  font-weight: 700;
  color: #eef3ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.behavior-row__meta {
  font-size: 10px;
  color: rgba(185, 196, 238, 0.82);
}

.behavior-row__track {
  position: relative;
  min-height: 20px;
  border-radius: 6px;
  border: none;
  background: transparent;
  overflow: hidden;
}

.behavior-occurrence {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border: none;
  border-radius: 4px;
  min-width: 4px;
  cursor: pointer;
  opacity: 0.82;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.behavior-occurrence:hover {
  opacity: 0.96;
}

.behavior-occurrence.is-active {
  opacity: 1;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.26),
    0 0 0 1px rgba(126, 211, 255, 0.42);
}

.behavior-occurrence--point {
  top: 1px;
  bottom: 1px;
  min-width: 2px;
  border-radius: 999px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 0 0 1px rgba(0, 0, 0, 0.12);
}

.behavior-global-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(126, 211, 255, 0.96);
  box-shadow:
    0 0 0 1px rgba(126, 211, 255, 0.18),
    0 0 12px rgba(126, 211, 255, 0.18);
  transform: translateX(-1px);
  pointer-events: none;
  opacity: 0;
}

.behavior-global-playhead.is-visible {
  opacity: 1;
}

.behavior-details {
  height: 100%;
  overflow: auto;
  padding: 8px 10px 10px;
  display: grid;
  gap: 6px;
  scrollbar-width: thin;
  align-content: start;
}

.behavior-details[hidden] {
  display: none;
}

.behavior-details__title {
  font-size: 11px;
  font-weight: 700;
  color: #eef3ff;
}

.behavior-details__meta,
.behavior-details__description {
  font-size: 10px;
  color: rgba(185, 196, 238, 0.86);
  line-height: 1.45;
}

.behavior-details__participants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.behavior-details__participant {
  border: 1px solid rgba(209, 222, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  font-size: 9px;
  color: #e9eeff;
  line-height: 1.3;
}

.behavior-details__observations {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.behavior-details__observation {
  border: 1px solid rgba(209, 222, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 7px;
  font-size: 10px;
  line-height: 1.4;
  color: #e9eeff;
}

.behavior-details__observation-meta {
  color: rgba(185, 196, 238, 0.82);
  font-size: 9px;
  margin-bottom: 3px;
}

.replay-panel {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg-strong);
  box-shadow: var(--hud-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  z-index: 20;
}

.replay-panel[hidden] {
  display: none;
}

.replay-button,
.replay-speed {
  appearance: none;
  border: 1px solid rgba(209, 222, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #eef3ff;
  border-radius: 10px;
  font: inherit;
  font-size: 12px;
}

.replay-button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.replay-button--label {
  width: auto;
  padding: 0 10px;
}

.replay-button:hover,
.replay-speed:hover {
  background: rgba(255, 255, 255, 0.08);
}

.replay-button--icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex: 0 0 auto;
}

.replay-button:focus-visible,
.replay-speed:focus-visible,
.replay-slider:focus-visible {
  outline: 2px solid rgba(126, 211, 255, 0.9);
  outline-offset: 2px;
}

.replay-timeline {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.replay-slider {
  width: 100%;
  margin: 0;
  accent-color: #7ed3ff;
  cursor: pointer;
}

.replay-time-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(233, 238, 255, 0.9);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.replay-speed-label {
  color: rgba(185, 196, 238, 0.86);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.replay-speed {
  padding: 7px 10px;
  cursor: pointer;
}

.replay-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(233, 238, 255, 0.92);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.replay-toggle input {
  margin: 0;
  accent-color: #7ed3ff;
}

body[data-mode="replay"] .chat-input-row {
  display: none;
}

@media (max-width: 1120px) {
  .behavior-panel {
    width: min(720px, calc(100vw - 28px));
  }
}

@media (max-width: 640px) {
  .chat-toggle {
    top: 10px;
    left: 10px;
  }

  .agent-log-toggle {
    left: 10px;
    bottom: 10px;
  }

  .chat-panel {
    top: 58px;
    left: 10px;
    width: min(270px, calc(100vw - 20px));
    height: min(295px, calc(52vh - 14px));
  }

  .player-list {
    top: 10px;
    right: 10px;
    width: min(180px, calc(100vw - 20px));
    max-height: min(34vh, 220px);
  }

  .agent-log-panel {
    left: 10px;
    bottom: 114px;
    width: min(320px, calc(100vw - 20px));
    max-height: min(36vh, 260px);
  }

  .behavior-panel {
    bottom: 132px;
    width: min(calc(100vw - 20px), 560px);
    height: min(30vh, 220px);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .replay-panel {
    bottom: 10px;
    width: min(100vw - 20px, 560px);
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "play speed"
      "timeline timeline"
      "toggle behaviors";
  }

  .replay-button {
    grid-area: play;
  }

  .replay-timeline {
    grid-area: timeline;
  }

  .replay-speed-label {
    display: none;
  }

  .replay-speed {
    grid-area: speed;
    justify-self: end;
  }

  .replay-toggle {
    grid-area: toggle;
    justify-self: start;
  }

  .replay-button--label {
    grid-area: behaviors;
    justify-self: end;
  }

  .behavior-row {
    grid-template-columns: 1fr;
  }

  .behavior-timeline-shell {
    border-right: none;
    border-bottom: 1px solid rgba(209, 222, 255, 0.08);
  }

  .behavior-ruler {
    grid-template-columns: 1fr;
  }

  .behavior-ruler__spacer {
    display: none;
  }

  .behavior-details {
    height: min(18vh, 160px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud-icon-button,
  .chat-panel,
  .agent-log-panel,
  .behavior-panel {
    transition: none;
  }
}
