* { box-sizing: border-box; margin: 0; padding: 0; }

/* body는 .game-shell-body (공유 CSS)에서 100dvh flex column 처리 */
body {
  background: linear-gradient(160deg, #e8f5e9 0%, #f0f9ff 60%, #fff9e6 100%);
  font-family: 'Noto Sans KR', 'Segoe UI', sans-serif;
  color: #2d3748;
}

#app {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ===== 좌우 2컬럼 레이아웃 (오목과 동일 구조) ===== */
.game-shell {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.play-layout {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 0.4fr) minmax(0, 1.6fr);
  gap: 0.75rem;
  align-items: stretch;
  padding-left: 6rem; /* back-pill 공간 */
}

.side-panel {
  overflow-y: auto;
  max-height: 100%;
  display: grid;
  gap: 0.65rem;
  /* 그리드 기본 stretch가 블록을 세로로 늘리지 않도록 */
  align-content: start;
}

.panel-block {
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid #e2e8f0;
  border-radius: 22px;
  padding: 0.9rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.toolbar-label {
  margin: 0 0 0.45rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
  color: #43a047;
}

.board-card {
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid #e2e8f0;
  border-radius: 22px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  padding: 0.75rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}

.btn-row > * {
  flex: 1 1 0;
  min-width: 0;
}

#difficulty-group .diff-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

/* ===== 상태 블록 ===== */
#info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.score-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #fff;
  padding: 0 8px;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  font-weight: 700;
  color: #2d3748;
  border: 2px solid #e2e8f0;
  height: 46px;
  min-width: 0;
  font-size: 0.95rem;
}

.disc-icon {
  /* 레이아웃 공간은 항상 36px — transform만 바꿔서 layout shift 없음 */
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transform: scale(0.55);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.disc-icon.black { background: radial-gradient(circle at 35% 35%, #555, #111); border: 2px solid #888; }
.disc-icon.white { background: radial-gradient(circle at 35% 35%, #fff, #ddd); border: 2px solid #aaa; box-shadow: 0 0 0 1px #ccc; }

.score-box.active-turn .disc-icon {
  transform: scale(1);
  animation: discBounce 1.4s ease-in-out infinite;
}

@keyframes discBounce {
  0%   { transform: scale(1); }
  18%  { transform: scale(1.32); }
  36%  { transform: scale(0.86); }
  54%  { transform: scale(1.18); }
  72%  { transform: scale(0.95); }
  88%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ===== 보드 ===== */
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
  background: #81c784;
  border: 5px solid #4caf50;
  border-radius: 14px;
  padding: 5px;
  flex-shrink: 0;
  width: min(100%, calc(100dvh - 110px));
  aspect-ratio: 1;
  box-shadow: 0 8px 32px rgba(76,175,80,0.25), 0 2px 8px rgba(0,0,0,0.10);
}

.cell {
  background: #43a047;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.cell:hover { background: #66bb6a; }

.cell.hint::after {
  content: '';
  width: 36%; height: 36%;
  border-radius: 50%;
  background: rgba(255, 240, 80, 0.70);
  position: absolute;
  box-shadow: 0 0 6px rgba(255,220,0,0.5);
}

.disc {
  width: 78%; height: 78%;
  border-radius: 50%;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.30);
  transition: transform 0.15s;
}
.disc.black { background: radial-gradient(circle at 35% 35%, #666, #111); border: 2px solid #888; }
.disc.white { background: radial-gradient(circle at 35% 35%, #fff, #ddd); border: 2px solid #bbb; }

/* ===== 버튼 ===== */
button {
  border: none;
  border-radius: 18px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.10);
}
button:active { transform: scale(0.96); }

#btn-restart {
  width: 100%;
  padding: 0.7rem 0.8rem;
  background: linear-gradient(135deg, #ff7043, #f44336);
  color: #fff;
}
#btn-restart:hover { filter: brightness(1.10); box-shadow: 0 4px 16px rgba(244,67,54,0.35); }

.mode-btn {
  padding: 0.55rem 0.4rem;
  font-size: 0.84rem;
  background: #fff;
  color: #4caf50;
  border: 2px solid #a5d6a7;
}
.mode-btn.active {
  background: linear-gradient(135deg, #66bb6a, #43a047);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(76,175,80,0.30);
}
.mode-btn:hover:not(.active) { background: #f1f8e9; }

.diff-btn {
  padding: 0.5rem 0.3rem;
  border-radius: 18px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #a0aec0;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.84rem;
  text-align: center;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
  transition: transform 0.1s, box-shadow 0.15s;
}
.diff-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.diff-btn[data-level="1"].active { border-color: #4caf50; background: #e8f5e9; color: #2e7d32; box-shadow: 0 3px 10px rgba(76,175,80,0.25); }
.diff-btn[data-level="2"].active { border-color: #8bc34a; background: #f1f8e9; color: #558b2f; box-shadow: 0 3px 10px rgba(139,195,74,0.25); }
.diff-btn[data-level="3"].active { border-color: #ffc107; background: #fffde7; color: #f57f17; box-shadow: 0 3px 10px rgba(255,193,7,0.25); }
.diff-btn[data-level="4"].active { border-color: #ff7043; background: #fbe9e7; color: #bf360c; box-shadow: 0 3px 10px rgba(255,112,67,0.25); }
.diff-btn[data-level="5"].active { border-color: #e91e63; background: #fce4ec; color: #880e4f; box-shadow: 0 3px 10px rgba(233,30,99,0.25); }

#thinking {
  font-size: 0.85rem;
  color: #fb8c00;
  min-height: 22px;
  margin-top: 0.5rem;
  font-weight: 600;
}

#status {
  font-size: 0.85rem;
  color: #718096;
  min-height: 1.2em;
}

/* ===== Modal ===== */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#modal-overlay.show { display: flex; }

#modal {
  background: #fff;
  border-radius: 24px;
  padding: 36px 40px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  animation: popIn 0.25s ease;
  border: 2px solid #e8f5e9;
}
@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

#modal-title { font-size: 2.2rem; margin-bottom: 10px; color: #2d3748; }
#modal-score { font-size: 1.15rem; color: #38a169; margin-bottom: 28px; font-weight: 700; }
#modal-btns { display: flex; gap: 14px; justify-content: center; }
#modal-btns button { padding: 12px 28px; font-size: 1rem; }
#btn-modal-restart { background: linear-gradient(135deg, #66bb6a, #43a047); color: #fff; border: none; }
#btn-modal-restart:hover { filter: brightness(1.08); }
#btn-modal-quit { background: #fff; color: #718096; border: 2px solid #e2e8f0 !important; box-shadow: none; }
#btn-modal-quit:hover { background: #f7fafc; }

/* ===== 온라인 대전 패널 (online.js) ===== */
.hidden { display: none !important; }

.online-input {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 8px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font: inherit;
  font-size: 0.92rem;
}
.online-input:focus { outline: none; border-color: #66bb6a; }

.online-join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}
.online-join-row .online-input { margin-bottom: 0; }

.online-btn {
  padding: 9px 18px;
  border-radius: 18px;
  border: 2px solid #a5d6a7;
  background: #fff;
  color: #4caf50;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}
.online-btn.primary {
  background: linear-gradient(135deg, #66bb6a, #43a047);
  color: #fff;
  border-color: transparent;
}
.online-btn:disabled { opacity: 0.5; cursor: default; }
#online-create-btn { width: 100%; }

.online-room-code {
  display: block;
  font-size: 1.9rem;
  letter-spacing: 0.35em;
  text-align: center;
  color: #2e7d32;
  margin-bottom: 6px;
}

.online-members {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  font-size: 0.9rem;
}
.online-members li { padding: 2px 0; }
.online-members li.muted { opacity: 0.6; font-size: 0.82rem; }

.online-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.online-message {
  margin: 8px 0 0;
  font-size: 0.85rem;
  min-height: 1.2em;
  color: #2e7d32;
}
.online-message.error { color: #d32f2f; }

/* ===== 반응형: 1컬럼 (보드 먼저) ===== */
@media (max-width: 1024px) {
  .play-layout {
    grid-template-columns: 1fr;
    padding-left: 0;
    padding-top: 3.5rem; /* back-pill 공간 (모바일은 위) */
  }
  .side-panel {
    max-height: none;
    overflow: visible;
  }
  .board-card {
    order: -1;
  }
  #board {
    width: min(100%, calc(100dvh - 140px));
    margin: 0 auto;
  }
}
