/* Wulin Saga — character select / create screen (js/ui/charselect.js). Owned by core-client. */

.screen-charselect {
  background:
    radial-gradient(ellipse at 50% 55%, rgba(12, 5, 6, 0.15) 0%, rgba(12, 5, 6, 0.55) 70%, rgba(12, 5, 6, 0.8) 100%),
    linear-gradient(180deg, rgba(12, 5, 6, 0.65) 0%, rgba(12, 5, 6, 0) 18%, rgba(12, 5, 6, 0) 70%, rgba(12, 5, 6, 0.7) 100%);
  animation: fade-in 0.4s ease-out;
}

/* --- Header ----------------------------------------------------------------------------------- */
.cs-header {
  position: absolute; left: 0; right: 0; top: 0; height: 64px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(20, 9, 8, 0.85), rgba(20, 9, 8, 0));
}
.cs-brand {
  font-size: 18px; font-weight: 700; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff3c4, #e8c46a 55%, #a8782a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 0 #3a0c06);
}
.cs-title {
  display: flex; align-items: center; gap: 14px;
  font-size: 26px; font-weight: 600; color: var(--c-gold); letter-spacing: 1px;
  text-shadow: 0 2px 0 #3a0c06, 0 0 18px rgba(232, 196, 106, 0.3);
}
.cs-title::before, .cs-title::after {
  content: ''; width: 70px; height: 9px;
  background:
    radial-gradient(circle, var(--c-gold) 0 2.4px, transparent 3px) right center / 9px 9px no-repeat,
    linear-gradient(90deg, transparent, var(--c-gold)) left center / calc(100% - 10px) 1px no-repeat;
}
.cs-title::after { transform: scaleX(-1); }
.cs-account { justify-self: end; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.cs-account-name { color: var(--c-gold-light); font-weight: 500; }

/* --- Views ------------------------------------------------------------------------------------ */
.cs-view {
  position: absolute; left: 24px; right: 24px; top: 76px; bottom: 26px;
  display: grid; gap: 18px 22px;
  grid-template-rows: minmax(0, 1fr) auto;
}
.cs-list-view { grid-template-columns: minmax(300px, 370px) minmax(0, 1fr); }
.cs-create-view { grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(330px, 390px); }
.cs-list-view .cs-actions, .cs-create-view .cs-actions { grid-column: 1 / -1; }
/* Panels use their whole grid cell (down to the action buttons); the body scrolls inside when needed. */
.cs-view > .win.cs-panel { position: relative; min-height: 0; max-height: 100%; align-self: start; }
.cs-view > .win.cs-panel > .win-body { max-height: none; }

/* --- Character list --------------------------------------------------------------------------- */
.cs-char-list { display: flex; flex-direction: column; gap: 8px; }
.char-card {
  --cls-color: #e8c46a;
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 10px; min-height: 86px;
  background: linear-gradient(90deg, rgba(40, 24, 16, 0.9), rgba(24, 14, 9, 0.85));
  border: 1px solid #5c3e23; border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.06), 0 2px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s, background 0.15s;
}
.char-card::before {
  content: ''; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px;
  background: var(--cls-color); opacity: 0.55; transition: opacity 0.15s, top 0.15s, bottom 0.15s;
}
.char-card:hover { border-color: var(--c-gold-dark); transform: translateX(2px); box-shadow: 0 0 12px rgba(232, 196, 106, 0.15), 0 2px 6px rgba(0, 0, 0, 0.45); }
.char-card:focus-visible { border-color: var(--c-gold); }
.char-card.selected {
  border-color: var(--c-gold);
  background:
    radial-gradient(120% 140% at 0% 50%, rgba(179, 38, 30, 0.45), transparent 70%),
    linear-gradient(90deg, rgba(70, 22, 14, 0.95), rgba(30, 14, 9, 0.9));
  box-shadow: 0 0 0 1px rgba(232, 196, 106, 0.35), 0 0 18px rgba(232, 196, 106, 0.22), 0 4px 10px rgba(0, 0, 0, 0.5);
}
.char-card.selected::before { opacity: 1; top: 4px; bottom: 4px; }
.cs-portrait-frame {
  flex: none; width: 68px; height: 68px; padding: 2px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, #8a5a18, #fff0b8, #c8952e, #6a4210, #e8c46a, #8a5a18);
  box-shadow: 0 0 0 1px #000, 0 3px 8px rgba(0, 0, 0, 0.6);
}
.cs-portrait { display: block; width: 64px; height: 64px; border-radius: 50%; background: #1a0f0a; }
.cs-card-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cs-card-name { font-size: 17px; font-weight: 600; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-card.selected .cs-card-name { color: var(--c-gold-light); }
.cs-card-line { display: flex; gap: 8px; font-size: 13px; }
.cs-card-level { color: var(--c-gold); font-weight: 600; }
.cs-card-class { color: var(--cls-color); filter: brightness(1.35); }
.cs-card-job { font-size: 12px; }
.cs-card-map { font-size: 11px; color: var(--c-muted); }
.char-slot-empty {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px;
  font-size: 13px; color: rgba(168, 151, 122, 0.8);
  border: 1px dashed rgba(139, 90, 43, 0.6); border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.char-slot-empty:hover { color: var(--c-gold); border-color: var(--c-gold-dark); background: rgba(232, 196, 106, 0.05); }
.cs-plus {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; border: 1px solid currentColor; border-radius: 50%;
}
.cs-list-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(232, 196, 106, 0.12); }
.cs-count { color: var(--c-gold); font-weight: 600; }

/* --- Stage (animated preview) ----------------------------------------------------------------- */
.cs-stage { position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.cs-preview-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cs-stage-info {
  position: relative; z-index: 1; text-align: center; padding: 10px 26px 4px;
  background: radial-gradient(ellipse at 50% 60%, rgba(12, 5, 6, 0.65), rgba(12, 5, 6, 0) 72%);
}
.cs-stage-name {
  font-size: 30px; font-weight: 700; letter-spacing: 1px; color: var(--c-gold-light);
  text-shadow: 0 2px 0 #3a0c06, 0 0 16px rgba(232, 196, 106, 0.35);
}
.cs-stage-class { font-size: 15px; color: var(--c-text); }
.cs-stage-sub { font-size: 13px; display: flex; gap: 6px; justify-content: center; }
.cs-stage-job { color: var(--c-gold); }
.cs-dot { color: var(--c-muted); }
.cs-stage-map { font-size: 12px; color: var(--c-muted); }
.cs-stage-empty {
  position: absolute; top: 40%; left: 0; right: 0; text-align: center;
  font-size: 18px; color: var(--c-text); text-shadow: 0 2px 6px #000;
}
.cs-turns {
  position: absolute; left: 0; right: 0; bottom: 12px; z-index: 1;
  display: flex; justify-content: center; gap: min(38vw, 260px);
}
.cs-turn { width: 38px; height: 38px; border-radius: 50%; font-size: 13px; }

/* --- Actions ---------------------------------------------------------------------------------- */
.cs-actions { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.cs-btn-enter { min-width: 240px; font-size: 20px; letter-spacing: 1px; }
.cs-actions .btn:not(.btn-lg) { min-height: 38px; }

/* --- Create view: classes --------------------------------------------------------------------- */
.cs-class-list { display: flex; flex-direction: column; gap: 8px; }
.class-opt {
  --cls-color: #e8c46a;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  background: linear-gradient(90deg, rgba(40, 24, 16, 0.9), rgba(24, 14, 9, 0.85));
  border: 1px solid #5c3e23; border-radius: 4px;
  cursor: pointer; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.class-opt:hover { border-color: var(--c-gold-dark); transform: translateX(2px); }
.class-opt.selected {
  border-color: var(--c-gold);
  background:
    radial-gradient(120% 160% at 0% 50%, rgba(179, 38, 30, 0.42), transparent 72%),
    linear-gradient(90deg, rgba(70, 22, 14, 0.95), rgba(30, 14, 9, 0.9));
  box-shadow: 0 0 0 1px rgba(232, 196, 106, 0.3), 0 0 16px rgba(232, 196, 106, 0.2);
}
.cs-class-emblem {
  flex: none; width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 35%, #3a2416, #120a06 75%);
  border: 2px solid var(--cls-color);
  box-shadow: 0 0 0 1px #000, inset 0 0 10px rgba(0, 0, 0, 0.8);
  font-size: 20px; font-weight: 700; color: var(--cls-color);
}
.class-opt.selected .cs-class-emblem { box-shadow: 0 0 0 1px #000, 0 0 12px var(--cls-color), inset 0 0 10px rgba(0, 0, 0, 0.8); }
.cs-class-emblem img { width: 36px; height: 36px; }
.cs-class-name { font-size: 16px; font-weight: 600; }
.class-opt.selected .cs-class-name { color: var(--c-gold-light); }
.cs-class-role { font-size: 12px; color: var(--c-muted); }

/* --- Create view: details --------------------------------------------------------------------- */
.cs-detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cs-detail-name { font-size: 24px; font-weight: 700; filter: brightness(1.3); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.cs-detail-role {
  padding: 1px 10px; font-size: 12px; color: var(--c-gold-light);
  background: rgba(179, 38, 30, 0.35); border: 1px solid var(--c-gold-dark); border-radius: 10px;
}
.cs-detail-primary { font-size: 13px; color: var(--c-gold); margin-top: 2px; }
.cs-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.cs-tag { padding: 0 8px; font-size: 11px; line-height: 19px; color: var(--c-text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(232, 196, 106, 0.25); border-radius: 3px; }
.cs-detail-desc { font-size: 13px; color: rgba(243, 230, 200, 0.85); line-height: 1.55; }
.cs-stats { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.cs-stat { display: grid; grid-template-columns: 60px 1fr 24px; align-items: center; gap: 8px; font-size: 12px; }
.cs-stat-name { color: var(--c-muted); }
.cs-stat.primary .cs-stat-name { color: var(--c-gold); font-weight: 600; }
.cs-stat.primary .bar { box-shadow: 0 0 0 1px var(--c-gold-dark), 0 0 6px rgba(232, 196, 106, 0.35); }
.cs-stat-value { text-align: right; font-weight: 600; }
.cs-detail-meta { margin-top: 8px; font-size: 12px; color: var(--c-muted); }
.cs-look-row { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; margin: 5px 0; }
/* 'สุ่มรูปลักษณ์' sits at the end of the section heading (saves a row at 720p). */
.cs-look-title .btn { order: 1; flex: none; min-height: 24px; padding: 1px 10px; font-size: 12px; }
.cs-look-label { font-size: 12px; color: var(--c-muted); }
.cs-choices { display: flex; flex-wrap: wrap; gap: 5px; }
.cs-choice {
  min-height: 26px; padding: 2px 10px;
  font: inherit; font-size: 12px; color: var(--c-text);
  background: linear-gradient(180deg, #33201a, #1d110b);
  border: 1px solid #5c3e23; border-radius: 3px; cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.cs-choice:hover { border-color: var(--c-gold-dark); }
.cs-choice.active { color: var(--c-gold-light); border-color: var(--c-gold); background: linear-gradient(180deg, #74201a, #3e0e09); box-shadow: 0 0 8px rgba(232, 196, 106, 0.25); }
.cs-choice.cs-swatch {
  width: 24px; min-height: 24px; height: 24px; padding: 0; border-radius: 50%;
  background: var(--sw); border: 2px solid #2a1a10; box-shadow: 0 0 0 1px #5c3e23;
}
.cs-choice.cs-swatch.active { border-color: #fff4d0; box-shadow: 0 0 0 2px var(--c-gold), 0 0 8px rgba(232, 196, 106, 0.6); }
.cs-name-row { display: flex; gap: 8px; }
.cs-name-row input { flex: 1 1 auto; min-width: 0; font-size: 15px; }
.cs-name-msg { min-height: 18px; margin-top: 4px; font-size: 12px; }
.cs-name-msg.ok { color: var(--c-good); }
.cs-name-msg.bad { color: var(--c-bad); }

/* --- Messages & busy overlay ------------------------------------------------------------------ */
.cs-msg {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%);
  max-width: min(640px, 90vw); padding: 6px 18px;
  font-size: 14px; text-align: center; color: #ff9a8a;
  background: rgba(20, 8, 6, 0.85); border: 1px solid rgba(179, 38, 30, 0.6); border-radius: 3px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.cs-msg.show { opacity: 1; }
.cs-msg.info { color: var(--c-gold); border-color: var(--c-gold-dark); }
.cs-busy {
  position: absolute; inset: 0; z-index: 5;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(10, 4, 3, 0.55);
}
.screen-charselect.busy .cs-busy { display: flex; animation: fade-in 0.2s ease-out; }
.cs-busy-text { font-size: 18px; color: var(--c-gold-light); text-shadow: 0 2px 6px #000; }

/* --- Responsive ------------------------------------------------------------------------------- */
/* Short screens (720p): tighter spacing so the whole detail panel — class name and role at the top,
   name field at the bottom — fits without scrolling. */
@media (max-height: 820px) {
  .cs-detail-panel .win-body { padding-top: 10px; padding-bottom: 8px; }
  .cs-detail-panel .cs-tags { margin: 4px 0; }
  .cs-detail-panel .cs-stats { gap: 4px; margin-top: 6px; }
  .cs-detail-panel .cs-detail-meta { margin-top: 5px; }
  .cs-detail-panel .section-title { margin: 7px 0 4px; }
  .cs-detail-panel .cs-look-row { margin: 3px 0; }
  .cs-detail-panel .cs-name-msg { min-height: 16px; margin-top: 2px; }
}
@media (max-width: 1080px) {
  .cs-create-view { grid-template-columns: minmax(200px, 240px) minmax(0, 1fr) minmax(300px, 340px); }
  .cs-brand { display: none; }
  .cs-header { grid-template-columns: auto 1fr; }
  .cs-title { justify-self: start; }
}
@media (max-width: 860px) {
  .cs-view { top: 70px; bottom: 16px; left: 12px; right: 12px; overflow-y: auto; display: flex; flex-direction: column; }
  .cs-stage { min-height: 280px; flex: none; }
  .cs-view > .win.cs-panel { max-height: none; }
  .cs-title { font-size: 20px; }
  .cs-title::before, .cs-title::after { width: 30px; }
  .cs-msg { bottom: 20px; }
}
