/* 샤봇 체스 */
.stage { background: radial-gradient(120% 80% at 50% 0%, #34307a 0%, #1c2140 62%, #141833 100%); padding: 6px; overscroll-behavior: none; }
.cs { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; user-select: none; -webkit-user-select: none; }
.cs-main { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cs-side { width: var(--bw, 360px); max-width: 100%; display: flex; flex-direction: column; gap: 6px; }
.cs-board { line-height: 0; position: relative; }

.cs-board canvas {
  display: block; border-radius: 10px; touch-action: none; cursor: pointer; -webkit-touch-callout: none;
  box-shadow: 0 0 0 3px #2d3388, 0 0 0 5px rgba(120, 132, 255, 0.55), 0 0 30px rgba(100, 112, 255, 0.45), 0 18px 40px rgba(0, 0, 0, 0.5);
}
.cs-board canvas.cs-shake { animation: cs-shake 0.3s ease-out; }
@keyframes cs-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, 1px); }
}

/* 선수 칸 */
.cs-pl { width: var(--bw, 360px); max-width: 100%; height: 40px; display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 4px; border-radius: 12px; color: #fff; background: rgba(255, 255, 255, 0.06); border: 2px solid rgba(255, 255, 255, 0.05); transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; }
.cs-pl.on { border-color: #ffc83d; background: rgba(255, 200, 61, 0.1); box-shadow: 0 0 14px rgba(255, 200, 61, 0.25); }
.cs-pl.won { border-color: #3ee0b5; background: rgba(62, 224, 181, 0.12); box-shadow: 0 0 16px rgba(62, 224, 181, 0.35); }
.cs-av { flex: none; width: 34px; height: 30px; display: grid; place-items: center; }
.cs-av .cs-bot { width: 34px; height: 29px; }
.cs-pl.think .cs-bot { animation: cs-bob 0.9s ease-in-out infinite; }
@keyframes cs-bob { 50% { transform: translateY(-3px) rotate(-4deg); } }
.cs-avp { width: 32px; height: 32px; }
.cs-who { flex: none; min-width: 0; max-width: 40%; display: flex; flex-direction: column; line-height: 1.15; }
.cs-who b { font-family: var(--title); font-weight: 400; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-who small { font-size: 11px; color: #a9afd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-who small:empty { display: none; }
.cs-cap { flex: 1; min-width: 0; display: flex; align-items: center; overflow: hidden; height: 24px; }
.cs-pi { display: block; width: 22px; height: 22px; margin-right: -7px; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)); }
.cs-adv { flex: none; font-style: normal; font-weight: 800; font-size: 14px; color: #3ee0b5; }

/* 상태 줄 */
.cs-status { text-align: center; font-weight: 700; font-size: 15px; color: #e6e8ff; min-height: 22px; line-height: 22px; padding: 0 6px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-status.check { color: #ff8f8f; }
.cs-status.coach { color: #1c2140; background: #3ee0b5; white-space: normal; line-height: 1.3; padding: 4px 10px; }
.cs-status.think::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: cs-dots 1s steps(4) infinite; }
@keyframes cs-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* 기보: 세로 화면은 한 줄로 옆으로 흐름 */
.cs-log { display: flex; align-items: center; gap: 6px; min-width: 0; height: 30px; padding: 0 4px 0 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.2); }
.cs-log-h { flex: none; font-size: 11px; font-weight: 800; color: #8d93c9; letter-spacing: 0.04em; }
.cs-moves { flex: 1; min-width: 0; display: flex; gap: 10px; margin: 0; padding: 0; list-style: none; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; font-size: 14px; color: #d6d9f7; }
.cs-moves::-webkit-scrollbar { display: none; }
.cs-moves li { flex: none; display: flex; gap: 5px; align-items: baseline; }
.cs-moves li i { font-style: normal; color: #7f86c4; font-size: 12px; }
.cs-moves li span { font-weight: 700; }
.cs-moves li span.now { color: #ffc83d; }
.cs-moves li.empty { color: #7f86c4; font-size: 13px; }

/* 단추 */
.cs-ctrl { display: flex; gap: 6px; }
.cs-btn { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 9px 4px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.08); color: #fff; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.cs-btn span { overflow: hidden; text-overflow: ellipsis; }
.cs-btn i { font-style: normal; font-size: 16px; line-height: 1; color: #ffc83d; }
.cs-btn:hover { background: rgba(100, 112, 255, 0.3); border-color: rgba(100, 112, 255, 0.7); }
.cs-btn:active { transform: scale(0.97); }
.cs-btn:disabled { opacity: 0.38; cursor: default; background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); transform: none; }

/* 알림 */
.cs-toast { position: absolute; left: 50%; top: 50%; z-index: 5; transform: translate(-50%, -50%); line-height: 1.3; text-align: center; pointer-events: none; min-width: 58%; max-width: 92%; padding: 12px 18px; border-radius: 18px; background: rgba(16, 18, 46, 0.93); border: 2px solid #ffc83d; box-shadow: 0 0 24px rgba(255, 200, 61, 0.35), 0 14px 30px rgba(0, 0, 0, 0.5); color: #fff; }
.cs-toast[hidden] { display: none; }
.cs-toast b { display: block; font-family: var(--title); font-weight: 400; font-size: 24px; color: #ffd65e; }
.cs-toast span { display: block; font-size: 15px; font-weight: 700; color: #e6e8ff; margin-top: 2px; }
.cs-toast.show { animation: cs-toast 1.8s ease-out forwards; }
@keyframes cs-toast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  20% { transform: translate(-50%, -50%) scale(1); }
  84% { opacity: 1; }
  100% { opacity: 0; }
}

/* 승격 고르기 */
.cs-promo { position: absolute; inset: 0; z-index: 6; border-radius: 10px; background: rgba(10, 12, 40, 0.55); }
.cs-promo[hidden] { display: none; }
.cs-promo-box { position: absolute; display: flex; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 0 0 3px #ffc83d, 0 12px 30px rgba(0, 0, 0, 0.55); animation: pop-in 0.18s ease-out; }
.cs-promo-box button { display: grid; place-items: center; padding: 0; border: 0; background: #f1f2ff; cursor: pointer; width: 100%; }
.cs-promo-box button + button { border-top: 1px solid #d6d9f7; }
.cs-promo-box button:hover, .cs-promo-box button:focus-visible { background: #ffe9a8; }
.cs-pp { width: 88%; height: 88%; }

/* 넓은 화면: 판 왼쪽 · 기보와 단추 오른쪽 */
.cs.wide { flex-direction: row; gap: 18px; }
.cs.wide .cs-side { width: 250px; align-self: stretch; justify-content: center; max-height: calc(var(--bw, 400px) + 92px); }
.cs.wide .cs-status { white-space: normal; line-height: 1.3; padding: 8px; background: rgba(0, 0, 0, 0.2); }
.cs.wide .cs-status.coach { background: #3ee0b5; }
.cs.wide .cs-log { flex: 1; min-height: 120px; flex-direction: column; align-items: stretch; height: auto; padding: 8px 6px 8px 10px; }
.cs.wide .cs-moves { flex-direction: column; gap: 2px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
.cs.wide .cs-moves::-webkit-scrollbar { display: block; width: 6px; }
.cs.wide .cs-moves::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 3px; }
.cs.wide .cs-moves li { display: grid; grid-template-columns: 30px 1fr 1fr; gap: 4px; padding: 2px 0; }
.cs.wide .cs-moves li.empty { display: block; }
.cs.wide .cs-ctrl { display: grid; grid-template-columns: 1fr 1fr; }
.cs.wide .cs-btn { padding: 11px 6px; font-size: 15px; }

/* 시작 · 끝 화면 */
.cs-panel h2 { font-size: 32px; margin: 2px 0 4px; }
.cs-panel > p { margin-bottom: 8px; font-size: 15px; }
.cs-mark { display: flex; justify-content: center; align-items: flex-end; gap: 2px; margin-top: 2px; }
.cs-mark .cs-bot { width: 62px; height: 52px; margin-right: 4px; }
.cs-mk { width: 46px; height: 46px; }
.cs-l { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); margin: 6px 2px 2px; }
.cs-panel .seg { margin: 2px 0 6px; }
.cs-panel .seg button { font: inherit; font-size: 14px; font-weight: 700; padding: 8px 3px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; line-height: 1.15; }
.cs-lv { gap: 4px !important; }
.cs-lv button { flex-direction: column; font-size: 12px !important; padding: 6px 2px !important; min-width: 0; word-break: keep-all; }
.cs-lv button b { font-family: var(--title); font-weight: 400; font-size: 18px; line-height: 1; color: var(--main-ink); }
.cs-si { width: 22px; height: 22px; }
.cs-lvd { font-size: 13px; color: var(--ink-2) !important; margin: 0 0 2px !important; min-height: 1.3em; }
.cs-ai[hidden], .cs-pvp[hidden] { display: none; }
.cs-rec { font-size: 13px; color: var(--muted) !important; margin: 0 0 2px !important; }
.cs-panel .big-btn { margin-top: 10px; cursor: pointer; }
.cs-panel .big-btn.b-resume { background: #17b39b; box-shadow: 0 8px 20px rgba(23, 179, 155, 0.35); margin: 4px 0 6px; font-size: 21px; padding: 11px; }
.cs-panel .big-btn[hidden] { display: none; }
.cs-panel .sub-btn { cursor: pointer; font: inherit; font-size: 15px; text-decoration: none; }
.cs-rules { margin-top: 10px; text-align: left; font-size: 14px; color: var(--ink-2); }
.cs-rules summary { cursor: pointer; text-align: center; font-weight: 700; color: var(--main-ink); }
.cs-rules ul { margin: 8px 0 0; font-size: 14px; }
.cs-rules li + li { margin-top: 4px; }
.cs-end-ico { font-size: 46px; line-height: 1; margin-top: 2px; display: flex; justify-content: center; }
.cs-end-ico .cs-bot { width: 74px; height: 62px; }
.cs-endp { width: 64px; height: 64px; }
.end-why { font-weight: 700; color: var(--main-ink) !important; margin-bottom: 4px !important; }
.end-why:empty, .end-msg:empty { display: none; }
.cs-panel .stats { margin: 8px 0 8px; }
.cs-best { font-size: 14px; margin: 0 0 6px !important; }
.cs-best:empty { display: none; }

@media (max-height: 640px) {
  .cs-panel { padding: 16px 18px; }
  .cs-panel h2 { font-size: 26px; }
  .cs-mark { display: none; }
  .cs-end-ico { font-size: 36px; }
}
@media (max-width: 380px) {
  .cs-btn { font-size: 12px; gap: 3px; }
  .cs-btn i { font-size: 14px; }
  .cs-who b { font-size: 15px; }
  .cs-pi { width: 19px; height: 19px; margin-right: -6px; }
  .cs-panel .seg button { font-size: 13px; }
}
.cs-fg { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; margin-right: 1px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }

/* 낮은 가로 화면(폰 가로): 선수 칸도 옆 칸에 */
.cs.short { gap: 12px; }
.cs.short .cs-side { width: 228px; max-height: none; height: 100%; gap: 5px; justify-content: center; }
.cs.short .cs-pl { width: 100%; height: 34px; flex: none; }
.cs.short .cs-who b { font-size: 15px; }
.cs.short .cs-status { padding: 4px 6px; font-size: 13px; }
.cs.short .cs-log { min-height: 40px; padding: 4px 6px; }
.cs.short .cs-log-h { display: none; }
.cs.short .cs-moves { font-size: 13px; }
.cs.short .cs-btn { padding: 7px 4px; font-size: 13px; }

/* 실력 단추 = 숫자 + 별 (이름은 아래 설명 줄에, 언어마다 길이가 달라서) · 색 단추 = 그림 위 글자 아래 */
.cs-panel .seg button { word-break: normal; overflow-wrap: normal; }
.cs-lv button { gap: 1px !important; padding: 6px 2px 5px !important; }
.cs-lv button i { font-style: normal; font-size: 8px; letter-spacing: -1px; color: #ffb800; line-height: 1; }
.cs-lvd b { color: var(--main-ink); }
.cs-col button { flex-direction: column; gap: 2px !important; padding: 6px 3px !important; font-size: 13px !important; line-height: 1.15; }
.cs-col .cs-si { width: 24px; height: 24px; }
.cs-col .cs-dice { font-style: normal; font-size: 19px; line-height: 24px; }
