.select-scene { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.select-main {
  flex: 1; position: relative; display: flex; gap: 16px; padding: 14px;
  background:
    linear-gradient(rgba(0,255,255,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,255,0.10) 1px, transparent 1px),
    linear-gradient(var(--bg1), var(--bg2));
  background-size: 40px 40px, 40px 40px, auto;
  min-height: 0;
}

.preview {
  width: 280px;
  background: linear-gradient(#09111f, #001122);
  border: 5px solid var(--cyan);
  box-shadow: 0 0 22px var(--cyan);
  padding: 12px;
  display: flex; flex-direction: column; align-items: center;
  z-index: 2; position: relative;
}

.preview.p2 { border-color: var(--magenta); box-shadow: 0 0 22px var(--magenta); }

.player-tag {
  align-self: flex-start; background: #000; color: var(--green);
  border: 2px solid var(--green); padding: 4px 8px;
  font-size: 9px; margin-bottom: 8px;
  box-shadow: 0 0 6px var(--green);
}

.preview.p2 .player-tag {
  color: var(--magenta); border-color: var(--magenta);
  box-shadow: 0 0 6px var(--magenta);
}

.preview-name {
  min-height: 44px; width: 100%;
  display: flex; align-items: center; justify-content: center;
  text-align: center; line-height: 1.35; font-size: 12px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 #a00000, 4px 4px 0 #000;
  margin-bottom: 10px;
}

.portrait-frame {
  width: 220px; height: 220px; padding: 6px;
  background: linear-gradient(135deg, #ffdd00 0%, #ff6a00 25%, #ff3030 60%, #6d0000 100%);
  border: 3px solid rgba(255,255,255,0.25);
  box-shadow: 0 0 0 3px #000, 0 0 18px #ff3030, inset 0 0 0 3px rgba(255,255,255,0.18);
  position: relative; margin-bottom: 10px;
}

.preview.p2 .portrait-frame {
  background: linear-gradient(135deg, #ff00ff 0%, #aa00ff 30%, #5500aa 70%, #220033 100%);
  box-shadow: 0 0 0 3px #000, 0 0 18px var(--magenta), inset 0 0 0 3px rgba(255,255,255,0.18);
}

.portrait-inner {
  width: 100%; height: 100%;
  background: radial-gradient(circle at center, #1f324b 0%, #0e1621 70%, #070b10 100%);
  border: 3px solid #000;
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

.preview-stage {
  width: 100%; height: 100%; position: relative;
  display: flex; align-items: center; justify-content: center;
}

.preview-static {
  width: 100%; height: 100%;
  object-fit: contain; image-rendering: pixelated;
}

.preview-desc {
  width: 100%; min-height: 36px; text-align: center;
  font-size: 8px; line-height: 1.5; color: #fff;
  text-shadow: 2px 2px 0 #000; margin-bottom: 8px; padding: 0 4px;
}

.stat-box {
  background: #000; border: 2px solid var(--cyan);
  padding: 5px; font-size: 8px; color: var(--yellow);
  text-align: center; width: 100%; margin-bottom: 6px;
}

.preview.p2 .stat-box { border-color: var(--magenta); }

.preview-ready {
  display: none; font-size: 18px; color: var(--green);
  text-shadow: 2px 2px 0 #000; animation: blink 1s infinite;
}

.preview-ready.show { display: block; }

.grid-wrap { flex: 1; display: flex; align-items: stretch; z-index: 2; min-width: 0; }

.char-grid {
  flex: 1; display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
}

.char-card {
  position: relative;
  background: linear-gradient(#1a2b3d, #102030);
  border: 3px solid var(--yellow); padding: 4px; cursor: pointer;
  overflow: hidden;
  transition: transform 0.08s, box-shadow 0.08s, border-color 0.08s;
  user-select: none; display: flex; flex-direction: column;
}

.char-card:hover { transform: scale(1.04); border-color: var(--red); }

.char-card.p1-selected { border-color: var(--green) !important; box-shadow: 0 0 22px var(--green); }
.char-card.p2-selected { border-color: var(--magenta) !important; box-shadow: 0 0 22px var(--magenta); }

.char-card.p1-selected.p2-selected {
  box-shadow: 0 0 22px var(--green), 0 0 32px var(--magenta);
}

.char-portrait {
  width: 100%; flex: 1; border: 2px solid #000;
  background: #223344; margin-bottom: 4px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}

.char-portrait img {
  width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated;
}

.char-name {
  font-size: 7px; text-align: center; line-height: 1.3;
  color: var(--yellow); text-shadow: 1px 1px 0 #000;
  padding: 2px 0; min-height: 18px;
  display: flex; align-items: center; justify-content: center;
}

.select-cursor { position: absolute; inset: -2px; pointer-events: none; display: none; z-index: 3; }

.char-card.p1-selected .p1-cursor { display: block; animation: cursorPulse 0.58s infinite alternate; }
.char-card.p2-selected .p2-cursor { display: block; animation: cursorPulse 0.58s infinite alternate; }

.corner { position: absolute; width: 16px; height: 16px; }

.p1-cursor .corner { border: 3px solid var(--green); box-shadow: 0 0 6px var(--green); }
.p2-cursor .corner { border: 3px solid var(--magenta); box-shadow: 0 0 6px var(--magenta); }

.corner.tl { top: 1px; left: 1px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 1px; right: 1px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 1px; left: 1px; border-right: 0; border-top: 0; }
.corner.br { bottom: 1px; right: 1px; border-left: 0; border-top: 0; }

@keyframes cursorPulse {
  from { transform: scale(1); filter: brightness(1); }
  to { transform: scale(1.03); filter: brightness(1.35); }
}

.confirm-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.78);
  display: none; align-items: center; justify-content: center;
  z-index: 50;
}

.confirm-overlay.show { display: flex; }

.confirm-box {
  width: min(90vw, 700px);
  background: linear-gradient(#111, #000);
  border: 5px solid var(--red);
  box-shadow: 0 0 28px var(--red);
  padding: 22px 18px; text-align: center;
}

.confirm-box h2 {
  font-size: 18px; color: var(--yellow);
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 14px; line-height: 1.4;
}

.confirm-box p { font-size: 10px; line-height: 1.8; color: #fff; margin-bottom: 4px; }

.confirm-box .mini-tip {
  color: var(--green); margin-top: 12px;
  font-size: 9px; animation: blink 1s infinite;
}

@media (max-width: 900px) {
  .preview { width: 200px; }
  .portrait-frame { width: 160px; height: 160px; }
  .preview-name { font-size: 10px; }
  .char-grid { gap: 6px; }
}

@media (max-width: 700px) {
  /* Padding bottom to clear touch controls */
  .select-scene { padding-bottom: 200px; }
  .select-main { flex-direction: column; padding: 8px; gap: 8px; }
  .preview { width: 100%; flex-direction: row; align-items: center; padding: 6px; }
  .preview .player-tag { align-self: center; margin: 0 8px 0 0; }
  .preview-name { display: none; }
  .portrait-frame { width: 70px; height: 70px; padding: 3px; flex-shrink: 0; }
  .preview-desc { display: none; }
  .stat-box { font-size: 7px; padding: 3px; }
  .preview-ready { font-size: 12px; margin-left: auto; }
  .char-grid { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(3, 1fr); }
  .char-name { font-size: 6px; }
}

@media (max-width: 480px) {
  .select-scene { padding-bottom: 190px; }
  .portrait-frame { width: 58px; height: 58px; }
  .char-card { padding: 3px; }
  .char-name { font-size: 5px; min-height: 14px; }
}
