*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-app: #e9f2fb;
  --bg-screen: #f4f9ff;
  --bg-surface: rgba(255,255,255,0.88);
  --bg-surface-strong: #ffffff;
  --bg-muted: rgba(51, 144, 236, 0.08);
  --bg-muted-strong: rgba(51, 144, 236, 0.14);
  --bg-accent: #3390ec;
  --bg-accent-hover: #2481dd;
  --text-main: #18324a;
  --text-soft: rgba(24, 50, 74, 0.72);
  --text-faint: rgba(24, 50, 74, 0.48);
  --border-soft: rgba(51, 144, 236, 0.14);
  --shadow-soft: 0 10px 30px rgba(64, 116, 168, 0.14);
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-app);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

.hidden { display: none !important; }

/* App wrapper: fixed 1080x1920, scaled by JS */
#app-wrap {
  position: absolute;
  width: 1080px;
  height: 1920px;
  transform-origin: 0 0;
  overflow: hidden;
  background: linear-gradient(180deg, #edf6ff 0%, #e4f0fb 100%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
}

/* Rotate overlay (mobile landscape) */
.rotate-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
}
.rotate-overlay.hidden { display: none; }
.rotate-icon {
  font-size: 130px;
  color: rgba(255,255,255,0.8);
  animation: rotate-hint 2s ease-in-out infinite;
}
@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}
.rotate-text { font-size: 50px; color: var(--text-soft); }

/* Screen visibility */
.screen { display: block; width: 1080px; height: 1920px; }
.screen.hidden { display: none !important; }

/* PIN / Landing screen */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(51, 144, 236, 0.10), transparent 32%),
    linear-gradient(180deg, #eff7ff 0%, #e6f1fb 100%);
}

.landing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 50px;
  width: 920px;
  max-width: 920px;
  padding: 60px 80px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 48px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.landing-title { font-size: 194px; line-height: 1; }

.landing-sub {
  width: 100%;
  max-width: 760px;
  font-size: 65px;
  line-height: 1.08;
  color: var(--text-soft);
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.landing-hint {
  font-size: 49px;
  color: var(--text-faint);
  min-height: 1em;
  text-align: center;
}

.copy-link-btn {
  padding: 27px 54px;
  border-radius: 999px;
  border: 1px solid rgba(51, 144, 236, 0.18);
  background: var(--bg-surface-strong);
  color: var(--bg-accent);
  font-size: 43px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-shadow: 0 6px 20px rgba(51, 144, 236, 0.12);
}
.copy-link-btn:hover { background: #f7fbff; border-color: rgba(51, 144, 236, 0.28); }

/* PIN dots */
.pin-dots { display: flex; gap: 38px; }
.pin-dots span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(51, 144, 236, 0.08);
  border: 2px solid rgba(51, 144, 236, 0.18);
  transition: background 0.15s, border-color 0.15s;
}
.pin-dots span.filled { background: var(--bg-accent); border-color: var(--bg-accent); }

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 227px);
  gap: 27px;
}

.np {
  width: 227px;
  height: 227px;
  border-radius: 50%;
  border: none;
  background: rgba(51, 144, 236, 0.10);
  color: var(--text-main);
  font-size: 86px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(51, 144, 236, 0.10);
}
.np:hover { background: rgba(51, 144, 236, 0.16); }
.np:active { transform: scale(0.92); }

.np-del { background: transparent; font-size: 60px; box-shadow: none; }
.np-ok { background: var(--bg-accent); color: #fff; font-size: 60px; box-shadow: 0 10px 30px rgba(51, 144, 236, 0.24); }
.np-ok:hover { background: var(--bg-accent-hover); }
.np-ok:disabled { background: rgba(51, 144, 236, 0.4); cursor: default; }

/* Call screen */
.app { position: relative; background: var(--bg-screen); }

.call-container {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(51, 144, 236, 0.08), transparent 28%),
    linear-gradient(180deg, #f2f8ff 0%, #e8f2fc 100%);
  overflow: hidden;
}

/* Remote canvas */
#remoteCanvas {
  position: absolute;
  inset: 0;
  display: block;
}

/* Local video PiP */
#localVideo {
  position: absolute;
  display: none;
  right: 32px;
  top: 124px;
  width: 238px;
  height: 421px;
  object-fit: cover;
  border-radius: 22px;
  border: 2px solid rgba(255,255,255,0.9);
  background: #cfe0f2;
  z-index: 40;
  transition: opacity 0.2s;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
#localVideo.dragging { cursor: grabbing; transition: none; }

/* Status bar */
.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 32px 43px;
  display: flex;
  align-items: center;
  gap: 22px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.82), rgba(255,255,255,0));
  z-index: 30;
  pointer-events: none;
  transition: opacity 0.3s;
}

.status-main {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.status-dot {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #9fb3c7;
}

.status-dot.connecting { background: #f59e0b; animation: blink 1s infinite; }
.status-dot.waiting { background: #f59e0b; animation: blink 1.5s infinite; }
.status-dot.connected { background: var(--bg-accent); }
.status-dot.reconnecting { background: #ef4444; animation: blink 0.6s infinite; }
.status-dot.error { background: #ef4444; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

#statusText {
  font-size: 38px;
  font-weight: 500;
  color: var(--text-main);
  text-shadow: none;
}

.status-meta {
  margin-left: auto;
  max-width: 430px;
  font-size: 30px;
  font-weight: 600;
  color: var(--text-soft);
  text-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Room chat */
.room-chat {
  position: absolute;
  left: 32px;
  right: 32px;
  top: 124px;
  bottom: 228px;
  display: flex;
  flex-direction: column;
  z-index: 15;
  border-radius: 28px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(51, 144, 236, 0.10);
  backdrop-filter: blur(14px);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.chat-empty {
  margin: auto;
  font-size: 64px;
  color: var(--text-faint);
  text-align: center;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 84%;
}

.chat-message.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message-meta {
  font-size: 40px;
  color: var(--text-faint);
}

.chat-message-body {
  padding: 28px 32px;
  border-radius: 28px;
  background: #ffffff;
  color: var(--text-main);
  font-size: 64px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 4px 14px rgba(64, 116, 168, 0.08);
}

.chat-message.mine .chat-message-body {
  background: rgba(51, 144, 236, 0.14);
  border-bottom-right-radius: 8px;
}

.chat-message.other .chat-message-body {
  border-bottom-left-radius: 8px;
}

.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 28px 30px 30px;
  border-top: 1px solid rgba(51, 144, 236, 0.10);
  background: rgba(244, 249, 255, 0.92);
}

.chat-input {
  order: 1;
  flex: 1;
  min-height: 156px;
  max-height: 320px;
  resize: none;
  padding: 32px 36px;
  border: 1px solid rgba(51, 144, 236, 0.12);
  border-radius: 28px;
  background: #ffffff;
  color: var(--text-main);
  font-size: 68px;
  line-height: 1.35;
  outline: none;
}

.chat-input::placeholder {
  color: var(--text-faint);
}

.chat-input:focus {
  border-color: rgba(51, 144, 236, 0.38);
  background: #ffffff;
}

.chat-send-btn {
  order: 3;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg-accent);
  color: #fff;
  font-size: 50px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 10px 30px rgba(51, 144, 236, 0.22);
}
.chat-send-btn:hover { background: var(--bg-accent-hover); }
.chat-send-btn:active { transform: scale(0.94); }
.chat-send-btn:disabled {
  background: rgba(51, 144, 236, 0.45);
  cursor: default;
}

.chat-call-btn {
  order: 2;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-size: 50px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.22);
}
.chat-call-btn:hover { background: #e78e00; }
.chat-call-btn:active { transform: scale(0.94); }
.chat-call-btn:disabled {
  background: rgba(245, 158, 11, 0.45);
  cursor: default;
}

.info-modal {
  position: absolute;
  inset: 124px 32px 228px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(24, 50, 74, 0.16);
  backdrop-filter: blur(10px);
}

.info-card {
  width: 100%;
  max-width: 880px;
  max-height: 100%;
  overflow-y: auto;
  padding: 34px 36px 38px;
  border-radius: 28px;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 20px 50px rgba(64, 116, 168, 0.18);
}

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.info-title {
  font-size: 48px;
  font-weight: 700;
  color: var(--text-main);
}

.info-close-btn {
  width: 88px;
  height: 88px;
  border: none;
  border-radius: 50%;
  background: rgba(24, 50, 74, 0.08);
  color: var(--text-main);
  font-size: 40px;
  cursor: pointer;
}

.info-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 34px;
  line-height: 1.35;
  color: var(--text-soft);
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-label {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.info-code {
  display: block;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(51, 144, 236, 0.08);
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
  overflow-wrap: anywhere;
}

.info-copy-btn {
  align-self: flex-start;
  padding: 16px 22px;
  border: none;
  border-radius: 16px;
  background: rgba(51, 144, 236, 0.14);
  color: #1565c0;
  font-size: 28px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.info-copy-btn:hover { background: rgba(51, 144, 236, 0.2); }
.info-copy-btn:active { transform: scale(0.97); }

/* Controls */
.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 43px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: linear-gradient(to top, rgba(255,255,255,0.88), rgba(255,255,255,0));
  z-index: 30;
  transition: opacity 0.3s;
}
.ui-hidden { opacity: 0 !important; pointer-events: none !important; }

.control-action-btn {
  padding: 0;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  font-size: 38px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 1px solid rgba(51, 144, 236, 0.12);
  cursor: pointer;
  font-size: 42px;
  background: rgba(255,255,255,0.92);
  color: var(--bg-accent);
  backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(64, 116, 168, 0.12);
}
.ctrl-btn:hover { background: #f7fbff; }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.off { background: rgba(239,68,68,0.16); color: #dc2626; }
.ctrl-btn:disabled { opacity: 0.45; cursor: default; }

#videoModeBtn { background: rgba(139, 92, 246, 0.16); color: #6d28d9; }
#reloadBtn { background: rgba(245, 158, 11, 0.16); color: #c2410c; }
#infoBtn { background: rgba(16, 185, 129, 0.16); color: #047857; }
#fullscreenBtn { background: rgba(59, 130, 246, 0.16); color: #1d4ed8; }
#copyBtn2 { background: rgba(51, 144, 236, 0.16); color: #1565c0; }
#installBtn { background: rgba(34, 197, 94, 0.18); color: #15803d; }

/* Call timer */
.call-timer {
  font-size: 38px;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  text-shadow: none;
}
.call-timer.hidden { display: none; }

/* Name input (misc) */
.name-input {
  width: 100%;
  padding: 30px 40px;
  border-radius: 20px;
  border: 1px solid rgba(51, 144, 236, 0.12);
  background: #fff;
  color: var(--text-main);
  font-size: 50px;
  outline: none;
  text-align: center;
}
.name-input::placeholder { color: var(--text-faint); }
.name-input:focus { border-color: rgba(51, 144, 236, 0.35); background: #fff; }
