:root {
  --wood: #6d4526;
  --wood-d: #4a2d18;
  --wood-l: #a8723f;
  --paper: #fff4d6;
  --paper-2: #f6e3b4;
  --ink: #2b1d16;
  --muted: #7a6152;
  --red: #b23a2a;
  --red-d: #7a2318;
  --green: #2e7d32;
  --tea: #c7862a;
  --shadow: 0 6px 0 rgba(40, 22, 10, 0.35), 0 14px 30px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b2f2a; color: var(--ink);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; image-rendering: pixelated; }
.hidden { display: none !important; }
a { color: var(--red); }
button { font: inherit; cursor: pointer; }

/* Nút kiểu gỗ */
.btn { border: 2px solid var(--wood-d); background: linear-gradient(#fff9e8, var(--paper-2)); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; box-shadow: 0 3px 0 var(--wood-d); font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: transform .05s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-d); }
.btn.warm { background: linear-gradient(#e65a43, var(--red)); color: #fff; border-color: var(--red-d); box-shadow: 0 3px 0 var(--red-d); }
.btn.green { background: linear-gradient(#4caf50, var(--green)); color: #fff; border-color: #1b5e20; box-shadow: 0 3px 0 #1b5e20; }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn.big { padding: 10px 18px; font-size: 17px; width: 100%; justify-content: center; }
.btn.on { background: linear-gradient(#ffe39a, #f3c623); }
.btn:disabled { opacity: .55; cursor: default; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px; pointer-events: none; flex-wrap: wrap; }
#hud > * { pointer-events: auto; }
.brand { background: rgba(122, 35, 24, .92); color: var(--paper); padding: 6px 12px; border-radius: 10px; border: 2px solid #4a150e;
  box-shadow: 0 3px 0 #4a150e; display: flex; gap: 8px; align-items: center; }
.chip { background: rgba(255, 244, 214, .18); border-radius: 99px; padding: 1px 8px; font-size: 13px; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { background: var(--red); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 12px; min-width: 18px; text-align: center; }

#chatbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); width: min(680px, calc(100% - 20px));
  display: flex; flex-direction: column; gap: 6px; }
.emotes { display: flex; gap: 4px; justify-content: center; }
.emotes button { background: rgba(255, 244, 214, .9); border: 2px solid var(--wood-d); border-radius: 8px; font-size: 18px; padding: 2px 6px; box-shadow: 0 2px 0 var(--wood-d); }
#chatForm { display: flex; gap: 6px; }
#chatForm input { flex: 1; min-width: 0; }
#help { position: fixed; left: 12px; bottom: 110px; background: rgba(20, 20, 28, .6); color: #fff; padding: 4px 10px; border-radius: 8px; font-size: 13px; pointer-events: none; }

input, textarea, select { font: inherit; color: var(--ink); background: #fffdf6; border: 2px solid var(--wood-l); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(199, 134, 42, .45); border-color: var(--wood); }
textarea { resize: vertical; min-height: 140px; }

/* Overlay & panel */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(15, 12, 10, .45); overflow-y: auto; z-index: 10; }
#auth { background: radial-gradient(ellipse at top, rgba(255, 180, 90, .25), rgba(15, 12, 10, .65)); }
.panel { background: var(--paper); border: 4px solid var(--wood); border-radius: 14px; box-shadow: var(--shadow); position: relative;
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(168, 114, 63, .07) 27px 28px); }
.auth-panel { width: min(560px, 100%); padding: 20px 22px; margin: auto; }
.modal-panel { width: min(680px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px 22px; margin: auto; }
.close { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 20px; color: var(--muted); }
.auth-hero { text-align: center; }
.logo { font-size: 46px; line-height: 1; }
h1 { margin: 4px 0 2px; color: var(--red-d); font-size: 28px; letter-spacing: .5px; }
h2 { margin: 0 0 10px; color: var(--red-d); font-size: 21px; padding-right: 26px; }
h3 { margin: 14px 0 6px; font-size: 16px; color: var(--wood-d); }
.tag { margin: 0; color: var(--muted); }
.promises { padding: 0; list-style: none; margin: 14px 0; display: grid; gap: 6px; font-size: 14px; }
.promises li { background: rgba(255, 255, 255, .55); border-radius: 8px; padding: 6px 10px; border: 1px dashed var(--wood-l); }
.tabs { display: flex; gap: 4px; border-bottom: 3px solid var(--wood); margin-bottom: 12px; }
.tab { flex: 1; background: var(--paper-2); border: 2px solid var(--wood); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 7px; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--wood); color: var(--paper); }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.form label.check input { width: auto; margin-top: 4px; }
.row { display: flex; gap: 6px; align-items: center; }
.grow { flex: 1; min-width: 0; display: grid; gap: 8px; }
.err { color: var(--red); margin: 0; min-height: 1em; font-weight: 600; font-size: 14px; }
.fine { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; text-align: center; }

.avatar-row { display: flex; gap: 12px; align-items: flex-start; }
.avatar-row canvas { background: linear-gradient(#cfe8ff, #f6e3b4 70%, #c96f4a 70%); border: 3px solid var(--wood); border-radius: 10px; image-rendering: pixelated; flex: none; width: 96px; height: 120px; }
.avatar-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 10px; font-size: 13px; }
.avatar-editor .opt { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.avatar-editor .opt span { font-weight: 600; }
.avatar-editor .opt div { display: flex; align-items: center; gap: 4px; }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--wood-d); display: inline-block; }
.avatar-editor .opt em { font-style: normal; min-width: 64px; text-align: center; font-size: 12px; }

/* Tâm sự */
.post { background: #fffdf6; border: 2px solid var(--wood-l); border-radius: 10px; padding: 10px 12px; margin: 10px 0; box-shadow: 0 3px 0 rgba(109, 69, 38, .25); }
.post.clickable { cursor: pointer; }
.post.clickable:hover { border-color: var(--wood); }
.post .meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.post .who { font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.post .who canvas, .comment .meta canvas { width: 20px; height: 30px; image-rendering: pixelated; vertical-align: middle; }
.post .content { white-space: pre-wrap; word-wrap: break-word; margin: 6px 0; }
.post .content.clamp { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.mood { background: var(--paper-2); border-radius: 99px; padding: 0 8px; font-size: 12.5px; color: var(--wood-d); font-weight: 600; }
.resolved { background: #dff3d8; color: #1b5e20; border-radius: 99px; padding: 0 8px; font-size: 12.5px; font-weight: 700; }
.reacts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.reacts .btn { font-size: 13.5px; padding: 3px 10px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 13px; padding: 2px 4px; }
.comment { border-left: 4px solid var(--tea); background: rgba(255, 255, 255, .7); padding: 6px 10px; border-radius: 0 8px 8px 0; margin: 8px 0; }
.comment.author { border-left-color: var(--green); }
.comment .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.comment .content { white-space: pre-wrap; word-wrap: break-word; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }
.empty .big { font-size: 40px; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.suggest button { background: var(--paper-2); border: 1px solid var(--wood-l); border-radius: 99px; font-size: 13px; padding: 2px 10px; }
.choices { display: flex; gap: 6px; flex-wrap: wrap; }
.choices label { display: inline-flex; align-items: center; gap: 4px; background: var(--paper-2); border: 2px solid transparent; border-radius: 99px; padding: 3px 10px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.choices input { display: none; }
.choices label:has(input:checked) { border-color: var(--wood); background: #ffe39a; }
.counter { text-align: right; font-size: 12px; color: var(--muted); }

.support { background: #fff; border: 3px solid var(--red); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.support h3 { color: var(--red); margin-top: 4px; }
.support ul { margin: 6px 0; padding-left: 20px; }
.support a { font-weight: 700; }

.npc { display: flex; gap: 12px; align-items: flex-start; }
.npc canvas { width: 80px; height: 100px; image-rendering: pixelated; flex: none; }
.npc .say { background: #fff; border: 2px solid var(--wood-l); border-radius: 12px; padding: 10px 12px; position: relative; }
.npc-menu { display: grid; gap: 6px; margin-top: 12px; }

.notif { padding: 8px 10px; border-bottom: 1px dashed var(--wood-l); cursor: pointer; }
.notif.unread { background: #fff7d1; }
.notif small { color: var(--muted); display: block; }

#toasts { position: fixed; top: 64px; right: 12px; display: grid; gap: 6px; z-index: 30; width: min(320px, calc(100% - 24px)); }
.toast { background: var(--paper); border: 3px solid var(--wood); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); animation: pop .25s ease-out; font-size: 14px; }
.toast.warn { border-color: var(--red); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

.admin-item { border: 2px solid var(--wood-l); border-radius: 8px; padding: 8px; margin: 8px 0; background: #fff; font-size: 14px; }

@media (max-width: 720px) {
  nav .btn span:not(.badge) { display: none; }
  .brand b { display: none; }
  #help { display: none; }
  .modal-panel, .auth-panel { padding: 16px 14px; }
  .avatar-row canvas { width: 72px; height: 90px; }
  #chatForm .btn { padding: 6px 10px; }
}
@media (max-width: 720px) {
  #toasts { top: auto; bottom: 120px; right: 50%; transform: translateX(50%); }
}

/* Nhãn chữ trong không gian 3D */
.labels3d { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.lb { position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 600; font-size: 12px; will-change: transform; }
.lb.name { background: rgba(20, 20, 28, .62); color: #fff; padding: 1px 8px; border-radius: 99px; }
.lb.name.me { background: rgba(46, 125, 50, .9); }
.lb.npcname { background: rgba(122, 35, 24, .85); color: #fff4d6; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; }
.lb.tbl { background: rgba(40, 28, 20, .6); color: #fff4d6; padding: 2px 9px; border-radius: 8px; font-size: 12px; }
.lb.tbl.hov { background: rgba(255, 244, 214, .97); color: #5a2d14; box-shadow: 0 0 0 2px #f3c623; }
.lb.bubble { background: #fff; color: #2b1d16; padding: 6px 10px; border-radius: 12px; font-weight: 500; font-size: 13px;
  white-space: normal; width: max-content; max-width: 220px; text-align: center; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.lb.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
.lb.emote { font-size: 26px; }
.lb.prompt { background: rgba(255, 244, 214, .96); color: #5a2d14; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 13px; box-shadow: 0 2px 0 rgba(90,45,20,.4); }
#hud, #chatbar, #help, #toasts { z-index: 2; }

/* ===== Thực đơn nước – bảng đen viết phấn ===== */
.menu-board { background: #22392c; background-image: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.07), transparent 60%), repeating-linear-gradient(115deg, rgba(255,255,255,.015) 0 3px, transparent 3px 9px);
  border: 10px solid #7a4a24; border-radius: 10px; box-shadow: inset 0 0 30px rgba(0,0,0,.45); padding: 16px 14px 10px; margin: -6px -6px 0; color: #f4f1e6; }
.chalk-title { color: #fff8e0; text-align: center; font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive; font-size: 24px; padding: 0; text-shadow: 0 0 2px rgba(255,255,255,.4); }
.chalk-sub, .chalk-foot { text-align: center; margin: 4px 0 10px; color: #d9e6d4; font-size: 14px; }
.chalk-foot { font-size: 12px; opacity: .8; margin-top: 12px; }
.mood-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.chip-btn { background: transparent; color: #f4f1e6; border: 2px dashed rgba(244,241,230,.6); border-radius: 99px; padding: 3px 10px; font-size: 13.5px; font-weight: 600; }
.chip-btn.on { background: #f3c623; color: #3a2216; border-style: solid; border-color: #f3c623; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; }
.menu-item { position: relative; display: grid; justify-items: center; gap: 2px; text-align: center; padding: 12px 8px 10px; background: rgba(255,255,255,.05);
  color: #f4f1e6; border: 2px solid rgba(244,241,230,.35); border-radius: 10px; transition: transform .1s, background .1s; }
.menu-item:hover, .menu-item:focus-visible { transform: translateY(-2px); background: rgba(255,255,255,.12); border-color: #fff8e0; }
.menu-item.rec { border-color: #f3c623; box-shadow: 0 0 0 2px rgba(243,198,35,.35); }
.mi-icon { font-size: 34px; line-height: 1.1; }
.mi-name { font-family: "Comic Sans MS", "Segoe Print", cursive; font-weight: 700; font-size: 15.5px; color: #fff8e0; }
.mi-price { font-weight: 800; color: #f3c623; font-size: 13px; }
.mi-tag { font-size: 12.5px; color: #cfe0c8; }
.rec-badge { position: absolute; top: -9px; right: -6px; background: #f3c623; color: #3a2216; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; transform: rotate(6deg); }

.served { display: flex; gap: 12px; align-items: center; margin: 6px 0 10px; }
.served-icon { font-size: 54px; animation: serve .6s ease-out; }
@keyframes serve { from { transform: translateY(-30px) rotate(-15deg); opacity: 0; } }
.served h2 { margin: 0 0 2px; }
.center { text-align: center; justify-content: center; }
.done-box { background: #eef7e8; border: 2px solid #8bc34a; border-radius: 12px; padding: 14px 16px; text-align: center; line-height: 1.7; animation: pop .3s ease-out; }
.say-box { background: #fff; border: 2px solid var(--wood-l); border-radius: 12px; padding: 12px 14px; font-size: 16px; line-height: 1.6; margin-bottom: 10px; }
.say-box small { display: block; text-align: right; color: var(--muted); }
.say-box.joke { min-height: 90px; }

textarea.pour { animation: pour 1.3s ease-in forwards; }
@keyframes pour { 40% { transform: rotate(-4deg); color: #c8862a; } 100% { transform: translateY(60px) rotate(-12deg) scale(.6); opacity: 0; filter: blur(4px); } }

.breath { display: grid; place-items: center; height: 230px; }
.breath-circle { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; text-align: center; font-weight: 700; color: #5a2d14;
  background: radial-gradient(circle at 35% 30%, #ffe7b3, #e9a845 70%); box-shadow: 0 0 0 10px rgba(233,168,69,.2), 0 0 40px rgba(233,168,69,.5); transition: transform 4s ease-in-out; }

.ground-step { text-align: center; padding: 10px; }
.g-num { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 800; font-size: 20px; }
.g-icon { font-size: 40px; margin-left: 8px; vertical-align: middle; }
.ground-step p { font-size: 17px; margin: 10px 0; }
.progress { height: 8px; background: var(--paper-2); border-radius: 99px; overflow: hidden; margin: 6px 0 12px; }
.progress i { display: block; height: 100%; width: 0; background: #8bc34a; transition: width .4s; }

.plan-row { display: flex !important; gap: 8px; align-items: center; }
.plan-row input[type=text], .plan-row input:not([type]) { flex: 1; }
.plan-row input[type=checkbox] { width: 20px; height: 20px; flex: none; margin: 0 !important; }

.jar { display: flex; flex-wrap: wrap; gap: 8px; max-height: 240px; overflow-y: auto; padding: 4px; }
.jar-note { background: #fff7c2; border-radius: 4px; padding: 6px 10px; font-size: 14px; box-shadow: 0 2px 0 rgba(0,0,0,.12); transform: rotate(-1deg); max-width: 100%; }
.jar-note:nth-child(even) { background: #e3f4ff; transform: rotate(1deg); }
.jar-note small { display: block; color: var(--muted); font-size: 11px; }

.rest { text-align: center; padding: 10px; }
.rest-time { font-size: 54px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.rest-step { font-size: 17px; min-height: 52px; }

.gift-row { border: 2px solid var(--wood-l); border-radius: 10px; padding: 8px 10px; margin: 8px 0; background: #fffdf6; }
.gift-row.gifted { opacity: .55; }
.gift-row.gifted .gift-drinks { pointer-events: none; }
.gift-text { font-size: 14px; margin-bottom: 6px; }
.gift-drinks { display: flex; flex-wrap: wrap; gap: 4px; }
.gift-drinks .btn { font-size: 17px; padding: 2px 8px; }

/* ===== Ví xu, gói Cô Tư AI, mời nước ===== */
.wallet { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; background: rgba(0,0,0,.2); border-radius: 99px; padding: 4px 12px; margin: 4px auto 6px; width: fit-content; color: #fff8e0; }
.wallet .tag { color: #cfe0c8; }
.rec-badge.own { background: #8bc34a; color: #12300f; }
.served-tabs { margin: 4px 0 12px; }
.served-tabs .tab { font-size: 13.5px; padding: 6px 4px; }

.ai-buy { text-align: center; }
.ai-buy .btn.big { max-width: 360px; margin: 6px auto; }
.ai-fine { text-align: left; margin-top: 10px; }
.ai-chat { display: grid; gap: 8px; }
.ai-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; gap: 6px; }
.ai-log { background: #f3ead2; border: 2px solid var(--wood-l); border-radius: 12px; padding: 10px; height: min(46vh, 420px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; animation: pop .2s ease-out; }
.ai-msg.bot { background: #fff; border: 1px solid #e3d3ad; align-self: flex-start; border-bottom-left-radius: 4px; }
.ai-msg.bot::before { content: "🍵 Cô Tư"; display: block; font-size: 11.5px; font-weight: 700; color: var(--red-d); }
.ai-msg.me { background: #d9f0d0; align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-msg.typing { color: var(--muted); font-style: italic; }
.ai-msg.typing::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.ai-msg.err { background: #fde2e0; border-color: #f2a9a2; }
.ai-form { display: flex; gap: 6px; align-items: flex-end; }
.ai-form textarea { min-height: 48px; flex: 1; resize: none; }

.treat-form { display: grid; gap: 8px; margin-top: 8px; background: #fffdf6; border: 2px dashed var(--wood-l); border-radius: 10px; padding: 10px; }
.drink-pick, .qty-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 600; }
.drink-pick input, .qty-pick input { display: none; }
.drink-pick span { display: inline-grid; place-items: center; width: 42px; height: 42px; font-size: 24px; border-radius: 10px; border: 2px solid var(--wood-l); background: #fff; cursor: pointer; }
.drink-pick input:checked + span { border-color: var(--red); background: #ffe39a; transform: scale(1.08); }
.qty-pick span { display: inline-block; padding: 3px 10px; border-radius: 99px; border: 2px solid var(--wood-l); background: #fff; cursor: pointer; font-size: 13.5px; }
.qty-pick input:checked + span { border-color: var(--red); background: #ffe39a; }
.treat-done { background: #eef7e8; border: 2px solid #8bc34a; border-radius: 12px; padding: 10px 12px; margin-top: 8px; display: grid; gap: 6px; animation: pop .3s ease-out; }
.td-head { font-weight: 800; font-size: 16px; }
.reply-bubble { position: relative; background: #fff; border: 2px solid #f3c623; border-radius: 14px; padding: 8px 12px; font-size: 15px; }
.counters { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.counters.big .tchip { font-size: 16px; padding: 3px 10px; }
.tchip { background: #fff3c4; border: 1px solid #e8c95a; border-radius: 99px; padding: 0 8px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.treat-box { background: #fffaf0; border: 2px solid #f0d9a0; border-radius: 12px; padding: 8px 12px 12px; margin: 10px 0; display: grid; gap: 8px; }
.treat-box h3 { margin: 4px 0 0; }
.treat-notes { display: grid; gap: 4px; max-height: 200px; overflow-y: auto; }
.tnote { font-size: 14px; background: #fff; border-radius: 8px; padding: 4px 8px; }
.tnote small, .notif-msg { color: var(--muted); }
.notif-msg { font-size: 14px; color: var(--ink); margin: 2px 0; }

/* ===== Ví mới: miễn phí / phiếu / khay / mua xu Telegram ===== */
.wallet-box { display: grid; gap: 6px; margin: 4px 0 8px; }
.wallet-box .tag { color: #cfe0c8; }
.wallet.free { flex-direction: column; gap: 0; border-radius: 12px; text-align: center; background: rgba(243,198,35,.18); }
.tray { text-align: center; color: #fff8e0; font-size: 14px; display: flex; gap: 4px; justify-content: center; align-items: center; flex-wrap: wrap; }
.tray .tchip { background: rgba(255,255,255,.85); color: #3a2216; }
.need-xu { margin: 8px auto; display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; font-weight: 600; color: var(--red-d); }
.pay-note { margin: 0; font-size: 13.5px; color: var(--green); font-weight: 600; }
.pay-note.warn { color: var(--red); }
a.btn { text-decoration: none; }

/* ===== Gọi 1 ly tặng kèm 1 ly, khay để tặng ===== */
.order-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; background: #fff7e0; border: 2px solid #f0d9a0; border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; min-height: 48px; }
.ob-status { font-weight: 700; color: var(--green); }
.ob-tray { font-size: 14px; }
.mi-tray { font-size: 11.5px; background: rgba(255,255,255,.15); border-radius: 99px; padding: 0 8px; color: #ffe39a; }
.no-cups { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; padding: 10px; background: #fff7e0; border-radius: 10px; margin: 6px 0; }
.qty-pick input[type=number] { display: inline-block; width: 80px; padding: 4px 8px; text-align: center; font-weight: 700; }
.qty-pick .btn.small { padding: 2px 8px; }
.drink-pick span { position: relative; }
.drink-pick span i { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: 11px; background: var(--red); color: #fff; border-radius: 99px; padding: 0 5px; line-height: 1.5; }

/* ===== Chat 3 kênh ===== */
#chatbar { width: min(720px, calc(100% - 20px)); }
.chat-panel { background: rgba(255, 248, 230, .94); border: 2px solid var(--wood); border-radius: 12px; box-shadow: 0 3px 0 var(--wood-d); overflow: hidden; }
.chat-tabs { display: flex; gap: 2px; align-items: center; background: var(--wood); padding: 3px; }
.ctab { background: transparent; color: var(--paper); border: 0; border-radius: 8px; padding: 3px 10px; font-weight: 700; font-size: 13px; position: relative; }
.ctab.active { background: var(--paper); color: var(--wood-d); }
.ctab.ping::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: #f3c623; }
.ctab-wrap { display: inline-flex; align-items: center; gap: 2px; }
.ctab-wrap select { width: auto; padding: 1px 4px; font-size: 12.5px; border-radius: 6px; border-width: 1px; max-width: 150px; }
.ctab-min { margin-left: auto; background: transparent; border: 0; color: var(--paper); font-size: 16px; padding: 0 8px; }
.chat-log { height: 150px; overflow-y: auto; padding: 6px 10px; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.chat-panel.collapsed .chat-log { display: none; }
.cm { line-height: 1.4; word-wrap: break-word; }
.cm time { color: var(--muted); font-size: 11px; margin-left: 4px; }
.cm.mine .cm-nick { color: var(--green); }
.cm.sys { color: var(--muted); font-style: italic; font-size: 13px; }
.cm-nick { cursor: pointer; color: var(--red-d); }
.cm-nick:hover { text-decoration: underline; }
.dm-head { position: sticky; top: -6px; background: rgba(255, 248, 230, .98); padding: 2px 0 4px; border-bottom: 1px dashed var(--wood-l); margin-bottom: 4px; }
.conv { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: center; text-align: left; background: #fff; border: 1px solid #ecd9b0; border-radius: 8px; padding: 5px 8px; margin: 2px 0; }
.conv span:last-child { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatbar.locked #chatInput { background: #f3ead2; cursor: pointer; }
#chatbar.locked .emotes { opacity: .5; }
.gate-banner { background: #f3c623; color: #3a2216; border-radius: 10px; padding: 8px 12px; margin: 0 0 8px; text-align: center; font-size: 14.5px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
#help { bottom: 250px; }

/* ===== Menu tương tác người chơi ===== */
.pl-card { display: flex; gap: 12px; align-items: center; }
.pl-card canvas { width: 72px; height: 90px; background: linear-gradient(#cfe8ff, #f6e3b4 70%, #c96f4a 70%); border: 3px solid var(--wood); border-radius: 10px; image-rendering: pixelated; flex: none; }
.pl-card h2 { margin: 0; }
.pl-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 6px; }
.pl-actions .btn { justify-content: center; }
.cheer-box { display: grid; gap: 6px; background: #fffaf0; border: 2px dashed var(--wood-l); border-radius: 10px; padding: 10px; }
.cheer-box .row input { flex: 1; }
@media (max-width: 720px) {
  .pl-actions { grid-template-columns: repeat(2, 1fr); }
  .chat-log { height: 110px; }
  .ctab { padding: 3px 6px; }
}
#help { bottom: auto; top: 64px; left: 12px; max-width: min(520px, 45vw); font-size: 12.5px; }
.chat-log { height: 120px; }

/* ===== Cô Tư hoạt náo ===== */
.cm.cm-npc { background: #fff1c9; border-left: 4px solid var(--red); border-radius: 0 8px 8px 0; padding: 3px 8px; margin: 2px 0; }
.cm.cm-npc b { color: var(--red-d); }
.ai-tag { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .5px; background: #3b5bdb; color: #fff; border-radius: 4px; padding: 0 4px; vertical-align: middle; }
.poll { display: grid; gap: 4px; margin: 6px 0 2px; }
.poll small { color: var(--muted); font-size: 11.5px; }
.popt { position: relative; display: flex; justify-content: space-between; gap: 8px; text-align: left; background: #fff; border: 2px solid var(--wood-l); border-radius: 8px; padding: 4px 10px; overflow: hidden; font-size: 13.5px; }
.popt:hover:not(:disabled) { border-color: var(--wood); }
.popt.on { border-color: var(--red); font-weight: 700; }
.popt:disabled { cursor: default; }
.pbar { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(243, 198, 35, .35); transition: width .4s; }
.plabel, .pcount { position: relative; }
.pcount { font-weight: 700; color: var(--wood-d); }
.poll.closed .popt { opacity: .85; }
/* ---- Nạp xu ---- */
.topup { display: grid; gap: 10px; }
.topup-bal { margin: 0; font-size: 16px; }
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.pkg { border: 2px solid #e6d6b4; border-radius: 12px; padding: 10px; display: grid; gap: 6px; background: #fffaf0; text-align: center; }
.pkg-name { font-weight: 800; color: var(--red-d); }
.pkg-xu { font-size: 20px; font-weight: 800; }
.topup-pending { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pay-box { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.pay-qr { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid #e6d6b4; }
.pay-info { flex: 1; min-width: 220px; display: grid; gap: 4px; }
.crow { display: grid; grid-template-columns: 105px 1fr auto; gap: 6px; align-items: center; border-bottom: 1px dashed #e6d6b4; padding: 3px 0; }
.crow b { word-break: break-all; }
.pay-status { background: #fff3c4; border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.pay-status.ok { background: #d9f2d5; color: #1e5b22; }
.pay-status.off { background: #eee; color: #555; }
.row-c { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ledger summary { cursor: pointer; font-weight: 600; }
.lrow { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; padding: 3px 0; border-bottom: 1px dashed #e6d6b4; }
.lrow .plus { color: #2e7d32; } .lrow .minus { color: #b23a2a; }

/* ===== Điện thoại: gọn HUD, chat, biểu cảm ===== */
.emo-toggle { display: none; }
#actBtn { position: fixed; left: 50%; transform: translateX(-50%); bottom: 140px; z-index: 3; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) {
  #hud { flex-wrap: nowrap; gap: 6px; padding: max(6px, env(safe-area-inset-top)) 8px 6px; align-items: center; }
  .brand { padding: 4px 8px; flex: none; }
  .brand .olabel { display: none; }
  nav { flex-wrap: nowrap; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav .btn { padding: 5px 7px; font-size: 16px; flex: none; }
  #chatbar { width: calc(100% - 16px); bottom: max(6px, env(safe-area-inset-bottom)); gap: 4px; }
  .emo-toggle { display: inline-flex; padding: 4px 8px; font-size: 18px; }
  #chatbar .emotes { display: none; flex-wrap: wrap; }
  #chatbar.emo-open .emotes { display: flex; }
  .chat-tabs { flex-wrap: nowrap; }
  .ctab { white-space: nowrap; font-size: 12.5px; padding: 3px 6px; }
  .ctab-wrap select { max-width: 130px; }
  .chat-log { height: 96px; font-size: 13.5px; }
  /* thu gọn: vẫn hiện tin nhắn mới nhất */
  .chat-panel.collapsed .chat-log { display: flex; height: auto; max-height: 26px; overflow: hidden; justify-content: flex-end; padding: 3px 10px; }
  .chat-panel.collapsed .chat-log .cm-npc { padding: 0 6px; margin: 0; }
  #chatForm input { padding: 6px 10px; }
  .lb.bubble { max-width: 180px; font-size: 12.5px; padding: 5px 8px; }
}
@media (max-width: 720px) {
  .chat-panel.collapsed .chat-log .cm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
  .chat-panel.collapsed .chat-log .poll { display: none; }
}
/* ===== Đồng ý điều khoản, mã khôi phục, liên kết pháp lý ===== */
.consent { display: grid; gap: 6px; background: #fff7e0; border: 1px dashed var(--wood-l); border-radius: 10px; padding: 8px 10px; }
.consent .check { font-size: 13.5px; line-height: 1.4; }
.legal-links { text-align: center; font-size: 12.5px; margin-top: 8px; color: var(--muted); }
.legal-links a { color: var(--muted); }
.recovery { display: grid; gap: 10px; }
.rc-code { font: 700 22px/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: 1px; text-align: center; background: #fff; border: 3px dashed var(--red); border-radius: 12px; padding: 12px; word-break: break-all; user-select: all; }
#forgotBtn, #backLogin { justify-self: center; margin-top: 4px; }
/* nút ✕ luôn nằm trên nội dung hộp thoại (bong bóng thoại của Cô Tư từng che mất) */
.modal-panel > .close { z-index: 5; background: var(--paper); border-radius: 99px; width: 34px; height: 34px; line-height: 1; }
/* .btn đặt display nên thuộc tính hidden không có tác dụng */
#actBtn[hidden] { display: none !important; }
.recovery label.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.recovery label.check input { width: auto; margin: 0; }
