/* 대국 페이지 */

.game {
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 24px 32px 36px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start;
}
.board-col {
  width: 100%; justify-self: center; display: flex; flex-direction: column; gap: 10px;
  /* 데스크탑: 화면 높이에 맞춰 판 크기를 정함 (판 비율 960:1060) */
  max-width: clamp(460px, calc((100svh - var(--header-h) - 150px) * 0.906), 680px);
}
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.settings-card { order: 1; } .actions-card { order: 2; } .status-card { order: 3; } .moves-card { order: 4; } .game-ad { order: 5; }

/* 태블릿: 판 위, 패널은 아래 2열 */
@media (max-width: 1023px) {
  .game { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px 24px 32px; max-width: 760px; }
  .board-col { max-width: 620px; }
  .panel {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start;
    grid-template-areas: "actions status" "settings moves" "ad ad";
  }
  .actions-card { grid-area: actions; } .status-card { grid-area: status; }
  .settings-card { grid-area: settings; } .moves-card { grid-area: moves; } .game-ad { grid-area: ad; }
}
/* 모바일: 한 줄 */
@media (max-width: 639px) {
  .game { padding: 12px 12px 24px; gap: 12px; }
  .board-col { gap: 8px; }
  .panel { display: flex; gap: 12px; align-items: stretch; }
  .actions-card { order: 1; } .status-card { order: 2; } .moves-card { order: 3; } .settings-card { order: 4; } .game-ad { order: 5; }
  .card { padding: 16px; }
}

/* ---------- 플레이어 줄 ---------- */
.pbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; min-height: 30px; }
.player { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; min-width: 0; }
.chip {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  font-family: var(--font-hanja); font-weight: 900; font-size: 14px;
  border: 2px solid currentColor; border-radius: 7px; background: var(--face);
}
.chip.cho { color: var(--cho); } .chip.han { color: var(--han); }
.turn { margin-left: 4px; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 400; color: var(--sub); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.turn.cho { color: var(--cho); } .turn.han { color: var(--han); }
.turn .dot { box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 16%, transparent); }
.turn span:last-child { color: var(--sub); }
.thinking .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .thinking .dot { animation: none; } }

/* ---------- 장기판 ---------- */
.board-wrap { position: relative; }
#board { width: 100%; height: auto; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#board .grid line { stroke: var(--grid); stroke-opacity: .75; stroke-width: 2.2; }
#board .grid .edge { stroke-opacity: 1; stroke-width: 4; fill: none; stroke: var(--grid); }
.piece .octa { fill: var(--face); stroke-width: 3.2; }
.piece .inner { fill: none; stroke-width: 1.5; opacity: .28; }
.piece.cho .octa, .piece.cho .inner { stroke: var(--cho); }
.piece.han .octa, .piece.han .inner { stroke: var(--han); }
.piece text { font-family: var(--font-hanja); font-weight: 900; text-anchor: middle; dominant-baseline: central; }
.piece.cho text { fill: var(--cho); } .piece.han text { fill: var(--han); }
.sel-ring { fill: none; stroke: var(--blue); stroke-width: 5; }
.dest { fill: var(--blue); opacity: .7; }
.dest-cap { fill: none; stroke: var(--blue); stroke-width: 5; opacity: .85; }
.last-from { fill: var(--han); opacity: .4; }
.last-to { fill: none; stroke: var(--han); stroke-width: 4.5; stroke-linecap: round; }
.check-ring { fill: none; stroke: var(--han); stroke-width: 6; }
.hint-line { stroke: var(--blue); stroke-width: 13; stroke-linecap: round; opacity: .75; }
.hint-head { fill: var(--blue); opacity: .9; }
.hint-ring { fill: var(--blue); fill-opacity: .12; stroke: var(--blue); stroke-width: 3.5; stroke-dasharray: 8 6; }

/* 대국 결과 */
.result {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px;
  background: rgba(245, 244, 240, .55); border-radius: 14px;
  backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px);
}
.result-box {
  width: min(320px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 24px 22px 20px; text-align: center; box-shadow: 0 18px 40px rgba(0, 0, 0, .12);
}
.result-box strong { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.result-box p { margin: 6px 0 18px; color: var(--sub); font-size: 14px; }
.result-box .row { display: flex; gap: 8px; }
.result-box .btn { flex: 1; }
.result-box .close { margin-top: 10px; border: 0; background: none; color: var(--sub); font-size: 13px; padding: 4px 8px; }

/* ---------- 패널 ---------- */
.seg + .select, .two { margin-top: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.note { font-size: 12px; color: var(--sub); margin-top: 10px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions .primary { grid-column: 1 / -1; margin-top: 2px; }
@media (max-width: 639px) {
  .actions-card { background: none; border: 0; padding: 0; }
  .actions { grid-template-columns: repeat(4, 1fr); }
  .actions .primary { grid-column: auto; margin-top: 0; }
  .actions .btn { height: 46px; padding: 0 4px; font-size: 13.5px; }
}

.status-line { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.substatus { color: var(--sub); font-size: 13px; min-height: 1.5em; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.alert { color: var(--han); font-weight: 700; }
.evalbar { height: 10px; border-radius: 6px; background: #f0d6d2; overflow: hidden; }
.evalbar span { display: block; height: 100%; width: 50%; background: var(--cho); transition: width .4s ease; }
.evalrow { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--sub); margin-top: 8px; font-variant-numeric: tabular-nums; }
.material { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--soft); font-size: 12.5px; color: var(--sub); font-variant-numeric: tabular-nums; }
#evalText.cho { color: var(--cho); } #evalText.han { color: var(--han); }

.moves {
  display: grid; grid-template-columns: 28px 1fr 1fr; row-gap: 2px; font-size: 13.5px;
  max-height: 228px; overflow-y: auto; font-variant-numeric: tabular-nums; overscroll-behavior: contain;
}
.moves > span { padding: 6px 6px; border-radius: 6px; }
.moves .n { color: #aaa; padding-left: 2px; }
.moves .last { background: #fbeceb; color: var(--han); font-weight: 700; }
.moves .last.c { background: #e8f3ee; color: var(--cho); }
.moves .empty { grid-column: 1 / -1; color: var(--sub); padding: 6px 2px; }

/* 광고 자리: 늦게 떠도 화면이 밀리지 않게 높이를 미리 잡음 */
.game-ad.on { min-height: 250px; }
@media (max-width: 1023px) { .game-ad.on { min-height: 90px; } }
@media (max-width: 639px) { .game-ad.on { min-height: 100px; margin-top: 8px; } }
