/* play.css — màn hình "Chơi + Trợ lý" / Đấu máy (mục 3 dac-ta-giao-dien.md).
   Tông chủ đạo trầm ấm (gỗ/đồng), mobile-first, bàn cờ luôn chiếm phần lớn màn
   hình, panel phụ (chọn cấp độ, kết quả ván) đều dạng bottom sheet trượt lên —
   đúng mục 7 (quy tắc thiết kế chung) dac-ta-giao-dien.md. */

:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --wood-dark: #241a12;
  --wood-mid: #3a2a1a;
  --wood-panel: #4a3826;
  --wood-accent: #caa06a;
  --wood-accent-soft: #e4d2ab;
  --red-accent: #b3261e;
  --red-accent-hover: #8f1e18;
  --green-accent: #2e7d4f;
  --text-main: #f2e9d8;
  --text-muted: #cbbfa6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(ellipse at top, var(--wood-mid) 0%, var(--wood-dark) 70%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #2e2115 0%, #241a12 100%);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #4a3826 0%, #3a2a1a 100%);
  border-bottom: 2px solid #5a442c;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar__title {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  color: var(--wood-accent-soft);
  letter-spacing: 0.02em;
}

.topbar__actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #6b5236;
  background: #4a3826;
  color: var(--text-main);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover {
  background: #5a442c;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- Board stage ---------- */
.board-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 14px 6px;
  position: relative;
}

.turn-status {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--wood-accent-soft);
  text-align: center;
  min-height: 1.3em;
}

.turn-status.is-check {
  color: #ff8a80;
}

.board-container {
  width: min(94vw, 480px);
  display: flex;
  justify-content: center;
}

.board-container svg {
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
  /* Đẩy SVG lên 1 layer composite riêng (GPU) thay vì để trình duyệt tính lại
     drop-shadow trên toàn khung hình mỗi khi có node con thay đổi — đây là
     nguyên nhân phổ biến gây "chớp chớp" khi 1 filter CSS bọc ngoài 1 SVG hay
     đổi nội dung trên Safari/Chrome mobile. */
  will-change: transform;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.thinking-indicator {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.3em;
}

.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 8, 0.86);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 12px;
}

.pause-overlay[hidden] {
  display: none;
}

/* ---------- Bottom action bar ---------- */
.action-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, #3a2a1a 0%, #4a3826 100%);
  border-top: 2px solid #5a442c;
  position: sticky;
  bottom: 0;
}

.action-bar button {
  flex: 1;
}

button {
  background: var(--red-accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #6b6156;
  color: #cfc6b8;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  background: var(--red-accent-hover);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  background: var(--green-accent);
  padding: 13px 10px;
  font-size: 1rem;
  margin-top: 14px;
}

.btn-primary:hover:not(:disabled) {
  background: #256b41;
}

/* ---------- Bottom sheets (chọn cấp độ / kết quả ván) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10;
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg, #4a3826 0%, #382a1c 100%);
  border-radius: 18px 18px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  z-index: 11;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
}

.bottom-sheet__handle {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: #6b5236;
  margin: 6px auto 14px;
}

.bottom-sheet h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
  text-align: center;
  color: var(--wood-accent-soft);
}

.level-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.level-option {
  background: #2e2115;
  border: 2px solid #6b5236;
  border-radius: 10px;
  padding: 14px 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.level-option[aria-pressed="true"] {
  border-color: var(--wood-accent);
  background: #4a3826;
  box-shadow: 0 0 0 2px var(--wood-accent) inset;
}

.level-option__depth {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.result-text {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--wood-accent-soft);
  white-space: pre-line;
}
