/* ======================================================================
   Pháo Thủ Huyền Thoại — giao diện
   ====================================================================== */
:root {
  --bg: #0a1024;
  --panel: rgba(14, 22, 48, 0.88);
  --panel2: rgba(24, 36, 74, 0.9);
  --line: rgba(255, 211, 77, 0.28);
  --gold: #ffd34d;
  --gold2: #ff9f1c;
  --txt: #e8ecff;
  --dim: #95a0c8;
  --red: #ff5a5a;
  --blue: #4ea8ff;
  --green: #46e06a;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); font-family: var(--font); overflow: hidden; font-size: 17px; -webkit-text-size-adjust: 100%; }
#bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
body[data-view="game"] #bg-canvas { display: none; }
.screen { position: fixed; inset: 0; display: none; z-index: 1; }
.screen.on { display: block; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
h1, h2, h3 { margin: 0 0 10px; }
h2 { font-size: 20px; color: var(--gold); text-shadow: 0 2px 0 #000; }
h3 { font-size: 17px; }
small { color: var(--dim); }
input, select {
  background: rgba(5, 10, 26, 0.85); color: var(--txt); border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 16px; width: 100%; margin: 4px 0 8px; outline: none;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 211, 77, 0.2); }
label { display: block; font-size: 15px; color: var(--dim); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
}
.btn {
  font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; border: 0; border-radius: 9px; padding: 9px 14px;
  color: #1a1200; background: linear-gradient(#ffe27a, #ffb52e); box-shadow: 0 3px 0 #a86800, 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform .08s, filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #a86800; }
.btn:disabled { filter: grayscale(1) brightness(0.6); cursor: not-allowed; }
.btn.ghost { background: rgba(255, 255, 255, 0.08); color: var(--txt); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.btn.go { background: linear-gradient(#7dff8f, #23b14d); color: #04220c; box-shadow: 0 3px 0 #0c6a2a, 0 4px 12px rgba(0, 0, 0, 0.4); }
.btn.ok { background: linear-gradient(#9fd3ff, #3d8bfd); color: #021433; box-shadow: 0 3px 0 #1b4f9c; }
.btn.big { width: 100%; padding: 12px; font-size: 18px; margin-top: 6px; }
.btn.sm { padding: 6px 10px; font-size: 15px; }
.btn.xs { padding: 3px 7px; font-size: 14px; }
.tag { display: inline-block; font-size: 13px; padding: 2px 7px; border-radius: 20px; background: rgba(255, 255, 255, 0.12); color: var(--dim); }
.tag.green { background: rgba(70, 224, 106, 0.2); color: var(--green); }
.tag.red { background: rgba(255, 90, 90, 0.2); color: var(--red); }
.tag.gold { background: rgba(255, 211, 77, 0.2); color: var(--gold); }
.msg { min-height: 20px; color: #ff8080; font-size: 15px; margin-top: 8px; }
.msg.ok { color: var(--green); }

.logo { font-size: 44px; line-height: 0.95; text-align: center; letter-spacing: 2px; font-weight: 900; color: #fff;
  text-shadow: 0 3px 0 #b35f00, 0 6px 0 #5a2d00, 0 10px 24px rgba(0, 0, 0, 0.6); }
.logo span { display: block; font-size: 30px; color: var(--gold); letter-spacing: 6px; }
.logo.sm { font-size: 20px; text-align: left; margin: 0; text-shadow: 0 2px 0 #b35f00; }
.logo.sm span { font-size: 15px; letter-spacing: 3px; }

/* ---------------- Đăng nhập */
.login-box { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -55%); width: min(420px, 92vw); padding: 28px; }
.tag-line { text-align: center; color: var(--dim); font-size: 15px; margin: 10px 0 18px; }

/* ---------------- Thanh trên */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: rgba(6, 10, 24, 0.82); border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; flex: 1; }
#online { flex: 1; color: var(--green); font-size: 15px; }
#me-card { display: flex; align-items: center; gap: 10px; font-size: 15px; }
#me-card .avatar { font-size: 28px; }

/* ---------------- Sảnh */
.lobby-grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; padding: 16px; height: calc(100% - 62px); }
.lobby-grid > .panel { overflow: auto; }
.side { display: flex; flex-direction: column; gap: 16px; overflow: auto; }
#room-list .empty { color: var(--dim); padding: 30px; text-align: center; }
.room-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; margin-bottom: 8px;
  background: var(--panel2); border: 1px solid rgba(255, 255, 255, 0.06); transition: transform .1s; }
.room-item:hover { transform: translateX(3px); border-color: var(--line); }
.room-item.playing { opacity: 0.7; }
.ri-main { flex: 1; }
.ri-count { font-size: 20px; font-weight: 900; color: var(--gold); }
table.top { width: 100%; border-collapse: collapse; font-size: 15px; }
table.top td, table.top th { padding: 5px 4px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
table.top th { color: var(--dim); font-weight: 400; }

/* ---------------- Phòng chờ */
.room-grid { display: grid; grid-template-columns: 300px 1fr 440px; gap: 14px; padding: 14px; height: calc(100% - 58px); }
.map-panel { display: flex; flex-direction: column; overflow: hidden; }
#room-thumb { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; }
#room-mapdesc { font-size: 14px; margin: 0 0 6px; }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 120px; margin-top: 10px; }
.chatlog { flex: 1; overflow: auto; font-size: 15px; background: rgba(0, 0, 0, 0.3); border-radius: 8px; padding: 8px; }
.chatlog .sys, #g-chatlog .sys { color: var(--gold); font-style: italic; }
.teams { display: grid; grid-template-rows: 1fr auto 1fr; gap: 6px; overflow: auto; }
.team { background: var(--panel); border-radius: 14px; padding: 12px; border: 1px solid; }
.team.red { border-color: rgba(255, 90, 90, 0.5); background: linear-gradient(rgba(120, 20, 30, 0.55), var(--panel)); }
.team.blue { border-color: rgba(78, 168, 255, 0.5); background: linear-gradient(rgba(20, 50, 120, 0.55), var(--panel)); }
.vs { text-align: center; font-size: 26px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #7a3c00; }
.team > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.slot { position: relative; display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.08); min-height: 86px; }
.slot.me { border-color: var(--gold); box-shadow: 0 0 12px rgba(255, 211, 77, 0.25); }
.slot.empty { justify-content: center; flex-direction: column; color: var(--dim); border-style: dashed; }
.slot canvas { background: radial-gradient(circle at 50% 70%, rgba(255, 255, 255, 0.12), transparent 70%); border-radius: 8px; flex: none; }
.slot-info { display: flex; flex-direction: column; gap: 3px; font-size: 15px; min-width: 0; }
.slot-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.botctl { display: flex; gap: 4px; }
.botctl select { padding: 3px; font-size: 13px; margin: 0; }
.addbot { display: flex; gap: 6px; align-items: center; }
.addbot select { margin: 0; padding: 6px; font-size: 14px; }
.kick { position: absolute; top: 4px; right: 6px; background: none; border: 0; color: #ff8080; cursor: pointer; font-size: 16px; }
.picker { overflow: auto; }
.pick-top { display: flex; gap: 10px; }
#mob-big { width: 200px; height: 131px; border-radius: 10px; border: 1px solid var(--line); flex: none; }
#mob-info { font-size: 14px; flex: 1; }
#mob-info h3 { font-size: 19px; color: var(--gold); margin-bottom: 2px; }
#mob-info h3 small { font-size: 14px; }
#mob-info p { margin: 2px 0 6px; color: var(--dim); }
.stats { display: grid; grid-template-columns: 70px 1fr; gap: 3px 8px; align-items: center; }
.stats label { font-size: 14px; }
.stats label b { color: var(--txt); float: right; }
.sbar { height: 7px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; }
.sbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.stars { color: var(--gold); letter-spacing: 2px; }
.shots { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; grid-column: 1 / -1; }
.picker .shots { width: 100%; }
.shot { display: flex; gap: 8px; align-items: flex-start; background: rgba(0, 0, 0, 0.3); border-radius: 8px; padding: 6px; font-size: 14px; }
.shot .k { flex: none; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-weight: 900; background: #2b3a70; }
.shot.ss .k { background: linear-gradient(#ffe27a, #ff9f1c); color: #2a1600; }
.shot em { color: var(--gold); font-style: normal; font-size: 13px; }
#mob-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 10px 0; }
.mob-tile { background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 9px; padding: 3px; cursor: pointer; color: var(--txt); font: inherit; font-size: 13px; display: flex; flex-direction: column; align-items: center; }
.mob-tile canvas { width: 100%; height: auto; }
.mob-tile span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mob-tile:hover { border-color: var(--line); }
.mob-tile.sel { border-color: var(--gold); background: rgba(255, 211, 77, 0.15); box-shadow: 0 0 10px rgba(255, 211, 77, 0.3); }
.items-pick h3 { color: var(--gold); }
#item-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 8px; }
.islot { aspect-ratio: 1; border-radius: 9px; background: rgba(255, 211, 77, 0.12); border: 1px solid var(--line); display: grid; place-items: center; font-size: 22px; cursor: pointer; position: relative; }
.islot small { position: absolute; bottom: 1px; right: 4px; font-size: 12px; }
.islot.empty { background: rgba(0, 0, 0, 0.3); border-style: dashed; cursor: default; }
#item-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.item-row { display: flex; gap: 6px; text-align: left; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 8px; padding: 6px; color: var(--txt); font: inherit; font-size: 14px; cursor: pointer; }
.item-row .ic { font-size: 20px; }
.item-row em { color: var(--gold); font-style: normal; font-size: 13px; }
.item-row:disabled { opacity: 0.4; cursor: not-allowed; }
.item-row:not(:disabled):hover { border-color: var(--line); }

/* ---------------- Trận đấu: khung 800×600 cố định (4:3) như GunBound */
#screen-game { background: #000; }
#g-stage { position: absolute; left: 50%; top: 50%; width: 800px; height: 600px; overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--k, 1)); transform-origin: center center; background: #000; }
#gcanvas { position: absolute; left: 0; top: 0; width: 800px; height: 100%; display: block; cursor: default; touch-action: none; }
#g-top { position: absolute; top: 4px; left: 4px; right: 4px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.g-team { display: flex; flex-direction: column; gap: 3px; width: 206px; pointer-events: auto; }
.gp { background: rgba(6, 10, 26, 0.72); border-radius: 6px; padding: 2px 6px 3px; font-size: 13px; border-left: 4px solid var(--red); }
.g-team.blue .gp { border-left-color: var(--blue); }
.gp.act { box-shadow: 0 0 0 2px var(--gold); }
.gp.me b { color: var(--gold); }
.gp.dead { opacity: 0.45; }
.gp-top { display: flex; gap: 5px; align-items: baseline; }
.gp-top b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-top span { color: var(--dim); font-size: 12px; white-space: nowrap; }
.gp-top em { font-style: normal; color: var(--gold); font-size: 12px; }
.hpbar { position: relative; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; margin-top: 1px; }
.hpbar i { display: block; height: 100%; background: linear-gradient(90deg, #2fbf55, #7dff8f); transition: width .3s; }
.hpbar span { position: absolute; inset: 0; font-size: 9px; line-height: 8px; text-align: center; text-shadow: 0 1px 1px #000; }
#g-center { display: flex; flex-direction: column; align-items: center; gap: 1px; }
#g-weather { background: rgba(6, 10, 26, 0.75); padding: 1px 8px; border-radius: 20px; font-size: 11px; pointer-events: auto; white-space: nowrap; }
#g-weather .sd { color: #ff4d4d; }
#g-timerbox { position: absolute; right: 8px; bottom: 206px; text-align: center; pointer-events: none; min-width: 60px; }
#g-timer { font-size: 30px; font-weight: 900; text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, 0.7); }
#g-timer.low { color: #ff4d4d; animation: pulse .5s infinite alternate; }
#g-turnname { font-size: 11px; text-shadow: 0 1px 2px #000; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { to { transform: scale(1.15); } }
#g-mini { position: absolute; right: 4px; bottom: 116px; border: 1px solid var(--line); border-radius: 6px; background: rgba(0, 0, 0, 0.3); cursor: pointer; opacity: 0.9; }
#g-banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: 38px; font-weight: 900; pointer-events: none; opacity: 0;
  text-shadow: 0 4px 0 #000, 0 0 24px rgba(0, 0, 0, 0.7); letter-spacing: 1px; }
#g-banner.show { animation: banner 2.2s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(2); } 12% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
#g-toast, #toast { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 5px; align-items: center; pointer-events: none; z-index: 50; }
#toast { position: fixed; top: 80px; }
#g-toast div, #toast div { background: rgba(6, 10, 26, 0.88); border: 1px solid var(--line); padding: 5px 14px; border-radius: 20px; font-size: 13px; animation: fadein .25s; max-width: 640px; text-align: center; }
#toast div { font-size: 16px; max-width: 80vw; }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px); } }
#g-chat { position: absolute; left: 4px; bottom: 116px; width: 250px; }
#g-chatlog { max-height: 84px; overflow: auto; font-size: 11px; text-shadow: 0 1px 2px #000; padding: 2px 4px; }
#g-chatin { background: rgba(0, 0, 0, 0.45); margin: 2px 0 0; padding: 3px 8px; font-size: 11px; border-radius: 6px; }
#g-hud { position: absolute; left: 0; right: 0; bottom: 0; height: 112px; display: flex; gap: 8px; align-items: center; padding: 6px 8px;
  background: linear-gradient(rgba(16, 24, 56, 0.92), rgba(5, 8, 22, 0.98)); border-top: 2px solid var(--line); }
#g-hud.active { border-top-color: var(--gold); box-shadow: 0 -3px 20px rgba(255, 211, 77, 0.25); }
#g-dial { width: 100px; height: 100px; flex: none; }
#g-mid { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#g-shots { display: flex; gap: 4px; }
.shot-btn { flex: 1; display: flex; align-items: center; gap: 5px; position: relative; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 6px; color: var(--txt); font: inherit; font-size: 11px; padding: 3px 6px; cursor: pointer; overflow: hidden; min-width: 0; }
.shot-btn .k { font-weight: 900; color: var(--gold); }
.shot-btn .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot-btn.sel { background: rgba(255, 211, 77, 0.22); border-color: var(--gold); }
.shot-btn.ss .ssbar { position: absolute; left: 0; bottom: 0; right: 0; height: 3px; background: rgba(255, 255, 255, 0.1); }
.shot-btn.ss .ssbar i { display: block; height: 100%; background: linear-gradient(90deg, #ff9f1c, #ffd34d); }
.shot-btn.ss.ready { animation: glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 14px rgba(255, 211, 77, 0.7); } }
/* thanh lực 4 vạch kiểu GunBound */
#g-power { position: relative; height: 26px; border-radius: 4px; background: linear-gradient(#0b1230, #1a2450); border: 2px solid #8b93b8; overflow: hidden; cursor: ew-resize; }
#g-power-fill { height: 100%; width: 0; background: linear-gradient(180deg, #fff3a0, #ffb52e 45%, #ff6a1a); box-shadow: 0 0 10px rgba(255, 160, 40, 0.6); }
#g-power-ticks i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.18); }
#g-power-ticks i.mid { top: 0; bottom: 0; background: rgba(255, 255, 255, 0.35); }
#g-power-ticks i.major { width: 2px; margin-left: -1px; background: rgba(255, 255, 255, 0.85); }
#g-power-ticks b { position: absolute; bottom: -1px; font-size: 9px; color: rgba(255, 255, 255, 0.55); margin-left: -12px; font-weight: 400; }
#g-power-last { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: #ff3b3b; box-shadow: 0 0 6px #ff3b3b; }
#g-power-val { margin-left: auto; font-weight: 900; font-size: 16px; color: #ffe680; text-shadow: 0 1px 2px #000; white-space: nowrap; }
#g-move { position: relative; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; }
#g-move-fill { height: 100%; background: linear-gradient(90deg, #26c6da, #7df9ff); }
#g-move span { position: absolute; right: 6px; top: -4px; font-size: 7px; color: var(--dim); }
.g-row { display: flex; align-items: center; gap: 8px; }
#g-items { display: flex; gap: 4px; }
.item-btn { width: 34px; height: 30px; border-radius: 6px; background: rgba(255, 211, 77, 0.14); border: 1px solid var(--line); font-size: 17px; cursor: pointer; position: relative; color: #fff; padding: 0; }
.item-btn .k { position: absolute; right: 2px; bottom: 0; font-size: 9px; color: var(--dim); }
.item-btn.empty { background: rgba(0, 0, 0, 0.3); border-style: dashed; cursor: default; }
#g-itemact { font-size: 11px; color: var(--gold); }
#g-side { display: flex; flex-direction: column; gap: 4px; width: 104px; flex: none; }
#g-side .row { gap: 4px; }
#g-touch { display: none; }
/* ---- v5.0: điều khiển cảm ứng (Android · iPhone · iPad) — hai ngón cái, không đè lên HUD */
body.touch #screen-game { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch #screen-game.on #g-touch { display: block; }
#g-touch .tc-left, #g-touch .tc-right { position: fixed; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 30; display: flex; gap: 10px; align-items: flex-end; }
#g-touch .tc-left { left: calc(10px + env(safe-area-inset-left, 0px)); flex-direction: column; align-items: stretch; }
#g-touch .tc-right { right: calc(10px + env(safe-area-inset-right, 0px)); }
#g-touch .tc-row, #g-touch .tc-ang { display: flex; gap: 10px; }
#g-touch .tc-ang { flex-direction: column; }
#g-touch button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; -webkit-tap-highlight-color: transparent; font-family: inherit; }
.tc-btn { width: var(--tb, 74px); height: var(--tb, 74px); border: 0; border-radius: 22px; background: rgba(255, 255, 255, 0.94); box-shadow: 0 5px 0 #d9c3d3, 0 6px 14px rgba(0, 0, 0, 0.18); display: flex; align-items: center; justify-content: center; }
.tc-btn svg { width: 46%; height: 46%; fill: #3d6fb6; }
.tc-btn.ang { height: calc(var(--tb, 74px) * 0.8); width: calc(var(--tb, 74px) * 0.86); }
.tc-btn.ang svg { fill: #d6337f; }
.tc-btn.down, .tc-fire.down { transform: translateY(3px); box-shadow: 0 2px 0 #d9c3d3; }
.tc-fire { width: calc(var(--tb, 74px) * 1.5); height: calc(var(--tb, 74px) * 1.5); border: 0; border-radius: 50%; color: #fff; background: #e2413b; box-shadow: 0 0 0 var(--ring, 0px) rgba(255, 213, 74, 0.75), 0 6px 0 #9f2622; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tc-fire b { font-family: 'Baloo 2', 'Nunito', sans-serif; font-size: calc(var(--tb, 74px) * 0.34); line-height: 1; }
.tc-fire small { font-size: 11px; font-weight: 900; opacity: .95; }
.tc-fire.cancel { background: #8a7a93; }
.tc-stam { background: rgba(255, 255, 255, 0.88); border-radius: 12px; padding: 4px 8px; font-size: 11px; font-weight: 900; color: #3a2540; }
.tc-stam div { height: 8px; border-radius: 9px; background: #f3d6e6; overflow: hidden; margin-top: 2px; }
.tc-stam i { display: block; height: 100%; background: #36c97a; border-radius: 9px; width: 100%; }
.tc-hint { display: none; position: fixed; left: 50%; transform: translateX(-50%); z-index: 30; background: #fff0c2; color: #5a3200; border-radius: 12px; padding: 6px 12px; font-size: 12px; font-weight: 800; white-space: nowrap; }
body.touch.portrait #screen-game.on .tc-hint { display: block; }
body.touch.portrait #g-touch .tc-left, body.touch.portrait #g-touch .tc-right { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
#g-wxbanner { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 12px; background: rgba(43, 47, 69, 0.95); color: #fff; border: 3px solid #ffd54a; border-radius: 18px; padding: 10px 18px; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: fadein .3s; pointer-events: none; }
#g-wxbanner .wx-ic { font-size: 34px; }
#g-wxbanner b { display: block; font-size: 20px; font-weight: 900; }
#g-wxbanner small { font-size: 13px; font-weight: 700; color: #e9e2f2; }
#g-over { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 40; }
.over-box { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 18px; width: 680px; text-align: center; animation: fadein .4s; }
.over-box h1 { font-size: 42px; color: var(--gold); text-shadow: 0 4px 0 #7a3c00; }
.over-box.lose h1 { color: #ff7a7a; text-shadow: 0 4px 0 #5a0000; }
.over-box table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
.over-box td, .over-box th { padding: 5px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.over-box tr.ta td:first-child { border-left: 4px solid var(--red); }
.over-box tr.tb td:first-child { border-left: 4px solid var(--blue); }
.over-box tr.w { background: rgba(255, 211, 77, 0.08); }

/* ---------------- Modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 100; }
.modal-box { width: min(900px, 94vw); max-height: 88vh; overflow: auto; position: relative; }
.close { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; font-size: 16px; line-height: 1.5; }
.help-cols h3 { color: var(--gold); margin-top: 10px; }
kbd { background: #24305c; border: 1px solid #556; border-bottom-width: 3px; border-radius: 5px; padding: 0 6px; font-size: 14px; }

@media (max-width: 1250px) {
  .room-grid { grid-template-columns: 260px 1fr; overflow: auto; }
  .picker { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .lobby-grid { grid-template-columns: 1fr; overflow: auto; }
  .room-grid { grid-template-columns: 1fr; }
  .help-cols { grid-template-columns: 1fr; }
}

/* ======================================================================
   v2: cổng mã mời, đăng ký nhanh, cấp bậc, bài học tiếng Anh
   ====================================================================== */
.center { text-align: center; }
.center a, a { color: var(--gold); }
.tabs2 { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs2 button { flex: 1; padding: 9px; border-radius: 9px; border: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.3); color: var(--dim); font: inherit; font-weight: 700; cursor: pointer; }
.tabs2 button.on { background: rgba(255,211,77,.18); color: var(--gold); border-color: var(--gold); }
.or { text-align: center; color: var(--dim); font-size: 14px; margin: 8px 0 0; }
.login-box select { margin: 4px 0 8px; }
.rk { vertical-align: middle; flex: none; }
.rank-badge { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.rank-badge b { font-size: 14px; }
.gpbar { position: relative; width: 190px; height: 12px; background: rgba(255,255,255,.1); border-radius: 6px; overflow: hidden; margin: 3px 0; }
.gpbar i { display: block; height: 100%; background: linear-gradient(90deg, #ff9f1c, #ffd34d); }
.gpbar span { position: absolute; inset: 0; font-size: 10px; line-height: 12px; text-align: center; text-shadow: 0 1px 1px #000; }
#me-card .avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; background: rgba(255,211,77,.12); border: 1px solid var(--line); }
.announce { margin: 10px 16px 0; padding: 9px 14px; border-radius: 10px; background: linear-gradient(90deg, rgba(255,159,28,.25), rgba(255,211,77,.1)); border: 1px solid var(--line); font-weight: 700; }
.lobby-grid { height: calc(100% - 62px); }
.announce:not(.hidden) + .lobby-grid { height: calc(100% - 110px); }
.ref-code { display: flex; align-items: center; gap: 10px; }
.ref-code b { font-size: 24px; letter-spacing: 4px; color: var(--gold); background: rgba(0,0,0,.35); padding: 4px 12px; border-radius: 8px; border: 1px dashed var(--gold); }
.rank-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 15px; margin: 8px 0 14px; padding: 10px; background: rgba(0,0,0,.3); border-radius: 10px; }
.rank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.rank-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 6px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.08); text-align: center; font-size: 15px; }
.rank-cell small { color: var(--dim); }
.rank-cell.me { border-color: var(--gold); background: rgba(255,211,77,.15); box-shadow: 0 0 12px rgba(255,211,77,.3); }
.rank-cell.dragon { background: linear-gradient(rgba(120,40,160,.35), rgba(0,0,0,.3)); }
.modal-box.small { width: min(440px, 94vw); text-align: center; }
.cred { background: rgba(0,0,0,.35); border: 1px dashed var(--gold); border-radius: 10px; padding: 12px; margin: 12px 0; font-size: 20px; line-height: 1.7; }
.cred b { color: var(--gold); letter-spacing: 1px; user-select: all; }
.gpd { font-weight: 900; }
.gpd.up { color: var(--green); }
.gpd.down { color: #ff7a7a; }
.lvup { color: var(--gold); animation: pulse .5s infinite alternate; }
.gp-top .rk { margin-right: 2px; }

/* ---------------- Bài học */
#screen-quiz { overflow: auto; background: rgba(5, 8, 20, .55); }
.quiz-wrap { max-width: 860px; margin: 18px auto; padding: 0 12px 30px; }
.quiz-panel { padding: 18px 22px; }
.quiz-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.quiz-head h2 { margin: 0; flex: 1; font-size: 22px; }
.quiz-grade { display: flex; align-items: center; gap: 6px; }
.quiz-grade select { width: auto; margin: 0; padding: 5px 8px; }
.quiz-loading { text-align: center; padding: 40px 10px; color: var(--dim); }
.spinner { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#quiz-title { font-size: 20px; color: var(--gold); }
#quiz-title small { color: var(--dim); font-size: 15px; font-weight: 400; }
.quiz-theory { background: rgba(78,168,255,.1); border-left: 4px solid var(--blue); border-radius: 8px; padding: 12px 14px; line-height: 1.65; font-size: 17px; }
.quiz-examples { display: grid; gap: 6px; margin: 10px 0 14px; }
.quiz-examples .ex { display: flex; flex-direction: column; background: rgba(0,0,0,.25); border-radius: 8px; padding: 7px 12px; }
.quiz-examples .ex b { color: #b8f5c8; font-size: 17px; }
.quiz-examples .ex span { color: var(--dim); font-size: 15px; }
.quiz-progress { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.quiz-progress .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 15px; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.2); }
.quiz-progress .dot.cur { border-color: var(--gold); color: var(--gold); }
.quiz-progress .dot.ok { background: var(--green); border-color: var(--green); color: #04220c; }
.quiz-progress em { color: var(--dim); font-style: normal; font-size: 15px; margin-left: 6px; }
.quiz-q { background: rgba(255,211,77,.06); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.quiz-q .qlabel { font-size: 14px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.quiz-q .qvi { color: var(--dim); margin: 4px 0; }
.quiz-q .qtext { font-size: 22px; font-weight: 700; margin: 6px 0 12px; line-height: 1.4; }
.quiz-q .blank { color: var(--gold); letter-spacing: 2px; }
.ans-row { display: flex; gap: 8px; align-items: center; }
.ans-row input { margin: 0; font-size: 20px; padding: 11px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { padding: 7px 12px; border-radius: 20px; border: 1px solid var(--line); background: rgba(255,211,77,.12); color: #fff; font: inherit; font-size: 17px; cursor: pointer; }
.chip:disabled { opacity: .3; cursor: default; }
.mc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mc .btn { font-size: 19px; padding: 12px; }
.hint-btn { background: none; border: 0; color: var(--gold); cursor: pointer; margin-top: 8px; font: inherit; }
.hint { margin-top: 8px; color: #ffe8a3; font-style: italic; }
.quiz-feedback { margin-top: 12px; border-radius: 10px; padding: 12px 14px; line-height: 1.55; animation: fadein .25s; }
.quiz-feedback.ok { background: rgba(70,224,106,.14); border: 1px solid rgba(70,224,106,.5); }
.quiz-feedback.bad { background: rgba(255,90,90,.13); border: 1px solid rgba(255,90,90,.5); }
.quiz-feedback b { display: block; margin-bottom: 3px; }
.quiz-done { text-align: center; padding: 18px; }
.quiz-done .big-emoji { font-size: 60px; animation: pulse .6s infinite alternate; }
@media (max-width: 600px) { .mc { grid-template-columns: 1fr; } .quiz-q .qtext { font-size: 20px; } .rank-rules { grid-template-columns: 1fr; } }

/* ======================================================================
   v3: xu, cửa hàng trang phục, góc học tập, bài học đa môn
   ====================================================================== */
#screen-quiz, #screen-shop, #screen-learn { overflow-y: auto; }
.grow { flex: 1; }
.small { font-size: 14px; }
.center { text-align: center; }
.btn.gold { background: linear-gradient(#ffe27a, #ffb52e); color: #1a1200; }
.btn:disabled { filter: grayscale(.7) brightness(.8); cursor: not-allowed; transform: none; }
.coin { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px; margin-right: 4px;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #ffd34d 45%, #c98d0b); box-shadow: inset 0 0 0 2px #b8860b; }
.coin-pill { display: inline-flex; align-items: center; gap: 2px; padding: 5px 12px; border-radius: 999px; background: #1a1400; border: 2px solid var(--gold);
  color: #e8d9a0; font-size: 16px; white-space: nowrap; }
.coin-pill b { color: var(--gold); font-size: 18px; margin-right: 3px; }
.coin-pill.sm { padding: 2px 9px; font-size: 14px; border-width: 1.5px; }
.coin-pill.sm b { font-size: 15px; }
.meter { flex: 1; height: 10px; border-radius: 999px; background: #0b1226; border: 1px solid #26345f; overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.reg-level { align-items: flex-end; }
.reg-level select, .reg-level input { margin-bottom: 0; }

/* ---------------- bài học đa môn */
.quiz-wrap { max-width: 900px; }
.quiz-head h2 { flex: 0 0 auto; }
.quiz-progress { flex-wrap: wrap; }
.qdot { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; padding: 4px 10px; border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,.2); background: rgba(255,255,255,.05); color: var(--dim); }
.qdot.cur { border-color: var(--c); color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.08); }
.qdot.ok { background: rgba(70,224,106,.18); border-color: var(--green); color: #b8f5c8; }
.qdot.fixed { background: rgba(255,159,28,.15); border-color: var(--gold2); color: #ffd9a8; }
.qhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 12px; }
.qhead b { font-size: 20px; }
.subj-chip { font-size: 15px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1.5px solid var(--c); color: var(--c); }
.pocket-card { background: #1a1400; border: 2px solid var(--gold); border-radius: 16px; padding: 18px 20px; animation: fadein .25s; }
.pocket-card .pc-title { font-weight: 900; font-size: 20px; color: var(--gold); margin-bottom: 8px; }
.pocket-card ul { margin: 0 0 12px; padding-left: 22px; font-size: 19px; line-height: 1.6; }
.pc-tip, .pc-ex { border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
.pc-tip { background: #2a2000; color: #f5e7b5; }
.pc-ex { background: rgba(255,255,255,.05); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; }
.pc-tip small, .pc-ex small, .fb small { display: block; font-weight: 700; color: var(--gold); font-size: 14px; margin-bottom: 2px; font-family: var(--font); }
.passage { background: #f8fafc; color: #0b1226; border-radius: 12px; padding: 12px 16px; font-size: 18px; line-height: 1.65; margin-bottom: 10px; }
.scenario { background: rgba(78,168,255,.08); border: 1.5px solid rgba(108,180,255,.5); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.scenario .who { display: flex; align-items: center; gap: 8px; color: #9fd0ff; font-size: 15px; margin-bottom: 8px; }
.scenario .av { width: 30px; height: 30px; border-radius: 50%; background: #6cb4ff; color: #04203f; display: grid; place-items: center; font-weight: 900; }
.work { margin: 0; white-space: pre-wrap; background: #0b1226; border: 1px solid #33427a; border-radius: 10px; padding: 10px 14px; font-size: 20px; line-height: 1.55;
  font-family: ui-monospace, Menlo, Consolas, monospace; color: #fff; }
.qtext { font-size: 20px; font-weight: 700; margin: 10px 0 12px; line-height: 1.4; }
.qtext .blank { color: var(--gold); letter-spacing: 2px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.opt { display: flex; gap: 10px; align-items: center; text-align: left; min-height: 56px; padding: 10px 14px; border-radius: 14px; cursor: pointer;
  border: 2px solid #33427a; background: #17203f; color: var(--txt); font: inherit; font-size: 18px; transition: border-color .15s, transform .08s; }
.opt:hover { border-color: var(--gold); }
.opt:active { transform: scale(.99); }
.opt .k { flex: none; width: 30px; height: 30px; border-radius: 8px; background: #26345f; display: grid; place-items: center; font-weight: 900; }
.opt.picked { border-color: var(--gold); opacity: .7; }
.opt.reveal { border-color: var(--green); box-shadow: 0 0 0 2px rgba(70,224,106,.25); }
.q-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.fb { border-radius: 16px; padding: 16px 18px; animation: fadein .25s; display: grid; gap: 10px; }
.fb.ok { background: rgba(70,224,106,.1); border: 2px solid rgba(70,224,106,.6); }
.fb.bad { background: rgba(255,159,28,.08); border: 2px solid rgba(255,159,28,.6); }
.fb-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 22px; font-weight: 900; }
.fb-think { background: #2a1606; border: 1px solid #fb923c; border-radius: 12px; padding: 10px 12px; color: #fde3c8; }
.fb-think small { color: #fdba74 !important; }
.fb-folk { background: #17203f; border-radius: 12px; padding: 10px 12px; font-size: 18px; line-height: 1.6; }
.fb-right pre { margin: 0; white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 19px; color: #b8f5c8; }
.fb-right small { color: var(--green) !important; }
.fb-gap { margin: 0; color: #fdba74; }

/* ---------------- cửa hàng */
.shop-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; padding: 16px; max-width: 1280px; margin: 0 auto; align-items: start; }
.shop-preview { position: sticky; top: 12px; display: grid; gap: 10px; }
.shop-preview h2 { font-size: 26px; margin: 0; color: #fff; }
.sp-top { display: flex; justify-content: space-between; align-items: center; }
.tier-badge { font-size: 14px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1.5px solid var(--c); color: var(--c); }
.sp-img { background: #0e1630; border: 1px solid #22305a; border-radius: 14px; padding: 8px; }
.outfit-svg, .outfit-svg svg { display: block; width: 100%; height: auto; }
.sp-bonus { background: rgba(255,255,255,.05); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.sp-stats { display: grid; gap: 7px; }
.sm-head { display: flex; justify-content: space-between; align-items: baseline; }
.sm-row { display: grid; grid-template-columns: 82px 1fr 74px; gap: 8px; align-items: center; font-size: 15px; }
.sm-row b { text-align: right; }
.shop-main { display: grid; gap: 12px; min-width: 0; }
.shop-daily { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; }
.shop-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tier-tab { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--c); background: transparent; color: var(--c); font: inherit; font-weight: 700; cursor: pointer; }
.tier-tab.on { background: var(--c); color: #0b1226; }
.outfit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.outfit-card { display: flex; flex-direction: column; gap: 5px; text-align: left; padding: 10px; border-radius: 14px; border: 2px solid #26345f;
  background: var(--panel); color: var(--txt); font: inherit; cursor: pointer; transition: border-color .15s, transform .1s; }
.outfit-card:hover { transform: translateY(-2px); border-color: #4a5a8f; }
.outfit-card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,211,77,.2); }
.oc-img { background: #0e1630; border-radius: 10px; padding: 4px; }
.oc-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; }
.oc-row em { font-style: normal; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: #3a2208; color: #fdba74; }
.oc-row em.own { background: #123d2a; color: #a7f3c0; }
.outfit-card b { font-size: 17px; line-height: 1.25; }
.outfit-card small { line-height: 1.35; }
.oc-price { color: var(--gold); font-weight: 900; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; }
.earn-grid { display: grid; gap: 6px; font-size: 16px; }
.outfit-tag { border: 1px solid var(--c); }
@media (max-width: 900px) { .shop-grid { grid-template-columns: 1fr; } .shop-preview { position: static; } }

/* ---------------- góc học tập */
.learn-wrap { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.learn-next { border: 2px solid rgba(70,224,106,.6); }
.learn-next h2 { color: #fff; font-size: 24px; margin: 4px 0; }
.eyebrow { font-size: 14px; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: .06em; }
.plan { list-style: none; padding: 0; margin: 10px 0 6px; display: grid; gap: 6px; }
.plan li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(255,255,255,.05); border-radius: 10px; }
.plan li span:nth-child(2) { flex: 1; }
.why { font-size: 14px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.why.gap { background: #fb923c; color: #2a1200; } .why.learn { background: #6cb4ff; color: #04203f; } .why.new { background: #e8edff; color: #0b1226; }
.subj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.subj-card { display: grid; gap: 10px; text-align: left; padding: 14px; border-radius: 16px; border: 1px solid #26345f; border-top: 4px solid var(--c);
  background: var(--panel); color: var(--txt); font: inherit; cursor: pointer; }
.subj-card.on { box-shadow: 0 0 0 2px var(--c); }
.sc-top { display: flex; gap: 12px; align-items: center; }
.sc-top b { display: block; font-size: 19px; }
.st { font-size: 14px; padding: 3px 8px; border-radius: 8px; border: 1.5px solid; }
.st.solid { background: #123d2a; color: #a7f3c0; border-color: #4ade80; }
.st.learn { background: #0d1d33; color: #c9dcf5; border-color: #6cb4ff; }
.st.gap { background: #3a2208; color: #fdba74; border-color: #fb923c; }
.st.todo { color: var(--dim); border-style: dashed; border-color: #4a5a8f; }
.gap-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #22305a; flex-wrap: wrap; }
.gap-prog { flex: 0 0 160px; display: grid; gap: 4px; }
.ls-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.skill-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.sk-col { display: grid; gap: 8px; align-content: start; background: #0e1630; border-radius: 14px; padding: 10px; }
.sk { display: grid; gap: 2px; border-radius: 10px; padding: 8px 10px; }
.sk > div { display: flex; justify-content: space-between; gap: 8px; }
.sk span { font-weight: 700; } .sk em { font-style: normal; font-size: 13px; white-space: nowrap; }
.sk small { font-size: 13px; }
.learn-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.learn-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chain { list-style: none; margin: 0 0 12px; padding: 0 0 0 4px; }
.chain li { position: relative; padding: 0 0 12px 22px; border-left: 2px solid #33427a; }
.chain li:last-child { border-left-color: transparent; }
.chain li::before { content: ''; position: absolute; left: -8px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #4a5a8f; }
.chain li.gap::before { background: #fb923c; } .chain li.learn::before { background: #6cb4ff; } .chain li.solid::before { background: #4ade80; }
.chain b { display: block; } .chain small { font-size: 14px; }
.mis-row, .rev-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid #22305a; }
.rev-row { flex-direction: column; gap: 0; } .rev-row small { color: #6cb4ff; font-weight: 700; }
.warn { color: #fdba74; }
.note-panel p { line-height: 1.6; }

/* ---------------- chọn lớp / tuổi */
.grade-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 10px 0; }
.gchip { min-height: 44px; border-radius: 10px; border: 2px solid #33427a; background: #0b1226; color: var(--txt); font: inherit; font-weight: 700; cursor: pointer; }
.gchip.on { background: var(--gold); border-color: var(--gold); color: #1a1300; }
.pf-age input { max-width: 140px; }
#screen-shop, #screen-learn { background: rgba(5, 8, 20, .6); }
.topbar { flex-wrap: wrap; }

/* ======================================================================
   v4: cửa hàng theo ô, nhân vật chibi có hoạt ảnh, thẻ mời
   ====================================================================== */
.avatar-svg, .avatar-svg svg { display: block; width: 100%; height: auto; }
.avatar-svg svg { border-radius: 16px; }
#me-card .avatar { overflow: hidden; }
#me-card .avatar .avatar-svg { width: 46px; }
.shop-tabs { display: grid; gap: 10px; }
.slot-tabs { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.slot-tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; min-height: 60px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--panel); color: var(--txt); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; transition: transform .12s; }
.slot-tab .ic { font-size: 22px; line-height: 1; }
.slot-tab:hover { transform: translateY(-2px); }
.slot-tab.on { background: var(--gold); border-color: var(--gold); color: #fff; box-shadow: 0 4px 14px rgba(255, 126, 182, .35); }
.tier-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tier-row .tier-tab { min-height: 34px; font-size: 15px; }
.item-card { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 8px; border-radius: 18px; border: 2px solid var(--line);
  background: var(--panel); color: var(--txt); font: inherit; cursor: pointer; transition: transform .12s, box-shadow .15s; overflow: hidden; }
.item-card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0, 0, 0, .18); }
.item-card.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 126, 182, .35); }
.item-card.tier1 { border-color: rgba(75, 157, 255, .6); } .item-card.tier2 { border-color: rgba(169, 112, 255, .7); }
.item-card.tier3 { border-color: rgba(255, 159, 28, .85); }
.item-card.tier3::after { content: ''; position: absolute; inset: -40%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .35) 50%, transparent 60%); animation: shine 3.5s infinite; pointer-events: none; }
@keyframes shine { 0% { transform: translateX(-60%); } 60%, 100% { transform: translateX(60%); } }
.ic-img { border-radius: 14px; overflow: hidden; }
.ic-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; }
.tier-dot { color: var(--c); }
.tier-dot::before { content: '●'; margin-right: 3px; }
.ic-row em { font-style: normal; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: rgba(255, 159, 28, .2); color: #ff9f1c; }
.ic-row em.own { background: rgba(47, 191, 113, .18); color: #2fbf71; } .ic-row em.on { background: var(--gold); color: #fff; }
.item-card b { font-size: 16px; line-height: 1.25; } .item-card small { line-height: 1.35; font-size: 14px; }
.ic-price { color: #ff9f1c; font-weight: 900; }
.wear-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ws { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 12px; border: 1.5px dashed var(--line); font-size: 14px; min-width: 0; }
.ws.has { border-style: solid; background: rgba(255, 126, 182, .08); }
.ws .ic { font-size: 18px; } .ws .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-x { border: 0; background: none; color: var(--dim); cursor: pointer; font-size: 15px; }
.sm-row em { font-style: normal; font-size: 13px; } .sm-row em.up { color: #2fbf71; } .sm-row em.down { color: #ff6b8a; }
.sm-row small { color: var(--dim); font-weight: 400; }
.chip.own { border-color: #2fbf71; }
.sp-img .avatar-svg { max-width: 300px; margin: 0 auto; }
@media (max-width: 1100px) { .slot-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* hoạt ảnh nhẹ cho nhân vật */
.avatar-svg.anim .av-bob { animation: avBob 2.6s ease-in-out infinite; }
@keyframes avBob { 50% { transform: translateY(-4px); } }
.avatar-svg.anim .av-flapL { transform-box: fill-box; transform-origin: 100% 60%; animation: flapL 1.5s ease-in-out infinite; }
.avatar-svg.anim .av-flapR { transform-box: fill-box; transform-origin: 0% 60%; animation: flapR 1.5s ease-in-out infinite; }
@keyframes flapL { 50% { transform: rotate(-12deg); } } @keyframes flapR { 50% { transform: rotate(12deg); } }
.avatar-svg.anim .av-blink { transform-box: fill-box; transform-origin: center; animation: blink 4.6s infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.avatar-svg.anim .av-sway, .avatar-svg.anim .av-tail { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 2.8s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.avatar-svg.anim .av-hop { animation: hop 2s ease-in-out infinite; }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 75% { transform: translateY(-6px); } }
.avatar-svg.anim .av-drift { animation: drift 8s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translateX(-10px); } to { transform: translateX(12px); } }
.avatar-svg.anim .av-tw, .avatar-svg.anim .av-halo { animation: tw 1.6s ease-in-out infinite alternate; }
@keyframes tw { from { opacity: .25; } to { opacity: 1; } }
.avatar-svg.anim .av-fall { animation: fall 6s linear infinite; }
@keyframes fall { from { transform: translate(0, -10px) rotate(0); } to { transform: translate(-30px, 260px) rotate(300deg); } }
.avatar-svg.anim .av-wave { animation: wave 3s ease-in-out infinite alternate; }
@keyframes wave { to { transform: translateX(-20px); } }
.avatar-svg.anim .av-bub { animation: bub 3.2s ease-in infinite; }
@keyframes bub { from { transform: translateY(0); opacity: .9; } to { transform: translateY(-140px); opacity: 0; } }
.avatar-svg.anim .av-spin { transform-box: fill-box; transform-origin: center; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar-svg.anim .av-cape { transform-box: fill-box; transform-origin: 50% 0; animation: cape 2.4s ease-in-out infinite alternate; }
@keyframes cape { from { transform: skewX(-4deg); } to { transform: skewX(4deg); } }
.avatar-svg.anim .av-flame { transform-box: fill-box; transform-origin: 50% 0; animation: flame .25s ease-in-out infinite alternate; }
@keyframes flame { to { transform: scaleY(1.35); } }
.avatar-svg.anim .av-glow { animation: tw 2.4s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) { .avatar-svg.anim * { animation: none !important; } .item-card.tier3::after { animation: none; } }

/* thẻ mời */
.card-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.card-hero > div:last-child { flex: 1 1 280px; }
.ticket { width: 200px; height: 120px; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: linear-gradient(135deg, #ff7eb6, #a970ff 60%, #4b9dff); box-shadow: 0 10px 24px rgba(169, 112, 255, .35); position: relative; overflow: hidden; transform: rotate(-4deg); }
.ticket::after { content: ''; position: absolute; inset: -40%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .45) 50%, transparent 60%); animation: shine 3s infinite; }
.ticket span { font-weight: 900; letter-spacing: 3px; font-size: 20px; } .ticket b { font-size: 15px; }
.card-list { display: grid; gap: 8px; }
.card-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); }
.card-row.used { opacity: .65; }
.card-row .code { font-size: 20px; letter-spacing: 3px; color: var(--gold); font-family: ui-monospace, Menlo, Consolas, monospace; }
.theme-fab { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-size: 20px; }

/* ======================================================================
   Giao diện SÁNG DỄ THƯƠNG (body.theme-cute)
   ====================================================================== */
body.theme-cute {
  --bg: #fff5fb; --panel: rgba(255, 255, 255, .94); --panel2: #fff7fc; --line: rgba(255, 126, 182, .35);
  --gold: #ff7eb6; --gold2: #ffa94d; --txt: #4a3b5c; --dim: #8b7c9f; --red: #ff6b8a; --blue: #4b9dff; --green: #2fbf71;
  --font: "Nunito", "Quicksand", "Segoe UI Rounded", "Trebuchet MS", system-ui, sans-serif;
}
body.theme-cute::after { content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 15% 20%, rgba(255, 214, 236, .75), transparent 45%), radial-gradient(circle at 85% 10%, rgba(214, 236, 255, .8), transparent 45%),
  radial-gradient(circle at 70% 90%, rgba(226, 214, 255, .75), transparent 50%), rgba(255, 249, 253, .55); }
body.theme-cute[data-view="game"]::before { display: none; }
body.theme-cute .panel { box-shadow: 0 8px 24px rgba(186, 120, 200, .16); border: 2px solid var(--line); border-radius: 20px; }
body.theme-cute h2 { color: #e8559b; text-shadow: none; }
body.theme-cute .logo { color: #fff; text-shadow: 0 3px 0 #e8559b, 0 6px 14px rgba(232, 85, 155, .35); }
body.theme-cute .logo span { color: #ffb020; text-shadow: 0 2px 0 #b35f00; }
body.theme-cute .logo.sm { text-shadow: 0 2px 0 #e8559b; }
body.theme-cute input, body.theme-cute select, body.theme-cute textarea { background: #fff; color: var(--txt); border: 2px solid #f3d6e6; border-radius: 12px; }
body.theme-cute input:focus, body.theme-cute select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 126, 182, .2); }
body.theme-cute .btn { border-radius: 14px; color: #5a3200; background: linear-gradient(#ffe48a, #ffbf3f); box-shadow: 0 4px 0 #e59a12, 0 6px 14px rgba(229, 154, 18, .25); }
body.theme-cute .btn.go { background: linear-gradient(#8ff0b0, #36c97a); color: #fff; box-shadow: 0 4px 0 #22995a, 0 6px 14px rgba(54, 201, 122, .3); text-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
body.theme-cute .btn.ghost { background: #fff; color: var(--txt); box-shadow: inset 0 0 0 2px #f3d6e6, 0 3px 0 #f0cfe0; }
body.theme-cute .btn.ok { background: linear-gradient(#a9d8ff, #5aa9ff); color: #fff; }
body.theme-cute .btn.gold { background: linear-gradient(#ffb3d6, #ff6fae); color: #fff; box-shadow: 0 4px 0 #d94b8c, 0 6px 14px rgba(255, 111, 174, .3); }
body.theme-cute .topbar { background: rgba(255, 255, 255, .88); border-bottom: 2px solid var(--line); backdrop-filter: blur(6px); }
body.theme-cute .tag { background: #f6eefb; color: var(--dim); }
body.theme-cute .tag.gold { background: #ffe3f0; color: #e8559b; }
body.theme-cute .tag.green { background: #dcf8e8; } body.theme-cute .tag.red { background: #ffe1e8; }
body.theme-cute .room-item, body.theme-cute .slot, body.theme-cute .mob-tile, body.theme-cute .item-row, body.theme-cute .shot,
body.theme-cute .rank-cell, body.theme-cute .rank-rules, body.theme-cute .chatlog, body.theme-cute .cred, body.theme-cute .islot.empty,
body.theme-cute .quiz-examples .ex, body.theme-cute .tabs2 button { background: #fff; border: 1.5px solid #f3d6e6; color: var(--txt); }
body.theme-cute .tabs2 button.on { background: #ffe3f0; color: #e8559b; border-color: var(--gold); }
body.theme-cute .mob-tile.sel, body.theme-cute .rank-cell.me { background: #ffe9f4; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 126, 182, .25); }
body.theme-cute .team.red { background: linear-gradient(#ffe3ea, #fff); border: 2px solid #ffb3c4; }
body.theme-cute .team.blue { background: linear-gradient(#e1efff, #fff); border: 2px solid #a9d0ff; }
body.theme-cute .shot .k { background: #e7defa; color: #6b4fa0; }
body.theme-cute .sbar, body.theme-cute .gpbar { background: #f3e6f0; }
body.theme-cute #me-card .avatar { background: #ffe9f4; }
body.theme-cute .announce { background: linear-gradient(90deg, #ffe3f0, #fff4d6); }
body.theme-cute .modal { background: rgba(120, 80, 140, .35); }
body.theme-cute .close { color: var(--dim); }
body.theme-cute kbd { background: #fff; border-color: #e5cfe0; }
body.theme-cute .ref-code b { background: #fff; }
body.theme-cute #screen-quiz, body.theme-cute #screen-shop, body.theme-cute #screen-learn { background: transparent; }
body.theme-cute .coin-pill { background: #fff8e0; border-color: #ffbf3f; color: #a0700a; }
body.theme-cute .coin-pill b { color: #e59a12; }
body.theme-cute .meter { background: #f6edf4; border-color: #f0d9e7; }
body.theme-cute .chip { background: #fff3f9; color: var(--txt); }
body.theme-cute .qdot { background: #fff; border-color: #f0d9e7; }
body.theme-cute .qdot.ok { background: #dcf8e8; color: #1f8a52; } body.theme-cute .qdot.fixed { background: #fff1dc; color: #b86b00; }
body.theme-cute .pocket-card { background: #fffbe8; border-color: #ffcf5a; }
body.theme-cute .pocket-card .pc-title { color: #e59a12; }
body.theme-cute .pc-tip { background: #fff2c6; color: #6b4f00; } body.theme-cute .pc-ex { background: #fff; }
body.theme-cute .pc-tip small, body.theme-cute .pc-ex small, body.theme-cute .fb small { color: #e59a12; }
body.theme-cute .scenario { background: #eef6ff; border-color: #b9dbff; } body.theme-cute .scenario .who { color: #3a7fd0; }
body.theme-cute .work { background: #fff; border-color: #cfe3ff; color: #3b2a4a; }
body.theme-cute .opt { background: #fff; border-color: #f0d9e7; color: var(--txt); box-shadow: 0 3px 0 #f0d9e7; }
body.theme-cute .opt:hover { border-color: var(--gold); } body.theme-cute .opt .k { background: #ffe3f0; color: #e8559b; }
body.theme-cute .fb.ok { background: #ecfbf2; } body.theme-cute .fb.bad { background: #fff6ea; }
body.theme-cute .fb-think { background: #fff0e2; color: #7a4210; } body.theme-cute .fb-think small { color: #d9731a !important; }
body.theme-cute .fb-folk { background: #f4efff; } body.theme-cute .fb-right pre { color: #1f8a52; }
body.theme-cute .sp-img, body.theme-cute .sk-col, body.theme-cute .oc-img { background: #fdf4fa; border-color: #f3d6e6; }
body.theme-cute .sp-bonus, body.theme-cute .plan li { background: #fff3f9; }
body.theme-cute .st.solid { background: #dcf8e8; color: #1f8a52; } body.theme-cute .st.learn { background: #e3efff; color: #2f6fc0; }
body.theme-cute .st.gap { background: #fff0e2; color: #c2610c; }
body.theme-cute .gap-row, body.theme-cute .mis-row, body.theme-cute .rev-row { border-color: #f3e3ee; }
body.theme-cute .gchip { background: #fff; border-color: #f0d9e7; color: var(--txt); }
body.theme-cute .gchip.on { background: var(--gold); color: #fff; }
body.theme-cute .slot-tab { background: #fff; }
body.theme-cute .learn-next { border-color: #8ee3b2; } body.theme-cute .eyebrow { color: #1f8a52; }
body.theme-cute .learn-next h2, body.theme-cute .shop-preview h2 { color: var(--txt); }
body.theme-cute .hint { color: #c2610c; }
body.theme-cute table.top td, body.theme-cute table.top th { border-color: #f3e3ee; }
body.theme-cute .quiz-theory { background: #eef6ff; }
body.theme-cute .tier-tab.on { color: #fff; }

/* v4.0 cute: nút bị khoá dịu mắt + chữ HUD trong trận đủ tương phản */
body.theme-cute .btn:disabled { filter: none; background: #efe6ee; color: #a890a6; box-shadow: inset 0 0 0 2px #e6d6e4; text-shadow: none; }
body.theme-cute .shot-btn { color: #fff; }
body.theme-cute .shot-btn .n { color: #fff; }
body.theme-cute .shot-btn.sel { background: rgba(255, 111, 174, .35); border-color: #ff8cc0; }
body.theme-cute .shot-btn .k { color: #ffd34d; }

/* ---- v5.0: nhân vật Bin/Mi, thú cưng (sinh từ mockup) */
.cb-bob{animation:cbBob 2.6s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 100%}
.cb-sway{animation:cbSway 3s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 0}
.cb-swayR{animation:cbSwayR 3s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 0}
.cb-flapL{animation:cbFlapL 1.8s ease-in-out infinite;transform-box:fill-box;transform-origin:100% 60%}
.cb-flapR{animation:cbFlapR 1.8s ease-in-out infinite;transform-box:fill-box;transform-origin:0 60%}
.cb-blink{animation:cbBlink 4.2s infinite;transform-box:fill-box;transform-origin:50% 50%}
.cb-tool{animation:cbTool 2.6s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 100%}
.cb-flame{animation:cbFlame .35s ease-in-out infinite alternate;transform-box:fill-box;transform-origin:50% 0}
.cb-wave{animation:cbWave 1.6s ease-in-out infinite;transform-box:fill-box;transform-origin:0 50%}
.cb-fall{animation:cbFall 4s ease-in-out infinite}
@keyframes cbWave{0%,100%{transform:skewY(0)}50%{transform:skewY(-6deg) scaleX(.94)}}
@keyframes cbFall{0%,100%{transform:translateY(-4px)}50%{transform:translateY(6px)}}
@keyframes cbBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}
@keyframes cbSway{0%,100%{transform:rotate(3deg)}50%{transform:rotate(-4deg)}}
@keyframes cbSwayR{0%,100%{transform:rotate(-3deg)}50%{transform:rotate(4deg)}}
@keyframes cbFlapL{0%,100%{transform:rotate(0)}50%{transform:rotate(12deg)}}
@keyframes cbFlapR{0%,100%{transform:rotate(0)}50%{transform:rotate(-12deg)}}
@keyframes cbBlink{0%,92%,100%{transform:scaleY(1)}95%{transform:scaleY(.1)}}
@keyframes cbTool{0%,100%{transform:rotate(0)}50%{transform:rotate(-6deg)}}
@keyframes cbFlame{from{transform:scaleY(.8)}to{transform:scaleY(1.2)}}
.cb-still *{animation:none !important}
@media (prefers-reduced-motion: reduce){.cb-bob,.cb-sway,.cb-swayR,.cb-flapL,.cb-flapR,.cb-blink,.cb-tool,.cb-flame,.cb-wave,.cb-fall{animation:none}}
.rd-bob{animation:rdBob 2.4s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 100%}
.rd-sway{animation:rdSway 2.6s ease-in-out infinite;transform-box:fill-box;transform-origin:100% 0}
.rd-flap{animation:rdFlap 1.6s ease-in-out infinite;transform-box:fill-box;transform-origin:100% 80%}
.rd-blink{animation:rdBlink 4.2s infinite;transform-box:fill-box;transform-origin:50% 50%}
.rd-arm{animation:rdArm 2.4s ease-in-out infinite;transform-box:fill-box;transform-origin:0 0}
@keyframes rdBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-2px)}}
@keyframes rdSway{0%,100%{transform:rotate(0)}50%{transform:rotate(6deg)}}
@keyframes rdFlap{0%,100%{transform:rotate(0)}50%{transform:rotate(-12deg)}}
@keyframes rdBlink{0%,92%,100%{transform:scaleY(1)}95%{transform:scaleY(.1)}}
@keyframes rdArm{0%,100%{transform:rotate(0)}50%{transform:rotate(-4deg)}}
.rd-still *{animation:none !important}
@media (prefers-reduced-motion: reduce){.rd-bob,.rd-sway,.rd-flap,.rd-blink,.rd-arm{animation:none}}
.pt-bob{animation:ptBob 2.2s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 100%}
.pt-wag{animation:ptWag 1s ease-in-out infinite;transform-box:fill-box;transform-origin:0 100%}
.pt-flapL{animation:ptFlapL 1.4s ease-in-out infinite;transform-box:fill-box;transform-origin:100% 30%}
.pt-flapR{animation:ptFlapR 1.4s ease-in-out infinite;transform-box:fill-box;transform-origin:0 30%}
.pt-blink{animation:ptBlink 4s infinite;transform-box:fill-box;transform-origin:50% 50%}
.pt-sway{animation:ptSway 2.8s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 0}
.pt-glow{animation:ptGlow 2.4s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 50%}
@keyframes ptBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
@keyframes ptWag{0%,100%{transform:rotate(-6deg)}50%{transform:rotate(10deg)}}
@keyframes ptFlapL{0%,100%{transform:rotate(0)}50%{transform:rotate(14deg)}}
@keyframes ptFlapR{0%,100%{transform:rotate(0)}50%{transform:rotate(-14deg)}}
@keyframes ptBlink{0%,93%,100%{transform:scaleY(1)}96%{transform:scaleY(.1)}}
@keyframes ptSway{0%,100%{transform:rotate(4deg)}50%{transform:rotate(-4deg)}}
@keyframes ptGlow{0%,100%{transform:scale(.94);opacity:.7}50%{transform:scale(1.04);opacity:1}}
.pt-still *{animation:none !important}
@media (prefers-reduced-motion: reduce){.pt-bob,.pt-wag,.pt-flapL,.pt-flapR,.pt-blink,.pt-sway,.pt-glow{animation:none}}
.ps-bob{animation:psBob .6s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 100%}
.ps-legA{animation:psLeg .6s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 0}
.ps-legB{animation:psLeg .6s ease-in-out infinite reverse;transform-box:fill-box;transform-origin:50% 0}
.ps-wag{animation:psWag .5s ease-in-out infinite;transform-box:fill-box;transform-origin:100% 100%}
.ps-flap{animation:psFlap .7s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 20%}
.ps-blink{animation:psBlink 4s infinite;transform-box:fill-box;transform-origin:50% 50%}
.ps-glow{animation:psGlow 2.4s ease-in-out infinite;transform-box:fill-box;transform-origin:50% 50%}
.ps-wave{animation:psWave 1.2s ease-in-out infinite;transform-box:fill-box;transform-origin:100% 50%}
@keyframes psBob{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}
@keyframes psLeg{0%,100%{transform:rotate(16deg)}50%{transform:rotate(-16deg)}}
@keyframes psWag{0%,100%{transform:rotate(-8deg)}50%{transform:rotate(12deg)}}
@keyframes psFlap{0%,100%{transform:rotate(0)}50%{transform:rotate(-18deg)}}
@keyframes psBlink{0%,93%,100%{transform:scaleY(1)}96%{transform:scaleY(.1)}}
@keyframes psGlow{0%,100%{opacity:.6}50%{opacity:1}}
@keyframes psWave{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
.ps-still *{animation:none !important}
@media (prefers-reduced-motion: reduce){.ps-bob,.ps-legA,.ps-legB,.ps-wag,.ps-flap,.ps-blink,.ps-glow,.ps-wave{animation:none}}
.avatar-svg.tiny { width: 34px; display: inline-block; vertical-align: middle; }
.avatar-svg.tiny svg, .avatar-svg.mini svg { border-radius: 0; }
#me-card .avatar { overflow: hidden; border-radius: 50%; background: #fff0f7; }
#me-card .avatar .avatar-svg { width: 52px; margin: -2px 0 0 -3px; }
.reg-gender { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 10px; }
.gpick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border-radius: 18px; border: 3px solid transparent; background: rgba(255,255,255,.7); cursor: pointer; font: inherit; color: inherit; }
.gpick .gp-img { width: 86px; }
.gpick.on { border-color: #ff7eb6; background: #fff; box-shadow: 0 4px 0 #f3d6e6; }
.gpick b { font-size: 18px; } .gpick small { font-size: 13px; opacity: .8; }
.gender-switch { display: flex; gap: 6px; background: #fff; border-radius: 16px; padding: 4px; box-shadow: inset 0 0 0 2px #f3d6e6; }
.gsw { display: flex; align-items: center; gap: 6px; min-height: 44px; border: 0; border-radius: 12px; padding: 0 12px 0 6px; background: transparent; color: #3a2540; font: inherit; font-weight: 900; cursor: pointer; }
.gsw.on { background: #3d6fb6; color: #fff; } .gsw.on[data-gender="nu"] { background: #d6337f; }
.shop-daily { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.shop-daily .meter { width: 140px; }
.ic-img { position: relative; background: #fff3f8; }
.gtag { position: absolute; top: 6px; left: 6px; z-index: 2; font-size: 12px; font-weight: 900; color: #fff; border-radius: 6px; padding: 2px 6px; }
.gtag.nam { background: #2f5a9a; } .gtag.nu { background: #b0307e; } .gtag.chung { background: #2f7a64; }
.ex-ic { display: flex; align-items: center; justify-content: center; aspect-ratio: 240 / 320; background: #f3ecff; }
.reward { font-size: 13px; font-weight: 900; color: #2f7a4f; }
.seed-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; color: #1f6b40; background: #dff5e6; border-radius: 999px; padding: 4px 12px; box-shadow: inset 0 0 0 2px #9ed9b0; }
.fb-notes { background: #fff8e1; border: 2px solid #f5c542; border-radius: 14px; padding: 8px 12px; font-weight: 800; display: flex; flex-direction: column; gap: 4px; }
.pet-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.pets-note { margin: 0 0 6px; }
.pet-card .ic-img { background: #fff6dc; }
.pet-card.dim-pet .ic-img { opacity: .5; }
.pet-card .cond { color: #7c3aed; font-weight: 800; }
.pet-stage { display: flex; align-items: flex-end; justify-content: center; background: linear-gradient(#bfe6ff, #d9f5d0); border-radius: 18px; padding: 10px; min-height: 230px; }
.pet-stage .pet-owner { width: 150px; }
.pet-stage .pet-big { width: 130px; margin-left: -16px; }
.egg-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; background: #fff; border: 3px dashed #9ed9b0; border-radius: 20px; padding: 12px 16px; margin-bottom: 10px; }
.egg-card .grow { flex: 1; min-width: 200px; } .egg-card p { margin: 2px 0; } .ok-txt { color: #2f7a4f; font-weight: 800; }
.ws { position: relative; }
body.theme-cute .slot-tab.on { background: #ff4f9a; border-color: #ff4f9a; color: #fff; }
.slot-tabs { grid-template-columns: repeat(9, minmax(0, 1fr)); }
@media (max-width: 1100px) { .slot-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 600px) { .slot-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#g-touch .tc-fire, #g-touch .tc-fire small, #g-touch .tc-fire b { color: #fff !important; }
#g-touch .tc-fire { box-shadow: 0 0 0 var(--ring, 0px) rgba(255, 213, 74, 0.75), 0 6px 0 #9f2622 !important; background: #e2413b !important; }
#g-touch .tc-fire.cancel { background: #8a7a93 !important; }

/* ======================================================================
   v5.1: chữ to hơn cho bé + phòng chờ trên iPad/điện thoại
   - nút SẴN SÀNG / BẮT ĐẦU luôn nhìn thấy (trước đây bị khung trái cắt mất trên iPad)
   - bảng chọn nhân vật gọn lại
   ====================================================================== */
.map-panel { overflow: auto; -webkit-overflow-scrolling: touch; }
#btn-ready { position: fixed; left: 28px; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: 274px; z-index: 40; min-height: 58px; font-size: 22px; box-shadow: 0 5px 0 #1f7f4c, 0 10px 26px rgba(0, 0, 0, 0.3); }
.map-panel { padding-bottom: 86px; }
.room-grid, .lobby-grid, .shop-grid, .teams, .picker, .lobby-grid > .panel { -webkit-overflow-scrolling: touch; }
@media (max-width: 1250px) {
  .room-grid { grid-template-columns: minmax(250px, 300px) 1fr; height: calc(100% - 58px); overflow-y: auto; align-content: start; padding-bottom: 100px; box-sizing: border-box; }
  .map-panel { overflow: visible; }
  .map-panel .chat { min-height: 150px; max-height: 220px; }
  #btn-ready { position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 40; min-width: 260px; min-height: 64px; font-size: 24px; box-shadow: 0 5px 0 #1f7f4c, 0 10px 26px rgba(0, 0, 0, 0.35); }
  .teams { overflow: visible; }
  .picker { grid-column: 1 / -1; overflow: visible; }
  .pick-top { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: start; }
  #mob-big { width: 170px; height: auto; }
  #mob-info p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #mob-info .stats { grid-template-columns: 80px 1fr 80px 1fr; }
  #mob-info .shots { flex-direction: row; flex-wrap: wrap; }
  #mob-info .shot { flex: 1 1 200px; padding: 6px 8px; }
  #mob-info .shot small { display: none; }
  #mob-grid { margin-top: 8px; }
}
@media (max-width: 860px) {
  .room-grid { grid-template-columns: 1fr; }
  .pick-top { grid-template-columns: 130px 1fr; }
  #mob-big { width: 130px; }
  #mob-info .stats { grid-template-columns: 70px 1fr; }
  #btn-ready { left: 12px; right: 12px; min-width: 0; }
}
#screen-pets { overflow-y: auto; -webkit-overflow-scrolling: touch; }
#screen-pets .shop-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; padding: 16px; max-width: 1280px; margin: 0 auto; align-items: start; }
@media (max-width: 900px) { #screen-pets .shop-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .lobby-grid { align-content: start; overflow-y: auto; padding-bottom: 30px; box-sizing: border-box; }
  .lobby-grid > .panel { overflow: visible; }
}

/* sảnh & phòng chờ: đầu trang cao bao nhiêu thì khung chính co lại bấy nhiêu (điện thoại cầm ngang) */
#screen-lobby.on, #screen-room.on { display: flex; flex-direction: column; }
#screen-lobby .lobby-grid, #screen-room .room-grid { flex: 1 1 auto; min-height: 0; height: auto !important; }
#screen-room:not(.on) #btn-ready { display: none; }
@media (max-width: 1250px) { .map-panel { padding-bottom: 14px; } }
@media (max-width: 860px) {
  #room-thumb { max-height: 130px; width: auto; max-width: 100%; align-self: center; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
}
@media (max-height: 500px) {
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  #btn-ready { min-height: 50px; font-size: 20px; }
}
@media (max-width: 1250px) { #btn-ready { left: auto; width: auto; } }
@media (max-width: 860px) { #btn-ready { left: 12px; right: 12px; } }
.stats { grid-template-columns: 86px 1fr; }
.addbot select, .botctl select { min-width: 0; max-width: 150px; }
.addbot select { width: auto; }
.side > .panel { flex-shrink: 0; }
@media (max-width: 860px) { .side { overflow: visible; } }
.warn-txt{color:#c2410c}.stat-note{margin:6px 0 0;line-height:1.45}
.gup{font-style:normal;font-weight:900;color:#1f8a4f;font-size:.85em}.gear-line{margin:6px 0;font-size:14px;font-weight:800;color:#1f8a4f}
.sp-stats .sm-row b{white-space:nowrap;font-size:14px}.sp-stats .sm-row b small{font-size:12px}.sp-stats .sm-row b em{font-size:12px}

/* v5.1 — hình trong câu hỏi */
.qfig { margin: 10px auto 12px; max-width: 480px; }
.qfig-btn { position: relative; display: block; width: 100%; padding: 0; border: 2px solid #f0dbe8; border-radius: 18px; background: #fffdf7; cursor: zoom-in; overflow: hidden; }
.qfig-svg { display: block; width: 100%; height: auto; }
.qfig-zoom { display: block; text-align: right; margin-top: 4px; font-size: 13px; font-weight: 800; color: #8a6fb8; }
.qfig.rev .qfig-btn { border-color: #ffb3d1; }
.qfig figcaption { margin-top: 6px; text-align: center; font-weight: 900; font-size: 17px; color: #c2185b; }
.qfig-over { position: fixed; inset: 0; z-index: 200; background: rgba(30, 16, 40, .78); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; cursor: zoom-out; }
.qfig-big { width: min(96vw, 140vh); max-height: 86vh; background: #fffdf7; border-radius: 20px; padding: 10px; box-sizing: border-box; display: flex; }
.qfig-big svg { width: 100%; height: auto; max-height: calc(86vh - 20px); }
.qfig-over p { color: #fff; font-weight: 800; margin: 0; font-size: 15px; }
body.theme-dark .qfig-btn, body:not(.theme-cute) .qfig-btn { border-color: rgba(255,255,255,.15); }
body.theme-cute .qdot.cur { color: #3a2540; background: #fff; border-color: var(--c); border-width: 2px; font-weight: 900; }
body.theme-cute .subj-chip { color: #3a2540; background: color-mix(in srgb, var(--c) 16%, #fff); }
body.theme-cute .fb-gap { color: #a14d00; } .fb .qfig { max-width: 440px; }
/* v5.2 — sảnh trên điện thoại dọc: nút trên cùng xếp lưới gọn, không chiếm nửa màn hình */
@media (max-width: 600px) {
  #screen-lobby .topbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; align-items: stretch; }
  #screen-lobby .topbar .logo, #screen-lobby #online, #screen-lobby #me-card { grid-column: 1 / -1; }
  #screen-lobby .topbar .logo { font-size: 22px; margin: 0; }
  #screen-lobby .topbar .btn { font-size: 13px; padding: 6px 4px; min-height: 44px; min-width: 0; white-space: normal; line-height: 1.15; text-align: center; justify-content: center; }
  #screen-lobby #lobby-coins { grid-column: span 2; justify-content: center; font-size: 16px; }
}
/* v5.3 — chân dung trong bảng tên, băng "Lượt của bạn" có nhân vật */
.gp.has-ava { display: flex; gap: 5px; align-items: center; padding-left: 3px; }
.gp-main { flex: 1; min-width: 0; }
.gp-ava { flex: none; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; background: #ffe6f1; border: 2px solid rgba(255,255,255,.85); position: relative; }
.gp-ava img { position: absolute; width: 62px; height: 62px; left: -17px; top: -6px; }
#g-banner.with-ava { display: flex; align-items: center; justify-content: center; gap: 6px; }
#g-banner .gb-ava { width: 120px; height: 120px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.45)); }
/* v5.4 — cú bắn đẹp */
#g-trick { position: absolute; left: 0; right: 0; top: 24%; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; opacity: 0; z-index: 30; }
#g-trick.show { animation: trickIn 2.6s ease-out forwards; }
#g-trick b { font-family: 'Baloo 2', Nunito, sans-serif; font-size: 50px; font-weight: 800; color: #ffd34d; letter-spacing: 1px; text-shadow: 0 4px 0 #3a2540, 0 0 18px rgba(0,0,0,.6); line-height: 1; }
#g-trick .tk-chips { display: flex; gap: 8px; }
#g-trick .tk-chips span { font-size: 18px; font-weight: 900; border-radius: 12px; padding: 4px 12px; }
.tk-xu { background: #ffd34d; color: #3a2540; } .tk-gp { background: #6b3fd1; color: #fff; } .tk-combo { background: #d6337f; color: #fff; }
#g-trick small { font-size: 19px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #3a2540; }
@keyframes trickIn { 0% { opacity: 0; transform: scale(1.8); } 10% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }
.over-tricks { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.over-tricks > b { font-size: 16px; }
.ot-row { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 10px; align-items: center; background: rgba(255,255,255,.08); border-radius: 10px; padding: 6px 10px; font-size: 14px; font-weight: 800; }
body.theme-cute .ot-row { background: #faf5fb; }
.ot-xu { color: #e0a000; } .ot-gp { color: #b78bff; }

/* v5.4 — trận tràn màn hình, HUD là dải mỏng trong suốt */
#g-hud { left: 6px; right: 6px; bottom: 6px; height: 96px; border-radius: 18px; border: 0 !important; background: rgba(16, 12, 36, 0.72) !important; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 4px 10px; }
#g-hud.active { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 211, 77, 0.25) !important; }
#g-dial { width: 88px; height: 88px; }
.shot-btn { font-size: 13px; font-weight: 800; padding: 4px 8px; border-radius: 10px; }
.shot-btn.sel { background: #ff4f9a; border-color: #ff4f9a; color: #fff; }
.shot-btn.sel .k { color: #fff; }
#g-power { height: 22px; border-radius: 10px; }
#g-power-val { font-size: 15px; }
.item-btn { width: 36px; height: 32px; border-radius: 9px; }
#g-mini { bottom: 108px; }
#g-chat { bottom: 108px; }
#g-timerbox { bottom: 196px; }
#g-side .btn { min-height: 30px; }
/* iPad / máy tính bảng ngang: nút cảm ứng nổi ở hai góc dưới, ngay trên dải HUD */
body.touch.tc-overlay #g-touch .tc-left, body.touch.tc-overlay #g-touch .tc-right { bottom: calc(var(--hudpx, 150px) + env(safe-area-inset-bottom, 0px)); }
body.touch.tc-overlay #g-touch .tc-btn { opacity: 0.92; }
body.touch.tc-overlay #g-chat { bottom: auto; top: 170px; width: 230px; }
body.touch.tc-overlay #g-chatin { display: none; }
body.touch.tc-overlay #g-mini { bottom: auto; top: 170px; }
body.touch.tc-overlay #g-timerbox { bottom: auto; top: 262px; }

/* ======================================================================
   v5.4 — sắp xếp lại giao diện: thanh 5 mục, sảnh mới, màn "Tôi",
   phòng chờ có chân trang cố định + bảng cài đặt trượt
   ====================================================================== */
#mainnav { display: none; position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
body[data-view="lobby"] #mainnav, body[data-view="shop"] #mainnav, body[data-view="pets"] #mainnav,
body[data-view="learn"] #mainnav, body[data-view="me"] #mainnav { display: flex; }
#mainnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; color: var(--dim); font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; border-radius: 14px; padding: 6px 2px; min-height: 52px; }
#mainnav button i { font-style: normal; font-size: 22px; line-height: 1; filter: grayscale(.5); }
#mainnav button.on { color: var(--gold); background: rgba(255, 211, 77, .12); }
#mainnav button.on i { filter: none; transform: scale(1.12); }
#mainnav button.hidden { display: none; }
/* dọc: thanh dưới */
#mainnav { left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom, 0px)); padding: 6px 8px env(safe-area-inset-bottom, 0px); border-width: 1px 0 0; gap: 4px; }
body[data-view] .screen.navscr { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
/* ngang: thanh dọc bên trái */
@media (orientation: landscape) {
  #mainnav { top: 0; bottom: 0; right: auto; width: calc(80px + env(safe-area-inset-left, 0px)); height: auto; flex-direction: column; justify-content: center; padding: 10px 6px 10px calc(6px + env(safe-area-inset-left, 0px)); border-width: 0 1px 0 0; gap: 6px; }
  #mainnav button { flex: 0 0 auto; min-height: 64px; }
  body[data-view] .screen.navscr { bottom: 0; left: calc(80px + env(safe-area-inset-left, 0px)); }
}
@media (orientation: landscape) and (max-height: 430px) {
  #mainnav { width: calc(66px + env(safe-area-inset-left, 0px)); gap: 2px; }
  #mainnav button { min-height: 52px; font-size: 11px; }
  #mainnav button i { font-size: 19px; }
  body[data-view] .screen.navscr { left: calc(66px + env(safe-area-inset-left, 0px)); }
}
body.theme-cute #mainnav { background: rgba(255, 255, 255, .92); border-color: #f0dbe8; }
body.theme-cute #mainnav button { color: #9b7aa6; }
body.theme-cute #mainnav button.on { color: #e8559b; background: #ffe6f1; }

/* sảnh */
#screen-lobby .topbar.lb-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#screen-lobby .lb-top #me-card { flex: 0 1 auto; min-width: 0; }
#screen-lobby .lb-top #me-card .gpbar { min-width: 160px; }
#screen-lobby .lb-top #online { font-size: 14px; color: var(--dim); }
.streak-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; color: #a14d00; background: #ffe9cf; border-radius: 999px; padding: 4px 12px; box-shadow: inset 0 0 0 2px #ffc58a; }
.streak-pill.hidden { display: none; }
.lobby-grid.lb2 { grid-template-columns: 1fr 340px; }
.lb-main { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.lb-main > .panel { flex-shrink: 0; }
.lb-hero { display: flex; align-items: center; gap: 18px; background: linear-gradient(135deg, rgba(107, 63, 209, .35), rgba(14, 22, 48, .9)); }
.lb-hero canvas { flex: none; width: 240px; height: 150px; }
.lb-hero-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-hero-txt h2 { margin: 0; font-size: 26px; }
.lb-hero-txt p { margin: 0; }
.lb-hero-txt #btn-practice { font-size: 22px; min-height: 60px; }
.lb-hero-row { display: flex; gap: 8px; }
.lb-hero-row .btn { flex: 1; min-height: 48px; }
.lb-learn { display: flex; align-items: center; gap: 14px; }
.lb-learn .ll-ico { font-size: 34px; }
.lb-learn .ll-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lb-learn .ll-txt b { font-size: 18px; }
.lb-learn .ll-txt small { color: var(--dim); }
.lb-rooms h2 { margin-top: 0; }
.room-item .ri-id { font-weight: 900; font-size: 18px; color: var(--gold); min-width: 46px; }
.room-item .ri-count { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 13px; font-weight: 800; }
.ri-dots { display: flex; gap: 3px; }
.ri-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .18); }
.ri-dots i.on { background: var(--green); }
.room-item.full .ri-dots i.on { background: var(--red); }
body.theme-cute .lb-hero { background: linear-gradient(135deg, #ffe6f1, #fff7e0); }
body.theme-cute .lb-hero-txt h2 { color: #6b3fd1; }
body.theme-cute .ri-dots i { background: #eadcef; }
body.theme-cute .room-item .ri-id { color: #e8559b; }
@media (max-width: 1100px) { .lobby-grid.lb2 { grid-template-columns: 1fr 280px; } .lb-hero canvas { width: 190px; height: 119px; } }
@media (max-width: 860px) {
  .lobby-grid.lb2 { grid-template-columns: 1fr; }
  .lb-main { overflow: visible; min-height: auto; }
  #screen-lobby #top-list tr:nth-child(n+4) { display: none; }
}
@media (max-width: 600px) {
  #screen-lobby .topbar.lb-top { display: flex; padding: 8px 10px; gap: 6px; }
  #screen-lobby .lb-top #me-card { flex: 1 1 100%; }
  #screen-lobby .lb-top #online { display: none; }
  .lb-hero { flex-direction: column; text-align: center; gap: 6px; }
  .lb-hero canvas { width: 200px; height: 125px; }
  .lb-hero-txt h2 { font-size: 22px; }
  .lb-learn { flex-wrap: wrap; }
  .lb-learn .btn { flex: 1 1 100%; }
}
/* bảng trượt (tạo phòng / cài đặt phòng) */
.sheet-box { width: min(560px, 96vw); display: flex; flex-direction: column; gap: 10px; }
.sheet-box h2 { margin: 0 0 4px; }
@media (orientation: portrait) {
  .sheet-modal { place-items: end center; }
  .sheet-box { width: 100vw; max-height: 86vh; border-radius: 22px 22px 0 0 !important; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); animation: sheetUp .22s ease-out; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .3; } to { transform: none; opacity: 1; } }

/* màn Tôi */
#screen-me { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.me-wrap { max-width: 1000px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.me-head { display: flex; align-items: center; gap: 18px; }
.me-av { width: 110px; height: 110px; flex: none; border-radius: 50%; overflow: hidden; background: rgba(255, 255, 255, .08); display: grid; place-items: center; }
.me-av > * { max-width: 100%; max-height: 100%; }
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.me-info h3 { margin: 0; font-size: 24px; }
.me-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.me-stats span { display: flex; flex-direction: column; align-items: center; background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 6px 2px; font-size: 12px; color: var(--dim); }
.me-stats b { font-size: 20px; color: var(--txt); }
.me-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.me-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 84px; font-size: 26px; text-decoration: none; }
.me-tile span { font-size: 15px; font-weight: 800; }
#btn-theme.me-tile { font-size: 16px; font-weight: 800; }
.me-tile.hidden { display: none; }
.trick-book { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tb-item { display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 14px; padding: 10px 6px; background: rgba(255, 255, 255, .05); opacity: .55; text-align: center; }
.tb-item i { font-style: normal; font-size: 30px; filter: grayscale(1); }
.tb-item b { font-size: 14px; }
.tb-item small { color: var(--dim); font-weight: 800; }
.tb-item.got { opacity: 1; background: rgba(255, 211, 77, .14); box-shadow: inset 0 0 0 2px var(--line); }
.tb-item.got i { filter: none; }
.tb-item.got small { color: var(--gold); }
body.theme-cute .me-stats span, body.theme-cute .tb-item { background: #faf5fb; }
body.theme-cute .me-stats b { color: #3a2540; }
body.theme-cute .tb-item.got { background: #fff4d6; box-shadow: inset 0 0 0 2px #ffd34d; }
body.theme-cute .tb-item.got small { color: #b07800; }
@media (max-width: 600px) {
  .me-head { flex-direction: column; text-align: center; }
  .me-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .me-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .me-tile { min-height: 72px; font-size: 22px; }
  .me-tile span { font-size: 13px; }
}

/* phòng chờ: chip cài đặt + chân trang cố định */
.room-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; font-weight: 800; background: rgba(255, 255, 255, .1); color: var(--txt); cursor: pointer; }
.chip:disabled { cursor: default; opacity: .9; }
.chip.edit { background: var(--gold); color: #3a2540; }
body.theme-cute .chip { background: #f3e8f7; color: #3a2540; }
body.theme-cute .chip.edit { background: #e8559b; color: #fff; }
.room-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--panel); border-top: 1px solid var(--line); z-index: 40; }
.room-foot #room-foot-info { flex: 1; min-width: 0; font-weight: 800; }
.room-foot .tr { color: var(--red); } .room-foot .tb { color: var(--blue); }
.room-foot #btn-roomset.hidden { display: none; }
#screen-room .room-foot #btn-ready { position: static; left: auto; right: auto; bottom: auto; width: auto; min-width: 240px; min-height: 56px; font-size: 22px; }
#screen-room .room-grid { padding-bottom: 16px !important; }
#screen-room .map-panel { padding-bottom: 14px; }
body.theme-cute .room-foot { background: rgba(255, 255, 255, .94); border-top: 2px solid #f0dbe8; }
@media (max-width: 860px) {
  .room-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  #screen-room .room-foot #btn-ready { min-width: 0; flex: 1 1 50%; }
  .room-foot #room-foot-info { flex: 0 1 auto; font-size: 13px; }
}
@media (max-height: 500px) { #screen-room .room-foot #btn-ready { min-height: 46px; font-size: 19px; } .room-foot { padding-top: 6px; padding-bottom: 6px; } }
@media (max-width: 600px) {
  .room-foot { gap: 6px; }
  .room-foot #btn-roomset .lbl { display: none; }
  .room-foot #room-foot-info { font-size: 12px; line-height: 1.2; max-width: 92px; }
  #screen-room .room-foot #btn-ready { font-size: 19px; padding-left: 8px; padding-right: 8px; }
}
#screen-lobby .lb-top #online { white-space: nowrap; }

/* v5.4.1 — HUD gọn: 1 hàng đạn + vật phẩm, thanh lực, nút biểu tượng 3×2; chữ góc/lực nổi phía trên */
#g-hud { height: 66px; gap: 8px; padding: 4px 8px; overflow: visible; }
#g-dial { width: 58px; height: 58px; }
#g-mid { gap: 3px; justify-content: center; }
#g-hud .g-top { gap: 6px; }
#g-hud #g-shots { flex: 1; min-width: 0; gap: 4px; }
#g-hud .shot-btn { font-size: 11.5px; padding: 3px 7px; border-radius: 8px; min-height: 24px; }
#g-hud #g-items { flex: none; gap: 3px; }
#g-hud .item-btn { width: 26px; height: 24px; font-size: 14px; border-radius: 7px; }
#g-hud .item-btn .k { font-size: 7px; }
#g-hud #g-power { height: 18px; border-radius: 8px; }
#g-hud #g-power-ticks b { font-size: 8px; }
#g-hud #g-move { height: 4px; }
#g-hud #g-side { display: grid; grid-template-columns: repeat(3, 26px); grid-auto-rows: 26px; gap: 3px; width: auto; align-content: center; }
#g-hud #g-side .btn { min-height: 0; height: 26px; width: 26px; padding: 0; font-size: 13px; border-radius: 8px; display: grid; place-items: center; position: relative; }
#g-hud #g-gfx[data-q]::after { content: attr(data-q); position: absolute; right: 1px; bottom: -1px; font-size: 8px; font-weight: 900; color: var(--gold); }
#g-hud #g-power-val { position: absolute; right: 10px; bottom: calc(100% + 4px); margin: 0; font-size: 13px; pointer-events: none; background: rgba(16, 12, 36, 0.6); padding: 1px 8px; border-radius: 8px; }
#g-hud #g-itemact { position: absolute; left: 10px; bottom: calc(100% + 4px); font-size: 11px; pointer-events: none; text-shadow: 0 1px 2px #000; }
#g-hud #g-itemact:empty, #g-hud #g-power-val:empty { display: none; }
#g-mini { bottom: 96px; }
#g-chat { bottom: 96px; }
#g-timerbox { bottom: 184px; }

/* bảng kết thúc trận: cuộn được, nút "Về phòng chờ" luôn thấy */
#g-over { padding: 8px; overflow: hidden; }
#g-over .over-box { max-height: calc(100% - 4px); width: min(680px, 100%); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 14px 0; display: flex; flex-direction: column; }
#g-over .over-box h1 { font-size: 34px; margin: 4px 0; }
#g-over .over-box p { margin: 0 0 4px; }
#g-over .over-box table { font-size: 13px; margin: 4px 0; }
#g-over .over-box td, #g-over .over-box th { padding: 3px 4px; }
#g-over .over-tricks { margin: 4px 0; gap: 4px; }
#g-over .ot-row { font-size: 12px; padding: 3px 8px; grid-template-columns: 100px 1fr auto auto; }
#g-over .over-foot { position: sticky; bottom: 0; margin-top: auto; padding: 8px 0 10px; background: var(--panel); display: flex; gap: 8px; justify-content: center; }
#g-over .over-foot .btn { min-height: 40px; font-size: 16px; }

/* ======================================================================
   v5.5 — thông báo trong trận gọn lại: giữa sân luôn trống
   ====================================================================== */
#g-center { position: relative; }
#g-weather { transition: opacity .2s; }
#g-weather.under { opacity: 0; }
/* dải thông báo một dòng, đè đúng chỗ chip thời tiết */
#g-ticker { position: absolute; top: 84px; left: 50%; transform: translateX(-50%) translateY(-4px); display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px 0 4px; border-radius: 999px;
  background: rgba(22, 14, 44, 0.9); border: 2px solid #6b6f8a; color: #fff; font-size: 12.5px; white-space: nowrap; max-width: 380px; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 35; box-shadow: 0 3px 10px rgba(0,0,0,.3); }
#g-ticker.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#g-ticker .tk-ic { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; background: #6b6f8a; flex: none; }
#g-ticker b { font-weight: 900; }
#g-ticker .tk-t { color: #ddd3f2; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
#g-ticker.k-wx { border-color: #8b5cf6; } #g-ticker.k-wx .tk-ic { background: #8b5cf6; }
#g-ticker.k-warn { border-color: #ff8a3d; } #g-ticker.k-warn .tk-ic { background: #ff8a3d; }
#g-ticker.k-legend { border-color: #ffd34d; background: linear-gradient(90deg, #7a3c00, #3a2540); } #g-ticker.k-legend .tk-ic { background: #ffd34d; color: #3a2540; font-weight: 900; }
#g-ticker.k-legend b { color: #ffd34d; }
/* lượt của bé: dải vàng cỡ vừa ngay dưới đồng hồ gió */
#g-banner { left: 50%; right: auto; top: 112px; transform: translateX(-50%); display: flex !important; align-items: center; gap: 6px; height: 34px; padding: 0 16px 0 5px; border-radius: 999px;
  background: linear-gradient(90deg, #ffb703, #ffd34d); border: 2px solid #fff; color: #3a2540 !important; font-family: 'Baloo 2', Nunito, sans-serif; font-size: 20px; font-weight: 800; letter-spacing: .5px;
  text-shadow: none; box-shadow: 0 3px 0 #c98a00, 0 6px 14px rgba(0,0,0,.25); white-space: nowrap; z-index: 34; }
#g-banner .rb-ic { width: 26px; height: 26px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
#g-banner.show { animation: ribbon 1.5s ease-out forwards; }
@keyframes ribbon { 0% { opacity: 0; transform: translateX(-50%) scale(.6); } 12% { opacity: 1; transform: translateX(-50%) scale(1.06); } 20% { transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); } }
/* người đang bắn: bảng tên sáng viền vàng, người khác mờ đi */
#g-top.turn .gp:not(.act):not(.dead) { opacity: .62; }
.gp.act { box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(255, 211, 77, .6); position: relative; }
.gp.act::after { content: '▶ đang ngắm'; position: absolute; right: 4px; bottom: -11px; font-size: 9px; font-weight: 900; color: #3a2540; background: var(--gold); border-radius: 999px; padding: 0 6px; line-height: 13px; }
/* cú bắn đẹp: bỏ băng chữ giữa màn hình (đã vẽ ngay chỗ đạn trúng) */
#g-trick { display: none !important; }
#g-toast { display: none !important; }
/* bong bóng nhắc lỗi ngay trên nút */
#g-bubble { position: absolute; bottom: 82px; transform: translateX(-50%) translateY(6px); background: #fff; color: #3a2540; border-radius: 10px; padding: 4px 10px; font-size: 12px; font-weight: 900; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 46; }
#g-bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
#g-bubble.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* chú thích nút (chỉ chuột) */
#g-tip { position: absolute; bottom: 74px; transform: translateX(-50%); background: rgba(22, 14, 44, 0.95); color: #fff; border-radius: 8px; padding: 3px 9px; font-size: 11px; font-weight: 800; white-space: nowrap;
  max-width: 420px; overflow: hidden; text-overflow: ellipsis; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 45; }
#g-tip.show { opacity: 1; }
/* phòng chờ: ô 🎲 Ngẫu nhiên */
.mob-tile.rnd { background: linear-gradient(160deg, #6b3fd1, #ff4f9a) !important; color: #fff !important; }
.mob-tile.rnd .rnd-dice { font-size: 34px; line-height: 58px; height: 58px; display: block; }
.mob-tile.rnd.sel { box-shadow: 0 0 0 3px #ffb703, 0 0 0 6px rgba(255, 183, 3, .35); }
.legend-note { background: #fff4d6; color: #7a4d00; border-radius: 10px; padding: 8px 10px; font-weight: 700; }
body:not(.theme-cute) .legend-note { background: rgba(255, 211, 77, .14); color: #ffd34d; }
/* màn Tôi: sổ xe huyền thoại */
.legend-book { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lb-item { display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 14px; padding: 8px 6px; background: rgba(255, 255, 255, .05); text-align: center; }
.lb-item canvas { width: 120px; height: 96px; }
.lb-item b { font-size: 14px; }
.lb-item small { color: var(--dim); font-weight: 800; }
.lb-item.got { background: rgba(255, 211, 77, .14); box-shadow: inset 0 0 0 2px #ffd34d; }
.lb-item.got small { color: #c98a00; }
body.theme-cute .lb-item { background: #faf5fb; }
body.theme-cute .lb-item.got { background: #fff4d6; }
.me-ver { text-align: center; font-size: 13px; margin: 4px 0 12px; }
