:root { --ink: #f3e7cf; --gold: #e2b45c; --blood: #b3261e; --night: #140505; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font: 15px/1.4 -apple-system, BlinkMacSystemFont, system-ui, "Helvetica Neue", Arial, sans-serif; -webkit-user-select: none; user-select: none; }
#app { position: fixed; inset: 0; touch-action: none; }
#app canvas { display: block; width: 100%; height: 100%; }
button { font: inherit; cursor: pointer; }

#hud { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.brand { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; padding: 8px 12px; border: 1px solid rgba(226,180,92,.5); background: rgba(20,5,5,.6); border-radius: 6px; color: var(--gold); }
.ticket { text-align: right; font-size: 12px; padding: 8px 12px; background: rgba(20,5,5,.6); border-radius: 6px; }
.ticket b { color: var(--gold); font-size: 16px; }
.ticket span { display: block; opacity: .75; }

#prompt { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); padding: 14px 26px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); color: var(--ink); font-weight: 700; box-shadow: 0 0 24px rgba(255,80,40,.45); }
#lens { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); }
#lens i { position: absolute; width: 34px; height: 34px; border: 2px solid rgba(243,231,207,.55); }
#lens i:nth-child(1) { left: 16px; top: 64px; border-right: 0; border-bottom: 0; }
#lens i:nth-child(2) { right: 16px; top: 64px; border-left: 0; border-bottom: 0; }
#lens i:nth-child(3) { left: 16px; bottom: 44px; border-right: 0; border-top: 0; }
#lens i:nth-child(4) { right: 16px; bottom: 44px; border-left: 0; border-top: 0; }
#lens .rec, #tc { position: absolute; top: 74px; font: 700 12px ui-monospace, Menlo, monospace; letter-spacing: .1em; text-shadow: 0 1px 3px #000; }
#lens .rec { left: 60px; color: #ff4a3a; animation: rec 1.2s steps(2) infinite; }
#lens .rec::before { content: '●'; margin-right: 6px; }
#tc { right: 60px; color: rgba(243,231,207,.8); }
@keyframes rec { 50% { opacity: .25; } }
@media (max-width: 600px) {
  .brand { font-size: 10px; max-width: 150px; }
  #lens i:nth-child(1), #lens i:nth-child(2) { top: 104px; }
  #lens .rec, #tc { top: 114px; }
  #toast { top: 150px; width: calc(100% - 32px); }
}
#toast { position: fixed; left: 50%; top: 104px; transform: translateX(-50%); padding: 12px 18px; border-radius: 8px; background: rgba(10,0,0,.8); border: 1px solid var(--blood); font-weight: 700; color: #ff9b8c; letter-spacing: .04em; text-align: center; }

#card { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: rgba(10,0,0,.55); backdrop-filter: blur(3px); padding: 16px; }
#card[hidden], #gate[hidden], #prompt[hidden], #toast[hidden] { display: none; }
.id { width: min(440px, calc(100vw - 32px)); background: linear-gradient(135deg, #f1e7d1, #d9c9a6); color: #2a1410; border-radius: 14px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 0 2px #8a1d16; animation: rise .5s ease-out; }
.id-head { display: flex; flex-direction: column; border-bottom: 2px solid #8a1d16; padding-bottom: 8px; margin-bottom: 12px; }
.id-head span { font-size: 10px; letter-spacing: .14em; color: #8a1d16; font-weight: 700; }
.id-head strong { font-size: 20px; letter-spacing: .06em; }
.id-body { display: grid; grid-template-columns: 84px 1fr; gap: 12px; position: relative; }
.photo { height: 108px; border-radius: 6px; background: #3a2420; color: #c9b48d; display: grid; place-content: center; text-align: center; font-size: 10px; letter-spacing: .1em; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12px; }
dt { opacity: .65; } dd { margin: 0; font-weight: 700; }
dd.unk { color: #a3170f; letter-spacing: .04em; }
.seal { position: absolute; right: -10px; bottom: -22px; width: 64px; height: 64px; border: 3px solid rgba(179,38,30,.8); border-radius: 50%; color: rgba(179,38,30,.85); font-size: 10px; font-weight: 800; display: grid; place-content: center; text-align: center; line-height: 1.1; transform: rotate(-14deg); }
#cardOk, #enter { padding: 13px 26px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); color: var(--ink); font-weight: 700; }

#gate { position: fixed; inset: 0; display: grid; place-content: center start; padding: 16px 16px 16px max(16px, 6vw); background: linear-gradient(90deg, rgba(10,0,0,.88) 0%, rgba(10,0,0,.55) 45%, rgba(10,0,0,0) 70%); }
@media (max-width: 700px) { #gate { place-content: end center; padding: 16px; background: linear-gradient(0deg, rgba(10,0,0,.92) 0%, rgba(10,0,0,.6) 55%, rgba(10,0,0,0) 80%); } .gate-box { padding: 20px 18px; } .gate-box h1 { font-size: 24px; } }
.look-title { margin-top: 18px; }
#looks { display: grid; gap: 8px; margin: 4px 0 18px; }
#looks .pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#looks button { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(226,180,92,.35); background: rgba(255,255,255,.04); color: var(--ink); font-weight: 600; }
#looks button.on { background: rgba(120,24,14,.85); border-color: var(--gold); }
#bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.bubble { position: absolute; left: 0; top: 0; max-width: 240px; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: #fff; color: #1e1216; font-size: 14px; font-weight: 600; line-height: 1.3; text-align: left; box-shadow: 0 6px 18px rgba(0,0,0,.35); margin-top: -10px; overflow-wrap: anywhere; }
.bubble.ghost { background: #dfe9ec; color: #0d1416; font-style: italic; }
.bubble.scream { background: #b3261e; color: #fff; font-size: 20px; font-weight: 800; letter-spacing: .06em; }
.bubble.king { max-width: min(380px, 84vw); background: #2a0907; color: #ffd98a; border: 1px solid var(--gold); font-size: 15px; }
#scare { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(160,0,0,.15), rgba(120,0,0,.85)); }
#scare.on { animation: scare .9s ease-out; }
@keyframes scare { 0% { opacity: 1; } 12% { opacity: .2; } 22% { opacity: .9; } 100% { opacity: 0; } }
.css3d { position: absolute; inset: 0; pointer-events: none; }
.tv { width: 1280px; height: 720px; background: #000; pointer-events: none; }
.tv iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
#btn-tv[hidden] { display: none; }
.gate-box { width: min(460px, calc(100vw - 32px)); text-align: center; padding: 28px 22px; border: 1px solid rgba(226,180,92,.45); border-radius: 14px; background: rgba(20,5,5,.75); }
.gate-kicker { margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.gate-box h1 { margin: 0 0 10px; font-size: 28px; }
.gate-box small { display: block; margin-top: 16px; opacity: .55; font-size: 11px; }

.joystick { position: fixed; left: 22px; bottom: 60px; width: 128px; height: 128px; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); touch-action: none; }
.joystick span { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(226,180,92,.55); }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }

#lens[hidden], #dock[hidden], #dance-menu[hidden] { display: none; }
#lens .focus { position: absolute; left: 50%; top: 50%; width: 90px; height: 60px; margin: -30px 0 0 -45px; border: 1.5px solid rgba(243,231,207,.45); border-radius: 4px; }
#lens .focus::after { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; border: 1.5px solid rgba(255,90,60,.7); }
#lens .meta { position: absolute; left: 60px; bottom: 54px; font: 600 11px ui-monospace, Menlo, monospace; letter-spacing: .08em; color: rgba(243,231,207,.75); }
#lens .batt { position: absolute; right: 60px; bottom: 54px; width: 28px; height: 13px; border: 1.5px solid rgba(243,231,207,.75); border-radius: 2px; }
#lens .batt em { position: absolute; left: 2px; top: 2px; bottom: 2px; width: 40%; background: #ff5a3c; }
#lens .batt::after { content: ''; position: absolute; right: -4px; top: 3px; width: 2px; height: 5px; background: rgba(243,231,207,.75); }
#lens.cam { background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,.6) 100%), repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px); }
#dock { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; }
.gbtn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(226,180,92,.35); background: rgba(20,8,6,.6); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--ink); font-weight: 600; font-size: 14px; }
.gbtn svg { width: 18px; height: 18px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gbtn[aria-pressed="true"], .gbtn[aria-expanded="true"] { background: rgba(120,24,14,.75); }
.gbtn:active { transform: scale(.97); }
.dance-wrap { position: relative; }
#dance-menu { position: absolute; right: 0; bottom: 52px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; width: 240px; border-radius: 14px; background: rgba(20,8,6,.85); border: 1px solid rgba(226,180,92,.35); backdrop-filter: blur(16px); }
#dance-menu button { height: 38px; border-radius: 10px; border: 1px solid rgba(226,180,92,.25); background: rgba(255,255,255,.04); color: var(--ink); font-weight: 600; }
#dance-menu button.on { background: rgba(120,24,14,.85); border-color: var(--gold); }
#dance-menu .stop { grid-column: 1 / -1; }
@media (max-width: 600px) {
  #dock { flex-direction: column; align-items: flex-end; bottom: 200px; }
  .gbtn span { display: none; }
  .gbtn { width: 44px; padding: 0; justify-content: center; }
  #dance-menu { bottom: 0; right: 52px; }
}

#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; padding: 4px 10px; border-radius: 999px; background: rgba(16,10,16,.86); color: #fff; border: 1px solid rgba(255,255,255,.2); font: 800 13px/1.2 -apple-system, system-ui, sans-serif; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.35); margin-top: -4px; }
.tag.me { background: #fff; color: #1e1216; border-color: transparent; }
@media (max-width: 600px) { .tag { font-size: 11px; padding: 3px 8px; } }
#chatlog { position: fixed; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); width: min(360px, calc(100vw - 200px)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
#chatlog p { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35; transition: opacity .45s; text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,.7); overflow-wrap: anywhere; }
#chatlog p b { color: #ffd27a; font-weight: 800; margin-right: 6px; }
#chatlog p.me b { color: #ff9b8c; }
#chatlog p.old { opacity: 0; }
#chatbar { position: fixed; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px); transform: translateX(-50%); width: min(560px, calc(100% - 32px)); display: grid; gap: 8px; }
#chatbar[hidden], #actmenu[hidden], #invite[hidden] { display: none; }
#chatbar .quick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#chatbar .quick button { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(226,180,92,.35); background: rgba(20,8,6,.8); color: var(--ink); font-size: 13px; }
#chatbar .row { display: flex; gap: 8px; }
#chatbar input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(226,180,92,.45); background: rgba(20,8,6,.88); color: var(--ink); font: inherit; }
#chatbar .row button { height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); color: var(--ink); font-weight: 700; }
#actmenu { position: fixed; display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 999px; background: rgba(16,10,16,.92); border: 1px solid rgba(255,255,255,.18); box-shadow: 0 8px 24px rgba(0,0,0,.4); color: #fff; font-size: 13px; white-space: nowrap; transform: translate(-50%, -120%); }
#actmenu .who { font-weight: 800; max-width: 130px; overflow: hidden; text-overflow: ellipsis; margin-right: 2px; }
#actmenu button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; font: inherit; font-weight: 700; }
@media (hover: hover) { #actmenu button:hover { background: rgba(255,255,255,.22); } }
#invite { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 12px; background: rgba(10,0,0,.85); border: 1px solid var(--gold); }
#invite button { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); color: var(--ink); font-weight: 700; }
@media (max-width: 600px) {
  #chatlog { top: 150px; bottom: auto; width: calc(100vw - 90px); }
  #chatlog p { font-size: 12px; }
  #chatbar { bottom: 200px; }
}

/* Hồ sơ trên HUD và bảng sửa hồ sơ, như Làng Gai. */
.profile { pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 210px; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1px solid rgba(226,180,92,.35); background: rgba(20,8,6,.6); color: var(--ink); text-align: left; }
.profile svg { width: 26px; height: 26px; flex-shrink: 0; fill: none; stroke: var(--gold); stroke-width: 1.8; }
.profile span { display: grid; min-width: 0; }
.profile strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile small { font-size: 11px; color: var(--gold); }
#profileModal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(8,4,10,.55); backdrop-filter: blur(6px); z-index: 20; }
#profileModal[hidden] { display: none; }
.pbox { width: min(440px, 100%); padding: 24px; border-radius: 20px; background: rgba(28,14,12,.96); border: 1px solid rgba(226,180,92,.35); box-shadow: 0 30px 100px rgba(0,0,0,.5); display: grid; gap: 12px; }
.pbox h2 { margin: 0; font-size: 26px; }
.pbox .field { display: grid; gap: 6px; }
.pbox .field span, .pbox .field-label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.pbox input { height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(226,180,92,.35); background: rgba(255,255,255,.06); color: var(--ink); font: inherit; font-size: 16px; }
#profileLooks { display: grid; gap: 8px; }
#profileLooks .pick { display: flex; flex-wrap: wrap; gap: 6px; }
#profileLooks button { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(226,180,92,.35); background: rgba(255,255,255,.04); color: var(--ink); font-weight: 600; }
#profileLooks button.on { background: rgba(120,24,14,.85); border-color: var(--gold); }
.pactions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.pactions button { height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid rgba(226,180,92,.35); background: transparent; color: var(--ink); font-weight: 700; }
.pactions #profileSave { border-color: var(--gold); background: linear-gradient(#8f1c15, #5a0e0a); }
