:root {
  --bg: #0b0b0d;
  --surface: #17161b;
  --surface-2: #201f25;
  --line: #2a2930;
  --gold: #d4af37;
  --gold-soft: #f0d78c;
  --gold-deep: #4a3f1c;
  --gold-wash: #15130c;
  --text: #f5f2ea;
  --muted: #b3ada3;
  --live: #c8323a;
  --danger: #ff9b9f;
  --radius: 16px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: Cinzel, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-soft); }
:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

#app { max-width: 1180px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* header */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: rgba(11, 11, 13, 0.94); border-bottom: 1px solid #1d1c22; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: 4px; color: var(--gold); text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 19px; background: var(--gold-wash); border: 1px solid var(--gold-deep); color: var(--gold-soft); font-weight: 600; font-size: 14px; text-decoration: none; }
.who { font-size: 13px; color: var(--muted); }

main { flex: 1; padding: 16px 16px 110px; }
h1, h2 { margin: 0; }
.section-title { font-family: var(--display); color: var(--gold-soft); font-size: 22px; margin-bottom: 12px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 23px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #0b0b0d; font-weight: 700; }
.btn-gold:hover { background: #e2bf4b; }
.btn-outline { background: transparent; border-color: var(--gold); color: var(--gold-soft); }
.btn-danger { background: transparent; border-color: var(--live); color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn { width: 46px; height: 46px; border-radius: 23px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.tab { flex: none; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; }
.tab[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #0b0b0d; }

/* banner */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; margin-bottom: 16px; border-radius: var(--radius); background: var(--gold-wash); border: 1px solid var(--gold-deep); }
.banner strong { font-family: var(--display); color: var(--gold-soft); font-size: 17px; display: block; margin-bottom: 4px; }
.banner span { color: #cbc5ba; font-size: 14px; }

/* grid of live cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.card { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 240px; padding: 12px; border-radius: var(--radius); border: 1px solid #26252b; background: var(--surface); color: var(--text); text-decoration: none; overflow: hidden; text-align: left; }
.card:hover { border-color: var(--gold-deep); }
.card .badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; }
.live-badge { padding: 3px 8px; border-radius: 6px; background: var(--live); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; background: #000; font-size: 11px; font-weight: 600; }
.avatar { display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid var(--gold); background: #0f0e12; color: var(--gold-soft); font-family: var(--display); font-weight: 700; flex: none; }
.card .avatar { position: absolute; top: 66px; left: 50%; transform: translateX(-50%); width: 80px; height: 80px; font-size: 26px; }
.card .name { font-weight: 700; font-size: 15px; }
.card .title { font-size: 13px; color: #cbc5ba; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cat { font-size: 11px; color: var(--gold-soft); margin-top: 2px; }

.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty p { margin: 0 0 18px; }

/* room */
.room { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .room { grid-template-columns: minmax(0, 1fr) 360px; } }
.stage { position: relative; aspect-ratio: 9 / 16; max-height: calc(100vh - 150px); width: 100%; margin: 0 auto; border-radius: 20px; overflow: hidden; background: #131217; border: 1px solid #222128; }
@media (min-width: 900px) { .stage { aspect-ratio: auto; height: calc(100vh - 140px); } }
.stage video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.stage video.mirror { transform: scaleX(-1); }
.stage-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; color: var(--muted); }
.stage-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; z-index: 3; }
.host-chip { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 24px; background: rgba(0, 0, 0, 0.72); min-width: 0; flex: 1; }
.host-chip .avatar { width: 36px; height: 36px; font-size: 13px; border-width: 1.5px; }
.host-chip .meta { min-width: 0; }
.host-chip .meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-chip .meta span { font-size: 12px; color: #d6d0c5; }
.stage-bottom { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; z-index: 3; }
.unmute { position: absolute; top: 66px; left: 50%; transform: translateX(-50%); z-index: 4; }

.overlay-chat { position: absolute; left: 12px; bottom: 76px; width: min(78%, 300px); display: flex; flex-direction: column; gap: 6px; z-index: 2; pointer-events: none; }
.bubble { align-self: flex-start; max-width: 100%; padding: 7px 11px; border-radius: 14px; background: rgba(0, 0, 0, 0.74); font-size: 13px; line-height: 1.35; word-wrap: break-word; }
.bubble b { color: var(--gold-soft); margin-right: 4px; }
.bubble.giftmsg { color: var(--gold-soft); border: 1px solid var(--gold-deep); }
.bubble.system { color: #d6d0c5; font-style: italic; }
.bubble .host-tag { display: inline-block; margin-right: 4px; padding: 0 5px; border-radius: 4px; background: var(--gold); color: #0b0b0d; font-size: 10px; font-weight: 700; vertical-align: 1px; }

.hearts { position: absolute; right: 18px; bottom: 80px; width: 60px; height: 260px; pointer-events: none; z-index: 2; }
.float-heart { position: absolute; bottom: 0; left: 18px; color: var(--gold); animation: floatUp 1.8s ease-out forwards; }
@keyframes floatUp { 0% { transform: translate(0, 0) scale(0.7); opacity: 1; } 100% { transform: translate(var(--dx, 0), -240px) scale(1.2); opacity: 0; } }

.gift-burst { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 18px; background: rgba(21, 19, 12, 0.94); border: 1px solid var(--gold); box-shadow: 0 0 40px rgba(212, 175, 55, 0.35); animation: burst 2.6s ease forwards; pointer-events: none; white-space: nowrap; }
.gift-burst b { color: var(--gold-soft); font-family: var(--display); font-size: 18px; }
@keyframes burst { 0% { opacity: 0; transform: translate(-50%, 20px) scale(0.8); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 20% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px); } }

/* side panel */
.panel { display: flex; flex-direction: column; gap: 12px; }
.box { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid #26252b; }
.box h2 { font-size: 15px; margin-bottom: 10px; }
.chat-log { height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.chat-log .bubble { background: var(--surface-2); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 23px; border: 1px solid var(--line); background: #111014; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; color: var(--gold-soft); }
.stats span { font-size: 12px; color: var(--muted); }

.gift-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.gift { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; border: 1.5px solid #2a2930; background: #111014; }
.gift[aria-pressed="true"] { border-color: var(--gold); background: #1f1b10; }
.gift .gname { font-size: 12px; font-weight: 600; }
.gift .gcost { font-size: 11px; color: var(--gold-soft); }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 1em; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: #cbc5ba; }
.field input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #111014; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* wallet */
.wallet { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.balance { padding: 22px; border-radius: 20px; background: var(--gold-wash); border: 1px solid var(--gold-deep); }
.balance .big { font-size: 38px; font-weight: 700; color: var(--gold-soft); display: flex; align-items: center; gap: 10px; margin: 6px 0; }

/* bottom nav */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: space-around; height: 76px; padding: 0 20px 8px; background: #111114; border-top: 1px solid #1d1c22; }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 70px; min-height: 48px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.nav-item[aria-current="page"] { color: var(--gold); }
.nav-live { width: 60px; height: 60px; margin-top: -24px; border-radius: 50%; background: var(--gold); color: #0b0b0d; border: 4px solid var(--bg); display: flex; align-items: center; justify-content: center; }

/* modal */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.78); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 400px; padding: 26px; border-radius: 22px; background: #121115; border: 1px solid var(--gold-deep); }
.modal .wordmark { display: block; text-align: center; margin-bottom: 8px; font-size: 30px; }
.modal p { color: var(--muted); text-align: center; margin: 0 0 20px; font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60; padding: 12px 18px; border-radius: 14px; background: #201f25; border: 1px solid var(--gold-deep); font-size: 14px; max-width: calc(100% - 32px); }
