/* Ai là gián điệp — trên nền shared/css/app.css và shared/css/game.css (màn hình của ván, hộp thoại kết quả).
   Phần bảng điều khiển của trang Admin (.ts-live) nằm trong modules/admin/css/admin.css. */

.gd-help { flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin-left: auto; border: 1px solid var(--line); border-radius: 50%; background: var(--white); color: var(--accent-dark); font-size: 17px; font-weight: 800; cursor: pointer; }
.appbar .gd-help + .appbar-user { margin-left: 8px; }
/* Điện thoại nhỏ: tên người chơi được giữ chỗ; hướng dẫn vẫn có trong menu ("Hướng dẫn"), ở sảnh chờ và
   trong ván ("? Luật"). */
@media (max-width: 399px) {
  .appbar .gd-help { display: none; }
  .appbar .gd-help + .appbar-user { margin-left: auto; }
}

/* --- Một ván --- */
.gd-play { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 12px; width: min(100%, 720px); margin: 0 auto; padding: 12px var(--pad-right) calc(16px + var(--safe-bottom)) var(--pad-left); }
.gd-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-radius: var(--radius); background: #241c17; color: #faf6f0; }
.gd-bar-label { display: block; color: #f2b45a; font-size: 13px; font-weight: 700; }
.gd-timer { display: block; font-family: "Playfair Display", Georgia, serif; font-size: 40px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.gd-timer.is-low { color: #ff9b8c; }
.gd-timer.is-paused { opacity: 0.6; }
.gd-rules { flex: none; }

/* Thẻ vai: che kín tới khi nhấn giữ. */
.gd-card {
  position: relative;
  display: grid;
  min-height: 132px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.gd-card-cover, .gd-card-face { grid-area: 1 / 1; display: grid; place-content: center; gap: 6px; min-width: 0; padding: 18px; text-align: center; overflow-wrap: anywhere; }
.gd-card-cover { background: repeating-linear-gradient(135deg, #f3ece2 0 12px, #efe2d3 12px 24px); }
.gd-card-cover b { font-size: 18px; }
.gd-card-cover small { color: var(--muted); font-size: 13px; }
.gd-card-face { visibility: hidden; background: #241c17; color: #faf6f0; }
.gd-card-face small { color: #f2b45a; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.gd-card-face b { font-family: "Playfair Display", Georgia, serif; font-size: 30px; font-weight: 500; }
.gd-card.is-open .gd-card-cover { visibility: hidden; }
.gd-card.is-open .gd-card-face { visibility: visible; }
.gd-card.is-spy .gd-card-face { background: #7a1f1f; }
.gd-card[disabled] { cursor: default; opacity: 0.6; }

.gd-turn { display: grid; gap: 10px; }
.gd-turn-text { font-size: 17px; font-weight: 700; }
.gd-turn-text small { display: block; color: var(--muted); font-size: 14px; font-weight: 500; }
.gd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.gd-chips:empty { display: none; }
.gd-chips button { padding: 10px 14px; border: 1px solid var(--accent); border-radius: 999px; background: var(--blush); color: var(--accent-dark); font-weight: 700; cursor: pointer; }

.gd-players { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.gd-players li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.gd-players li.is-me { border-color: var(--accent); }
.gd-players li.is-turn { box-shadow: 0 0 0 2px #f2b45a inset; }
.gd-players .tag { margin-left: 6px; }
.gd-players .btn { flex: none; }

.gd-cheatsheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.gd-cheatsheet li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-size: 14px; cursor: pointer; user-select: none; }
.gd-cheatsheet li.is-out { color: var(--muted); text-decoration: line-through; opacity: 0.55; }

/* Bỏ phiếu, đoán */
.gd-dialog { width: min(100% - 24px, 520px); padding: 0; border: 0; border-radius: 20px; background: var(--cream); color: var(--ink); box-shadow: 0 30px 80px -30px rgb(43 35 30 / 0.6); }
.gd-dialog::backdrop { background: rgb(43 35 30 / 0.55); }
.gd-dialog-body { display: grid; gap: 12px; padding: 22px 20px 20px; }
.gd-dialog h2 { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 24px; font-weight: 500; }
.gd-vote-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gd-vote-buttons .btn { min-height: 52px; }
/* Điện thoại nhỏ: mỗi hàng 1 nút, mỗi nút trên 1 dòng. */
@media (max-width: 399px) {
  .gd-vote-buttons { grid-template-columns: 1fr; }
}
.gd-guess-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 50vh; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.gd-guess-list button { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-weight: 700; text-align: left; cursor: pointer; }
.gd-guess-list button:hover { border-color: var(--accent); }

.gd-team { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.gd-team.is-citizens { background: var(--green-soft); color: var(--green-text); }
.gd-team.is-spies { background: #f9dede; color: #8f1f1f; }

/* --- Hướng dẫn chơi: bottom sheet (điện thoại), modal (màn hình rộng) ---
   Dialog là chỗ lớn nhất mà sheet được chiếm (trong suốt: bấm vào đó thì đóng, như nền mờ); sheet bên
   trong cao bằng phần đang hiện (js/guide.js đặt chiều cao của track theo phần đó), nên phần ngắn không
   để trống bên dưới, và phần cao hơn chỗ đó thì cuộn bên trong sheet. */
.gd-guide { width: min(100% - 32px, 760px); max-width: none; height: min(100% - 48px, 640px); max-height: none; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible; }
.gd-guide[open] { display: flex; flex-direction: column; justify-content: center; }
.gd-guide::backdrop { background: rgb(43 35 30 / 0.55); }
.gd-guide-sheet { display: flex; flex-direction: column; max-height: 100%; overflow: hidden; border-radius: 22px; background: var(--cream); box-shadow: 0 30px 80px -30px rgb(43 35 30 / 0.6); }
.gd-guide-sheet > :not(.gd-guide-track) { flex: none; }
.gd-guide-grip { display: none; }
.gd-guide-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 6px; }
.gd-guide-head h2 { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 24px; font-weight: 500; }
.gd-guide-close { flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font-size: 20px; cursor: pointer; }
.gd-guide-tabs { display: flex; gap: 6px; padding: 4px 18px 10px; overflow-x: auto; }
.gd-guide-tabs button { flex: none; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); font-size: 14px; font-weight: 700; cursor: pointer; }
.gd-guide-tabs button[aria-selected="true"] { border-color: var(--accent); background: var(--blush); color: var(--accent-dark); }
.gd-guide-track { display: grid; flex: 0 1 auto; grid-auto-columns: 100%; grid-auto-flow: column; min-height: 0; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.gd-guide-track::-webkit-scrollbar { display: none; }
.gd-slide { min-width: 0; padding: 6px 18px 12px; overflow-y: auto; scroll-snap-align: start; scroll-snap-stop: always; font-size: 15px; line-height: 1.5; }
.gd-slide h3 { margin: 4px 0 10px; font-size: 19px; }
.gd-points, .gd-steps { display: grid; gap: 10px; margin: 0 0 12px; padding-left: 20px; }
.gd-note { margin: 10px 0 6px; color: var(--muted); font-size: 14px; }
.gd-tips { display: grid; gap: 10px; }
.gd-tips p { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.gd-tips .gd-team { margin-right: 6px; }
.gd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.gd-table th, .gd-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.gd-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.gd-card-demo { min-height: 110px; margin-top: 4px; }
.gd-guide-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.gd-dots { display: flex; gap: 8px; }
.gd-dots span { width: 9px; height: 9px; border: 1.5px solid var(--subtle, #71645a); border-radius: 50%; cursor: pointer; }
.gd-dots span.is-on { border-color: var(--accent); background: var(--accent); }

@media (max-width: 640px) {
  .gd-guide { width: 100%; height: 90dvh; margin: auto 0 0; }
  .gd-guide[open] { justify-content: flex-end; }
  .gd-guide[open] .gd-guide-sheet { animation: gd-up 0.25s ease-out; }
  .gd-guide-sheet { border-radius: 22px 22px 0 0; transition: transform 0.05s; }
  .gd-guide-grip { display: block; width: 44px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--line-strong, #d7c8b7); }
  .gd-guide-tabs { display: none; }
  .gd-table thead { display: none; }
  .gd-table tr { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .gd-table td { padding: 0; border: 0; }
  .gd-table td:first-child { font-weight: 800; }
}
@keyframes gd-up { from { transform: translateY(40px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .gd-guide[open] .gd-guide-sheet { animation: none; }
}

/* --- Trang Admin --- */
.gd-card-admin { min-height: 96px; margin-top: 10px; width: 100%; }
.ts-live .spy-live-wide { grid-column: span 2; }
.ts-live .spy-live-wide output { font-size: 18px; line-height: 1.6; overflow-wrap: anywhere; }
