:root {
  color-scheme: light;
  font-family: 'Segoe UI', sans-serif;
  background: #0d1117;
  color: #e8e8e8;
  line-height: 1.5;
}

html, body {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 100vh;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: radial-gradient(circle at top left, #1f2a3d 0%, transparent 30%), radial-gradient(circle at bottom right, #090b10 0%, transparent 38%), #0d1117;
}

.app-shell {
  width: min(1080px, 100%);
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 16px 20px 0;
  text-align: center;
  flex-shrink: 0;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.version-info {
  margin: 12px 0 0;
  color: #8f9bb3;
  font-size: 0.94rem;
}

.card {
  width: 100%;
}

.copy-btn {
  display: inline-flex;
  justify-content: center;
  margin: 0 auto 16px;
  max-width: 320px;
}

.eyebrow {
  margin: 0 0 8px 0;
  color: #7d90a0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.description {
  margin: 12px 0 0;
  color: #abb2bf;
}

.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 16px;
  min-height: 0;
  overflow: hidden;
  min-height: 0;
}

.hidden {
  display: none !important;
}

.card {
  background: rgba(18, 24, 36, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  max-width: 680px;
  width: 100%;
}

#call-screen .card {
  max-width: none;
  height: 100%;
  max-height: calc(100vh - 90px);
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
}

.primary-btn {
  background: #58a6ff;
  color: #0b1220;
  width: 100%;
  max-width: 320px;
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover,
.copy-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  background: #212936;
  color: #e8e8e8;
}

.danger-btn {
  background: #ff6b6b;
  color: #0d1117;
  width: 100%;
}

.text-btn {
  background: transparent;
  color: #8f9bb3;
  padding: 0;
}

.join-group {
  margin-top: 20px;
  display: grid;
  gap: 12px;
}

.join-group label {
  color: #c3cdd8;
}

.join-group input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0d1117;
  color: #fff;
}

.message {
  min-height: 1.5em;
  margin-top: 14px;
  color: #f7c6c7;
}

.room-code {
  margin: 16px 0;
  padding: 18px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.8rem;
  letter-spacing: 0.22em;
  text-align: center;
  user-select: text;
}

.hint {
  color: #8f9bb3;
}

.call-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
  gap: 20px;
  min-height: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

.remote-video-wrapper {
  position: relative;
  height: 100%;
  min-height: 0;
  background: #0d1117;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.remote-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.connection-status {
  position: absolute;
  left: 16px;
  top: 16px;
  background: rgba(0, 0, 0, 0.65);
  color: #d2d8e0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.side-panel {
  display: grid;
  gap: 16px;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.call-layout > * {
  min-height: 0;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 0;
  height: 100%;
}

.timer-panel {
  text-align: center;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.timer-ring {
  width: 180px;
  height: 180px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top left, rgba(88, 166, 255, 0.18), transparent 40%), radial-gradient(circle at bottom right, rgba(111, 111, 255, 0.15), transparent 35%), #111827;
  border: 6px solid #2d3748;
}

.timer-ring.warning {
  border-color: #f59e0b;
}

.timer-ring.danger {
  border-color: #ef4444;
}

#remaining-time {
  font-size: 2.2rem;
  font-weight: 700;
}

.control-panel {
  display: grid;
  gap: 14px;
}

.local-video {
  width: 100%;
  min-height: 140px;
  max-height: 180px;
  border-radius: 18px;
  background: #020617;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 0;
  height: 100%;
}

.chat-header {
  font-weight: 700;
  color: #cbd5e1;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.96);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.chat-message {
  margin-bottom: 10px;
  line-height: 1.4;
}

.chat-message.self {
  text-align: right;
}

.chat-message span {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.chat-message.self span {
  background: #2f436d;
}

.chat-message.system span {
  background: rgba(89, 144, 255, 0.16);
  color: #cbd5e1;
  font-style: italic;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.chat-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0d1117;
  color: #fff;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal-content {
  width: min(420px, calc(100% - 40px));
  padding: 28px;
  border-radius: 24px;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.modal-buttons {
  margin-top: 24px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  body {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  .screen {
    padding: 12px;
  }

  .call-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .remote-video-wrapper {
    min-height: 40vh;
  }

  .side-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(200px, 1fr);
  }
  
  .chat-panel {
    height: auto;
    min-height: 0;
  }
  
  .timer-panel {
    padding: 18px;
  }
  
  .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

  .timer-ring {
    width: 150px;
    height: 150px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn,
  .copy-btn {
    width: 100%;
    max-width: 100%;
  }

  .room-code {
    font-size: 1.5rem;
  }
}

.status-banner {
  display: none;
  padding: 14px 18px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 0.95rem;
  text-align: center;
}

.status-banner.visible {
  display: block;
}

.call-layout.layout-alt {
  grid-template-columns: 1.2fr 0.8fr;
}

.call-layout.layout-alt .remote-video-wrapper {
  order: 2;
}

.call-layout.layout-alt .side-panel {
  order: 1;
  grid-template-columns: 1fr;
}

.call-layout.layout-alt .remote-video-wrapper video {
  object-fit: contain;
}
