/* ==========================================================================
   CHARACTER SELECT — one page, no vertical scroll, horizontal carousel
   ========================================================================== */
#screen-select { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
.select-panel {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 20px);
  max-height: 760px;
  max-width: 520px;
  padding: 14px 12px;
  overflow: hidden;
}
.select-panel h2 { margin: 0 0 4px; }
.select-panel .muted { margin: 0 0 8px; font-size: 8px; }
.select-panel .btn-row { margin-top: 10px; flex-wrap: nowrap; }
.select-panel .btn-row .btn { flex: 1; padding: 12px 8px; }
.select-panel .btn-row #btn-select-back { flex: 0 0 auto; }

.carousel { position: relative; flex: 1; min-height: 0; display: flex; align-items: stretch; }
.char-grid {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 4px 2px 8px;
}
.char-grid::-webkit-scrollbar { display: none; }

.car-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  width: 34px;
  height: 52px;
  font-size: 14px;
  background: var(--lamp);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.car-nav.prev { left: -6px; }
.car-nav.next { right: -6px; }
.car-nav:active { transform: translate(2px, calc(-50% + 2px)); box-shadow: 1px 1px 0 var(--ink); }

.char-dots { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.char-dots .dot { width: 12px; height: 12px; padding: 0; background: var(--night-800); border: 2px solid var(--ink); }
.char-dots .dot.on { background: var(--lamp); }

/* one card fills the carousel width */
.card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  background: var(--night-800);
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 12px 40px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.5;
}
.card::-webkit-scrollbar { display: none; }
.card.selected { border-color: var(--lamp); }

.card-head { display: flex; gap: 12px; align-items: center; }
.card-portrait {
  position: relative;
  flex: none;
  background: repeating-linear-gradient(45deg, #1d1650 0 6px, #221a5e 6px 12px);
  border: 3px solid var(--ink);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
}
.card.selected .card-portrait canvas { animation: hop 0.6s steps(2) infinite; }
.card-lvl { position: absolute; left: 3px; top: 3px; background: var(--cyan); color: var(--ink); font-size: 7px; padding: 2px 4px; border: 2px solid var(--ink); }
.card-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card h3 { margin: 0; font-size: 12px; color: var(--lamp); }
.card-title { margin: 0; font-size: 8px; color: var(--cyan); }
.card-rank { margin: 0; font-size: 7px; color: var(--lamp); }
.xpbar { height: 6px; background: var(--ink); border: 1px solid var(--night-500); }
.xpbar i { display: block; height: 100%; background: var(--cyan); }
.xptext { margin: 0; font-size: 6px; color: var(--cyan); }

.card-stats { display: flex; flex-direction: column; gap: 5px; }
.stat { display: flex; align-items: center; justify-content: space-between; font-size: 7px; color: var(--muted); }
.stat b { display: flex; gap: 3px; }
.stat i { width: 12px; height: 9px; background: var(--ink); border: 1px solid var(--night-500); }
.stat i.on { background: var(--lamp); }

.perk, .active-skill { font-size: 7px; line-height: 1.7; margin: 0; color: var(--paper); }
.perk b { color: var(--green); font-weight: normal; }
.active-skill b { color: #8fb2ff; font-weight: normal; }
.skills { margin: 0; font-size: 6px; line-height: 1.8; color: var(--green); }
.skills span { color: var(--muted); }
.quote { font-size: 7px; line-height: 1.7; margin: 0; color: var(--muted); font-style: italic; }
.card-foot { margin: auto 0 0; display: flex; justify-content: space-between; gap: 6px; font-size: 7px; color: var(--paper); }
.best { color: var(--pink); }

/* tall screens: big hero portrait on top */
@media (min-height: 720px) {
  .card { justify-content: flex-start; gap: 12px; }
  .card-head { flex-direction: column; text-align: center; }
  .card-portrait { padding: 14px 28px; }
  .card-portrait canvas { width: 92px !important; height: 132px !important; }
  .card-id { align-items: center; width: 100%; }
  .card-id .xpbar { width: 80%; }
  .card h3 { font-size: 15px; }
}

/* short screens (small phones, landscape): drop the optional lines */
@media (max-height: 640px) {
  .select-panel .muted, .quote { display: none; }
  .card { gap: 6px; padding: 8px 40px; }
}
@media (max-height: 460px) {
  #screen-select { padding: 6px; }
  .select-panel { height: calc(100dvh - 12px); padding: 8px 10px; }
  .select-panel h2 { font-size: 12px; }
  .skills, .char-dots { display: none; }
  .card { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-content: start; }
  .card-head { grid-row: span 3; flex-direction: column; align-items: flex-start; }
  .card-portrait canvas { width: 40px !important; height: 58px !important; }
  .card-foot { grid-column: 1 / -1; }
  .select-panel .btn-row { margin-top: 6px; }
  .select-panel .btn-row .btn { padding: 8px; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
