/*
 * 학생 게임 화면 공통 스타일 (오목·오셀로·님). 판(보드) 모양은 각 게임 CSS와 board.css에 둔다.
 * 색·간격은 style.css의 C.E.M 값을 쓰고, 차례 색(--turn)은 여기서 정한다.
 */
:root {
  --turn: var(--indigo-600);
}

/* 입장: 들어가기 버튼은 손가락으로 누르기 쉽게 한 줄 전체 */
#join-form button {
  width: 100%;
}

.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.player {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  min-width: 0;
}

.player .who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player .color-name {
  font-weight: 700;
}

/* 차례인 쪽: 색 + 두꺼운 테두리 + "차례" 글자 */
.player.active {
  border-color: var(--turn);
  border-width: 3px;
}

/* 이름이 길어 잘려도 "차례" 글자는 항상 보인다 */
.turn-badge {
  display: none;
  flex: none;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--turn);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.player.active .turn-badge {
  display: inline-block;
}

.player.me .name::after {
  content: ' (나)';
  color: var(--muted);
}

.status {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  margin: 10px 0 8px;
  min-height: 1.5em;
}

/* 돌 수·남은 돌 같은 판 요약 한 줄 (오셀로·님) */
.counts {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: -4px 0 8px;
}

.message {
  min-height: 1.4em;
  text-align: center;
  color: var(--danger);
  font-weight: 600;
  margin: 8px 0;
}

.actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
}

.wait p {
  margin: 0;
  font-size: 1.1rem;
}

.end {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.end-card {
  width: min(100%, 360px);
  text-align: center;
}

.end-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 4px 0 8px;
}

.end-detail {
  color: var(--muted);
  margin: 0 0 16px;
}

/* 이번 판 내 기록 한두 줄 (판이 끝난 창) */
.end-growth {
  margin: -6px 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--indigo-700);
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
}

.end-growth:empty {
  display: none;
}

/* 대기 화면: 이 방에서 내 기록 */
.growth {
  margin-top: 12px;
}

.growth h2 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.growth-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.growth-list div {
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
}

.growth-list dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.growth-list dd {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.growth .hint {
  margin: 10px 0 0;
}

.end-card button {
  width: 100%;
}

.wait .hint {
  margin-top: 8px;
  font-size: 0.95rem;
}

/* 도전 신청 대기실 */
.lobby {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.lobby h2 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.lobby p {
  margin: 0 0 8px;
}

.lobby-note {
  font-weight: 600;
}

.lobby-note:empty {
  display: none;
}

.lobby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.lobby-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-list .who {
  flex: 1 1 0;
  min-width: 3em;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* 일시정지: 화면 위에 띠를 띄우고 보드는 흐리게 (글자와 기호로도 알린다) */
.pause {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  background: #3b3a36;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
}

.pause-icon {
  letter-spacing: -0.15em;
}

/* 띠가 위쪽 내용을 가리지 않게 밀어 낸다 */
body:has(.pause:not([hidden])) main {
  padding-top: 64px;
}

.opponent-note {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  margin: -4px 0 6px;
  min-height: 0;
}

.opponent-note:empty {
  display: none;
}

/* 일시정지 중에는 판을 흐리게 */
body:has(.pause:not([hidden])) :is(#board, #piles) {
  opacity: 0.5;
}

.end-card button + button {
  margin-top: 8px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 4px;
}

.stepper button {
  min-width: 48px;
  padding: 0 10px;
}

.step-text {
  min-width: 7.5em;
  white-space: pre-line;
  line-height: 1.3;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.review-cards {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.q-text {
  font-weight: 700;
  margin: 0 0 10px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

button.choice {
  min-height: 44px;
  padding: 6px 8px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  line-height: 1.25;
}

/* 고른 보기: 색 + 굵은 테두리 + ✓ 표시 */
button.choice[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button.choice[aria-pressed='true']::before {
  content: '✓ ';
}

.q-card textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  resize: vertical;
}

.q-note {
  margin: 8px 0 0;
  color: var(--accent);
  font-weight: 600;
  min-height: 0;
}

.q-note:empty {
  display: none;
}

.wide-btn {
  width: 100%;
}

/* 판 남은 시간과 규칙 (한 줄). 줄이 바뀔 때 낱말 중간("이겨/요")에서 끊지 않는다 */
.match-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 12px;
  margin: -4px 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
  word-break: keep-all;
  text-wrap: balance;
}

.match-info span:empty {
  display: none;
}

.match-info .low {
  color: var(--text);
  font-weight: 800;
}

/* 턴 제한시간: 글자(남은 초)와 막대를 함께 보여 준다 */
.clock {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px 0 8px;
  font-weight: 600;
  color: var(--muted);
}

.clock-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.clock-bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--turn);
}

.clock.mine {
  color: var(--text);
}

.clock.low #clock-text {
  font-weight: 800;
}

/* ── 게임 방법: 입장 화면 링크, 대기 화면 버튼과 창 ── */
.guide-link {
  display: block;
  margin: 14px 0 0;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}

.wait .guide-open {
  width: 100%;
  margin-top: 4px;
}

.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 0 0 / 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.guide-sheet {
  width: min(100%, 560px);
  height: min(100%, 760px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}

.guide-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--border);
}

.guide-sheet-head button {
  min-height: 40px;
}

.guide-sheet iframe {
  flex: 1;
  width: 100%;
  border: 0;
}
