/* Lô tô: nền đỏ hội chợ; tờ dò 9×9 in màu (đỏ, xanh, vàng…) ô số trắng chữ đậm, hạt đỏ khi dò; số vừa hô là quả bóng vàng.
   Ghi đè màu của /room.css. Điện thoại: một cột (số vừa hô, bảng 90 số, tờ dò, thanh KINH); máy tính: bảng bên trái, tờ bên phải. */
:root {
  --bg: #5a0f12; --panel: #fff7e8; --line: #e9cfa4; --text: #3a1a10; --muted: #8a5a3c; --accent: #d62828;
  --good: #2e9e5b; --bad: #d9412b;
}
body { background: radial-gradient(circle at 50% 0%, #b3261e, #5a0f12 75%) fixed; color: #fff7e8; }
.card, #players li { color: var(--text); }
input { background: #fff; color: var(--text); }
button.primary { color: #fff; }
#overlay { background: #2a0607b0; }
header button { color: var(--text); }

.board-stage { width: 100%; height: 100%; display: grid; justify-items: center; min-height: 0; }
.lt {
  width: min(100%, 560px); height: 100%; min-height: 0; display: grid; gap: 8px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.now { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 10px 8px; border-radius: 14px; background: #fff7e8; color: var(--text); box-shadow: 0 6px 18px #0005; min-width: 0; }
.ball {
  width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 50%;
  font-size: 24px; font-weight: 800; color: #3a1a10; font-variant-numeric: tabular-nums;
  background: radial-gradient(circle at 35% 30%, #fff6b0, #ffd23f 55%, #d99a00); box-shadow: 0 4px 10px #0005, inset 0 -4px 0 #0002;
}
.ball.pulse { animation: ring 1.2s ease-out 1; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 #ffd23fcc; transform: scale(1.15); } 100% { box-shadow: 0 0 0 18px #ffd23f00; transform: scale(1); } }
.now .meta { flex: 1; display: grid; min-width: 0; line-height: 1.25; }
.now small { color: var(--muted); font-size: 12px; }
.now .count { font-variant-numeric: tabular-nums; }
.now .call { padding: 9px 14px; font-size: 15px; }
.now .wait { color: var(--muted); font-size: 13px; text-align: right; }
.now .pace-note { color: #b3261e; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now .pace { padding: 8px 10px; font-size: 14px; font-weight: 700; color: var(--text); }
.now .pace.on { background: #ffd23f; border-color: #e0a100; }
/* Vạch đếm ngược tới số tự hô kế tiếp, chạy dọc đáy thanh. */
.now .timer { position: absolute; left: 14px; right: 14px; bottom: 2px; height: 3px; border-radius: 2px; background: #e0a100; transform-origin: left; transform: scaleX(0); }
@keyframes countdown { from { transform: scaleX(var(--from, 0)); } to { transform: scaleX(1); } }
/* Câu vè của số vừa hô: một dòng dưới bóng số. */
.now .ve { flex: 1 0 100%; margin: 0; font-size: 13px; font-style: italic; font-weight: 600; color: #8a2a12; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Số mới: bóng số to giữa màn ~1,5 giây (không chặn chạm). */
.pop { position: fixed; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 10px; pointer-events: none; opacity: 0; }
.pop b {
  width: min(46vmin, 260px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: min(24vmin, 136px); font-weight: 900;
  color: #3a1a10; font-variant-numeric: tabular-nums; background: radial-gradient(circle at 35% 30%, #fff6b0, #ffd23f 55%, #d99a00);
  box-shadow: 0 18px 50px #000a, inset 0 -10px 0 #0002, 0 0 0 8px #fff7e8;
}
.pop span { max-width: min(90vw, 520px); padding: 6px 14px; border-radius: 12px; background: #2a0607e6; color: #fff7e8; font-size: 17px; font-weight: 700; text-align: center; }
.pop.show { animation: pop 1.5s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(.4); }
  14% { opacity: 1; transform: scale(1.08); }
  24% { transform: scale(1); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}
header .voice { color: var(--text); font-weight: 800; font-size: 13px; }
header .music { color: var(--text); opacity: .55; }
header .music.on { opacity: 1; }
header .music-vol { width: 56px; accent-color: #d99a00; }
/* Điện thoại hẹp: thanh trên có 8 nút, bỏ thanh trượt âm lượng (nút nhạc vẫn bật / tắt) cho vừa một hàng. */
@media (max-width: 420px) { header { gap: 4px; } header .music-vol { display: none; } }

/* Bảng 90 số: 9 hàng × 10, số đã hô sáng lên, số vừa hô vàng. */
.board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 5px; border-radius: 12px; background: #2a0607aa; }
.board span {
  height: clamp(13px, 2.1cqh, 30px); display: grid; place-items: center; border-radius: 4px; font-size: clamp(10px, 1.5cqh, 15px);
  font-weight: 700; font-variant-numeric: tabular-nums; color: #ffd9c955; background: #ffffff0d;
}
.board span.on { background: #fff7e8; color: var(--text); }
.board span.cur { background: #ffd23f; color: #3a1a10; box-shadow: 0 0 0 2px #fff; }

/* Mua tờ (trước số đầu tiên, thay chỗ bảng số): 8 ô màu, ô đã chọn ghi số thứ tự tờ. */
.shop { display: grid; gap: 8px; align-content: start; padding: 10px; border-radius: 12px; background: #fff7e8; color: var(--text); box-shadow: 0 6px 18px #0005; }
.shop p { margin: 0; font-weight: 700; font-size: 14px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.swatches button {
  aspect-ratio: 1; min-width: 0; padding: 0; border-radius: 10px; border: 3px solid #fff; background: var(--c);
  color: #fff; font-size: 18px; font-weight: 900; text-shadow: 0 1px 2px #0008; box-shadow: 0 2px 6px #0004;
}
.swatches button.on { border-color: #3a1a10; box-shadow: 0 0 0 3px #ffd23f; }
.shop .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shop .swap { color: var(--text); }
.shop .note { color: var(--muted); font-size: 13px; font-weight: 600; }

/* Tờ dò: khung màu tờ, dải tên, lưới 9×9 (vạch dày giữa 3 khối). Cỡ theo chỗ trống (container query). */
.sheet { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
/* Tab các tờ (từ 2 tờ): màu của tờ, dấu CHỜ, vàng khi có hàng kinh. */
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.tabs button {
  min-width: 42px; padding: 3px 10px; border-radius: 10px; border: 2px solid #fff8; background: var(--c); color: #fff;
  font-weight: 800; font-size: 15px; display: inline-flex; flex-direction: column; line-height: 1.1; opacity: .75;
}
.tabs button.on { opacity: 1; border-color: #ffd23f; box-shadow: 0 0 0 2px #ffd23f; }
.tabs button small { font-size: 9px; font-weight: 900; color: #ffd23f; }
.tabs button.win { background: #ffd23f; color: #5a0f12; }
.wrap { grid-row: 2; min-height: 0; container-type: size; display: grid; place-items: start center; touch-action: none; }
.ticket {
  --tc: #c62828; width: min(100cqw, calc((100cqh - 14px) / 1.07)); container-type: inline-size; padding: 4px; border-radius: 10px;
  background: var(--tc); box-shadow: 0 10px 24px #0007, inset 0 0 0 1px #fff3;
}
.strip { padding: 0.4cqw 1.5cqw 1cqw; font-size: 3.4cqw; font-weight: 800; letter-spacing: .12em; color: #fff; text-align: center; text-shadow: 0 1px 2px #0006; }
.grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 1px; background: color-mix(in srgb, var(--tc) 55%, #000); border: 1px solid color-mix(in srgb, var(--tc) 55%, #000); }
.ticket .cell {
  aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; position: relative; isolation: isolate;
  background: #fffdf5; color: #1d140f; font-size: 5.4cqw; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
}
.ticket .cell.bt { border-top: 3px solid color-mix(in srgb, var(--tc) 55%, #000); }
.ticket .cell:disabled { opacity: 1; cursor: default; } /* room.css làm mờ nút disabled */
.ticket .blank { background: color-mix(in srgb, var(--tc) 82%, #fff); }
.ticket .hit { color: #fff; }
.ticket .hit::before {
  content: ''; position: absolute; inset: 9%; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle at 35% 30%, #ff8a7a, #c4161c 60%, #7d0a0e); box-shadow: 0 1px 2px #0008;
}
.ticket .cur { animation: glow 1.1s ease-in-out infinite; box-shadow: inset 0 0 0 3px #ffb300; background: #fff3c4; }
@keyframes glow { 50% { background: #ffe082; } }
.ticket .wait:not(.hit)::after { content: ''; position: absolute; inset: 8%; border: 2px dashed #c4161c; border-radius: 50%; }
.ticket .win { background: #ffd23f; }
.ticket .win.hit::before { background: radial-gradient(circle at 35% 30%, #ffe28a, #e0a100 60%, #8a5a00); }

/* Thanh dưới: dòng CHỜ / gợi ý, Tự dò, KINH. */
.bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status { flex: 1; margin: 0; min-width: 0; font-weight: 700; font-size: 14px; color: #fff7e8; text-shadow: 0 1px 3px #0008; line-height: 1.25; }
.status.cho { color: #ffd23f; font-size: 16px; letter-spacing: .02em; }
.bar .auto { padding: 8px 10px; font-size: 13px; color: var(--text); }
.bar .auto.on { background: #ffd23f; border-color: #ffd23f; color: #3a1a10; font-weight: 700; }
.bar .auto.frozen { background: #cfe8ff; border-color: #7fb6e8; color: #12406b; font-weight: 700; }
.bar .kinh {
  padding: 10px 18px; font-size: 18px; font-weight: 900; letter-spacing: .06em; color: #fff; border: 0;
  background: linear-gradient(#ff5a4e, #c4161c); box-shadow: 0 4px 0 #7d0a0e, 0 6px 14px #0006;
}
.bar .kinh:active { transform: translateY(2px); box-shadow: 0 2px 0 #7d0a0e; }
.bar .kinh.ready { background: linear-gradient(#ffe066, #ffb300); color: #5a0f12; animation: shout .8s ease-in-out infinite; }
@keyframes shout { 50% { transform: scale(1.08); } }

/* Thẻ phạt kinh láo: cả phòng thấy, phạt trong game + vòng quay phạt vui. Nền không chặn chạm, chạm thẻ để đóng. */
.pen { position: fixed; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none; }
.pen-card {
  pointer-events: auto; width: min(340px, 88vw); display: grid; gap: 10px; padding: 18px 16px 12px; border-radius: 18px; text-align: center;
  background: #fff7e8; color: var(--text); border: 4px solid #c4161c; box-shadow: 0 20px 60px #000c; animation: penIn .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes penIn { from { transform: scale(.5) rotate(-6deg); opacity: 0; } }
.pen-card h3 { margin: 0; font-size: 22px; font-weight: 900; color: #c4161c; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pen-card .g { margin: 0; padding: 8px 10px; border-radius: 12px; background: #ffe2dc; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pen-card .reel { display: grid; gap: 4px; padding: 10px; border-radius: 14px; background: #3a1a10; color: #ffd23f; }
.pen-card .reel small { color: #ffd9c9; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.pen-card .reel b { min-height: 1.4em; font-size: 20px; }
.pen-card .reel.landed { background: #c4161c; color: #fff; animation: landed .5s ease-out; }
@keyframes landed { 40% { transform: scale(1.08); } }
.pen-card .tap { color: var(--muted); font-size: 11px; }

/* Sảnh chờ: nút sửa danh sách phạt vui; hộp thoại sửa (thêm / bỏ từng câu). */
.party-edit { color: var(--text); }
.party-dlg { border: 1px solid var(--line); max-height: 86vh; overflow: auto; }
.party-dlg::backdrop { background: #2a0607b0; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; text-align: left; max-height: 44vh; overflow: auto; }
.plist li { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.plist li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.plist .rm { padding: 4px 6px; color: var(--text); }
.party-dlg .seg button { color: var(--text); }
.party-dlg .seg button.primary { color: #fff; }

/* Máy tính / màn rộng: bảng số + nút bên trái, tờ dò bên phải cao hết cỡ. */
@container (min-width: 760px) {
  .lt {
    width: 100%; max-width: 1180px; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 18px;
  }
  .now, .board, .shop, .bar { grid-column: 1; }
  .bar { grid-row: 4; }
  .sheet { grid-column: 2; grid-row: 1 / -1; }
  .board span { height: clamp(22px, 4cqh, 34px); font-size: 14px; }
  .ball { width: 64px; height: 64px; font-size: 30px; }
}
