:root {
  color-scheme: light;
  --bg: #edf2f7;
  --ink: #172033;
  --muted: #667085;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --line: #d8dee9;
  --teal: #1f8a70;
  --blue: #0f6cbd;
  --red: #e3402e;
  --yellow: #f7ca38;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(31, 138, 112, 0.12), rgba(15, 108, 189, 0.09) 42%, rgba(227, 64, 46, 0.08)),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: center;
  padding: 30px 0;
}

.arena-panel,
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.arena-panel {
  padding: 18px;
}

.side-panel {
  align-self: stretch;
  display: grid;
  grid-template-rows: minmax(0, auto) minmax(160px, 1fr);
  align-content: start;
  gap: 24px;
  max-height: calc(100vh - 60px);
  overflow: hidden;
  padding: 18px;
}

.side-panel section {
  min-height: 0;
}

.top-bar,
.round-strip,
.controls {
  display: flex;
  align-items: center;
}

.top-bar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.icon-button,
.control-button,
.roster-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-strong);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.icon-button:hover,
.control-button:hover,
.roster-button:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
}

.hud-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.fighter-hud,
.round-strip {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.fighter-hud {
  padding: 12px;
}

.fighter-hud.right {
  text-align: right;
}

.fighter-hud strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.fighter-hud span,
.round-strip span,
.meter-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.round-strip {
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  text-align: center;
}

.round-strip strong {
  overflow-wrap: anywhere;
}

.meters {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.meter-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.fighter-hud.right .meter-row {
  grid-template-columns: minmax(0, 1fr) 56px;
}

.fighter-hud.right .meter-label {
  order: 2;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9f0;
}

.meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 120ms linear;
}

.health {
  background: var(--red);
}

.stamina {
  background: var(--teal);
}

.special {
  background: var(--yellow);
}

.arena-wrap {
  overflow: hidden;
  border: 8px solid #223047;
  border-radius: 8px;
  background: #dbeafe;
}

#arena-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 68vh;
}

.controls {
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.control-group {
  display: flex;
  gap: 8px;
}

.control-button {
  min-width: 58px;
  height: 42px;
  padding: 0 12px;
  font-weight: 800;
}

.control-button.special-action {
  min-width: 88px;
  background: #fff7d6;
}

.control-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
}

.control-legend span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.control-legend kbd {
  min-width: 18px;
  min-height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-color: #aab3c2;
  border-radius: 4px;
  background: var(--surface-strong);
  color: var(--ink);
  font: 800 0.68rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.roster-list {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.roster-button {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px;
  text-align: left;
}

.roster-button.selected {
  border-color: var(--teal);
  background: #ecfdf5;
}

.roster-button strong,
.roster-button small {
  display: block;
  overflow-wrap: anywhere;
}

.roster-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.avatar-token {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 3px solid var(--token-accent);
  border-radius: 50%;
  background: var(--token-color);
  color: #ffffff;
  font-weight: 900;
}

.match-log {
  max-height: 100%;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
}

.match-log li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.match-log li:first-child {
  color: var(--ink);
  font-weight: 750;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .side-panel {
    align-self: auto;
    max-height: none;
    overflow: visible;
  }

  .roster-list {
    max-height: 380px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1220px);
    padding: 10px 0 18px;
    gap: 12px;
  }

  .arena-panel,
  .side-panel {
    padding: 12px;
  }

  .hud-grid {
    grid-template-columns: 1fr;
  }

  .fighter-hud.right {
    text-align: left;
  }

  .fighter-hud.right .meter-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .fighter-hud.right .meter-label {
    order: 0;
  }

  .arena-wrap {
    border-width: 5px;
  }

  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .control-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  }

  .control-button,
  .control-button.special-action {
    min-width: 0;
  }
}
