:root {
  --forest: #0e3a2f;
  --forest-deep: #08261f;
  --leaf: #1c6b49;
  --gold: #c6a15b;
  --gold-soft: #f4e7c6;
  --saffron: #c45312;
  --saffron-hover: #a6440e;
  --cream: #f6f1e6;
  --card: #fffdf8;
  --ink: #1c1915;
  --muted: #5e584e;
  --line: #e7dcc6;
  --danger: #c42028;
  --live: #e11d2e;
  --shadow: 0 16px 40px rgba(8, 38, 31, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Inter", "Noto Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--forest-deep);
  min-height: 100dvh;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-live:disabled { opacity: 0.72; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== Gate (name entry) ===== */
.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(198, 161, 91, 0.22), transparent 55%),
    radial-gradient(700px 500px at 100% 100%, rgba(28, 107, 73, 0.35), transparent 50%),
    linear-gradient(180deg, #0c3329 0%, var(--forest-deep) 100%);
  color: var(--cream);
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 36px 28px 32px;
  text-align: center;
}

.gate-logo {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
}

.gate-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--live);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  margin-bottom: 14px;
  line-height: 1;
}

.gate h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--forest);
}

.gate .tagline {
  margin: 0 0 18px;
  color: var(--saffron);
  font-weight: 600;
  font-size: 14px;
}

.gate .status {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--forest);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 4px rgba(28, 107, 73, 0.15);
}

.btn-live {
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--saffron);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(196, 83, 18, 0.28);
  transition: transform 0.12s, background 0.12s;
}
.btn-live:hover:not(:disabled) { background: var(--saffron-hover); }
.btn-live:active:not(:disabled) { transform: scale(0.98); }

.gate-note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ===== Live room ===== */
.live {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #071c17;
  color: var(--cream);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(8, 38, 31, 0.92);
  border-bottom: 1px solid rgba(198, 161, 91, 0.22);
  flex-shrink: 0;
}
.topbar-logo { width: 36px; height: 36px; flex-shrink: 0; }
.topbar-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.watch-count {
  font-size: 12px;
  color: var(--gold-soft);
  white-space: nowrap;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--live);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  line-height: 1;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255,255,255,0.7);
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.7); opacity: 1; }
  70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); opacity: 0.85; }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

.stage {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.video-wrap {
  position: relative;
  background: #000;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
  display: block;
}
.video-wrap video::-webkit-media-controls,
.video-wrap video::-webkit-media-controls-enclosure,
.video-wrap video::-webkit-media-controls-panel {
  display: none !important;
  -webkit-appearance: none;
}

.video-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #0b2820;
  border-top: 1px solid rgba(198, 161, 91, 0.18);
  flex: 1;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--gold-soft);
  border-bottom: 1px solid rgba(198, 161, 91, 0.12);
}
.panel-head span.count { font-weight: 500; color: #b7c4be; font-size: 12px; }

.people {
  list-style: none;
  margin: 0;
  padding: 8px 10px 4px;
  overflow-y: auto;
  flex: 0 1 auto;
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 10px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.person-name {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.you-tag {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--forest-deep);
  background: var(--gold);
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: middle;
}
.demo-note {
  margin: 0 12px 10px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.35;
  color: #f4e7c6;
  background: rgba(196, 83, 18, 0.18);
  border: 1px dashed rgba(198, 161, 91, 0.45);
  border-radius: 10px;
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  border-top: 1px solid rgba(198, 161, 91, 0.12);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}
.chat-empty {
  margin: auto;
  font-size: 13px;
  color: #8aa099;
  text-align: center;
}
.bubble {
  max-width: 92%;
  align-self: flex-start;
  background: #14362c;
  border-radius: 12px 12px 12px 4px;
  padding: 7px 10px;
}
.bubble.mine {
  align-self: flex-end;
  background: #1c6b49;
  border-radius: 12px 12px 4px 12px;
}
.bubble .who {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 2px;
}
.bubble.mine .who { color: var(--gold-soft); }
.bubble .text { font-size: 13px; line-height: 1.4; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid rgba(198, 161, 91, 0.12);
  background: #0a241d;
}
.chat-form input {
  flex: 1;
  height: 42px;
  border: 1px solid rgba(198, 161, 91, 0.25);
  border-radius: 12px;
  padding: 0 12px;
  background: #0e2f26;
  color: var(--cream);
  outline: none;
}
.chat-form input:focus {
  border-color: var(--gold);
}
.chat-form input::placeholder { color: #8aa099; }
.chat-form button {
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--saffron);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

/* Desktop: video left, sidebar right */
@media (min-width: 900px) {
  .stage {
    flex-direction: row;
    align-items: stretch;
  }
  .video-wrap {
    flex: 1 1 auto;
    height: auto;
    aspect-ratio: auto;
    min-width: 0;
    align-self: stretch;
  }
  .video-wrap video { object-fit: cover; }
  .side {
    width: 340px;
    flex: 0 0 340px;
    border-top: 0;
    border-left: 1px solid rgba(198, 161, 91, 0.18);
  }
  .people { max-height: none; flex: 0 0 auto; max-height: 42vh; }
  .chat { flex: 1 1 auto; min-height: 0; }
  .topbar { padding: 12px 20px; }
  .topbar-title { font-size: 17px; }
  .gate-card { padding: 44px 40px 36px; }
}

@media (max-width: 899px) {
  .video-wrap { max-height: 42dvh; }
}

/* ===== Real version additions ===== */
.tap-play {
  position: absolute; inset: auto 50% 50% auto; transform: translate(50%, 50%);
  z-index: 3; border: 0; border-radius: 999px; padding: 14px 22px;
  background: var(--saffron); color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.waiting {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center;
  background: radial-gradient(600px 300px at 50% 0%, rgba(198,161,91,0.25), transparent 60%), rgba(8,38,31,0.94);
  padding: 16px; text-align: center;
}
.waiting-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.waiting-time { font-size: 28px; font-weight: 800; color: var(--cream); margin: 6px 0 4px; }
.waiting-countdown { font-size: 15px; color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.waiting-note { margin: 10px 0 0; font-size: 13px; color: #b7c4be; }
.more-row { padding: 6px 8px 10px; font-size: 13px; color: var(--gold-soft); font-weight: 600; }
.chat-hint { margin: 0; padding: 6px 14px; font-size: 12px; color: var(--gold-soft); background: rgba(196,83,18,0.18); }
.gate-kicker.soon { background: var(--leaf); }
