:root {
  --bg-dark: #070b14;
  --gold: #facc15;
  --orange: #f97316;
  --red: #ef4444;
  --cyan: #38bdf8;
  --panel: rgba(15, 23, 42, 0.92);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050811;
  color: #f8fafc;
  font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #050811 80%);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 8px) env(safe-area-inset-right, 12px) env(safe-area-inset-bottom, 8px) env(safe-area-inset-left, 12px);
}

.screen.active {
  display: flex;
}

/* --- TITLE SCREEN --- */
#screen-title {
  background:
    radial-gradient(circle at 50% 25%, rgba(249, 115, 22, 0.25), transparent 55%),
    radial-gradient(circle at 20% 80%, rgba(56, 189, 248, 0.16), transparent 45%),
    linear-gradient(180deg, #0b1120 0%, #050811 100%);
  gap: 12px;
}

.title-top-bar {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 5;
}

.arcade-logo {
  text-align: center;
  line-height: 0.95;
  margin-bottom: 2px;
}

.arcade-logo .sub-top {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-weight: 900;
  font-size: clamp(10px, 1.8vw, 13px);
  letter-spacing: 3px;
  padding: 3px 10px;
  border-radius: 4px;
  border: 2px solid #facc15;
  margin-bottom: 6px;
}

.arcade-logo h1 {
  margin: 0;
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(34px, 7.2vw, 68px);
  font-style: italic;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fef08a 0%, #facc15 45%, #ef4444 95%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #09090b) drop-shadow(0 0 18px rgba(250, 204, 21, 0.45));
}

.arcade-logo .edition {
  font-size: clamp(11px, 1.8vw, 16px);
  font-weight: 800;
  letter-spacing: 5px;
  color: #38bdf8;
  text-shadow: 0 2px 6px #000;
}

.roster-strip {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: nowrap;
  max-width: 94vw;
  overflow: hidden;
  padding: 4px 8px;
}

.roster-strip img {
  width: clamp(32px, 4.8vw, 50px);
  height: clamp(32px, 4.8vw, 50px);
  object-fit: contain;
  background: rgba(30, 41, 59, 0.7);
  border: 2px solid #facc15;
  border-radius: 8px;
  padding: 2px;
}

.menu-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(132px, 210px));
  gap: 8px;
  width: min(96vw, 880px);
}

@media (max-width: 680px) {
  .menu-buttons {
    grid-template-columns: repeat(2, minmax(135px, 1fr));
    width: min(94vw, 520px);
  }
}

.btn-arcade.net-accent {
  border-color: #38bdf8;
  background: linear-gradient(180deg, rgba(14, 116, 144, 0.45), rgba(15, 23, 42, 0.92));
}

.net-room-bar {
  width: min(96vw, 940px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(14, 116, 144, 0.25);
  border: 1.5px solid #38bdf8;
  font-size: 12px;
  flex-wrap: wrap;
}

.net-badge {
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #facc15;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #facc15;
  border-radius: 6px;
  padding: 2px 8px;
}

.net-status-text {
  flex: 1;
  text-align: center;
  color: #e0f2fe;
  font-weight: 700;
}

.net-mini-btn {
  padding: 3px 9px !important;
  font-size: 11px !important;
}

.net-role-pill {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.85);
  border: 1.5px solid #38bdf8;
  color: #bae6fd;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}

.net-lobby-card {
  width: min(94vw, 560px) !important;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 14px 16px !important;
}

.net-lobby-card h3 {
  margin: 0 0 4px;
  color: #38bdf8;
}

.net-lobby-sub {
  margin: 0 0 10px;
  font-size: 12px;
  color: #cbd5e1;
}

.net-lan-box {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  text-align: left;
}

.net-lan-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.net-lan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.net-lan-row code {
  font-size: 12.5px;
  font-weight: 800;
  color: #facc15;
  word-break: break-all;
}

.net-lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.net-create-btn {
  flex: 1 1 180px;
  padding: 8px 12px !important;
  font-size: 13px !important;
}

.net-join-row {
  flex: 1 1 200px;
  display: flex;
  gap: 6px;
}

.net-join-row input {
  flex: 1;
  min-width: 90px;
  background: #0f172a;
  color: #fff;
  border: 1.5px solid #475569;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.net-join-btn {
  white-space: nowrap;
  border-color: #22c55e !important;
}

.net-rooms-wrap {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.net-rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.net-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.net-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

.net-empty {
  font-size: 12px;
  color: #94a3b8;
  padding: 6px 0;
}

.net-lobby-status {
  min-height: 18px;
  font-size: 12px;
  font-weight: 700;
  color: #facc15;
  margin-bottom: 6px;
}

.btn-arcade {
  cursor: pointer;
  border: 3px solid #facc15;
  border-radius: 12px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  padding: 12px 12px;
  text-align: center;
  font-weight: 900;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 5px 0 #854d0e, 0 8px 18px rgba(0, 0, 0, 0.6);
}

.btn-arcade:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #854d0e;
}

.btn-arcade.primary {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border-color: #fef08a;
}

.btn-arcade .btn-title {
  display: block;
  font-size: clamp(13px, 2.2vw, 17px);
  letter-spacing: 0.5px;
}

.btn-arcade .btn-desc {
  display: block;
  font-size: clamp(10px, 1.3vw, 11.5px);
  font-weight: 500;
  color: #cbd5e1;
  margin-top: 3px;
}

.title-footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.pill-btn {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.85);
  border: 2px solid #475569;
  color: #e2e8f0;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill-btn.active {
  border-color: #38bdf8;
  color: #38bdf8;
}

/* --- CHARACTER & STAGE SELECT --- */
#screen-select {
  justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(180deg, #090d16 0%, #111827 100%);
}

.select-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.select-header h2 {
  margin: 0;
  font-size: clamp(15px, 2.6vw, 24px);
  font-family: 'Arial Black', sans-serif;
  color: #facc15;
  text-shadow: 0 2px 0 #000;
}

.select-body {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1.65fr 1fr;
  gap: 10px;
  align-items: center;
  margin: 4px 0;
}

.fighter-preview {
  background: var(--panel);
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 8px 10px;
  height: 100%;
  max-height: 270px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.fighter-preview.p1 { border-color: #38bdf8; }
.fighter-preview.p2 { border-color: #ef4444; }

.preview-top {
  display: flex;
  gap: 8px;
  align-items: center;
}

.preview-top img {
  width: clamp(48px, 7.5vw, 72px);
  height: clamp(64px, 9.5vw, 94px);
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid #facc15;
}

.preview-meta h3 {
  margin: 0;
  font-size: clamp(14px, 2vw, 19px);
  color: #facc15;
}

.preview-meta .role {
  font-size: clamp(10px, 1.3vw, 12px);
  color: #94a3b8;
  font-weight: 700;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  margin: 2px 0;
}

.stat-row span { width: 32px; font-weight: 700; color: #cbd5e1; }
.stat-bar {
  flex: 1;
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
}
.stat-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #facc15, #f97316);
}

.special-box {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 5px 7px;
  font-size: clamp(10px, 1.3vw, 11.5px);
}

.special-box strong { color: #fb923c; display: block; }
.quote-line {
  font-size: clamp(10px, 1.3vw, 11.5px);
  font-style: italic;
  color: #bae6fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  align-content: center;
  max-height: 270px;
}

.char-card {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid #334155;
  background: #0f172a;
  aspect-ratio: 171 / 259;
  max-height: 124px;
  margin: 0 auto;
  transition: transform 0.1s;
}

.char-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.char-card.sel-p1 {
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
  transform: scale(1.04);
  z-index: 2;
}

.char-card.sel-p2 {
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
  transform: scale(1.04);
  z-index: 2;
}

.char-card.sel-both {
  border-color: #facc15;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.9);
}

.char-badge {
  position: absolute;
  bottom: 2px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 900;
  border-radius: 4px;
  color: #fff;
}
.char-badge.b1 { left: 2px; background: #0284c7; }
.char-badge.b2 { right: 2px; background: #dc2626; }

.select-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.stage-pill {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  border: 2px solid #334155;
  background: #0f172a;
  color: #cbd5e1;
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 800;
}

.stage-pill.active {
  border-color: #facc15;
  background: #78350f;
  color: #fef08a;
}

.start-fight-btn {
  cursor: pointer;
  padding: 9px 22px;
  border-radius: 10px;
  border: 3px solid #fef08a;
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  font-family: 'Arial Black', sans-serif;
  font-size: clamp(13px, 2vw, 16px);
  box-shadow: 0 4px 0 #7f1d1d;
}

.start-fight-btn:active { transform: translateY(2px); }

/* --- VS SCREEN --- */
#screen-vs {
  background: radial-gradient(circle at center, #7c2d12 0%, #090d16 75%);
  gap: 14px;
}

.vs-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vw, 48px);
  width: 92vw;
}

.vs-card {
  text-align: center;
  max-width: 240px;
}

.vs-card img {
  width: clamp(92px, 16vw, 150px);
  height: auto;
  border-radius: 10px;
  border: 4px solid #facc15;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.vs-card h3 { margin: 6px 0 2px; color: #facc15; font-size: clamp(16px, 3vw, 24px); }
.vs-card p { margin: 0; font-size: clamp(11px, 1.5vw, 13px); color: #bae6fd; font-style: italic; }

.vs-bolt {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: clamp(40px, 8vw, 76px);
  font-style: italic;
  color: #facc15;
  text-shadow: 0 5px 0 #dc2626, 0 0 25px #f97316;
}

/* --- FIGHT SCREEN & CANVAS --- */
#screen-fight {
  padding: 0;
  background: #000;
}

#fight-stage-wrap {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.fight-top-controls {
  position: absolute;
  top: 11.8%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 15;
  opacity: 0.78;
}

.mini-icon-btn {
  cursor: pointer;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid #64748b;
  color: #fff;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

/* --- DOJO TEST MODE PANEL --- */
.dojo-panel {
  position: absolute;
  top: 17.5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(96%, 900px);
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.78);
  border: 1.5px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.dojo-panel.visible {
  display: flex;
}

.dojo-panel.collapsed .dojo-moves-row {
  display: none;
}

.dojo-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.dojo-badge {
  font-size: 10px;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(14, 116, 144, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.dojo-btn,
.dojo-select {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid #475569;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
}

.dojo-btn:hover {
  border-color: #38bdf8;
  color: #fff;
}

.dojo-btn.active {
  background: #0284c7;
  border-color: #7dd3fc;
  color: #fff;
}

.dojo-btn.dojo-special {
  border-color: #f59e0b;
  color: #fde047;
}

/* --- MOBILE TOUCH CONTROLS --- */
.touch-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: none;
}

.touch-layer.visible {
  display: block;
}

.dpad-zone {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  left: max(14px, env(safe-area-inset-left, 14px));
  width: clamp(116px, 18vw, 152px);
  height: clamp(116px, 18vw, 152px);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.42);
  border: 3px solid rgba(255, 255, 255, 0.32);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.dpad-knob {
  width: 44%;
  height: 44%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f8fafc, #64748b);
  border: 2px solid #09090b;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.action-pad {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  right: max(14px, env(safe-area-inset-right, 14px));
  width: clamp(150px, 23vw, 200px);
  height: clamp(128px, 20vw, 168px);
  pointer-events: none;
}

.arc-btn {
  position: absolute;
  pointer-events: auto;
  width: clamp(50px, 7.6vw, 66px);
  height: clamp(50px, 7.6vw, 66px);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.78);
  color: #fff;
  font-weight: 900;
  font-size: clamp(10px, 1.3vw, 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
  opacity: 0.82;
  transition: transform 0.06s;
}

.arc-btn span.ico { font-size: clamp(16px, 2.4vw, 22px); }
.arc-btn.pressed { transform: scale(0.9); opacity: 1; filter: brightness(1.25); }

.btn-punch { left: 0; top: 34%; background: rgba(37, 99, 235, 0.82); }
.btn-kick { left: 36%; bottom: 0; background: rgba(220, 38, 38, 0.82); }
.btn-special { right: 0; top: 18%; background: rgba(234, 88, 12, 0.88); border-color: #fde047; }
.btn-special:not(.super-ready) {
  opacity: 0.44;
  filter: grayscale(0.58);
}
.btn-block { left: 34%; top: 0; background: rgba(5, 150, 105, 0.78); }

.btn-special.super-ready {
  opacity: 1;
  filter: none;
  background: linear-gradient(135deg, #f97316, #facc15);
  box-shadow: 0 0 18px #f97316, 0 0 28px #facc15;
  animation: pulseSuper 0.65s infinite alternate;
}

@keyframes pulseSuper {
  from { transform: scale(1); }
  to { transform: scale(1.09); }
}

/* 2P Split Touch Controls */
.touch-layer.mode-2p .dpad-zone {
  width: 96px;
  height: 96px;
  bottom: 10px;
  left: 10px;
}
.touch-layer.mode-2p .p1-mini-actions {
  position: absolute;
  bottom: 10px;
  left: 114px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.touch-layer.mode-2p .p2-dpad {
  position: absolute;
  bottom: 10px;
  right: 114px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.42);
  border: 3px solid rgba(239, 68, 68, 0.55);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.touch-layer.mode-2p .p2-mini-actions {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.mini-act-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #fff;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

/* --- MODALS & RESULT --- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.modal-card {
  background: #0f172a;
  border: 3px solid #facc15;
  border-radius: 14px;
  padding: 16px 20px;
  width: min(92vw, 560px);
  max-height: 90dvh;
  overflow-y: auto;
  text-align: center;
}

.modal-card h2 { margin: 0 0 10px; color: #facc15; font-family: 'Arial Black', sans-serif; }

.result-grid {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.result-grid img {
  width: 96px;
  border-radius: 8px;
  border: 3px solid #facc15;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* --- PORTRAIT ORIENTATION WARNING --- */
#portrait-warning {
  position: fixed;
  inset: 0;
  background: #050811;
  z-index: 999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 14px;
}

@media (orientation: portrait) and (max-width: 900px) {
  #portrait-warning {
    display: flex;
  }
}
