:root {
  color-scheme: light;
  --video-blue: #209dcc;
  --arena-blue: #209dcc;
  --ink: #050505;
  --paper: #f8f8f8;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  min-height: 100vh;
  place-items: start center;
  overflow-x: hidden;
  background: #000;
  color: var(--paper);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
}

.short-video {
  display: flex;
  flex-direction: column;
  width: min(100vw, 620px);
  min-height: 100vh;
  overflow: hidden;
  background: var(--video-blue);
}

.title-card {
  display: grid;
  min-height: 116px;
  place-items: center;
  padding: 14px 12px 12px;
  text-align: center;
}

h1,
.subscribe-card p {
  margin: 0;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.015em;
  line-height: 0.97;
  -webkit-text-stroke: 3px #070707;
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 #070707;
}

h1 {
  font-size: clamp(2.25rem, 8vw, 3.25rem);
}

.arena-border {
  position: relative;
  width: calc(100% - 18px);
  margin: 0 9px;
  padding: 22px;
  border: 1px solid #050505;
  background: #050505;
}

#arena {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 0;
  outline: none;
  background: var(--arena-blue);
  cursor: pointer;
}

#arena:focus-visible {
  outline: 4px solid #fff;
  outline-offset: -6px;
}

.loading {
  position: absolute;
  inset: 22px;
  display: grid;
  place-items: center;
  background: var(--arena-blue);
  color: rgba(0, 0, 0, 0.58);
  font: 900 1rem Arial, sans-serif;
  letter-spacing: 0.12em;
}

.loading[hidden] {
  display: none;
}

.arena-border:has(.character-select:not([hidden])) #arena {
  display: none;
}

.character-select {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-rows: repeat(4, auto);
  gap: 12px;
  padding: 14px;
  background: var(--arena-blue);
}

.character-select[hidden] {
  display: none;
}

.pick-row {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto;
  gap: 5px;
}

.pick-label {
  margin: 0;
  color: #fff;
  font: 900 1.18rem/1 Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  letter-spacing: 0.06em;
  text-align: center;
  -webkit-text-stroke: 2px #050505;
  paint-order: stroke fill;
}

.character-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 112px;
  gap: 5px;
}

.character-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 28px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 5px solid #050505;
  background: #0b0b0b;
  color: #fff;
  cursor: pointer;
}

.character-card img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center 34%;
  opacity: 0.78;
  transform: none;
}

.magician-portrait {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  opacity: 0.78;
  overflow: hidden;
}

.character-card:hover .magician-portrait,
.character-card:focus-visible .magician-portrait,
.character-card.is-selected .magician-portrait {
  opacity: 1;
}

.character-card span {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 2px 0;
  background: #050505;
  color: #fff;
  font: 900 10px/1.1 Arial, sans-serif;
  overflow-wrap: anywhere;
  letter-spacing: 0.02em;
  text-align: center;
}

.character-card:hover img,
.character-card:focus-visible img,
.character-card.is-selected img {
  opacity: 1;
}

.character-card.is-selected {
  outline: 5px solid #fff;
  outline-offset: -9px;
}

.character-card:focus-visible,
.start-button:focus-visible {
  outline: 4px solid #ffe03b;
  outline-offset: 2px;
}

.versus-mark {
  color: #fff;
  font: 900 1.45rem/0.8 Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  letter-spacing: 0.04em;
  text-align: center;
  -webkit-text-stroke: 3px #050505;
  paint-order: stroke fill;
}

.start-button {
  justify-self: center;
  min-width: min(78%, 300px);
  padding: 10px 20px 8px;
  border: 5px solid #050505;
  background: #fff;
  color: #050505;
  font: 900 clamp(1.1rem, 4vw, 1.55rem)/1 Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  letter-spacing: 0.035em;
  box-shadow: 5px 5px 0 #050505;
  cursor: pointer;
}

.start-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #050505;
}

.subscribe-card {
  display: grid;
  flex: 1;
  min-height: 116px;
  place-items: center;
  align-content: center;
  padding: 16px 12px 22px;
  text-align: center;
}

.subscribe-card p {
  font-size: clamp(2.05rem, 7vw, 3rem);
}

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

@media (max-width: 600px) {
  .character-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {

  .title-card {
    min-height: 96px;
    padding-top: 10px;
  }

  h1 {
    -webkit-text-stroke-width: 2px;
    text-shadow: 2px 2px 0 #070707;
  }

  .arena-border {
    width: calc(100% - 12px);
    margin: 0 6px;
    padding: 15px;
  }

  .loading {
    inset: 15px;
  }

  .character-select {
    gap: 6px;
    padding: 9px;
  }

  .character-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .character-card {
    border-width: 4px;
  }

  .character-card.is-selected {
    outline-width: 4px;
    outline-offset: -7px;
  }

  .subscribe-card {
    min-height: 100px;
  }

  .subscribe-card p {
    -webkit-text-stroke-width: 2px;
    text-shadow: 2px 2px 0 #070707;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Release controls and compact, semantic character selection. */
[hidden] { display: none !important; }
body { min-width: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); font-family: system-ui, 'Noto Sans CJK SC', sans-serif; }
.short-video { width: min(100%, 760px); overflow: visible; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 14px; background: #102c3b; }
.toolbar a { color: #fff; padding: 10px 0; }
button, select { font: inherit; min-height: 44px; border: 2px solid #14232a; border-radius: 6px; padding: 7px 10px; background: #fff; color: #10202a; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #fff179; outline-offset: 3px; }
button:disabled { opacity: .6; cursor: wait; }
.title-card { min-height: 78px; }
h1 { font-size: clamp(1.6rem, 6vw, 2.5rem); line-height: 1.2; -webkit-text-stroke-width: 1px; text-shadow: 2px 2px #070707; }
.arena-border { padding: 8px; border-radius: 8px; }
.character-select { display: block; padding: 8px; color: #08212e; }
.character-select > p { margin: 0 0 12px; line-height: 1.45; }
.selected-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.selected-fighter { display: flex; flex-direction: column; align-items: center; padding: 9px; border-radius: 8px; background: #e8f6fd; text-align: center; }
.selected-fighter img { object-fit: contain; margin: 5px; }
.selected-fighter strong { line-height: 1.25; }
.selected-fighter p:not(.pick-label) { font-size: .85rem; line-height: 1.35; margin: 7px 0 10px; flex: 1; }
.pick-label { font: 700 .8rem system-ui, sans-serif; color: #24506a; -webkit-text-stroke: 0; }
.selection-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding-top: 12px; }
.selection-actions p { margin: 0; font-size: .85rem; }
.start-button { min-width: 100%; padding: 12px; border-width: 2px; font: 800 1.1rem system-ui, sans-serif; box-shadow: none; }
#rosterDialog { width: min(95vw, 680px); max-height: 85dvh; color: #fff; background: #123b50; border: 2px solid #9fdfff; border-radius: 12px; padding: 14px; }
#rosterDialog::backdrop { background: #000a; }
#rosterDialog h2 { font-size: 1.2rem; margin-top: 0; }
.character-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); grid-auto-rows: 132px; gap: 8px; }
.character-card { border: 2px solid #050505; border-radius: 6px; grid-template-rows: minmax(0, 1fr) 34px; }
.character-card span { font-size: 12px; }
#closeRoster { position: sticky; bottom: 0; width: 100%; margin-top: 12px; }
.loading { z-index: 4; position: relative; inset: auto; padding: 24px 16px; text-align: center; color: #092534; gap: 12px; letter-spacing: normal; font: 600 1rem/1.5 system-ui, sans-serif; }
.loading progress { width: 100%; }
.controls, .preferences { padding: 10px 14px; color: #092332; }
.controls p { margin: 6px 0; line-height: 1.4; }
.controls p[data-copy=limit] { font-size: .85rem; }
#gameStatus { font-weight: 750; }
#battleControls { display: flex; flex-wrap: wrap; gap: 8px; }
#battleControls button { flex: 1; }
.preferences { border-top: 1px solid #165774; }
.preferences summary { cursor: pointer; min-height: 44px; padding: 8px 0; font-weight: 700; }
.sound-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 14px 8px; color: #092332; }
.sound-controls label { display: flex; gap: 8px; align-items: center; }
input[type=range] { min-height: 44px; max-width: 140px; }
input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; }
#audioWarning, #preferenceWarning { padding: 10px; background: #fff0bb; color: #392800; }
.subscribe-card { min-height: 0; padding: 10px; }
.subscribe-card p { font: 500 .85rem/1.4 system-ui, sans-serif; -webkit-text-stroke: 0; text-shadow: none; color: #092332; }
@media (max-width: 380px) { .selected-fighter { padding: 6px; } .selected-fighter button { font-size: .8rem; } }
@media (orientation: landscape) and (max-height: 600px) { .short-video { max-width: 580px; } .title-card { min-height: 50px; } }

.arena-border:has(.loading:not([hidden])) #arena { display: none; }
/* Desktop windows are wider than tall: size the square arena by the viewport height so the
   match controls under it stay on screen (header, two-line match title, status and controls
   take about 390px). */
#arena { width: min(100%, max(320px, calc(100dvh - 390px))); margin-inline: auto; }
.character-card[hidden] { display: none; }
