.cabinet {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.cabinet-bar {
  padding: 11px 18px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.stage-badge {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-arcade); font-size: 11px; color: var(--gold);
}
.stage-dot { width: 10px; height: 10px; border-radius: 2px; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.cabinet-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.viewport-wrap {
  position: relative; width: 100%; background: #0b101d;
  aspect-ratio: 960 / 540; min-height: 410px; max-height: 660px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}

#gameCanvas {
  width: 100%; height: 100%; display: block;
}

.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(8, 12, 22, 0.92);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 18px; overflow-y: auto;
}
.overlay[hidden] { display: none !important; }

.select-header { text-align: center; margin-bottom: 14px; }
.select-kicker { font-family: var(--font-arcade); font-size: clamp(12px, 1.7vw, 16px); color: var(--gold); margin-bottom: 5px; }
.select-sub { font-size: 13px; color: var(--muted); }

.select-grid {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch;
  gap: 14px; width: 100%; max-width: 960px;
}

.player-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 11px;
  text-align: left; transition: transform .15s, border-color .15s, box-shadow .15s;
  cursor: pointer; position: relative;
}
.player-card.p1:hover, .player-card.p1.focused {
  border-color: var(--p1); transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(34, 211, 238, 0.22);
}
.player-card.p2:hover, .player-card.p2.focused {
  border-color: var(--p2); transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(255, 90, 54, 0.22);
}

.p-hero-row {
  display: grid; grid-template-columns: 92px 86px 1fr; align-items: center; gap: 12px;
}

.portrait-frame {
  width: 92px; height: 92px; border-radius: 12px; overflow: hidden;
  border: 2px solid var(--border); background: #0c1220; position: relative; flex-shrink: 0;
}
.p1 .portrait-frame { border-color: rgba(34, 211, 238, 0.55); }
.p2 .portrait-frame { border-color: rgba(255, 90, 54, 0.55); }
.portrait-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-badge {
  position: absolute; bottom: 4px; left: 4px;
  padding: 2px 5px; border-radius: 4px; font-family: var(--font-arcade); font-size: 8px;
  background: rgba(9, 12, 20, 0.85); color: var(--gold);
}

.sprite-stage {
  width: 86px; height: 92px; border-radius: 12px;
  background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 72%, #cbd5e1 100%);
  border: 1px solid var(--border);
  display: grid; place-items: center; flex-shrink: 0; position: relative; overflow: hidden;
}
.sprite-stage canvas { width: 78px; height: 84px; }
.sprite-caption {
  position: absolute; top: 3px; right: 5px;
  font-size: 9px; font-weight: 700; color: #1e293b; opacity: 0.75;
}

.p-tag { font-family: var(--font-arcade); font-size: 9px; margin-bottom: 4px; line-height: 1.4; }
.p1 .p-tag { color: var(--p1); }
.p2 .p-tag { color: var(--p2); }
.p-name { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.p-mode { font-size: 12px; color: var(--muted); }

.p-mech {
  font-size: 12.5px; color: #e2e8f0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; display: flex; align-items: center; gap: 10px;
}
.p-mech-enemy {
  width: 40px; height: 40px; border-radius: 8px; background: #f8fafc;
  border: 1px solid var(--border); flex-shrink: 0; display: grid; place-items: center; overflow: hidden;
}
.p-mech-enemy canvas { width: 36px; height: 36px; }

.p-reward-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--gold); font-weight: 600;
}

.play-cta {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  font-family: var(--font-arcade); font-size: 10.5px; text-align: center;
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.p1 .play-cta { background: var(--p1); color: #04151f; }
.p2 .play-cta { background: var(--p2); color: #fff; }

.vs-col {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 0 4px;
}
.vs-coin { width: 64px; height: 64px; filter: drop-shadow(0 4px 12px rgba(251, 191, 36, 0.45)); }
.vs-label { font-family: var(--font-arcade); font-size: 10px; color: var(--gold); }

.controls-bar {
  padding: 11px 18px; background: var(--surface-2); border-top: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.touch-pad { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pad-btn {
  min-width: 52px; min-height: 44px; padding: 0 14px;
  border-radius: 8px; background: var(--surface-3); border: 2px solid var(--border);
  font-family: var(--font-arcade); font-size: 10.5px; color: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.pad-btn:active, .pad-btn.pressed { border-color: var(--gold); background: #2d3a59; transform: translateY(1px); }
.pad-btn.jump { border-color: var(--p1); color: var(--p1); }
.pad-btn.fire { border-color: var(--p2); color: #ff8e75; }

.hint-keys { font-size: 12px; color: var(--muted); }
.hint-keys kbd {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; font-size: 11px; color: var(--ink);
}

.modal-card {
  background: var(--surface); border: 2px solid var(--gold);
  border-radius: 16px; padding: 22px; max-width: 650px; width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.78);
}
.modal-kicker { font-family: var(--font-arcade); font-size: 11px; color: var(--ok); margin-bottom: 8px; }
.modal-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.modal-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; font-size: 12px; }
.modal-stats span {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px; color: var(--ink);
}

@media (max-width: 880px) {
  .select-grid { grid-template-columns: 1fr; }
  .vs-col { flex-direction: row; padding: 2px 0; }
  .p-hero-row { grid-template-columns: 78px 74px 1fr; }
  .portrait-frame { width: 78px; height: 78px; }
  .sprite-stage { width: 74px; height: 78px; }
}
