@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;700;800;900&family=Orbitron:wght@500;700;800&display=swap");

:root {
  --bg-night: #050912;
  --bg-blue: #0d1d36;
  --bg-red: #420a16;
  --panel-main: rgba(7, 14, 27, 0.93);
  --panel-card: rgba(12, 25, 46, 0.93);
  --line-steel: #5d78a6;
  --line-bright: #91b5e7;
  --line-gold: #f4cc67;
  --text-main: #f2f8ff;
  --text-soft: #b8cde8;
  --text-dim: #8ca5c4;
  --brand-hot: #f84d3d;
  --brand-amber: #ffba39;
  --brand-cyan: #64ceff;
  --health: #26cc74;
  --danger: #f94144;
  --shadow-heavy: 0 24px 44px rgba(0, 0, 0, 0.55);
  --cf-vw: 100vw;
  --cf-vh: 100vh;
  --cf-safe-top: env(safe-area-inset-top, 0px);
  --cf-safe-right: env(safe-area-inset-right, 0px);
  --cf-safe-bottom: env(safe-area-inset-bottom, 0px);
  --cf-safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Barlow Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  background:
    radial-gradient(circle at 10% 18%, rgba(45, 91, 164, 0.42), transparent 33%),
    radial-gradient(circle at 85% 10%, rgba(196, 59, 77, 0.34), transparent 32%),
    radial-gradient(circle at 75% 88%, rgba(47, 122, 181, 0.26), transparent 37%),
    linear-gradient(145deg, var(--bg-night) 0%, var(--bg-blue) 48%, var(--bg-red) 100%);
  background-size: 150% 150%;
  animation: ambientShift 20s ease-in-out infinite alternate;
  display: grid;
  place-items: center;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.04),
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 3px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02), transparent 25%, transparent 75%, rgba(255, 255, 255, 0.02));
  opacity: 0.38;
  mix-blend-mode: soft-light;
  animation: scanMove 14s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.48) 100%);
}

.app-shell {
  width: min(1360px, 97vw);
  padding: 14px;
}

.menu-frame,
.game-frame {
  position: relative;
  overflow: hidden;
  border: 4px solid var(--line-steel);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(16, 30, 54, 0.82), rgba(8, 15, 26, 0.96)),
    var(--panel-main);
  box-shadow: var(--shadow-heavy), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.menu-frame {
  padding: 18px;
}

.menu-frame::before,
.menu-frame::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.menu-frame::before {
  width: 360px;
  height: 360px;
  top: -180px;
  left: -100px;
  background: radial-gradient(circle, rgba(100, 206, 255, 0.26), transparent 70%);
  animation: menuGlowPulse 4.2s ease-in-out infinite alternate;
}

.menu-frame::after {
  width: 320px;
  height: 320px;
  right: -100px;
  bottom: -120px;
  background: radial-gradient(circle, rgba(248, 77, 61, 0.22), transparent 72%);
  animation: menuFlicker 1.9s steps(2, end) infinite;
}

.title-marquee {
  position: relative;
  border: 2px solid rgba(244, 204, 103, 0.75);
  border-radius: 14px;
  padding: 16px 18px;
  background:
    linear-gradient(120deg, rgba(9, 24, 45, 0.96), rgba(30, 12, 19, 0.88)),
    var(--panel-card);
  box-shadow:
    inset 0 0 38px rgba(244, 204, 103, 0.17),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.title-marquee::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 170px;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.08) 100%);
  clip-path: polygon(42% 0, 100% 0, 100% 100%, 0 100%);
  pointer-events: none;
  animation: titleSweep 2.9s linear infinite;
}

.series-tag {
  margin: 0;
  font-family: "Orbitron", "Eurostile", "Bank Gothic", sans-serif;
  color: #9ec5f3;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
}

h1 {
  margin: 2px 0 5px;
  font-family: "Orbitron", "Eurostile", "Impact", sans-serif;
  font-size: clamp(2.35rem, 5.1vw, 4.2rem);
  font-weight: 800;
  line-height: 0.94;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff6d5;
  text-shadow:
    0 0 24px rgba(255, 195, 68, 0.45),
    4px 4px 0 rgba(113, 21, 41, 0.95);
}

h1 span {
  color: #9ed7ff;
}

.subtitle {
  margin: 0;
  font-size: 1.01rem;
  line-height: 1.1;
  letter-spacing: 0.01em;
  color: var(--text-soft);
}

.menu-mode-screen,
.menu-setup-screen {
  position: relative;
}

.menu-mode-screen::before,
.menu-setup-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.09),
      rgba(255, 255, 255, 0.09) 1px,
      transparent 1px,
      transparent 3px
    );
}

.menu-mode-screen {
  min-height: 250px;
  display: grid;
  place-items: center;
  padding: 22px 10px 8px;
}

/* First screen: custom art backdrop + compact mode buttons near lower center. */
.menu-frame.menu-step-mode .title-marquee {
  display: none;
}

body.menu-mode-immersive::before,
body.menu-mode-immersive::after {
  display: none;
}

body.menu-mode-immersive .app-shell {
  width: 100vw;
  height: 100vh;
  padding: 0;
}

.menu-frame.menu-step-mode {
  position: fixed;
  inset: 0;
  z-index: 5;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: none;
  box-shadow: none;
}

.menu-frame.menu-step-mode::before,
.menu-frame.menu-step-mode::after {
  display: none;
}

.menu-frame.menu-step-mode .menu-mode-screen {
  min-height: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: url("assets/ui/home/mode_select_bg.png");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  align-items: end;
  padding: 0 14px clamp(20px, 6vh, 56px);
}

.menu-frame.menu-step-mode .menu-mode-screen::before {
  display: none;
}

.menu-frame.menu-step-mode .mode-launch-row {
  width: min(560px, 92%);
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 12px;
}

.menu-frame.menu-step-mode .mode-launch-btn {
  min-height: 56px;
  padding: 10px 12px;
  font-size: clamp(0.72rem, 1.7vw, 0.96rem);
  letter-spacing: 0.08em;
  border-width: 3px;
  box-shadow:
    0 10px 16px rgba(0, 0, 0, 0.42),
    inset 0 0 18px rgba(255, 255, 255, 0.09);
}

.menu-frame.menu-step-mode .mode-launch-btn::before {
  opacity: 0.16;
}

.mode-launch-row {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 22px;
  align-items: stretch;
}

.mode-launch-btn {
  position: relative;
  min-height: 160px;
  border-width: 4px;
  font-size: clamp(1rem, 2.2vw, 1.4rem);
  letter-spacing: 0.11em;
  text-shadow: 2px 2px 0 rgba(11, 22, 42, 0.7);
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.4),
    inset 0 0 34px rgba(255, 255, 255, 0.08);
}

.mode-launch-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.18), transparent 35%, transparent 65%, rgba(255, 255, 255, 0.1));
  opacity: 0.25;
  pointer-events: none;
}

.mode-launch-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.48),
    inset 0 0 40px rgba(255, 255, 255, 0.12);
}

.menu-setup-screen {
  margin-top: 8px;
}

.title-badges {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.title-badges span {
  padding: 4px 10px;
  border: 1px solid rgba(155, 190, 236, 0.58);
  border-radius: 999px;
  background: rgba(14, 33, 60, 0.72);
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  color: #d8ecff;
}

.home-command {
  margin-top: 14px;
  padding: 12px;
  border: 3px solid rgba(125, 159, 203, 0.7);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(10, 23, 43, 0.9), rgba(8, 17, 34, 0.9));
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: end;
  box-shadow: inset 0 0 28px rgba(95, 166, 238, 0.12);
}

.setup-banner h2 {
  margin: 0;
  font-family: "Orbitron", "Eurostile", sans-serif;
  color: #ffdd90;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.setup-banner p {
  margin: 4px 0 0;
  color: #c6ddf8;
  font-size: 0.86rem;
}

.back-mode-btn {
  border: 3px solid #87aede;
  border-radius: 9px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #264a78, #183358);
  color: #e8f3ff;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.33);
}

.back-mode-btn:hover {
  filter: brightness(1.1);
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}

.mode-btn,
.start-btn,
#menuBtn,
#pauseBtn,
#nextRoundBtn,
.assign-btn,
#musicBtn {
  border: 2px solid #6f90c0;
  color: var(--text-main);
  cursor: pointer;
  border-radius: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: "Orbitron", "Eurostile", "Franklin Gothic Medium", sans-serif;
  font-weight: 700;
}

.mode-btn {
  padding: 10px 14px;
  font-size: 0.78rem;
  background: linear-gradient(180deg, #32598c, #17355e);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.mode-btn:hover {
  border-color: #9bc4ff;
}

.mode-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: saturate(0.4);
}

.mode-btn.active {
  border-color: var(--line-gold);
  background: linear-gradient(180deg, #cb3e4c, #8e1f37);
  box-shadow: inset 0 0 24px rgba(255, 222, 138, 0.18);
}

.right-pickers {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.stage-picker,
.difficulty-picker {
  display: grid;
  gap: 5px;
}

.stage-picker label,
.difficulty-picker label {
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.09em;
  color: #cae2ff;
}

select {
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid #5f7eaa;
  background: linear-gradient(180deg, #112a4d, #0c1d39);
  color: #f5f9ff;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
}

select:focus {
  border-color: var(--line-gold);
}

.mobile-cycle-picker {
  display: none;
  align-items: center;
  gap: 8px;
}

.mobile-cycle-picker__btn {
  border: 2px solid #6f90c0;
  border-radius: 8px;
  background: linear-gradient(180deg, #2f578a, #17385f);
  color: #eaf5ff;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 30px;
  height: 34px;
  padding: 0 6px;
}

.mobile-cycle-picker__value {
  min-width: 0;
  flex: 1 1 auto;
  border: 2px solid #5f7eaa;
  border-radius: 8px;
  background: linear-gradient(180deg, #112a4d, #0c1d39);
  color: #f5f9ff;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 34px;
  height: 34px;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-main-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(340px, 1fr);
  gap: 14px;
  align-items: start;
}

.select-board {
  border: 2px solid rgba(127, 165, 215, 0.72);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 18, 33, 0.97), rgba(13, 29, 51, 0.93));
  padding: 12px;
}

.select-board header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 10px;
}

.select-board h2,
.stage-spotlight h2 {
  margin: 0;
  font-family: "Orbitron", "Eurostile", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 1rem;
  color: #ffdf8a;
}

.select-board p {
  margin: 0;
  font-size: 0.84rem;
  color: #bcd5f4;
}

.char-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
}

.char-card {
  border: 3px solid #4e709a;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(25, 51, 83, 0.95), rgba(7, 16, 30, 0.95));
  padding: 10px;
  display: grid;
  gap: 8px;
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease, filter 130ms ease;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3);
}

.char-card:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: #89afe2;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.4), inset 0 0 18px rgba(122, 185, 255, 0.16);
  filter: brightness(1.03);
}

.char-card.selected-p1 {
  border-color: #50e087;
  box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.56);
}

.char-card.selected-p2 {
  border-color: #ff9248;
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.56);
}

.card-top {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
}

.card-top img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #8eafd8;
  background: #0c1d37;
}

.char-title {
  margin: 1px 0 0;
  font-size: 1rem;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.char-archetype {
  margin: 5px 0 0;
  font-size: 0.78rem;
  color: #c8ddf8;
  line-height: 1.2;
}

.card-power {
  margin: 0;
  font-size: 0.78rem;
  color: #98d8ff;
  line-height: 1.2;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.assign-btn {
  padding: 8px;
  font-size: 0.7rem;
  background: linear-gradient(180deg, #2f578a, #17385f);
}

.assign-btn:hover {
  filter: brightness(1.1);
}

.assign-btn[data-slot="p1"] {
  border-color: #50e087;
}

.assign-btn[data-slot="p2"] {
  border-color: #ff9248;
}

.menu-side {
  display: grid;
  gap: 10px;
}

.stage-spotlight {
  border: 2px solid rgba(114, 151, 201, 0.7);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(8, 20, 36, 0.95), rgba(15, 30, 52, 0.92));
  padding: 10px;
}

.stage-preview {
  margin-top: 8px;
  position: relative;
  border-radius: 10px;
  border: 2px solid #86a7d0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #0d1b33;
}

.stage-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.03);
  transition: transform 320ms ease;
}

.stage-preview img.is-broken {
  display: none;
}

.stage-preview.preview-missing {
  background:
    radial-gradient(circle at 24% 18%, rgba(120, 156, 211, 0.22), transparent 42%),
    linear-gradient(180deg, #15253f, #0d1b33);
}

.stage-preview:hover img {
  transform: scale(1.08);
}

.stage-preview-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(180deg, transparent 0%, rgba(2, 8, 15, 0.92) 85%);
}

#stagePreviewName {
  display: inline-block;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  color: #ffe09a;
  text-transform: uppercase;
}

.versus-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.pick-panel {
  min-height: 176px;
  border: 2px solid rgba(134, 169, 216, 0.74);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(9, 20, 39, 0.96), rgba(16, 36, 62, 0.9));
  padding: 10px;
  display: grid;
  justify-items: center;
  text-align: center;
  box-shadow: inset 0 0 30px rgba(102, 164, 232, 0.18);
}

.pick-panel h2 {
  margin: 0;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #ffd478;
  text-transform: uppercase;
}

.pick-panel img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #84a8d4;
  background: #0b1d37;
  margin-top: 6px;
}

.pick-panel h3 {
  margin: 8px 0 2px;
  font-size: 0.96rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.power-text {
  margin: 0;
  font-size: 0.76rem;
  color: #b9e3ff;
  line-height: 1.18;
}

.vs-badge {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  border: 3px solid var(--line-gold);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 32%, #ffb54a, #9d2035 74%);
  color: #fff9ee;
  text-shadow: 2px 2px 0 #4d0e18;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: 0 0 22px rgba(255, 199, 90, 0.34);
  animation: menuVsFlash 0.85s ease-in-out infinite alternate;
}

.versus-strip.single-strip {
  grid-template-columns: 1fr;
}

.versus-strip.single-strip .pick-panel {
  max-width: 260px;
  width: 100%;
  margin: 0 auto;
}

.controls-panel {
  border: 2px solid rgba(114, 151, 201, 0.66);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(8, 20, 38, 0.95);
}

.controls-panel h3 {
  margin: 0 0 6px;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.8rem;
  color: #ffd36d;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls-panel p {
  margin: 4px 0;
  font-size: 0.84rem;
  color: #d5e8ff;
  line-height: 1.14;
}

.controls-actions {
  margin-top: 10px;
}

#musicBtn {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.76rem;
  background: linear-gradient(180deg, #355f94, #1a3f69);
}

.start-btn {
  width: 100%;
  padding: 14px 16px;
  border-color: #ffe5a0;
  background: linear-gradient(180deg, #ffcb4b, #f58d0f);
  color: #1e1405;
  font-size: 1.02rem;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.45);
  box-shadow:
    0 10px 20px rgba(255, 144, 20, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.start-btn:hover {
  filter: brightness(1.09);
  transform: translateY(-1px);
}

@keyframes ambientShift {
  0% {
    background-position: 0% 18%;
  }
  100% {
    background-position: 100% 82%;
  }
}

@keyframes scanMove {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(7px);
  }
}

@keyframes titleSweep {
  0% {
    transform: translateX(0);
    opacity: 0.2;
  }
  45% {
    transform: translateX(-10px);
    opacity: 0.55;
  }
  100% {
    transform: translateX(0);
    opacity: 0.2;
  }
}

@keyframes menuGlowPulse {
  from {
    opacity: 0.78;
  }
  to {
    opacity: 1;
  }
}

@keyframes menuFlicker {
  0%,
  100% {
    opacity: 0.92;
  }
  48% {
    opacity: 1;
  }
  49% {
    opacity: 0.78;
  }
  50% {
    opacity: 0.98;
  }
}

@keyframes menuVsFlash {
  from {
    transform: scale(1);
    filter: brightness(0.95);
  }
  to {
    transform: scale(1.06);
    filter: brightness(1.14);
  }
}

.game-frame {
  padding: 10px;
}

body.game-screen:not(.mobile-mode) {
  overflow: hidden;
}

body.game-screen:not(.mobile-mode) .app-shell {
  width: 100vw;
  max-width: none;
  padding: 0;
}

body.game-screen:not(.mobile-mode) .game-frame {
  position: fixed;
  inset: 0;
  border: 0;
  border-radius: 0;
  padding: 6px 10px 6px;
  background: #050b16;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.game-screen:not(.mobile-mode) .hud {
  width: 100%;
  margin: 0 0 6px;
}

body.game-screen:not(.mobile-mode) #gameCanvas {
  display: block;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  max-width: 100%;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  margin-bottom: 8px;
  align-items: center;
}

.hud-side {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

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

.hud-portrait {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  border: 2px solid #86a7d0;
  background: #0d1f3a;
}

.hud-meta {
  display: grid;
  gap: 4px;
}

.hud-meta span {
  font-size: 0.86rem;
}

.bar {
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #6586b1;
  background: #222f44;
}

.fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transition: width 140ms linear;
}

.hud-center {
  text-align: center;
  display: grid;
  gap: 1px;
}

#timer {
  font-size: 2rem;
  color: #fff0c4;
  text-shadow: 2px 2px 0 #8e2133;
}

#stageName {
  font-size: 0.86rem;
  color: #d0e7ff;
}

#roundText {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #ffd166;
}

#adventureProgress {
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  color: #9de8ff;
  font-family: "Orbitron", "Eurostile", sans-serif;
  text-transform: uppercase;
}

canvas {
  width: 100%;
  max-width: 100vw;
  height: auto;
  border: 3px solid #5879a5;
  border-radius: 10px;
  background: #090f1a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 24px rgba(0, 0, 0, 0.35);
}

.mobile-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  z-index: 9;
  --mobile-safe-margin: 20px;
  --mobile-control-scale: 1;
}

.mobile-controls__side {
  position: absolute;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: column;
  display: flex;
  gap: 8px;
  pointer-events: auto;
  touch-action: none;
}

.mobile-controls__side--left {
  left: var(--mobile-safe-margin);
}

.mobile-controls__side--right {
  right: var(--mobile-safe-margin);
}

.mobile-touch-btn {
  width: calc(clamp(72px, 9vw, 92px) * var(--mobile-control-scale));
  height: calc(clamp(72px, 9vw, 92px) * var(--mobile-control-scale));
  border: 2px solid rgba(129, 177, 243, 0.92);
  border-radius: 999px;
  background: radial-gradient(circle at 30% 28%, rgba(62, 114, 182, 0.88), rgba(11, 34, 68, 0.86));
  color: #ecf5ff;
  font-family: "Orbitron", "Eurostile", "Franklin Gothic Medium", sans-serif;
  font-size: calc(clamp(0.52rem, 1.1vw, 0.72rem) * var(--mobile-control-scale));
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  opacity: 0.9;
}

.mobile-touch-btn:active,
.mobile-touch-btn.active-hold {
  transform: translateY(1px);
  filter: brightness(1.2);
  opacity: 1;
}

.mobile-touch-btn[data-action="punch"] {
  border-color: #77c7ff;
}

.mobile-touch-btn[data-action="kick"] {
  border-color: #ffb85a;
}

.mobile-touch-btn[data-action="special"] {
  border-color: #ffd166;
}

.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.03) 2px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0) 4px
    ),
    linear-gradient(180deg, rgba(5, 10, 18, 0.94), rgba(3, 6, 12, 0.95));
}

.rotate-hidden {
  display: none !important;
}

.rotate-overlay p {
  margin: 0;
  max-width: 520px;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: clamp(1rem, 2.8vw, 1.6rem);
  line-height: 1.3;
  color: #ffe4ac;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(71, 20, 11, 0.9);
}

.battle-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.03) 2px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0) 4px
    ),
    linear-gradient(180deg, rgba(5, 10, 18, 0.55), rgba(3, 6, 12, 0.64));
}

.battle-loading-card {
  width: min(560px, 74vw);
  border: 3px solid rgba(146, 188, 244, 0.95);
  border-radius: 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(11, 25, 44, 0.95), rgba(7, 14, 27, 0.95));
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.5),
    inset 0 0 30px rgba(120, 180, 255, 0.14);
}

.battle-loading-card h3 {
  margin: 0 0 10px;
  font-family: "Orbitron", "Eurostile", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  color: #ffe6a5;
  text-shadow: 2px 2px 0 rgba(76, 23, 13, 0.85);
}

.battle-loading-track {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  border: 2px solid #82abd9;
  background: #162a44;
  overflow: hidden;
}

.battle-loading-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #41c3ff, #ffd25f);
  transition: width 120ms linear;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.34);
}

.battle-loading-card p {
  margin: 8px 0 0;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  color: #d6ebff;
}

.game-actions {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  margin-top: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  z-index: 11;
}

.adventure-victory {
  position: absolute;
  inset: 86px 32px 84px;
  border-radius: 14px;
  border: 3px solid rgba(255, 207, 104, 0.9);
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 215, 130, 0.22), rgba(0, 0, 0, 0) 55%),
    linear-gradient(180deg, rgba(15, 24, 42, 0.95), rgba(10, 14, 28, 0.95));
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  z-index: 12;
  box-shadow:
    inset 0 0 48px rgba(255, 204, 88, 0.14),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

.adventure-versus {
  position: absolute;
  inset: 86px 32px 84px;
  z-index: 13;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.03) 2px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0) 4px
    ),
    radial-gradient(circle at 50% 18%, rgba(255, 182, 81, 0.22), rgba(0, 0, 0, 0) 57%),
    linear-gradient(180deg, rgba(11, 23, 43, 0.94), rgba(8, 15, 29, 0.96));
  border-radius: 14px;
  border: 3px solid rgba(255, 207, 104, 0.9);
  box-shadow:
    inset 0 0 40px rgba(255, 211, 116, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

.adventure-versus-panel {
  width: min(760px, 100%);
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  padding: 10px 14px;
}

.adventure-versus-label {
  margin: 0;
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #ffd882;
  font-family: "Orbitron", "Eurostile", sans-serif;
  text-shadow: 2px 2px 0 rgba(90, 28, 16, 0.9);
}

.adventure-versus-fighters {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.adventure-versus-fighter {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.adventure-versus-fighter img {
  width: clamp(132px, 22vw, 210px);
  height: clamp(132px, 22vw, 210px);
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid rgba(142, 184, 240, 0.92);
  background: #0b1830;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
}

.adventure-versus-fighter h3 {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.52rem);
  line-height: 1.08;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #f2f7ff;
  text-shadow: 2px 2px 0 rgba(19, 30, 63, 0.95);
}

.adventure-versus-mid {
  width: clamp(84px, 14vw, 124px);
  height: clamp(84px, 14vw, 124px);
  border-radius: 999px;
  border: 3px solid #f4cc67;
  display: grid;
  place-items: center;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: clamp(1.2rem, 3.7vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff3d1;
  text-shadow: 2px 2px 0 #5f111f;
  background: radial-gradient(circle at 30% 32%, #ffb54a, #9d2035 74%);
  box-shadow: 0 0 22px rgba(255, 199, 90, 0.34);
  animation: adventureVsPulse 0.9s ease-in-out infinite alternate;
}

@keyframes adventureVsPulse {
  from {
    transform: scale(1);
    filter: brightness(0.95);
  }
  to {
    transform: scale(1.06);
    filter: brightness(1.08);
  }
}

@keyframes adventureVsSlideLeft {
  from {
    opacity: 0;
    transform: translate3d(-26px, 0, 0) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes adventureVsSlideRight {
  from {
    opacity: 0;
    transform: translate3d(26px, 0, 0) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes adventureVsSplash {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }
  62% {
    opacity: 1;
    transform: scale(1.14);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.adventure-versus:not(.hidden) .adventure-versus-fighter:first-child {
  animation: adventureVsSlideLeft 300ms cubic-bezier(0.18, 0.88, 0.22, 1) both;
  will-change: transform, opacity;
}

.adventure-versus:not(.hidden) .adventure-versus-fighter:last-child {
  animation: adventureVsSlideRight 300ms cubic-bezier(0.18, 0.88, 0.22, 1) both;
  will-change: transform, opacity;
}

.adventure-versus:not(.hidden) .adventure-versus-mid {
  animation:
    adventureVsSplash 340ms cubic-bezier(0.22, 0.94, 0.2, 1) both,
    adventureVsPulse 0.9s ease-in-out 340ms infinite alternate;
  will-change: transform, opacity;
}

.adventure-victory h2 {
  margin: 0;
  font-family: "Orbitron", "Eurostile", sans-serif;
  font-size: clamp(1.45rem, 3.5vw, 2.2rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffe8b0;
  text-shadow: 2px 2px 0 rgba(116, 38, 19, 0.9);
}

#adventureChampionPortrait {
  width: 170px;
  height: 170px;
  border-radius: 14px;
  object-fit: cover;
  border: 3px solid rgba(155, 196, 255, 0.86);
  background: #0b1830;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

#adventureChampionName {
  margin: 0;
  font-size: 1.04rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #dff2ff;
}

#adventureBackBtn {
  border: 2px solid #6f90c0;
  color: var(--text-main);
  cursor: pointer;
  border-radius: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: "Orbitron", "Eurostile", "Franklin Gothic Medium", sans-serif;
  font-weight: 700;
  padding: 10px 16px;
  background: linear-gradient(180deg, #365f94, #1a3f6a);
}

#menuBtn,
#pauseBtn,
#nextRoundBtn {
  padding: 9px 14px;
  font-size: 0.74rem;
  background: linear-gradient(180deg, #365f94, #1a3f6a);
}

#pauseBtn.paused {
  border-color: #f6d07d;
  background: linear-gradient(180deg, #9b5a1d, #6f370e);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .menu-main-grid {
    grid-template-columns: 1fr;
  }

  .menu-side {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .stage-spotlight,
  .versus-strip,
  .controls-panel,
  .start-btn {
    grid-column: span 2;
  }
}

@media (max-width: 980px) {
  .home-command {
    grid-template-columns: 1fr;
  }

  .right-pickers {
    grid-template-columns: 1fr;
  }

  .mode-picker {
    grid-template-columns: 1fr;
  }

  .select-board header {
    flex-direction: column;
    align-items: flex-start;
  }

  .versus-strip {
    grid-template-columns: 1fr;
  }

  .vs-badge {
    margin: 0 auto;
  }

  .menu-side {
    grid-template-columns: 1fr;
  }

  .adventure-victory {
    inset: 72px 12px 74px;
    gap: 10px;
    padding: 10px;
  }

  .adventure-versus {
    inset: 72px 12px 74px;
    padding: 10px;
  }

  .adventure-versus-fighters {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .adventure-versus-mid {
    width: 74px;
    height: 74px;
    font-size: 1.2rem;
  }

  #adventureChampionPortrait {
    width: 136px;
    height: 136px;
  }

  .stage-spotlight,
  .versus-strip,
  .controls-panel,
  .start-btn {
    grid-column: auto;
  }

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

body.mobile-mode {
  overflow-x: hidden;
}

/* Portrait fallback: auto-present UI in landscape without blocking with rotate overlay. */
body.mobile-force-landscape {
  overflow: hidden;
}

body.mobile-force-landscape .app-shell {
  position: fixed;
  top: 50%;
  left: 50%;
  width: var(--cf-vh);
  height: var(--cf-vw);
  max-width: none;
  padding: 0;
  margin: 0;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

body.mobile-force-landscape .menu-frame,
body.mobile-force-landscape .game-frame {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

body.mobile-force-landscape:not(.game-screen) .menu-frame {
  border-width: 0;
  padding: 12px;
  overflow: auto;
}

body.mobile-mode:not(.game-screen) {
  display: block;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.mobile-mode:not(.game-screen) .app-shell {
  width: min(1360px, 97vw);
  margin: 0 auto;
  padding: 12px;
}

/* Mobile menu: replace native select popups (portrait UI) with horizontal cyclers. */
body.mobile-mode:not(.game-screen) .right-pickers {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}

body.mobile-mode:not(.game-screen) .right-pickers .stage-picker,
body.mobile-mode:not(.game-screen) .right-pickers .difficulty-picker {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1 1 0;
}

body.mobile-mode:not(.game-screen) .right-pickers .stage-picker > select,
body.mobile-mode:not(.game-screen) .right-pickers .difficulty-picker > select {
  display: none;
}

body.mobile-mode:not(.game-screen) .right-pickers .mobile-cycle-picker {
  display: flex;
}

body.mobile-mode.game-screen {
  overflow: hidden;
}

body.mobile-mode .controls-panel p:last-of-type {
  display: none;
}

body.mobile-mode #mobileControls.hidden {
  display: none !important;
}

body.mobile-mode.game-screen .app-shell {
  width: var(--cf-vw);
  height: var(--cf-vh);
  padding: 0;
}

body.mobile-mode.game-screen .game-frame {
  position: fixed;
  inset: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: #050b16;
}

body.mobile-mode.game-screen .hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: calc(4px + var(--cf-safe-top)) calc(8px + var(--cf-safe-right)) 3px calc(8px + var(--cf-safe-left));
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  background: linear-gradient(180deg, rgba(3, 8, 14, 0.85), rgba(3, 8, 14, 0));
  pointer-events: none;
}

body.mobile-mode.game-screen .hud-side {
  grid-template-columns: 1fr;
  min-width: 0;
  width: 100%;
  gap: 5px;
}

body.mobile-mode.game-screen .hud-portrait {
  display: none;
}

body.mobile-mode.game-screen .hud-meta {
  gap: 2px;
  min-width: 0;
  width: 100%;
}

body.mobile-mode.game-screen .hud-meta span {
  font-size: 0.62rem;
}

body.mobile-mode.game-screen .hud-meta small {
  display: none;
}

body.mobile-mode.game-screen .bar {
  width: 100%;
  height: 10px;
  border-width: 1px;
}

body.mobile-mode.game-screen .hud-side-right .hud-meta {
  text-align: right;
}

body.mobile-mode.game-screen #timer {
  font-size: 1.25rem;
}

body.mobile-mode.game-screen #stageName,
body.mobile-mode.game-screen #roundText {
  font-size: 0.58rem;
}

body.mobile-mode.game-screen #gameCanvas {
  width: 100%;
  height: 100%;
  max-width: none;
  min-width: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #090f1a;
}

body.mobile-mode.game-screen .game-actions {
  position: absolute;
  bottom: calc(8px + var(--cf-safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  margin: 0;
  gap: 6px;
}

body.mobile-mode.game-screen #menuBtn,
body.mobile-mode.game-screen #pauseBtn,
body.mobile-mode.game-screen #nextRoundBtn {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 0.62rem;
}

body.mobile-mode.game-screen .battle-loading-card {
  width: min(90vw, 540px);
  padding: 10px 12px;
}

body.mobile-mode.game-screen .battle-loading-card h3 {
  font-size: clamp(0.72rem, 2.1vw, 0.9rem);
}

body.mobile-mode.game-screen .battle-loading-track {
  height: 14px;
}

body.mobile-mode.game-screen .adventure-versus {
  inset: 48px 6px 54px;
  padding: 6px;
}

body.mobile-mode.game-screen .adventure-versus-panel {
  width: 100%;
  gap: 6px;
  padding: 4px;
}

body.mobile-mode.game-screen .adventure-versus-fighters {
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
}

body.mobile-mode.game-screen .adventure-versus-fighter img {
  width: clamp(88px, 19vw, 122px);
  height: clamp(88px, 19vw, 122px);
}

body.mobile-mode.game-screen .adventure-versus-fighter h3 {
  font-size: clamp(0.74rem, 1.9vw, 1rem);
}

body.mobile-mode.game-screen .adventure-versus-mid {
  width: clamp(86px, 17vw, 128px);
  height: clamp(86px, 17vw, 128px);
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  border-width: 4px;
  box-shadow:
    0 0 28px rgba(255, 202, 97, 0.42),
    inset 0 0 20px rgba(255, 230, 166, 0.18);
}

/* Stronger overrides when portrait is emulated as landscape. */
body.mobile-mode.mobile-force-landscape:not(.game-screen) {
  overflow: hidden;
}

body.mobile-mode.mobile-force-landscape:not(.game-screen) .app-shell {
  width: var(--cf-vh);
  height: var(--cf-vw);
  padding: 0;
}

body.mobile-mode.mobile-force-landscape.game-screen .app-shell {
  width: var(--cf-vh);
  height: var(--cf-vw);
  padding: 0;
}

body.mobile-mode.mobile-force-landscape.game-screen .game-frame {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
}

body.mobile-mode.mobile-force-landscape.game-screen #gameCanvas {
  width: 100%;
  height: 100%;
  max-width: none;
  min-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .adventure-versus:not(.hidden) .adventure-versus-fighter:first-child,
  .adventure-versus:not(.hidden) .adventure-versus-fighter:last-child,
  .adventure-versus:not(.hidden) .adventure-versus-mid {
    animation: none !important;
    will-change: auto;
  }
}

@media (max-width: 768px) {
  body {
    animation: none;
  }
}
