:root {
  color-scheme: dark;
  --ink: #f2f3f2;
  --ink-soft: #b9bdbb;
  --panel: rgba(18, 20, 20, 0.94);
  --panel-strong: rgba(12, 14, 14, 0.96);
  --line: rgba(220, 226, 222, 0.25);
  --red: #ff426d;
  --gold: #ffd85a;
  --cyan: #34e6ff;
  --green: #58f37a;
  --blue: #4b7cff;
  --shadow: rgba(0, 0, 0, 0.55);
}

#touch-controls[hidden] { display: none; }
#touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.touch-pad {
  flex: 0 0 144px;
  width: 144px;
  height: 144px;
  display: grid;
  grid-template: repeat(3, 48px) / repeat(3, 48px);
  border-radius: 50%;
  background: #202624;
  border: 1px solid #48544e;
  font-size: 28px;
  overflow: hidden;
}
.touch-pad span { display: grid; place-items: center; pointer-events: none; }
.pad-up { grid-area: 1 / 2; }
.pad-left { grid-area: 2 / 1; }
.pad-right { grid-area: 2 / 3; }
.pad-down { grid-area: 3 / 2; }
.held-up .pad-up, .held-left .pad-left,
.held-right .pad-right, .held-down .pad-down { background: #526b5e; }
.touch-attacks { display: grid; grid-template-columns: repeat(3, 48px); gap: 6px; }
.touch-attacks button { width: 48px; height: 44px; min-height: 44px; padding: 0; font-size: 12px; font-weight: 700; }
.touch-attacks button:nth-child(-n+3) { border-color: #7e949e; }
.touch-attacks button:nth-child(n+4):nth-child(-n+6) { border-color: #a18488; }
.touch-attacks button.held { background: #58645e; border-color: #eff3f0; }
.touch-attacks button[data-touch="pause"] { grid-column: 3; font-size: 18px; }

@media (any-pointer: coarse) and (orientation: landscape) {
  #cabinet.touch-active {
    width: min(100%, 1800px);
    grid-template-columns: 144px minmax(0, 1fr) 156px;
    gap: 10px;
  }
  .touch-active #screen-wrap { grid-column: 2; grid-row: 1; }
  .touch-active #touch-controls { display: contents; }
  .touch-active .touch-pad { grid-column: 1; grid-row: 1; }
  .touch-active .touch-attacks { grid-column: 3; grid-row: 1; }
  .touch-active #side-panel { grid-column: 1 / -1; grid-row: 2; }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: #111313;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 12px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #292d2b;
  color: var(--ink);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0;
  box-shadow: none;
}

button:hover,
button:focus-visible {
  border-color: #cedcd3;
  outline: none;
}

.option-row select {
  min-height: 44px;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #292d2b;
  color: var(--ink);
  padding: 0 8px;
}

.training-setting { margin: 10px 0; }

#cabinet {
  width: min(100%, 1800px, calc((100dvh - 92px) * 426 / 240));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

#screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 426 / 240;
  border: 1px solid #343936;
  border-radius: 2px;
  overflow: hidden;
  background: #070914;
  isolation: isolate;
  box-shadow: none;
}

#screen-wrap::before,
#screen-wrap::after {
  content: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: #070914;
}

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

.hud {
  z-index: 4;
}

.overlay {
  z-index: 5;
  display: grid;
  place-items: center;
}

.side-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  min-width: 0;
}

.brand-block,
.control-card,
.menu-panel,
.pause-panel,
.options-panel,
.summary-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 42px var(--shadow);
}

.brand-block {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.brand-block .kicker,
.side-panel .control-card {
  display: none;
}

.brand-block h1 {
  font-size: 14px;
  line-height: 1.3;
  text-shadow: none;
}

.side-panel .buttons-row {
  flex: 0 0 auto;
}

.side-panel button {
  min-width: 100px;
  min-height: 44px;
}

.kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--cyan);
  font-size: 11px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #141016, 5px 5px 0 rgba(255, 66, 109, 0.38);
}

h2 {
  font-size: 16px;
  color: #eff2ee;
  text-transform: uppercase;
}

h3 {
  font-size: 13px;
  text-transform: uppercase;
}

.control-card {
  padding: 14px;
  display: grid;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
}

.buttons-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.top-hud {
  position: absolute;
  top: 7px;
  left: 8px;
  right: 8px;
  display: grid;
  grid-template-columns: 1fr 58px 1fr;
  align-items: start;
  gap: 8px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.65));
  text-shadow: 0 1px 0 #000;
}

.fighter-hud {
  display: grid;
  gap: 3px;
}

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

.fighter-name {
  font-size: 9px;
  color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.health-shell {
  position: relative;
  height: 12px;
  border: 1px solid rgba(224, 231, 225, 0.7);
  border-radius: 2px;
  overflow: hidden;
  background: #302b2a;
  box-shadow: none;
}

.health-fill,
.health-trail {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  background: #a8bba8;
  transform-origin: left center;
}

.health-trail {
  background: #8d7772;
}

.right .health-trail {
  transform-origin: right center;
}

.right .health-fill {
  background: #c1ada1;
  transform-origin: right center;
  margin-left: auto;
}

.meter-row {
  display: flex;
  gap: 3px;
}

.right .meter-row {
  justify-content: flex-end;
}

.round-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.12);
}

.round-dot.won {
  background: var(--gold);
}

.timer {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #171b19;
  color: #f2f3f2;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  box-shadow: none;
}

.center-callout {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  text-transform: uppercase;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.15;
  padding: 24px;
  overflow-wrap: anywhere;
  color: #f4f5f3;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85), 0 0 16px rgba(0, 0, 0, 0.45);
}

.bottom-strip {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 9px;
  text-shadow: 2px 2px 0 #000;
}

.debug-readout {
  min-width: 0;
  flex: 1;
  font-size: 10px;
  line-height: 1.3;
  text-align: right;
  overflow-wrap: anywhere;
}

.input-feed {
  display: flex;
  flex: 0 1 40%;
  min-width: 0;
  max-width: 40%;
  overflow-x: auto;
  scrollbar-width: thin;
  pointer-events: auto;
  gap: 3px;
  min-height: 22px;
  align-items: center;
}

.input-token {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.5);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.input-token:empty { display: none; }
.input-feed:focus-visible { outline: 1px solid #c8d6cd; outline-offset: 2px; }

.menu-panel,
.pause-panel,
.options-panel,
.summary-panel {
  width: min(86%, 500px);
  max-height: 92%;
  padding: 16px;
  pointer-events: auto;
}

.menu-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.menu-title {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.menu-title p {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.35;
}

.menu-list {
  display: grid;
  gap: 7px;
}

.menu-item,
.char-card,
.stage-card,
.option-row {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.menu-item {
  padding: 10px 11px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  text-transform: uppercase;
  font-size: 13px;
}

.menu-item.selected {
  border-color: #a3b8aa;
  background: #344039;
  box-shadow: inset 3px 0 0 #c8d6cd;
}

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

.char-card,
.stage-card {
  min-height: 128px;
  padding: 8px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 9px;
  position: relative;
  overflow: hidden;
}

.char-card strong,
.stage-card strong {
  color: var(--ink);
  font-size: 10px;
  position: relative;
  z-index: 1;
}

.char-card > span:not(.portrait-scene):not(.swatches),
.stage-card > span:not(.stage-preview):not(.swatches) {
  position: relative;
  z-index: 1;
}

.char-card.selected,
.stage-card.selected {
  border-color: #c8d6cd;
  background: #344039;
  box-shadow: inset 0 0 0 1px #c8d6cd;
}

.char-card.locked {
  opacity: 0.44;
  filter: grayscale(0.8);
}

.portrait-scene,
.stage-preview {
  position: relative;
  z-index: 0;
  display: block;
  min-height: 56px;
  margin: -2px -2px 2px;
  border-radius: 5px;
  overflow: hidden;
}

.portrait-scene {
  background: #252b29;
  box-shadow: none;
}

.stage-panel .grid-select { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stage-panel .stage-preview { aspect-ratio: 16 / 9; min-height: 0; margin: 0; }
.stage-panel .stage-card { align-content: start; grid-template-rows: auto 1fr; min-height: 120px; }
.stage-panel .stage-card strong { align-self: center; font-size: 11px; line-height: 1.35; }

@media (max-width: 600px) {
  .stage-panel .grid-select { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.portrait-glow {
  position: absolute;
  inset: 8px 14px 4px;
  border-radius: 50%;
  background: var(--aura);
  filter: blur(18px);
  opacity: 0.34;
}

.portrait-raster {
  position: absolute;
  top: 0;
  left: 50%;
  width: 80px;
  height: 84px;
  transform: translateX(-50%);
  background-size: 400% 408%;
  background-position: 0 0;
  background-repeat: no-repeat;
}

.portrait-figure {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 44px;
  height: 58px;
  transform: translateX(-50%);
}

.portrait-head {
  position: absolute;
  left: 12px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50% 50% 45% 45%;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--skin), #fff 22%), var(--skin));
  box-shadow:
    inset 0 -4px 0 color-mix(in srgb, var(--skin), #000 18%),
    0 -5px 0 -1px var(--hair);
}

.portrait-head::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 10px;
  width: 3px;
  height: 2px;
  background: #05060c;
  border-radius: 2px;
}

.portrait-torso {
  position: absolute;
  left: 8px;
  top: 24px;
  width: 28px;
  height: 30px;
  border-radius: 9px 9px 5px 5px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cloth), #fff 28%), var(--cloth) 56%, var(--trim) 57%);
  box-shadow:
    inset -6px 0 color-mix(in srgb, var(--cloth), #000 18%),
    0 0 0 1px rgba(255, 255, 255, 0.16);
}

.portrait-arm {
  position: absolute;
  left: 2px;
  top: 27px;
  width: 42px;
  height: 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--skin), color-mix(in srgb, var(--skin), #000 16%));
  opacity: 0.95;
}

.portrait-figure.bruno,
.portrait-figure.toro {
  transform: translateX(-50%) scale(1.12);
}

.portrait-figure.maya,
.portrait-figure.nika {
  transform: translateX(-50%) scale(0.94);
}

.stage-preview {
  min-height: 62px;
  background:
    radial-gradient(circle at 22% 32%, color-mix(in srgb, var(--stage-accent), transparent 38%), transparent 34px),
    radial-gradient(circle at 82% 24%, color-mix(in srgb, var(--stage-line), transparent 44%), transparent 38px),
    linear-gradient(180deg, var(--stage-a), var(--stage-b) 52%, var(--stage-c));
}

.stage-preview img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 426 / 240;
  object-fit: cover;
}

.stage-skyline,
.stage-floor {
  position: absolute;
  left: 0;
  right: 0;
}

.stage-skyline {
  bottom: 15px;
  height: 34px;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(0, 0, 0, 0.42) 8% 22%, transparent 22% 30%, rgba(0, 0, 0, 0.5) 30% 48%, transparent 48% 56%, rgba(0, 0, 0, 0.48) 56% 77%, transparent 77%),
    linear-gradient(90deg, var(--stage-accent), var(--stage-line));
  mask-image: linear-gradient(180deg, transparent 0 10%, #000 10%);
  opacity: 0.9;
}

.stage-floor {
  bottom: 0;
  height: 18px;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--stage-accent), transparent 32%), transparent),
    repeating-linear-gradient(110deg, color-mix(in srgb, var(--stage-ground), #fff 14%) 0 16px, var(--stage-ground) 16px 34px);
  border-top: 2px solid var(--stage-line);
}

.swatches {
  display: flex;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.swatch {
  width: 14px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.options-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  width: min(92%, 690px);
  max-height: 96%;
  padding: 10px 14px;
  overflow: hidden;
}

.options-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.options-panel .menu-title {
  gap: 4px;
  padding-bottom: 6px;
}

.option-row {
  min-height: 44px;
  padding: 4px 8px;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 2fr);
  gap: 10px;
  align-items: center;
  font-size: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.option-row input[type="range"] {
  width: 100%;
  min-height: 44px;
  margin: 0;
}

.option-row button {
  min-height: 30px;
  font-size: 10px;
}

.remap-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.remap-column {
  display: grid;
  gap: 5px;
  padding: 6px;
  border-top: 1px solid var(--line);
}

.remap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.remap-grid button {
  min-height: 44px;
  padding: 6px;
  font-size: 12px;
}

.options-panel > .buttons-row button {
  min-height: 44px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--gold);
  font-size: 10px;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
    place-items: start center;
  }

  .side-panel {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .overlay:has(.menu-panel, .pause-panel, .summary-panel, .options-panel) {
    position: fixed;
    inset: 8px;
    z-index: 20;
    background: #111313;
    pointer-events: auto;
  }

  .overlay > :is(.menu-panel, .pause-panel, .summary-panel, .options-panel) {
    width: 100%;
    max-height: 100%;
    height: 100%;
    align-content: start;
  }

  .overlay:has(.menu-list) {
    background: linear-gradient(180deg, rgba(12, 14, 14, 0.94), rgba(12, 14, 14, 0.2)),
      url("assets/backgrounds/neon-market.jpg") center / cover;
  }

  .overlay:has(.menu-list) > .menu-panel {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body {
    padding: 8px;
  }

  #cabinet {
    gap: 10px;
  }

  .brand-block h1 {
    font-size: 11px;
  }

  .side-panel button {
    min-width: 78px;
    font-size: 11px;
  }

  .grid-select {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .char-card,
  .stage-card {
    min-height: 118px;
  }

  .menu-panel,
  .pause-panel,
  .options-panel,
  .summary-panel {
    width: 94%;
    padding: 8px;
    max-height: 96%;
    overflow: auto;
  }

  .menu-panel {
    gap: 6px;
  }

  .menu-title {
    gap: 4px;
    padding-bottom: 5px;
  }

  .menu-title p {
    font-size: 10px;
    line-height: 1.2;
  }

  .menu-item {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 12px;
  }

  .center-callout {
    font-size: 24px;
  }

  .menu-panel > .status-pill {
    display: none;
  }

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

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

  .top-hud {
    grid-template-columns: 1fr 42px 1fr;
    gap: 4px;
  }

  .timer {
    min-height: 28px;
    font-size: 16px;
  }
}
