* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #1e1e24;
  color: #eee;
}

.lobby-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.lobby-header h1 {
  font-size: 22px;
  margin: 0;
}

.btn {
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  background: #33333d;
  color: #eee;
  font-size: 14px;
  cursor: pointer;
}

.btn.primary {
  background: #4c8dff;
  color: #fff;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.look-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.room-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-item {
  background: #2a2a33;
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

.room-item:active {
  background: #35353f;
}

.room-item.playing {
  background: #232328;
  color: #999;
}

.room-info { display: flex; flex-direction: column; gap: 4px; }

.room-name { font-size: 16px; font-weight: 600; }
.room-item.playing .room-name { color: #aaa; }

.room-sub { font-size: 12px; color: #888; }

.room-status-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #3a3a44;
  color: #ccc;
}
.room-item.playing .room-status-badge { background: #3a3a3a; color: #888; }

.empty-msg {
  text-align: center;
  color: #777;
  margin-top: 60px;
  font-size: 14px;
}

/* 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: #2a2a33;
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal label {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

.modal input, .modal select {
  background: #1e1e24;
  border: 1px solid #444;
  color: #eee;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.error-msg {
  color: #ff6b6b;
  font-size: 12px;
  min-height: 16px;
  margin: 4px 0 0;
}

/* ===================== 방(게임) 화면 ===================== */

.waiting-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
}

.room-title { font-size: 20px; margin: 0 0 8px; }
.room-rule-summary { font-size: 13px; color: #999; margin: 0 0 24px; }
.waiting-status { font-size: 14px; color: #ccc; margin-bottom: 24px; }

.ready-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ready-label { font-size: 13px; color: #888; }

.game-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 12px 60px;
}

.game-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
}

.left-col {
  display: flex;
  flex-direction: column;
  padding-top: 40px;
}

.resign-btn {
  background: #4a2a2a;
  color: #ffb3b3;
}

.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.player-row {
  width: 480px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
}

.player-name {
  font-size: 15px;
  font-weight: 600;
  color: #ccc;
  transform-origin: center;
  transition: transform 0.2s ease, color 0.2s ease;
}

.player-name.turn-active {
  transform: scale(1.25);
  color: #fff;
}

.player-time { font-size: 13px; color: #888; }

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 60px);
  grid-template-rows: repeat(8, 60px);
  border: 4px solid #363431;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.cell {
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 38px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.white-cell { background-color: #ebecd0; color: #000; }
.black-cell { background-color: #739552; color: #000; }

.possible-move::after {
  content: '';
  width: 18px;
  height: 18px;
  background-color: rgba(20, 85, 30, 0.5);
  border-radius: 50%;
  position: absolute;
}

.possible-capture { background-color: #e57373 !important; }
.selected { background-color: #bbc742 !important; }
.last-move { box-shadow: inset 0 0 0 4px rgba(76, 141, 255, 0.75); }

/* AI(스톡피시) 힌트 — 나에게만 보이는 표시 */
.ai-suggest-piece { box-shadow: inset 0 0 0 999px rgba(64, 132, 255, 0.35); }
.possible-move-ai::after {
  content: '';
  width: 18px;
  height: 18px;
  background-color: rgba(220, 60, 60, 0.55);
  border-radius: 50%;
  position: absolute;
}

.game-status { font-size: 13px; color: #999; margin-top: 4px; }

.right-col {
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-panel {
  height: 480px;
  aspect-ratio: 1 / 3;
  overflow-y: auto;
  background: #262421;
  border: 1px solid #363431;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-btn {
  background: #312e2b;
  color: #e0e0e0;
  border: 1px solid #403d39;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}

.log-btn.active { background: #bbc742; color: #000; border-color: #bbc742; font-weight: bold; }

.history-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.nav-btn { flex: 1; }

.full-width-btn { width: 100%; }

/* ===================== 관리자 기능 ===================== */

.admin-corner {
  position: fixed;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  z-index: 999;
  cursor: default;
  background: transparent;
}

.room-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-delete-btn {
  background: #4a2a2a;
  color: #ff8a8a;
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 13px;
  cursor: pointer;
}

.admin-delete-btn {
  margin-top: 8px;
  background: #4a2a2a;
  color: #ff8a8a;
  font-size: 12px;
}

/* ===================== 이전 게임 돌아가기 배너 ===================== */

.resume-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: #24283a;
  border-bottom: 1px solid #3a3f5c;
  font-size: 13px;
  color: #ccc;
}

.resume-banner span {
  margin-right: 4px;
}

.resume-banner .btn {
  padding: 7px 14px;
  font-size: 13px;
}
