/* Ruộng Sen — giao diện gỗ mộc trong suốt trên cảnh 3D đồng quê (như ảnh mẫu): viên thuốc nâu sẫm mờ, chữ kem, nút tròn to ở dưới.
   Điện thoại cầm dọc là chính; ngang / máy tính gom gọn. Nhãn hai dòng: .c1 dòng chính (Việt hoặc Nhật), .c2 dòng nhỏ (thứ tiếng kia). */
:root {
  --kinh: rgba(60, 48, 34, 0.66);
  --kinh-dam: rgba(46, 37, 26, 0.93);
  --kinh-sang: rgba(86, 70, 50, 0.72);
  --vien: rgba(255, 238, 205, 0.2);
  --chu: #f8f0dd;
  --chu-mo: rgba(248, 240, 221, 0.76);
  --chu-nhat: rgba(248, 240, 221, 0.52);
  --kem: #f3e7cf;
  --vang: #f4c25b;
  --xanh: #a6cf7f;
  --xanh-dam: #5f8a45;
  --do: #ff7a62;
  --phong: 'Be Vietnam Pro', 'M PLUS Rounded 1c', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --phong-nhat: 'M PLUS Rounded 1c', 'Be Vietnam Pro', 'Hiragino Maru Gothic ProN', sans-serif;
  --tren: env(safe-area-inset-top, 0px);
  --duoi: env(safe-area-inset-bottom, 0px);
  --mu: #e7c47c; --yem: #4f78a8; --ao-trong: #f6f2e8;
  --hd: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fb7d8; color: var(--chu); font-family: var(--phong);
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
body.nn-ja { font-family: var(--phong-nhat); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
input { font: inherit; user-select: text; -webkit-user-select: text; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#chibi { stroke: none; }
.an { display: none !important; }
.c1, .c2 { display: block; }
.c2 { font-size: 0.72em; font-weight: 500; opacity: 0.72; letter-spacing: 0.01em; }
.nn-ja .c1 { font-family: var(--phong-nhat); }
.nn-ja .c2 { font-family: var(--phong); }

#khung3d { position: fixed; inset: 0; }
#khung3d canvas { display: block; }
#lopMan { position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(40, 32, 20, 0.22), rgba(40, 32, 20, 0) 14%), linear-gradient(to top, rgba(30, 22, 14, 0.38), rgba(30, 22, 14, 0) 24%); }
#lopNhan { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }

/* nhãn tên trên đầu nông dân, bóng chat, chữ nổi */
.nhan-nd { position: absolute; left: 0; top: 0; will-change: transform; white-space: nowrap; }
.nhan-nd b { display: block; padding: 2px 9px 3px; border-radius: 99px; font-size: 12px; font-weight: 700; color: var(--chu); background: rgba(52, 42, 30, 0.62);
  border: 1px solid rgba(255, 238, 205, 0.16); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.nhan-nd.minh b { background: rgba(95, 138, 69, 0.85); border-color: rgba(220, 255, 190, 0.45); }
.nhan-nd.lv b { background: linear-gradient(90deg, rgba(37, 216, 232, 0.88), rgba(254, 44, 85, 0.88)); border-color: rgba(255, 255, 255, 0.5); }
.nhan-nd.lv b::before { content: '♪ '; }
.nhan-nd.fan b::after { content: ' ★'; color: #ffe17a; }
.bong-chat { position: absolute; left: 0; top: 0; max-width: 200px; padding: 6px 11px; border-radius: 14px; font-size: 13px; line-height: 1.35; font-weight: 600;
  color: #3d2e1d; background: rgba(255, 250, 238, 0.95); box-shadow: 0 4px 14px rgba(40, 28, 10, 0.25); white-space: normal; word-break: break-word; animation: hienBong 0.25s ease-out; }
.bong-chat::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(255, 250, 238, 0.95); }
.bong-chat.lv { background: #fff; border: 2px solid #25d8e8; }
@keyframes hienBong { from { opacity: 0; transform: translate(-50%, -80%) scale(0.8); } }
.noi-len { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 17px; color: #fff8e2; text-shadow: 0 2px 6px rgba(50, 30, 0, 0.55), 0 0 2px rgba(0, 0, 0, 0.5);
  animation: noiLen 1.5s ease-out forwards; white-space: nowrap; }
.noi-len.vang { color: #ffe27a; font-size: 20px; }
.noi-len.xu { color: #ffe9a8; }
@keyframes noiLen { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); } 15% { opacity: 1; transform: translate(-50%, -70%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
.cx-noi { position: absolute; transform: translate(-50%, -50%); font-size: 34px; animation: cxNoi 1.8s ease-out forwards; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.25)); }
@keyframes cxNoi { 0% { opacity: 0; transform: translate(-50%, 0) scale(0.4); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }

/* ---------------- màn chào: tranh quê Nhật làm nền, logo, thẻ nhập tên */
.man-chao { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--tren) + 18px) 16px calc(var(--duoi) + 12px); overflow-y: auto;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 38%, rgba(48, 40, 26, 0.38) 66%, rgba(40, 32, 20, 0.82) 100%), url(anh_codex/troi_que_nhat.webp) 34% 100% / cover no-repeat, #8fb7d8; }
.chao-nn { position: absolute; top: calc(var(--tren) + 12px); right: 12px; }
.chao-dau { text-align: center; width: min(400px, 100%); }
.logo { display: block; width: min(330px, 86%); height: auto; margin: 6px auto 0; filter: drop-shadow(0 6px 16px rgba(40, 60, 20, 0.35)); }
.khau-hieu { margin: 2px auto 0; font-size: 14.5px; line-height: 1.4; font-weight: 700; color: #fffdf6; max-width: 330px; text-shadow: 0 1px 10px rgba(30, 50, 20, 0.7), 0 1px 2px rgba(20, 30, 10, 0.6); }
.khau-hieu .c2 { margin-top: 2px; }
.dang-o { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 13px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: rgba(50, 40, 28, 0.55); border: 1px solid var(--vien); }
.dang-o .c2 { display: none; }
.dang-o i { width: 7px; height: 7px; border-radius: 50%; background: #9be38f; box-shadow: 0 0 8px #9be38f; animation: nhay 2s infinite; }
@keyframes nhay { 50% { opacity: 0.35; } }
.the { background: var(--kinh); border: 1px solid var(--vien); border-radius: 26px; backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 18px 50px rgba(30, 20, 8, 0.4), inset 0 1px 0 rgba(255, 245, 225, 0.12); }
.chao-the { width: min(370px, 100%); padding: 10px 18px 16px; display: flex; flex-direction: column; margin-top: 50px; }
.xem-truoc { display: grid; place-items: center; margin: -66px auto 0; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, rgba(255, 246, 210, 0.75), rgba(200, 235, 160, 0.2) 62%, rgba(200, 235, 160, 0) 72%); }
#chibi { width: 104px; height: 112px; filter: drop-shadow(0 6px 10px rgba(30, 20, 10, 0.32)); }
#chibi .mu { fill: var(--mu); transition: fill 0.25s; }
#chibi .mu-bang { fill: rgba(0, 0, 0, 0.22); }
#chibi .yem { fill: var(--yem); transition: fill 0.25s; }
#chibi .ao-trong { fill: var(--ao-trong); }
.nhan { font-size: 12.5px; font-weight: 700; color: var(--chu-mo); margin: 9px 2px 6px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.nhan .c1, .nhan .c2 { display: inline; }
.nhan .c2 { margin-left: 6px; }
.chao-xv { color: var(--chu); }
.chao-xv b { color: var(--vang); }
#oTen { width: 100%; height: 48px; padding: 0 14px; font-size: 17px; font-weight: 700; color: var(--chu); background: rgba(255, 245, 225, 0.09);
  border: 1px solid rgba(255, 232, 196, 0.3); border-radius: 15px; outline: none; transition: border-color 0.2s; }
#oTen:focus { border-color: var(--vang); }
.chon-mau { display: flex; gap: 8px; }
.chon-mau button { flex: 1; height: 38px; border-radius: 12px; display: grid; place-items: center; border: 2px solid transparent; background: rgba(255, 245, 225, 0.06); }
.chon-mau button i { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.2), 0 2px 5px rgba(0, 0, 0, 0.25); }
.chon-mau button[aria-checked="true"] { border-color: var(--vang); background: rgba(255, 235, 190, 0.14); }
.nut { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 16px; font-weight: 800; font-size: 15px; padding: 11px 18px; transition: transform 0.12s, filter 0.2s; }
.nut:active { transform: scale(0.97); }
.nut svg { font-size: 20px; }
.nut img { width: 24px; height: 24px; }
.nut.chinh { color: #2e3b18; background: linear-gradient(180deg, #d6ef9e, #93c45e); box-shadow: 0 8px 22px rgba(110, 160, 60, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.nut.chinh:disabled { filter: grayscale(0.6) brightness(0.8); }
.nut.phu { color: var(--chu); background: rgba(255, 240, 220, 0.1); border: 1px solid var(--vien); }
.nut.to { width: 100%; min-height: 56px; font-size: 18px; margin-top: 14px; flex-direction: column; gap: 0; line-height: 1.2; }
.nut.to .c2 { font-size: 12px; }
.nut.nho { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 12px; }
.ghi-chu { margin: 0; font-size: 11px; line-height: 1.5; color: rgba(248, 240, 221, 0.68); text-align: center; max-width: 360px; text-shadow: 0 1px 3px rgba(20, 14, 6, 0.75); }
.ghi-chu .c2 { font-size: 10.5px; }
.ve-xom { color: var(--chu-mo); font-size: 13px; text-decoration: none; padding: 4px 10px; display: flex; gap: 6px; align-items: baseline; }
.ve-xom .c1, .ve-xom .c2 { display: inline; }
.khong-gl { margin: 6px 4px; font-size: 15px; line-height: 1.6; color: var(--chu-mo); text-align: center; }
.vien-nn { height: 34px; padding: 0 13px; border-radius: 99px; font-size: 13px; font-weight: 800; background: var(--kinh); border: 1px solid var(--vien); font-family: var(--phong-nhat); }
.nn-ja .vien-nn { font-family: var(--phong); }
@media (max-height: 740px) {
  .logo { width: min(250px, 70%); margin-top: 0; }
  .chao-the { margin-top: 44px; padding-top: 6px; }
  .xem-truoc { width: 100px; height: 100px; margin-top: -56px; }
  #chibi { width: 88px; height: 94px; }
  .nhan { margin: 6px 2px 4px; }
  .nut.to { min-height: 50px; margin-top: 10px; }
}
/* điện thoại thấp (360×640, 390×664 — trình duyệt có thanh địa chỉ): gọn thêm để cả ghi chú "xu chỉ trong game" lẫn nút ↩ Xóm Vui
   nằm trong màn, không phải cuộn mới thấy */
@media (max-height: 700px) and (orientation: portrait) {
  .man-chao { padding-top: calc(var(--tren) + 10px); gap: 6px; }
  .logo { width: min(210px, 62%); }
  .khau-hieu { font-size: 13.5px; }
  .dang-o { margin-top: 6px; padding: 5px 12px; }
  .chao-the { margin-top: 40px; padding: 4px 16px 12px; }
  .xem-truoc { width: 88px; height: 88px; margin-top: -48px; }
  #chibi { width: 76px; height: 82px; }
  .nhan { margin: 5px 2px 4px; }
  #oTen { height: 44px; }
  .chon-mau button { height: 34px; }
  .nut.to { min-height: 48px; margin-top: 10px; }
  .ghi-chu { font-size: 10.5px; line-height: 1.4; }
  .ghi-chu .c2 { font-size: 10px; }
  .ve-xom { padding: 2px 10px; }
}
/* màn rất thấp (320×568): bỏ hình nông dân xem trước (màu đã chọn vẫn hiện ở ô viền vàng) */
@media (max-height: 600px) and (orientation: portrait) {
  .logo { width: min(180px, 56%); }
  .khau-hieu { font-size: 12.5px; }
  .xem-truoc { display: none; }
  .chao-the { margin-top: 6px; padding-top: 8px; }
  #oTen { height: 40px; font-size: 16px; }
  .chon-mau button { height: 30px; }
  .nut.to { min-height: 44px; }
}
/* cầm ngang (điện thoại nằm): logo + lời chào bên trái, thẻ nhập tên bên phải — nút "Xuống ruộng" thấy ngay, không phải cuộn */
@media (max-height: 520px) and (orientation: landscape) {
  .man-chao { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 1fr auto auto; align-items: center; justify-items: center;
    column-gap: 24px; row-gap: 4px; padding: calc(var(--tren) + 10px) max(20px, env(safe-area-inset-right)) calc(var(--duoi) + 8px) max(20px, env(safe-area-inset-left)); }
  .chao-dau { grid-column: 1; grid-row: 1; }
  .chao-the { grid-column: 2; grid-row: 1 / span 3; margin-top: 34px; padding: 2px 16px 12px; width: min(360px, 100%); }
  .ghi-chu { grid-column: 1; grid-row: 2; }
  .ve-xom { grid-column: 1; grid-row: 3; }
  .logo { width: min(250px, 78%); }
  .khau-hieu { font-size: 13.5px; }
  .xem-truoc { width: 80px; height: 80px; margin-top: -44px; }
  #chibi { width: 70px; height: 76px; }
  .nhan { margin: 4px 2px 3px; }
  #oTen { height: 40px; }
  .chon-mau button { height: 32px; }
  .nut.to { min-height: 46px; margin-top: 10px; }
}

/* ---------------- trong ruộng */
#manChoi { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#manChoi > * { pointer-events: auto; }
#manChoi > .tren, #manChoi > .duoi, #manChoi > .nhan-noi { pointer-events: none; }
.tren > *, .duoi > *, .tren-trai > * { pointer-events: auto; }
.tren { position: absolute; top: calc(var(--tren) + 10px); left: 10px; right: 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tren-trai { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none !important; }
/* nút đổi tiếng nằm dưới nút ↩, KHÔNG chiếm bề ngang cột trái (để thanh trên đủ chỗ) và không bao giờ gãy dòng ("Tiếng Việt") */
.tren-trai { position: relative; }
.tren-trai .vien-nn { position: absolute; top: 50px; left: 0; white-space: nowrap; }
.nut-tron { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; color: var(--kem); flex: none;
  background: var(--kinh); border: 1px solid var(--vien); transition: transform 0.12s; text-decoration: none; }
.nut-tron:active { transform: scale(0.92); }
.vien-tren { display: flex; align-items: center; gap: 1px; padding: 3px 5px; border-radius: 99px; background: var(--kinh); border: 1px solid var(--vien); min-width: 0; }
.vien-tren > button { position: relative; height: 36px; min-width: 34px; display: grid; place-items: center; font-size: 19px; color: var(--kem); border-radius: 99px; }
.vien-tren > button:active { background: rgba(255, 240, 210, 0.12); }
.vien-tren .so-chip { display: inline-flex; gap: 4px; padding: 0 6px; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.so-chip img { width: 24px; height: 24px; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.so-chip .vang, svg.vang { color: var(--vang); }
.so-chip.nay { animation: nay 0.5s; }
.so-chip.day b { color: #ffd27a; }
@keyframes nay { 40% { transform: scale(1.18); } }
.nhan-noi { position: absolute; top: calc(var(--tren) + 62px); left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 99px; background: var(--kinh); border: 1px solid var(--vien); font-size: 14px; font-weight: 700; white-space: nowrap; max-width: calc(100% - 120px); }
.nhan-noi svg { font-size: 17px; color: var(--kem); }
.nhan-noi span { overflow: hidden; text-overflow: ellipsis; }
.nhan-noi i { width: 5px; height: 5px; border-radius: 50%; background: var(--xanh); box-shadow: 0 0 6px var(--xanh); }
.nhan-noi b { font-variant-numeric: tabular-nums; }
/* điện thoại dọc: nhãn nơi dịch sang phải cho khỏi chạm nút đổi tiếng ở góc trái ("Tiếng Việt" dài hơn "日本語") */
@media (max-width: 480px) { .nhan-noi { left: calc(50% + 34px); max-width: calc(100% - 136px); padding: 0 12px; } }
.cot-phai { position: absolute; right: 10px; top: calc(var(--tren) + 104px); display: flex; flex-direction: column; gap: 10px; }
.live-chip { position: absolute; left: 10px; top: calc(var(--tren) + 104px); height: 26px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 8px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.08em; color: #fff; background: linear-gradient(90deg, #25d8e8, #fe2c55); box-shadow: 0 4px 12px rgba(254, 44, 85, 0.35); }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: nhay 1.2s infinite; }

.duoi { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 8px calc(var(--duoi) + 8px); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.goi-y { max-width: min(360px, calc(100% - 20px)); padding: 6px 14px 7px; border-radius: 16px; text-align: center; font-size: 13.5px; font-weight: 700; line-height: 1.3;
  background: rgba(52, 42, 30, 0.6); border: 1px solid var(--vien); transition: opacity 0.3s; pointer-events: none !important; }
.goi-y:empty, .goi-y.tat { opacity: 0; }
.goi-y[data-anh="bun"], .goi-y[data-anh="sach"] { position: relative; padding-left: 46px; text-align: left; }
.goi-y[data-anh="bun"]::before, .goi-y[data-anh="sach"]::before { content: ''; position: absolute; left: 9px; top: 50%; width: 32px; height: 32px; transform: translateY(-50%);
  background: center / contain no-repeat url(anh_codex/cu_sen_bun.png); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
.goi-y[data-anh="sach"]::before { background-image: url(anh_codex/cu_sen.png); }
.nut-ban { display: inline-flex; align-items: center; gap: 9px; height: 48px; padding: 0 18px 0 12px; border-radius: 99px; font-weight: 800; font-size: 15px; color: #3a2a0e;
  background: linear-gradient(180deg, #ffe08f, #f0b440); box-shadow: 0 8px 22px rgba(240, 170, 50, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6); animation: goi 1.6s ease-in-out infinite; }
.nut-ban img { width: 28px; height: 28px; filter: brightness(0.35) sepia(1) saturate(2) hue-rotate(-10deg); }
.nut-ban span { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
@keyframes goi { 50% { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(240, 170, 50, 0.55); } }
.thanh { width: 100%; max-width: 560px; display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; }
.phu-trai { display: flex; gap: 7px; align-items: center; padding-bottom: 20px; }
.nut-nho { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--kem); background: var(--kinh); border: 1px solid var(--vien); }
.nut-nho:active { transform: scale(0.92); }
.cham { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--do); box-shadow: 0 0 0 2px rgba(50, 40, 28, 0.9); }
.hd { display: flex; gap: 5px; flex: 1; justify-content: center; }
.hd button { width: calc(var(--hd) + 6px); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 13.5px; font-weight: 800; line-height: 1.12; text-shadow: 0 1px 6px rgba(30, 20, 8, 0.75); }
.hd button > span .c2 { font-size: 11px; font-weight: 600; }
.tron { position: relative; width: var(--hd); height: var(--hd); border-radius: 50%; display: grid; place-items: center; background: var(--kinh); border: 1.5px solid rgba(255, 238, 205, 0.32);
  box-shadow: 0 6px 16px rgba(30, 20, 8, 0.28); transition: transform 0.12s, background 0.25s, box-shadow 0.25s; }
.hd button:active .tron { transform: scale(0.92); }
.anh { display: block; width: 58%; height: 58%; background: var(--kem); -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.a-dao { -webkit-mask-image: url(anh_codex/nut_dao.png); mask-image: url(anh_codex/nut_dao.png); }
.a-xit { -webkit-mask-image: url(anh_codex/nut_xit_nuoc.png); mask-image: url(anh_codex/nut_xit_nuoc.png); }
.a-nho { -webkit-mask-image: url(anh_codex/nut_nho.png); mask-image: url(anh_codex/nut_nho.png); }
.a-nhat { -webkit-mask-image: url(anh_codex/nut_nhat.png); mask-image: url(anh_codex/nut_nhat.png); }
.a-ban-do { -webkit-mask-image: url(anh_codex/nut_ban_do.png); mask-image: url(anh_codex/nut_ban_do.png); }
.hd button.ke .tron { background: linear-gradient(180deg, #b9de8a, #6f9e4c); border-color: rgba(240, 255, 220, 0.75); box-shadow: 0 0 0 4px rgba(166, 207, 127, 0.3), 0 8px 22px rgba(90, 140, 50, 0.45); animation: ke 1.4s ease-in-out infinite; }
.hd button.ke .anh { background: #fffbea; }
.hd button.dang .tron::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--vang); animation: quay 0.8s linear infinite; }
@keyframes ke { 50% { box-shadow: 0 0 0 8px rgba(166, 207, 127, 0.12), 0 8px 22px rgba(90, 140, 50, 0.45); } }
@keyframes quay { to { transform: rotate(360deg); } }
.nut-ban-do { width: 58px; height: 58px; margin-bottom: 20px; border-radius: 18px; display: grid; place-items: center; background: var(--kinh); border: 1.5px solid rgba(255, 238, 205, 0.32); flex: none; }
.nut-ban-do .anh { width: 66%; height: 66%; background: var(--kem); }
/* điện thoại dọc: trò chuyện + cảm xúc xếp thành cột bên trái để 4 nút hoạt động to, không nút nào tràn mép (390 / 375 / 360 px) */
@media (max-width: 440px) {
  :root { --hd: 56px; }
  .phu-trai { flex-direction: column; gap: 8px; padding-bottom: 24px; }
  .nut-nho { width: 40px; height: 40px; font-size: 20px; }
  .nut-ban-do { width: 50px; height: 50px; margin-bottom: 26px; border-radius: 16px; }
  .hd { gap: 3px; } .hd button { width: calc(var(--hd) + 4px); font-size: 13px; } .thanh { gap: 4px; }
}
@media (max-width: 372px) { :root { --hd: 52px; } .hd button { font-size: 12.5px; } }
@media (max-width: 352px) {
  :root { --hd: 50px; }
  .phu-trai { position: absolute; left: 8px; bottom: calc(var(--duoi) + 124px); flex-direction: column; padding: 0; }
  .nut-ban-do { position: absolute; right: 8px; bottom: calc(var(--duoi) + 124px); margin: 0; }
  .thanh { justify-content: center; }
  .hd button { width: 64px; font-size: 12px; }
  .vien-tren > button { min-width: 30px; font-size: 17px; }
  .vien-tren .so-chip { font-size: 13px; padding: 0 4px; }
  .nhan-noi { left: calc(50% + 40px); max-width: calc(100% - 152px); font-size: 13px; }
}
@media (max-width: 330px) { .vien-tren #nutNhac, .vien-tren #nutLoa { display: none; } }

/* ---------------- bảng trượt từ dưới lên */
.man-mo { position: fixed; inset: 0; z-index: 8; background: rgba(20, 14, 6, 0.32); }
.bang { position: fixed; left: 50%; bottom: 0; z-index: 9; width: min(460px, 100%); max-height: min(78vh, 680px); overflow-y: auto; transform: translateX(-50%);
  padding: 14px 16px calc(var(--duoi) + 16px); border-radius: 24px 24px 0 0; background: var(--kinh-dam); border: 1px solid var(--vien); border-bottom: 0;
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
  box-shadow: 0 -12px 40px rgba(20, 12, 4, 0.4); animation: truotLen 0.26s ease-out; }
@keyframes truotLen { from { transform: translate(-50%, 30px); opacity: 0; } }
.bang.nho { width: min(340px, calc(100% - 20px)); bottom: calc(var(--duoi) + 96px); left: 12px; transform: none; border-radius: 20px; border-bottom: 1px solid var(--vien); animation: hienCx 0.2s ease-out; padding: 10px; }
@keyframes hienCx { from { opacity: 0; transform: translateY(10px); } }
.bang-dau { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.bang-dau b { font-size: 17px; }
.bang-dau b .c2 { font-size: 12px; }
.nut-dong { position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: rgba(255, 240, 220, 0.08); flex: none; }
.nut-dong::after { content: ''; position: absolute; inset: -5px; border-radius: inherit; }
.bang h3 { margin: 14px 2px 8px; font-size: 13.5px; color: var(--chu-mo); display: flex; gap: 8px; align-items: baseline; }
.bang h3 .c1, .bang h3 .c2 { display: inline; }
.bang-giai { margin: 2px 2px 10px; font-size: 12.5px; line-height: 1.5; color: var(--chu-mo); }
.vi-sap { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 16px; background: rgba(255, 240, 220, 0.06); }
.vi-sap .so-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 20px; font-weight: 800; }
.vi-sap .nut { flex-direction: row; }
.vi-sap .nut span { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.vi-sap .nut img { filter: brightness(0.3) sepia(1) saturate(1.5) hue-rotate(40deg); }
#shXa { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: #ffd9a0; }
#shXa > span .c1, #shXa > span .c2 { display: inline; } #shXa > span .c2 { margin-left: 4px; }
.ds-mon { display: grid; gap: 8px; }
.mon { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: rgba(255, 240, 220, 0.06); border: 1px solid rgba(255, 240, 220, 0.08); }
.mon .hinh-mon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: rgba(166, 207, 127, 0.16); flex: none; }
.mon .hinh-mon .anh { width: 66%; height: 66%; }
.mon .hinh-mon img { width: 36px; height: 36px; }
.mon .ten-mon { flex: 1; min-width: 0; font-size: 14px; font-weight: 800; line-height: 1.2; }
.mon .ten-mon small { display: block; font-size: 11.5px; font-weight: 600; color: var(--chu-mo); margin-top: 2px; }
.mon .nut { min-width: 86px; flex-direction: column; gap: 0; padding: 7px 10px; font-size: 13px; line-height: 1.15; }
.mon .nut .c2 { font-size: 10.5px; }
.mon .nut.chinh .gia { display: inline-flex; align-items: center; gap: 3px; }
.mon .nut:disabled { opacity: 0.5; }
.ds-mau { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 10px; }
.mau-mon { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 5px; border-radius: 12px; background: rgba(255, 240, 220, 0.05); border: 2px solid transparent; font-size: 10.5px; font-weight: 800; color: var(--chu-mo); }
.mau-mon i { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.22), 0 2px 4px rgba(0, 0, 0, 0.25); }
.mau-mon.mac { border-color: var(--vang); color: var(--chu); }
.mau-mon .gia-nho { display: inline-flex; gap: 2px; align-items: center; }
.mau-mon .gia-nho svg { font-size: 11px; color: var(--vang); }
.nhan-mau { font-size: 12px; color: var(--chu-mo); margin: 2px 2px 6px; display: flex; gap: 6px; }
#banDo { display: block; width: 100%; height: auto; border-radius: 16px; background: #6d8a4a; touch-action: none; }
.ds-bang { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ds-bang li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(255, 240, 220, 0.06); font-weight: 700; font-size: 14px; }
.ds-bang li.minh { background: rgba(166, 207, 127, 0.2); }
.ds-bang .h { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: rgba(255, 240, 220, 0.1); flex: none; }
.ds-bang li:nth-child(1) .h { background: #f4c25b; color: #3a2a0e; } .ds-bang li:nth-child(2) .h { background: #d9dde2; color: #333; } .ds-bang li:nth-child(3) .h { background: #d8955a; color: #33200e; }
.ds-bang .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-bang .s { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.ds-bang .s img { width: 20px; height: 20px; }
.trong { text-align: center; padding: 18px; color: var(--chu-mo); font-size: 13px; }
.hang-toi { text-align: center; font-weight: 700; color: var(--xanh); font-size: 13.5px; margin: 10px 0 0; }
.dong-cd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 4px; border-bottom: 1px solid rgba(255, 240, 220, 0.08); font-weight: 700; font-size: 14px; }
.dong-cd > span .c2 { font-size: 11px; }
.chon-2 { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(255, 240, 220, 0.06); }
.chon-2 button { padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--chu-mo); }
.chon-2 button.chon { background: rgba(166, 207, 127, 0.3); color: var(--chu); }
.cong-tac { position: relative; display: inline-block; width: 48px; height: 28px; }
.cong-tac input { position: absolute; opacity: 0; inset: 0; }
.cong-tac i { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 240, 220, 0.18); transition: background 0.2s; }
.cong-tac i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.cong-tac input:checked + i { background: var(--xanh-dam); }
.cong-tac input:checked + i::after { transform: translateX(20px); }
input[type=range] { width: 150px; accent-color: var(--xanh); }
.ds-chat { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; padding: 4px 2px 8px; }
.dong-chat { font-size: 13.5px; line-height: 1.4; word-break: break-word; }
.dong-chat b { color: var(--xanh); margin-right: 6px; }
.dong-chat.lv b { color: #6fe6f0; }
.o-chat { display: flex; gap: 8px; margin-top: 6px; }
.o-chat input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--vien); background: rgba(255, 245, 225, 0.08); color: var(--chu); outline: none; font-size: 15px; }
.o-chat .nut { width: 48px; padding: 0; }
.luoi-cx { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.luoi-cx button { height: 52px; border-radius: 14px; font-size: 28px; background: rgba(255, 240, 220, 0.06); }
.luoi-cx button:active { transform: scale(0.9); }
.ds-ti-le { display: grid; gap: 8px; }
.dong-tl { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 240, 220, 0.06); font-size: 14px; font-weight: 700; }
.dong-tl .hinh-tl { position: relative; width: 44px; height: 40px; flex: none; }
.dong-tl .hinh-tl img { position: absolute; left: 0; top: 0; width: 40px; height: 40px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3)); }
.dong-tl.doi .hinh-tl img { width: 34px; height: 34px; }
.dong-tl.doi .hinh-tl img + img { left: 11px; top: 7px; transform: rotate(-24deg); }
.dong-tl .t { flex: 1; } .dong-tl .t .c2 { font-size: 11px; }
.dong-tl .pt { font-size: 18px; font-weight: 800; color: var(--vang); font-variant-numeric: tabular-nums; }
.dong-tl.vang img { filter: sepia(1) saturate(4) hue-rotate(-12deg) brightness(1.1) drop-shadow(0 0 6px rgba(255, 210, 90, 0.55)); }
.ghi-dot { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--chu-mo); margin: 6px 2px 0; }
.ghi-dot img { width: 34px; height: 34px; flex: none; }
.ghi-dot .c2 { font-size: 10.5px; }

/* băng rôn quà live, thông báo */
.bang-qua { position: fixed; z-index: 7; left: 50%; top: calc(var(--tren) + 150px); transform: translateX(-50%); width: min(360px, calc(100% - 24px)); padding: 10px 14px; border-radius: 18px;
  text-align: center; font-weight: 800; font-size: 14.5px; line-height: 1.35; color: #fff; background: linear-gradient(90deg, rgba(37, 216, 232, 0.92), rgba(254, 44, 85, 0.92));
  box-shadow: 0 10px 30px rgba(254, 44, 85, 0.35); animation: hienQua 0.4s cubic-bezier(.2, 1.4, .4, 1); pointer-events: none; }
.bang-qua .c2 { font-size: 12px; }
@keyframes hienQua { from { transform: translate(-50%, -20px) scale(0.85); opacity: 0; } }
.thong-bao { position: fixed; z-index: 10; left: 50%; top: calc(var(--tren) + 108px); transform: translate(-50%, -10px); max-width: min(360px, calc(100% - 40px)); padding: 9px 16px; border-radius: 16px;
  font-size: 14px; font-weight: 700; line-height: 1.35; text-align: center; background: var(--kinh-dam); border: 1px solid var(--vien); box-shadow: 0 8px 26px rgba(20, 12, 4, 0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.thong-bao.hien { opacity: 1; transform: translate(-50%, 0); }
.thong-bao.vui { background: linear-gradient(180deg, rgba(120, 160, 70, 0.95), rgba(80, 120, 50, 0.95)); }
.thong-bao.vang { background: linear-gradient(180deg, rgba(240, 190, 70, 0.96), rgba(200, 140, 30, 0.96)); color: #3a2a0e; }

/* máy tính / màn ngang: thanh dưới gọn giữa, bảng hiện bên phải */
@media (min-width: 760px) and (min-height: 520px) {
  :root { --hd: 64px; }
  .bang { left: auto; right: 16px; bottom: 16px; transform: none; border-radius: 24px; border-bottom: 1px solid var(--vien); width: 420px; animation: hienCx 0.2s ease-out; }
  .bang.nho { left: auto; right: auto; left: calc(50% - 300px); bottom: 110px; }
  .man-mo { background: rgba(20, 14, 6, 0.12); }
  .goi-y { font-size: 14.5px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root { --hd: 50px; }
  .nhan-noi { top: calc(var(--tren) + 10px); }
  .cot-phai { top: calc(var(--tren) + 58px); flex-direction: row; right: auto; left: 64px; }
  .tren-trai { flex-direction: row; }
  .tren-trai .vien-nn { position: static; }
  .live-chip { top: calc(var(--tren) + 62px); left: auto; right: 12px; }
  .duoi { gap: 4px; }
  .goi-y { font-size: 12.5px; padding: 4px 12px; }
  .hd button { font-size: 12.5px; gap: 2px; line-height: 1.05; }
  .hd button > span .c2 { font-size: 10px; }
  .duoi { padding-bottom: calc(var(--duoi) + 4px); }
  .hd { gap: 8px; }
  .hd button { width: auto; min-width: calc(var(--hd) + 8px); white-space: nowrap; }
  .phu-trai, .nut-ban-do { padding-bottom: 6px; margin-bottom: 6px; }
  .bang { max-height: 88vh; }
}
/* cầm ngang hẹp (667 / 740 / 780 px): nhãn nơi đặt ngay sau cụm nút trái, không chen vào thanh trên bên phải */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 800px) {
  .nhan-noi { left: var(--le-noi, 172px); transform: none; max-width: calc(100% - var(--le-noi, 172px) - 284px); padding: 0 11px; font-size: 13px; }
}
