:root {
  --bg: #2a1838;
  --panel: rgba(32, 14, 34, 0.78);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff6fa;
  --muted: #e9c9d8;
  --accent: #ff6f61;
  --accent2: #ff9f43;
  --pink: #ff7aa2;
  --font: "Be Vietnam Pro", system-ui, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: #ffc2d6; }

#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; }

/* bảng tên trên đầu nhân vật */
.tag { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 9px 4px; border-radius: 10px; background: rgba(25, 8, 25, 0.72); color: #fff; font-size: 12px; line-height: 1.2; white-space: nowrap; text-align: center; }
.tag b { font-weight: 700; }
.tag span { font-size: 10.5px; color: #ffd3e3; }
.tag.me { background: rgba(255, 111, 97, 0.92); }
.tag.me span { color: #fff; }
.zzz { font-size: 20px; animation: zzz 2.4s ease-in-out infinite; }
@keyframes zzz { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-10px); opacity: 1; } }
/* hiệu ứng cổ vũ: bắt đầu ngay trên bảng tên rồi bay lên */
.cheer { font-size: 34px; line-height: 1; white-space: nowrap; filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); animation: cheer 3s ease-out forwards; }
.cheer.txt { font-size: 16px; font-weight: 800; color: #fff; padding: 6px 12px; border-radius: 999px; background: linear-gradient(135deg, #ff9f43, #ff5e8a); filter: none; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
@keyframes cheer {
  0% { transform: translateY(-26px) scale(.4); opacity: 0; }
  12% { transform: translateY(-40px) scale(1.15); opacity: 1; }
  25% { transform: translateY(-44px) scale(1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-110px) scale(1); opacity: 0; }
}

/* thanh trên cùng */
#top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; z-index: 5; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { font-size: 17px; padding: 6px 12px; border-radius: 999px; background: var(--panel); backdrop-filter: blur(8px); white-space: nowrap; }
.grow { flex: 1; }
.pill { border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(8px); border-radius: 999px; padding: 7px 13px; font-size: 13.5px; white-space: nowrap; cursor: pointer; }
div.pill { cursor: default; }
.pill.strong { background: linear-gradient(135deg, var(--accent2), var(--accent)); border-color: transparent; font-weight: 600; }
.pill.icon { width: 38px; padding: 7px 0; text-align: center; }
.dot::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5be38a; margin-right: 6px; vertical-align: 1px; }

/* các nút trong game */
#courseChip { position: fixed; top: 62px; left: 16px; z-index: 4; display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 12px; background: linear-gradient(135deg, #ff9f43, #ff5e8a); color: #fff; text-decoration: none; font-weight: 600; font-size: 13.5px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
#courseChip small { font-weight: 400; font-size: 10.5px; opacity: .85; }
#roomBtns { position: fixed; top: 62px; right: 16px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#roomBtns button { border: 0; border-radius: 12px; padding: 9px 14px; background: #fff; color: #7a1e2e; font-weight: 700; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
#roomBtns #actBtn { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; }
#actList { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px 12px; border-radius: 16px; border: 2px solid transparent; background: rgba(255,255,255,.07); cursor: pointer; }
.act:hover { background: rgba(255,255,255,.13); }
.act.on { border-color: var(--accent); background: rgba(255,111,97,.18); }
.act .ic { font-size: 34px; }
.act b { font-size: 15px; }
.act small { font-size: 12px; color: var(--muted); }
#actionBtn { position: fixed; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 4; border: 0; border-radius: 16px; padding: 14px 26px; font-size: 17px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent2), var(--accent)); box-shadow: 0 8px 26px rgba(255, 111, 97, .45); cursor: pointer; animation: pop .25s ease-out; white-space: nowrap; }
#actionBtn small { display: block; font-size: 11px; font-weight: 400; opacity: .9; }
@keyframes pop { from { transform: translateX(-50%) scale(.85); opacity: 0; } }

#bar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4; display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: calc(100% - 32px); }
#bar .row { display: flex; gap: 6px; padding: 6px; border-radius: 16px; background: var(--panel); backdrop-filter: blur(8px); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
#bar button { flex: none; border: 1px solid transparent; background: rgba(255,255,255,.08); border-radius: 11px; padding: 7px 11px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
#bar button:hover { background: rgba(255,255,255,.16); }
#bar button.on { background: #fff; color: #7a1e2e; font-weight: 700; }
#cheers button { font-size: 18px; padding: 5px 9px; }
#cheers button.txt { font-size: 13px; font-weight: 600; }
#howto { position: fixed; bottom: 112px; left: 50%; transform: translateX(-50%); margin: 0; font-size: 12px; color: var(--muted); background: var(--panel); padding: 5px 12px; border-radius: 999px; white-space: nowrap; z-index: 3; transition: opacity 1s; }

#joy { position: fixed; left: 22px; bottom: max(26px, env(safe-area-inset-bottom)); width: 116px; height: 116px; border-radius: 50%; background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.3); z-index: 4; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 2px 10px rgba(0,0,0,.3); }

#toast { position: fixed; top: 110px; left: 50%; transform: translateX(-50%); z-index: 20; max-width: min(460px, calc(100% - 32px)); padding: 10px 16px; border-radius: 12px; background: rgba(20, 8, 20, .92); font-size: 14px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .3s; }
#toast.show { opacity: 1; }

#peerMenu { position: fixed; z-index: 15; min-width: 170px; padding: 6px; border-radius: 12px; background: #fff; color: #3a1420; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
#peerMenu b { display: block; padding: 6px 10px 4px; }
#peerMenu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: inherit; }
#peerMenu button:hover { background: #ffe3ec; }

/* màn hình chào */
#landing { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(42,24,56,.35), rgba(42,24,56,.8)); overflow-y: auto; }
.card { position: relative; width: min(440px, 100%); padding: 30px 26px 22px; border-radius: 24px; background: rgba(30, 12, 32, .86); border: 1px solid var(--line); backdrop-filter: blur(12px); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.card .lang { position: absolute; top: 14px; right: 14px; }
.logo { font-size: 46px; }
.card h1 { margin: 4px 0 6px; font-size: 34px; font-weight: 800; background: linear-gradient(135deg, #ffb36b, #ff6f91); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { font-weight: 600; font-size: 16px; margin: 0 0 10px; }
.card p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 8px 0; }
#gbtn { display: flex; justify-content: center; margin: 18px 0 10px; min-height: 44px; }
#devLogin { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
#devLogin input { width: 140px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.08); }
.card .note { font-size: 12.5px; }
.links { font-size: 13px; }

/* hộp thoại */
dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100% - 40px); overflow-y: auto; border: 1px solid var(--line); border-radius: 20px; padding: 20px; background: #26122b; color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(10, 2, 12, .55); }
dialog h2 { margin: 0 0 12px; font-size: 19px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dlg-head h2 { margin: 0; }
.x { border: 0; background: rgba(255,255,255,.1); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
label { display: block; font-size: 13.5px; color: var(--muted); margin: 10px 0; }
label input:not([type=checkbox]), textarea { display: block; width: 100%; margin-top: 6px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.07); font-size: 15px; color: var(--text); }
textarea { margin: 12px 0; resize: vertical; }
.lbl { font-size: 13.5px; color: var(--muted); }
#colors { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
#colors button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
#colors button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.err { color: #ffb4a8; font-size: 13px; min-height: 1em; margin: 6px 0; }
.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 13px; font-size: 16px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent2), var(--accent)); cursor: pointer; }
#devLogin .btn { width: auto; padding: 9px 14px; font-size: 14px; }
.menu { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.menu > button, .menu > a, .menu-row { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; border: 0; background: rgba(255,255,255,.05); padding: 12px 14px; border-radius: 12px; color: var(--text); text-decoration: none; font-size: 14.5px; cursor: pointer; margin: 0; }
.menu > button:hover, .menu > a:hover { background: rgba(255,255,255,.11); }
.menu-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.danger { color: #ffb4a8 !important; }

/* Hành trình */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.stat { padding: 14px; border-radius: 16px; background: rgba(255,255,255,.06); }
.stat .v { font-size: 24px; font-weight: 800; line-height: 1.15; }
.stat .k { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat.hot { background: linear-gradient(135deg, rgba(255,159,67,.3), rgba(255,94,138,.3)); }
.strip { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin: 6px 0 16px; }
.strip i { aspect-ratio: 1; border-radius: 4px; background: rgba(255,255,255,.08); }
.strip i.on { background: linear-gradient(135deg, #ffb36b, #ff6f91); }
.rooms-list { display: flex; flex-direction: column; gap: 10px; }
.rrow { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.rrow .bar { grid-column: 2 / 4; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.rrow .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb36b, #ff6f91); }
.rrow small { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }

@media (max-width: 640px) {
  .brand b { display: none; }
  #journeyBtn span { display: none; }
  #where { overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
  #online { font-size: 12px; padding: 7px 10px; }
  #howto { display: none; }
  #courseChip small { display: none; }
}
@media (pointer: coarse) {
  #bar { left: auto; right: 12px; transform: none; max-width: calc(100% - 160px); align-items: flex-end; }
  #bar .lbl-txt { display: none; }
  #actionBtn { bottom: 170px; }
}
@media (max-width: 380px) { #online { display: none; } }
