:root {
  --bg: #07111f;
  --bg-soft: #0b1730;
  --card: #0f1b35;
  --card-2: #122140;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7ff;
  --muted: #b9c4dc;
  --accent: #4ea1ff;
  --accent-soft: rgba(78, 161, 255, 0.16);
  --success: #2dd4bf;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #040b17 0%, #07111f 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  min-height: 100%;
}

body {
  min-height: 100vh;
  padding-bottom: 110px;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

header {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 10px;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
}

#status {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.geo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow);
  color: var(--text);
}

.flag {
  width: 24px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow);
}

.filter label {
  color: var(--muted);
  font-weight: 700;
}

.filter select {
  background: transparent;
  color: var(--text);
  border: 0;
  outline: none;
  min-width: 170px;
  cursor: pointer;
}

.filter select option {
  color: #111827;
}

.layoutSingle {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.twoVideos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 12px;
  font-size: clamp(1.3rem, 2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

video {
  width: 100%;
  aspect-ratio: 4 / 5;
  min-height: 320px;
  background: #000;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.belowActions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.actionBtn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 120px;
  background: #ffffff;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.actionBtn:hover {
  transform: translateY(-1px);
}

.actionBtn:active {
  transform: translateY(0);
}

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(4, 11, 23, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.controls button {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 110px;
  background: #ffffff;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.controls button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.controls button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#startBtn {
  background: #ffffff;
}

#nextBtn {
  background: #eaf2ff;
}

#stopBtn {
  background: #ffe8e8;
}

#camBtn,
#micBtn {
  background: #ffffff;
}

/* Modal */
.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 9998;
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(92vw, 620px);
  max-height: 84vh;
  transform: translate(-50%, -50%);
  overflow: auto;
  background: linear-gradient(180deg, #0d1830 0%, #0a1427 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
  z-index: 9999;
  padding: 16px;
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modalHeader h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.modalHeader button {
  appearance: none;
  border: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
}

.modalBody {
  display: block;
}

.hidden {
  display: none !important;
}

.popupSection h2,
.popupSection h3 {
  margin-top: 0;
}

.popupSection .muted {
  color: var(--muted);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
}

.popupSection input,
.popupSection select,
.popupSection textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
}

.popupSection input::placeholder,
.popupSection textarea::placeholder {
  color: #9aa7c4;
}

.popupSection select option {
  color: #111827;
}

.popupSection textarea {
  resize: vertical;
  min-height: 120px;
}

.popupSection button,
.contribCard button {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: #ffffff;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.chatBox {
  min-height: 250px;
  max-height: 45vh;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  margin-bottom: 12px;
}

.chatForm {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.chatForm input {
  flex: 1;
}

.chatForm button {
  min-width: 100px;
}

.chatLine {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 14px;
  max-width: 96%;
  line-height: 1.35;
  word-wrap: break-word;
}

.chatLine.me {
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.22);
}

.chatLine.them {
  background: rgba(78, 161, 255, 0.14);
  border: 1px solid rgba(78, 161, 255, 0.22);
}

.contribBox {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.contribCard {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.contribCard h3 {
  margin-top: 0;
}

.adminGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.adminCard {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.adminList {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.adminItem {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
}

.muted {
  color: var(--muted);
}

/* Old tab support if still present */
.tabs {
  display: block;
}

.tabRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tabBtn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #ffffff;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
}

.tabBtn.active {
  background: #dceaff;
}

.tabPanel {
  display: none;
}

.tabPanel.active {
  display: block;
}

/* Responsive */
@media (max-width: 980px) {
  .twoVideos {
    grid-template-columns: 1fr;
  }

  video {
    min-height: 260px;
    aspect-ratio: 16 / 12;
  }
}

@media (max-width: 720px) {
  header {
    padding: 16px 12px 8px;
  }

  .layoutSingle {
    padding: 8px 12px 16px;
  }

  .pill,
  .filter {
    min-height: 44px;
    padding: 8px 12px;
  }

  .filter select {
    min-width: 130px;
  }

  .belowActions {
    justify-content: stretch;
  }

  .belowActions .actionBtn {
    flex: 1 1 calc(50% - 12px);
    min-width: 0;
  }

  .controls {
    gap: 8px;
  }

  .controls button {
    min-width: 92px;
    padding: 11px 14px;
  }

  .modal {
    width: 94vw;
    max-height: 88vh;
    padding: 14px;
  }

  .chatForm {
    flex-direction: column;
  }

  .chatForm button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 2.2rem;
  }

  #status {
    font-size: 1rem;
  }

  .belowActions .actionBtn {
    flex: 1 1 100%;
  }

  .controls button {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  video {
    min-height: 220px;
  }
}