:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  color: #111827;
  background: #f3f4f6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
}

.app-shell {
  width: min(100% - 2rem, 96rem);
  margin: 0 auto;
  padding: 1.5rem 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
}

.team-key {
  display: flex;
  gap: 1.25rem;
  padding: 0;
  margin: 0;
  list-style: none;
  font-size: 0.875rem;
}

.team-key li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.team-key li::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border: 2px solid;
}

.team-key .team-one::before { border-color: #2563eb; }
.team-key .team-two::before { border-color: #dc2626; }

.map-panel {
  position: relative;
  padding: 0.5rem;
  background: #ffffff;
}

[data-map-canvas] {
  display: block;
  width: 100%;
  aspect-ratio: 12 / 7;
}

.map-feedback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #ffffff;
  text-align: center;
}

.map-feedback p { margin: 0; }
.possession-status { margin: 0.25rem 0.5rem 0.5rem; font-size: 0.875rem; color: #4b5563; }
.game-column { min-width: 0; display: grid; gap: 1rem; }
.test-scenario { margin: 0; padding: 0.75rem; border: 1px solid #d1d5db; background: #fff; }
.test-scenario p { margin: 0.5rem 0 0; max-width: 72rem; color: #4b5563; font-size: 0.875rem; line-height: 1.4; }
.own-half-setting { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.own-half-setting input { width: auto; }

button {
  padding: 0.45rem 0.9rem;
  border: 1px solid #9ca3af;
  border-radius: 0.25rem;
  font: inherit;
  color: inherit;
  background: #f9fafb;
  cursor: pointer;
}

button:hover { background: #f3f4f6; }
button:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 25rem; align-items: start; gap: 1rem; }
.match-status { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-bottom: 1rem; color: #4b5563; font-size: 0.875rem; }
.match-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.match-controls [aria-pressed="true"] { color: #1d4ed8; border-color: #2563eb; background: #eff6ff; }
.control-status { margin: 0 0 1rem; font-size: 0.875rem; color: #4b5563; overflow-wrap: anywhere; }
.control-status:empty { display: none; }
.strategy-panel { min-width: 0; padding: 1rem; background: white; }
h2 { margin: 0 0 1rem; font-size: 1.25rem; }
h3 { margin-bottom: 0.75rem; font-size: 1rem; }
.team-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.team-tabs button { flex: 1; font-size: 0.8rem; }
.team-tabs [aria-pressed="true"] { border-color: #2563eb; background: #eff6ff; }
.strategy-status { min-height: 2.5em; font-size: 0.85rem; line-height: 1.4; overflow-wrap: anywhere; }
.strategy-status[data-state="retrying"] { color: #92400e; }
.strategy-status[data-state="rejected"], .strategy-status[data-state="paused"] { color: #b91c1c; }
.strategy-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.strategy-fields > legend { margin-bottom: 0.75rem; font-weight: bold; }
.role-card { padding: 0.75rem; margin-bottom: 0.75rem; border: 1px solid #d1d5db; }
.role-header { display: flex; gap: 0.5rem; align-items: end; }
.role-header label { flex: 1; min-width: 0; font-size: 0.8rem; }
input, select { width: 100%; padding: 0.4rem; border: 1px solid #9ca3af; border-radius: 0.2rem; font: inherit; color: inherit; background: white; }
.role-header input { display: block; margin-top: 0.25rem; }
.role-card button { padding: 0.35rem 0.45rem; font-size: 0.75rem; }
.muted { color: #6b7280; font-size: 0.75rem; overflow-wrap: anywhere; }
.role-card p { margin: 0.5rem 0; }
.behavior-setting { display: block; margin-top: 0.5rem; font-size: 0.8rem; }
.behavior-setting select { margin-top: 0.25rem; }
.unit-energy { display: block; margin-top: 0.2rem; font-size: 0.75rem; }
.assignments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.assignment-row { min-width: 0; }
.assignment-row label { display: block; font-size: 0.8rem; }
.assignment-row select { display: block; margin: 0.25rem 0; }
.player-editor { margin-top: 1rem; padding: 0.75rem; border: 1px solid #d1d5db; }
.player-editor h3 { margin: 0; }
.player-editor > label { display: block; margin: 0.65rem 0; font-size: 0.8rem; }
.player-editor select, .player-editor input { margin-top: 0.25rem; }
.player-ratings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; margin-bottom: 0.65rem; }
.player-ratings label { min-width: 0; font-size: 0.8rem; }
.player-editor button { font-size: 0.8rem; }
.apply-button { width: 100%; margin-top: 1rem; color: white; background: #1d4ed8; border-color: #1d4ed8; }
.apply-button:hover { background: #1e40af; }
button:disabled, fieldset:disabled button { opacity: 0.5; cursor: default; }
.runner-output { max-height: 10rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.75rem; }
.strategy-library { margin-top: 1rem; padding: 0.75rem; border: 1px solid #d1d5db; }
.strategy-library h3 { margin: 0; }
.strategy-library label { display: block; margin-bottom: 0.5rem; font-size: 0.8rem; }
.strategy-library input, .strategy-library select { display: block; margin-top: 0.25rem; }
.strategy-library button { font-size: 0.8rem; }
.library-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.library-notice { margin: 0.5rem 0 0; font-size: 0.8rem; overflow-wrap: anywhere; }
.library-notice:empty { display: none; }
.library-notice[data-error="true"] { color: #b91c1c; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

.strategy-column { min-width: 0; display: grid; gap: 1rem; }
.event-panel { min-width: 0; padding: 1rem; background: white; }
.event-panel h2 { margin-bottom: 0.75rem; }
.event-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.6rem; }
.event-filters label { min-width: 0; font-size: 0.8rem; }
.event-filters select { display: block; margin-top: 0.25rem; }
.event-filters .event-important { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.4rem; }
.event-important input { width: auto; margin: 0; }
.event-list { position: relative; max-height: 16rem; min-height: 4rem; overflow: auto; overflow-anchor: none; margin: 0; padding: 0; list-style: none; border-top: 1px solid #e5e7eb; }
.event-list li { padding: 0.6rem 0; border-bottom: 1px solid #e5e7eb; font-size: 0.8rem; line-height: 1.4; overflow-wrap: anywhere; }
.event-meta { display: block; color: #6b7280; font-size: 0.72rem; margin-bottom: 0.15rem; }
.event-list li[data-stage="rejection"], .event-list li[data-stage="runner"] { color: #991b1b; }
.event-count { margin-bottom: 0; }

.match-length-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 0.65rem 1rem; margin: 0 0 1rem; }
.match-length-controls label { min-width: 12rem; font-size: 0.8rem; }
.match-length-controls select { display: block; margin-top: 0.25rem; }
.match-length-controls p { flex-basis: 100%; margin: 0; color: #4b5563; font-size: 0.8rem; line-height: 1.4; }
.match-length-controls > span { align-self: center; }
.match-result { margin: 0 0 1rem; padding: 0.75rem 1rem; border: 1px solid #93c5fd; background: #eff6ff; font-weight: bold; line-height: 1.4; }
