:root {
  --bg: #0b0d12;
  --panel: #12141c;
  --line: #232734;
  --text: #eaecef;
  --muted: #8b93a7;
  --accent: #ff3b5c;
  --good: #2de58c;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: 1fr;
  height: 100vh;
}

/* ---------- Player ---------- */
.stage {
  display: grid;
  place-items: center;
  padding: 18px;
  min-height: 0;
}

.player {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #1a1e29;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .8s ease;
}
.scene.loaded { opacity: 1; }

.scene-fallback {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 100%, #3a2a4d 0%, #141722 55%, #0a0c12 100%);
}
.scene-fallback.hidden { display: none; }

.topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .08em;
  padding: 5px 11px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(255,59,92,.4);
}
.live-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff;
  animation: blink 1.4s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

.viewey-count {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: #fff;
}
.viewey-count svg { width: 16px; height: 16px; }

.streamer {
  position: absolute;
  bottom: 8%;
  left: 0; right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
}

.avatar {
  width: clamp(120px, 26vw, 230px);
  height: auto;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,.5));
  transform-origin: bottom center;
  transition: transform .12s ease;
}
.streamer.talking .avatar {
  animation: bob .5s ease-in-out infinite;
}
@keyframes bob {
  0%,100% { transform: translateY(0) rotate(-.6deg); }
  50%     { transform: translateY(-7px) rotate(.6deg); }
}

.speech {
  background: rgba(10,12,18,.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
  max-width: 46ch;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: clamp(40px, 6vw, 70px);
}
.speech.show { display: block; }

.caption {
  position: absolute;
  bottom: 10px; left: 12px;
  color: #fff;
  font-size: 13px;
  opacity: .9;
  background: rgba(0,0,0,.4);
  padding: 4px 9px; border-radius: 8px;
}
.now-title { font-weight: 700; }

.timer {
  position: absolute;
  bottom: 10px; right: 12px;
  color: #fff; font-size: 13px;
  background: rgba(0,0,0,.4);
  padding: 4px 9px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}

/* ---------- Chat ---------- */
.chat-panel {
  position: relative;
  background: var(--panel);
  border-top: 1px solid var(--line);
  height: 280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.chat-title { font-size: 13px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }

.head-right { display: flex; align-items: center; gap: 10px; }

.tip-btn {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  color: var(--accent); font-size: 12px; font-weight: 700;
  padding: 6px 12px; cursor: pointer;
}
.tip-btn:hover { border-color: var(--accent); background: rgba(255,59,92,.08); }

.avatars { display: flex; }
.avatars .ava {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--panel);
  margin-left: -6px;
  object-fit: cover; background: #262b3a;
}
.avatars .ava:first-child { margin-left: 0; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 82%; font-size: 14px; line-height: 1.4; }
.msg .who { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.msg-stream .who { color: var(--good); }
.msg-you { align-self: flex-end; }
.msg-you .bubble {
  background: #2a3042; color: var(--text);
  padding: 8px 12px; border-radius: 14px 14px 4px 14px;
}
.msg-stream { align-self: flex-start; }
.msg-stream .bubble {
  background: #1b202e; color: var(--text);
  padding: 8px 12px; border-radius: 14px 14px 14px 4px;
}
.msg-you .who { color: var(--accent); text-align: right; }

.composer {
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  background: #0d1017; border: 1px solid var(--line); border-radius: 99px;
  color: var(--text); padding: 9px 15px; font-size: 15px; outline: none;
}
.composer input:focus { border-color: var(--accent); }
.composer button {
  background: var(--accent); color: #fff; border: none; border-radius: 99px;
  padding: 0 18px; font-weight: 700; cursor: pointer;
}
.composer button:active { transform: scale(.96); }

/* ---------- Donate ---------- */
.donate {
  position: absolute; inset: 0;
  z-index: 20;
  background: rgba(6,8,12,.6);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
}
.donate-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 22px 22px;
  width: min(300px, calc(100% - 32px));
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.donate-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.donate-card h3 { margin: 0 0 4px; font-size: 19px; }
.donate-sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amounts button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #1a1f2c; border: 1px solid var(--line); border-radius: 14px;
  color: var(--text); padding: 14px 0; cursor: pointer;
}
.amounts button:hover { border-color: var(--accent); }
.amounts .a { font-size: 22px; font-weight: 800; }
.amounts .c { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.custom { display: none; margin-top: 14px; gap: 8px; }
.custom.show { display: flex; }
.custom input {
  flex: 1; background: #0d1017; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 15px; outline: none;
}
.custom input:focus { border-color: var(--accent); }
.custom button {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 0 16px; font-weight: 700; cursor: pointer;
}



/* ---------- Loader ---------- */
.load {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity .5s ease;
}
.load.hide { opacity: 0; pointer-events: none; }
.load-inner { text-align: center; color: var(--muted); font-size: 15px; }
.pulse {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 860px) {
  .app {
    grid-template-columns: 1fr 320px;
    grid-template-rows: 1fr;
  }
  .chat-panel { border-top: none; border-left: 1px solid var(--line); height: 100%; }
}