:root {
  --viewport-gap: 8px;
}

html,
body {
  overflow-x: hidden;
}

.match-options {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(250px, 0.85fr);
  gap: 12px;
  margin-bottom: 14px;
}

.option-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 14, 25, 0.74);
  padding: 12px;
}

.option-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.option-heading h3 {
  font-size: 0.9rem;
}

.option-value {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
}

.arena-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.arena-option {
  min-height: 52px;
  padding: 7px;
  text-align: left;
}

.arena-option strong,
.arena-option small {
  display: block;
}

.arena-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
}

.arena-option.selected {
  border-color: var(--gold);
  background: rgba(224, 193, 109, 0.13);
  color: #ffe9a9;
}

.cooldown-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.cooldown-control input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.cooldown-control output {
  min-width: 52px;
  color: var(--gold);
  font-weight: 900;
  text-align: right;
}

.option-help {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.match-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.match-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 14, 25, 0.82);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.7rem;
  font-weight: 700;
}

.battle-tools {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.battle-tools .viewer-controls {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 0;
}

.battle-tools .notice {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(9, 15, 27, 0.82);
  padding: 10px;
}

.game-card {
  position: relative;
}

.result-actions {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 24px;
  width: min(86%, 390px);
  transform: translateX(-50%);
  border: 1px solid rgba(224, 193, 109, 0.62);
  border-radius: 16px;
  background: rgba(6, 10, 18, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.46);
  padding: 12px;
  text-align: center;
}

.result-actions[hidden] {
  display: none !important;
}

.result-actions p {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.78rem;
}

.result-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.result-buttons button:first-child {
  border-color: #efd27b;
  background: #caa94f;
  color: #10131b;
}

.skill-preview {
  border-color: color-mix(in srgb, var(--ability-color) 58%, var(--line));
}

.team-slot small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
}

@media (min-width: 801px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: flex;
    width: min(100%, 1180px);
    height: 100dvh;
    min-height: 620px;
    flex-direction: column;
    padding: var(--viewport-gap) 12px;
  }

  .page-header {
    flex: 0 0 auto;
    align-items: center;
    margin-bottom: 7px;
  }

  h1 {
    font-size: clamp(1.65rem, 4vh, 2.55rem);
  }

  .eyebrow {
    margin-bottom: 2px;
  }

  .subtitle {
    max-width: 820px;
    margin-top: 5px;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .setup-panel {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    padding: 12px;
    overflow: hidden;
  }

  .setup-heading,
  .team-preview-grid,
  .match-options,
  .setup-actions {
    flex: 0 0 auto;
  }

  .setup-heading {
    margin-bottom: 8px;
  }

  .team-preview-grid {
    margin-bottom: 8px;
  }

  .team-slot {
    min-height: 51px;
  }

  .match-options {
    margin-bottom: 8px;
  }

  .option-card {
    padding: 9px;
  }

  .roster-grid {
    min-height: 0;
    flex: 1 1 auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
  }

  .fighter-card {
    padding: 10px;
  }

  .fighter-summary {
    min-height: 0;
  }

  .setup-actions {
    margin-top: 8px;
  }

  .battle-panel:not([hidden]) {
    display: grid;
    min-height: 0;
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1fr) 194px;
    gap: 9px;
  }

  .game-card {
    display: grid;
    min-height: 0;
    height: 100%;
    place-items: center;
  }

  canvas {
    width: auto;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
  }

  .battle-tools {
    min-height: 0;
    overflow-y: auto;
  }
}

@media (max-width: 800px) {
  .match-options {
    grid-template-columns: 1fr;
  }

  .battle-panel:not([hidden]) {
    display: block;
  }

  .battle-tools {
    margin-top: 10px;
  }

  .battle-tools .viewer-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .arena-buttons {
    grid-template-columns: 1fr;
  }

  .result-buttons {
    grid-template-columns: 1fr;
  }
}
