/* ===== CSS Variables — AmRoom Dark Navy ===== */
:root {
  /* Deep navy backgrounds */
  --bg: #07071a;
  --surface: #0d0f24;
  --surface2: #141630;
  --surface3: #1a1d3a;

  /* Borders — subtle cyan tint */
  --border: rgba(136, 192, 208, 0.08);
  --border-strong: rgba(136, 192, 208, 0.18);

  /* Primary accent — bright cyan */
  --cyan: #5ce0d8;
  --cyan-dim: rgba(92, 224, 216, 0.1);

  /* Purple accent */
  --purple: #b48ead;
  --purple-dim: rgba(180, 142, 173, 0.1);

  /* Danger — vibrant red-pink */
  --pink: #e05572;
  --pink-dim: rgba(224, 85, 114, 0.1);

  /* Success — bright green */
  --green: #5cf290;
  --green-dim: rgba(92, 242, 144, 0.1);

  /* Warning — yellow */
  --yellow: #f2d05c;

  /* Text */
  --text: #e8eaf6;
  --text2: #b0b8d1;
  --muted: #5a6080;

  /* Glassmorphism */
  --glass: rgba(13, 15, 36, 0.75);
  --glass-border: rgba(136, 192, 208, 0.1);

  --radius: 10px;
  --radius-lg: 16px;

  /* Glows */
  --glow-cyan:   0 0 0 1px rgba(92, 224, 216, 0.2), 0 4px 20px rgba(92, 224, 216, 0.08);
  --glow-purple: 0 0 0 1px rgba(180, 142, 173, 0.2), 0 4px 20px rgba(180, 142, 173, 0.08);
  --glow-green:  0 0 0 1px rgba(92, 242, 144, 0.25), 0 4px 20px rgba(92, 242, 144, 0.1);
  --glow-pink:   0 0 0 1px rgba(224,  85, 114, 0.2), 0 4px 20px rgba(224,  85, 114, 0.08);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  --shadow-card: 0 2px 16px rgba(0,0,0,0.4), 0 0 0 1px var(--glass-border);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px var(--glass-border);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: relative;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 50% at 20% 60%, rgba(92, 224, 216, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 30%, rgba(180, 142, 173, 0.035) 0%, transparent 70%),
    radial-gradient(ellipse 40% 50% at 50% 90%, rgba(92, 242, 144, 0.025) 0%, transparent 70%);
  animation: meshMove 24s ease-in-out infinite alternate;
}

@keyframes meshMove {
  0%   { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.1) rotate(3deg); }
}

.screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(136, 192, 208, 0.22); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(136, 192, 208, 0.42); }
* { scrollbar-width: thin; scrollbar-color: rgba(136, 192, 208, 0.22) transparent; }

/* ===== Entrance animations ===== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== Shared Buttons ===== */
.primary-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #81A1C1, #88C0D0);
  color: #2E3440;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.primary-btn:hover {
  background: linear-gradient(135deg, #88C0D0, #8FBCBB);
  box-shadow: 0 4px 20px rgba(136, 192, 208, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}

.primary-btn:disabled {
  background: var(--surface3);
  color: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.primary-btn-small {
  padding: 8px 16px;
  background: linear-gradient(135deg, #81A1C1, #88C0D0);
  color: #2E3440;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.primary-btn-small:hover {
  background: linear-gradient(135deg, #88C0D0, #8FBCBB);
  box-shadow: 0 4px 16px rgba(136, 192, 208, 0.3), 0 2px 6px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.secondary-btn {
  padding: 14px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.secondary-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
  transform: translateY(-1px);
}

.secondary-btn:active {
  transform: scale(0.97);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
  transform: scale(1.07);
}

.icon-btn:active {
  transform: scale(0.93);
}

.icon-btn-small {
  background: none;
  border: none;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.icon-btn-small:hover {
  background: var(--pink-dim);
  color: var(--pink);
}

.error-text {
  color: var(--pink);
  margin-top: 10px;
  font-size: 14px;
  min-height: 0;
  text-align: center;
}

.error-text:empty {
  display: none;
}

/* ===== Avatar System ===== */
.avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.avatar-preset {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  user-select: none;
}

.avatar-small .avatar-preset {
  font-size: 14px;
}

.avatar-large .avatar-preset {
  font-size: 40px;
}

/* ===== Auth Screen ===== */
#auth-screen {
  background: var(--bg);
}

.auth-box {
  background: rgba(59, 66, 82, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 40px;
  border-radius: var(--radius-lg);
  text-align: center;
  width: 400px;
  max-width: 92vw;
  box-shadow: var(--shadow-modal);
  border: 1px solid rgba(216, 222, 233, 0.13);
  animation: fade-up 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.logo {
  margin-bottom: 12px;
}

.auth-box h1 {
  margin-bottom: 24px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
}

.auth-tab.active {
  background: linear-gradient(135deg, #81A1C1, #88C0D0);
  color: #2E3440;
  font-weight: 700;
}

.auth-tab:not(.active):hover {
  color: var(--text);
}

.auth-form input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}

.auth-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.auth-form input::placeholder {
  color: var(--muted);
}

.auth-form .primary-btn {
  margin-top: 4px;
}

/* ===== Lobby Screen ===== */
#lobby-screen {
  background: var(--bg);
}

.lobby {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  background: rgba(46, 52, 64, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lobby-header h1 {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #88C0D0, #8FBCBB, #B48EAD);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.lobby-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lobby-user-info span {
  font-size: 14px;
  color: var(--text2);
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  -webkit-overflow-scrolling: touch;
}

.lobby-actions {
  margin-bottom: 20px;
}

.lobby-actions .primary-btn {
  width: auto;
  padding: 12px 24px;
}

/* ===== Rooms List ===== */
.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rooms-empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(59, 66, 82, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: var(--transition);
  animation: fade-up 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.room-card:hover {
  border-color: rgba(136, 192, 208, 0.4);
  box-shadow: var(--glow-cyan), 0 8px 24px rgba(0,0,0,0.2);
  background: rgba(67, 76, 94, 0.85);
  transform: translateY(-2px);
}

.room-card:active {
  transform: translateY(0);
}

.room-info {
  flex: 1;
  min-width: 0;
}

.room-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 16px;
}

.room-lock {
  color: var(--yellow);
  display: flex;
  align-items: center;
}

.join-room-btn {
  white-space: nowrap;
}

.delete-room-btn {
  color: var(--muted);
}

.delete-room-btn:hover {
  color: var(--pink);
  border-color: var(--pink);
  box-shadow: var(--glow-pink);
}

/* ===== Profile Screen ===== */
#profile-screen {
  background: var(--bg);
}

.profile-box {
  background: rgba(59, 66, 82, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  border: 1px solid rgba(216, 222, 233, 0.13);
  animation: fade-up 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.profile-header h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.avatar-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar-options .secondary-btn {
  padding: 10px 20px;
  font-size: 14px;
  border-radius: 8px;
}

.preset-avatars {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.preset-avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  color: #fff;
}

.preset-avatar-btn:hover {
  transform: scale(1.1);
  border-color: var(--border-strong);
  box-shadow: var(--glow-cyan);
}

.preset-avatar-btn.active {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.profile-form {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.profile-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  margin-bottom: 14px;
}

.profile-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.profile-form textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 72px;
  transition: var(--transition);
  margin-bottom: 14px;
  -webkit-appearance: none;
}

.profile-form textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.profile-form textarea::placeholder {
  color: var(--muted);
}

.profile-info {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.profile-info p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.profile-info strong {
  color: var(--text2);
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  background: rgba(59, 66, 82, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 28px;
  border-radius: var(--radius-lg);
  width: 380px;
  max-width: 90vw;
  box-shadow: var(--shadow-modal);
  border: 1px solid rgba(216, 222, 233, 0.13);
  z-index: 1;
  animation: modal-pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-content h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-content input[type=text],
.modal-content input[type=password] {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}

.modal-content input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.modal-content input::placeholder {
  color: var(--muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text2);
}

.checkbox-label input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-buttons .secondary-btn,
.modal-buttons .primary-btn {
  flex: 1;
  padding: 12px;
  font-size: 15px;
}

/* ===== Avatar Crop Modal ===== */
.crop-content {
  position: relative;
  background: rgba(59, 66, 82, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  width: 320px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(216, 222, 233, 0.08), inset 0 1px 0 rgba(236, 239, 244, 0.05);
  border: 1px solid rgba(216, 222, 233, 0.13);
  z-index: 1;
}

.crop-content h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.crop-wrapper {
  width: 256px;
  height: 256px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(136, 192, 208, 0.5);
  box-shadow: 0 0 0 4px rgba(136, 192, 208, 0.08), 0 8px 32px rgba(0, 0, 0, 0.3);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.crop-wrapper:active {
  cursor: grabbing;
}

#crop-canvas {
  display: block;
  touch-action: none;
}

.crop-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin: 0;
}

.crop-content .modal-buttons {
  width: 100%;
}

/* ===== Room Screen ===== */
#room-screen {
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: auto;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(46, 52, 64, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: 100%;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  transition: opacity 0.3s, transform 0.3s;
}

.room-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.room-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

#peer-count {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.room-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  width: 100%;
  overflow-y: auto;
  gap: 24px;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* ===== Screen Share ===== */
#screen-area {
  width: 100%;
  max-width: 1100px;
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(136, 192, 208, 0.06);
}

#screen-video {
  width: 100%;
  display: block;
  max-height: 65vh;
  object-fit: contain;
  background: #000;
}

#screen-label {
  display: none;
}

.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(46, 52, 64, 0.88);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  z-index: 10;
}

#screen-area:hover .fullscreen-btn {
  opacity: 1;
}

.fullscreen-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
  background: rgba(136, 192, 208, 0.1);
}

#screen-area:fullscreen,
#screen-area:-webkit-full-screen {
  background: #000;
}

#screen-area:fullscreen #screen-video,
#screen-area:-webkit-full-screen #screen-video {
  max-height: 100vh;
  height: 100vh;
}

/* ===== Screen Volume Control ===== */
.screen-volume-control {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(46, 52, 64, 0.88);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  z-index: 10;
  opacity: 0;
  transition: var(--transition);
}

#screen-area:hover .screen-volume-control,
.screen-volume-control:focus-within {
  opacity: 1;
}

.screen-volume-control svg {
  color: var(--cyan);
  flex-shrink: 0;
}

#screen-volume-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, var(--cyan) var(--vol-pct, 50%), var(--surface2) var(--vol-pct, 50%));
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#screen-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}

#screen-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.25);
}

#screen-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

#screen-volume-slider::-moz-range-track {
  background: linear-gradient(to right, var(--cyan) var(--vol-pct, 50%), var(--surface2) var(--vol-pct, 50%));
  height: 4px;
  border-radius: 2px;
}

#screen-volume-label {
  color: var(--text2);
  font-size: 12px;
  min-width: 36px;
  text-align: right;
}

/* ===== Screen Quality Control ===== */
.screen-quality-control {
  position: absolute;
  bottom: 10px;
  right: 50px;
  z-index: 10;
  opacity: 1;
}

.stream-mode-btn {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 10;
  background: rgba(46, 52, 64, 0.88);
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.stream-mode-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.stream-mode-btn.active {
  background: var(--green-dim);
  color: var(--green);
  border-color: var(--green);
  box-shadow: var(--glow-green);
}

.screen-quality-btn {
  background: rgba(46, 52, 64, 0.88);
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.screen-quality-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.screen-quality-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: rgba(59, 66, 82, 0.98);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 140px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(216, 222, 233, 0.06);
}

.screen-quality-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text2);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.screen-quality-option:hover {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.screen-quality-option.active {
  color: var(--cyan);
  font-weight: 600;
  background: var(--cyan-dim);
}

.quality-detail {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  margin-left: 4px;
}

/* ===== Participants ===== */
#participants {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.participant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 22px;
  background: rgba(59, 66, 82, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  min-width: 120px;
  transition: var(--transition);
  border: 1px solid var(--border);
  position: relative;
  animation: fade-up 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.participant:hover {
  background: rgba(67, 76, 94, 0.85);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.participant.speaking {
  border-color: var(--green);
  box-shadow: var(--glow-green), inset 0 0 0 1px var(--green);
}

.participant.speaking:hover {
  transform: translateY(-2px);
}

.participant-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  font-weight: 600;
  user-select: none;
}

.participant-avatar .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.participant-avatar .avatar-preset {
  width: 100%;
  height: 100%;
}

.online-indicator {
  display: none;
}

.participant-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  letter-spacing: -0.01em;
}

.role-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--cyan);
  background: var(--cyan-dim);
  border: 1px solid var(--border-strong);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.participant-status {
  display: flex;
  gap: 6px;
  align-items: center;
}

.participant-mic,
.participant-hp {
  display: flex;
  align-items: center;
}

.peer-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--cyan) var(--vol-pct, 100%), var(--surface2) var(--vol-pct, 100%));
  outline: none;
  cursor: pointer;
  margin-top: 2px;
}

.peer-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}

.peer-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.25);
}

.peer-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ===== Chat Panel ===== */
.chat-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 100%;
  background: rgba(46, 52, 64, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  animation: chat-slide-in 0.25s ease;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.2);
}

@keyframes chat-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.load-more-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  margin: 0 auto 12px;
  transition: var(--transition);
}

.load-more-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ===== Chat Messages ===== */
.chat-msg {
  display: flex;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 10px;
  transition: background 0.15s;
  animation: slide-in-right 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.chat-msg:hover {
  background: rgba(136, 192, 208, 0.04);
}

.chat-msg-mine {
  position: relative;
}

.chat-msg-mine::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, var(--cyan), transparent);
  border-radius: 2px;
  opacity: 0.5;
}

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg-avatar .avatar-preset {
  font-size: 13px;
}

.chat-msg-content {
  flex: 1;
  min-width: 0;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-msg-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.chat-msg-mine .chat-msg-author {
  color: var(--cyan);
}

.chat-msg-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.chat-msg-body {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ===== Chat Typing & Input ===== */
.chat-typing {
  padding: 4px 16px 4px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  animation: typing-pulse 1.5s ease-in-out infinite;
}

@keyframes typing-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.chat-input-area input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.chat-input-area input::placeholder {
  color: var(--muted);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #81A1C1, #88C0D0);
  color: #2E3440;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.chat-send-btn:hover {
  background: linear-gradient(135deg, #88C0D0, #8FBCBB);
  box-shadow: 0 4px 16px rgba(136, 192, 208, 0.3);
  transform: translateY(-1px);
}

/* ===== Chat Badge ===== */
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 14px;
  padding: 14px 24px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(46, 52, 64, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: 100%;
  justify-content: center;
  align-items: center;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  transition: opacity 0.3s, transform 0.3s;
}

.control-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  touch-action: manipulation;
  position: relative;
}

.control-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
  transform: scale(1.06) translateY(-1px);
}

.control-btn:active {
  transform: scale(0.91);
}

.control-btn.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.control-btn.sharing {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--purple);
  box-shadow: var(--glow-purple);
}

.control-btn.danger {
  background: var(--pink-dim);
  border-color: var(--pink);
  color: var(--pink);
  box-shadow: var(--glow-pink);
}

.control-btn.danger:hover {
  background: rgba(191, 97, 106, 0.25);
  box-shadow: 0 0 0 2px rgba(191, 97, 106, 0.4), 0 6px 20px rgba(191, 97, 106, 0.2);
}

.control-btn.muted-btn {
  background: var(--pink-dim);
  border-color: var(--pink);
  color: var(--pink);
  box-shadow: var(--glow-pink);
}

.control-btn.ptt-active {
  background: rgba(235, 203, 139, 0.13);
  border-color: var(--yellow);
  color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(235, 203, 139, 0.25), 0 6px 20px rgba(235, 203, 139, 0.12);
}

/* ===== Fullscreen Auto-Hide ===== */
.controls-hidden .room-header,
.controls-hidden .controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.controls-hidden .controls {
  transform: translateY(10px);
}

/* ===== Audio Hint ===== */
.audio-hint {
  background: rgba(136, 192, 208, 0.1);
  border: 1px solid rgba(136, 192, 208, 0.3);
  color: var(--cyan);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  text-align: center;
  animation: pulse-hint 2s ease-in-out infinite;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(136, 192, 208, 0.1);
}

@keyframes pulse-hint {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ===== Toast Notifications ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(59, 66, 82, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(216, 222, 233, 0.1), inset 0 1px 0 rgba(236, 239, 244, 0.05);
  border: 1px solid rgba(216, 222, 233, 0.13);
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-hide {
  opacity: 0;
  transition: opacity 0.3s;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Reconnect Overlay ===== */
.reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(46, 52, 64, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.reconnect-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.reconnect-content p {
  font-size: 16px;
  color: var(--text2);
}

.reconnect-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(136, 192, 208, 0.15);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-small {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(136, 192, 208, 0.15);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

.img-upload-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface2);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  max-width: 220px;
}

/* ===== Screen Share List (multi-screen switcher) ===== */
#screen-share-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.screen-share-item {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.screen-share-item:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.screen-share-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(136, 192, 208, 0.35);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(136, 192, 208, 0.55);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(136, 192, 208, 0.35) transparent;
}

/* ===== Mobile Portrait ===== */
@media (max-width: 600px) {
  .auth-box {
    width: 92vw;
    padding: 28px 20px;
  }

  .auth-box h1 {
    font-size: 20px;
    margin-bottom: 16px;
  }

  .profile-box {
    width: 92vw;
    padding: 24px 16px;
  }

  .lobby-header {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .lobby-header h1 {
    font-size: 17px;
  }

  .lobby-user-info span {
    display: none;
  }

  .lobby-content {
    padding: 16px;
  }

  .room-card {
    padding: 14px 16px;
  }

  .room-header {
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .room-header h2 {
    font-size: 15px;
  }

  .room-content {
    padding: 12px;
    gap: 16px;
  }

  #participants {
    gap: 10px;
  }

  .participant {
    padding: 12px 14px;
    min-width: 80px;
    border-radius: var(--radius);
  }

  .participant-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .participant-name {
    font-size: 12px;
    max-width: 80px;
  }

  .controls {
    gap: 12px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .control-btn {
    width: 48px;
    height: 48px;
  }

  .control-btn svg {
    width: 22px;
    height: 22px;
  }

  .fullscreen-btn {
    opacity: 1;
    padding: 10px 12px;
  }

  .screen-volume-control,
  .screen-quality-control {
    opacity: 1;
  }

  #screen-volume-slider {
    width: 80px;
  }

  .screen-quality-option {
    padding: 12px 16px;
  }

  #screen-area {
    border-radius: 8px;
  }

  #screen-video {
    max-height: 40vh;
  }

  .audio-hint {
    font-size: 14px;
    padding: 10px 20px;
  }

  .chat-panel {
    width: 100%;
  }

  .modal-content {
    width: 92vw;
    padding: 24px 20px;
  }
}

/* ===== Mobile Landscape ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .room-header {
    padding: 6px 16px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }

  .room-header h2 {
    font-size: 13px;
  }

  #peer-count {
    font-size: 12px;
  }

  .room-content {
    padding: 8px 16px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    gap: 8px;
    flex-direction: row;
  }

  #screen-area {
    flex: 1;
    border-radius: 8px;
  }

  #screen-video {
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
  }

  #participants {
    flex-direction: column;
    gap: 6px;
  }

  .participant {
    padding: 8px 12px;
    min-width: auto;
    flex-direction: row;
    gap: 8px;
  }

  .participant-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .participant-name {
    font-size: 12px;
  }

  .controls {
    gap: 16px;
    padding: 8px 20px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
  }

  .control-btn {
    width: 44px;
    height: 44px;
  }

  .control-btn svg {
    width: 22px;
    height: 22px;
  }

  .fullscreen-btn {
    opacity: 1;
  }

  .screen-volume-control,
  .screen-quality-control {
    opacity: 1;
  }

  .chat-panel {
    width: 280px;
  }
}

/* ===== Tablet ===== */
@media (min-width: 601px) and (max-width: 1024px) {
  .control-btn {
    width: 52px;
    height: 52px;
  }

  .fullscreen-btn {
    opacity: 1;
  }

  .screen-volume-control,
  .screen-quality-control {
    opacity: 1;
  }
}

/* ===== Small height (keyboard open) ===== */
@media (max-height: 450px) {
  .auth-box {
    padding: 16px 20px;
  }

  .auth-box h1 {
    font-size: 18px;
    margin-bottom: 12px;
  }

  .logo {
    margin-bottom: 6px;
  }

  .logo svg {
    width: 32px;
    height: 32px;
  }

  .auth-form input {
    padding: 10px 14px;
    margin-bottom: 8px;
  }

  .primary-btn {
    padding: 10px;
  }
}

/* ===== Friends Panel ===== */
.friends-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 100vw;
  height: 100%;
  background: rgba(46, 52, 64, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: -8px 0 48px rgba(0, 0, 0, 0.35), -1px 0 0 rgba(216, 222, 233, 0.04);
  animation: slide-from-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slide-from-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.friends-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.friends-header > span {
  font-size: 16px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.03em;
}

.friends-add {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.friends-search {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.friends-search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(136, 192, 208, 0.15);
}

.friends-section-title {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.friends-list {
  padding: 4px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.friends-empty {
  padding: 20px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.friend-item:hover {
  background: var(--surface2);
  transform: translateX(2px);
}

.friend-avatar { flex-shrink: 0; }

.friend-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.friend-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-status { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.friend-status.online { color: var(--green); }

/* ===== Join Mode Modal ===== */
.join-mode-options {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.join-mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.join-mode-btn span { font-size: 14px; font-weight: 700; }
.join-mode-btn small { font-size: 11px; color: var(--muted); text-align: center; }

.join-mode-btn:hover {
  border-color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: var(--glow-cyan);
  color: var(--cyan);
  transform: translateY(-2px);
}

.join-mode-btn:active {
  transform: scale(0.97);
}

.join-mode-btn:hover small { color: var(--text2); }

/* ===== Listener Badge ===== */
.listener-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--purple-dim);
  border: 1px solid var(--purple);
  color: var(--purple);
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ===== Disabled mic for listener ===== */
.control-btn.listener-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Room Profile Modal ===== */
/* ===== Room Side Panel ===== */
.room-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100%;
  background: rgba(46, 52, 64, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 35;
  box-shadow: -8px 0 32px rgba(0,0,0,0.25);
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

.room-panel.open {
  transform: translateX(0);
}

/* ===== Panel Header ===== */
.room-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(59, 66, 82, 0.6);
}

.room-panel-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.rp-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(136, 192, 208, 0.3);
}

.rp-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rp-header-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.rp-header-status {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Panel Tabs ===== */
.room-panel-tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.room-panel-tab {
  flex: 1;
  padding: 11px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: inherit;
  position: relative;
}

.room-panel-tab:hover {
  color: var(--text2);
}

.room-panel-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  background: rgba(136, 192, 208, 0.04);
}

.rp-tab-badge {
  min-width: 16px;
  height: 16px;
  background: var(--pink);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* ===== Panel Body ===== */
.room-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.rp-tab-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

/* ===== Profile Tab ===== */
.rp-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 0 8px;
}

.rp-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(136, 192, 208, 0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.rp-upload-btn {
  padding: 7px 16px !important;
  font-size: 12px !important;
}

.rp-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 8px 0;
}

.rp-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
}

.rp-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

.rp-form input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: var(--transition);
}

.rp-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.rp-form input::placeholder { color: var(--muted); }

/* ===== Friends Tab ===== */
.rp-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.rp-search-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.rp-search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(136, 192, 208, 0.15);
}

.rp-search-input::placeholder { color: var(--muted); }

/* ===== Background Tab ===== */
.rp-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ===== Room header right ===== */
.room-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Friends badge position ===== */
#friends-btn { position: relative; }

#friends-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  padding: 0 4px;
  line-height: 16px;
}

/* ===== Background Picker ===== */
.bg-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.bg-preset-btn {
  height: 64px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.bg-preset-btn:hover {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
  transform: scale(1.04);
}

.bg-preset-btn.active {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

.bg-preset-btn.active::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 12px;
  color: var(--cyan);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  font-weight: 700;
}

.bg-preset-label {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  font-weight: 600;
  pointer-events: none;
}

.bg-custom-section {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

/* ===== Design touchup: icon-btn-small neon border ===== */
.icon-btn-small {
  border: 1px solid transparent;
  transition: var(--transition);
}

.icon-btn-small:hover {
  border-color: var(--pink);
}

/* ===== Chat Tool Buttons (attach / voice) ===== */
.chat-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  align-self: center;
}

.chat-tool-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(136, 192, 208, 0.15);
}

.chat-tool-btn.recording {
  border-color: var(--pink);
  color: var(--pink);
  background: rgba(191, 97, 106, 0.12);
  animation: pulse-record 1s ease-in-out infinite;
}

@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 2px rgba(191, 97, 106, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(191, 97, 106, 0.0); }
}

/* ===== Voice Recording Indicator ===== */
.voice-recording-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(191, 97, 106, 0.06);
  border-top: 1px solid rgba(191, 97, 106, 0.15);
  flex-shrink: 0;
}

.voice-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  flex-shrink: 0;
  animation: pulse-rec-dot 1s ease-in-out infinite;
}

@keyframes pulse-rec-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.voice-rec-time {
  font-size: 14px;
  font-weight: 600;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

.voice-rec-label {
  font-size: 13px;
  color: var(--muted);
}

.voice-rec-stop-btn {
  margin-left: auto;
  padding: 6px 16px;
  background: rgba(191, 97, 106, 0.1);
  border: 1px solid rgba(191, 97, 106, 0.3);
  color: var(--pink);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.voice-rec-stop-btn:hover {
  background: rgba(191, 97, 106, 0.2);
}

/* ===== Voice Preview Bar ===== */
.voice-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(136, 192, 208, 0.04);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-preview-bar .voice-play-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.voice-preview-duration {
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

.voice-preview-spacer { flex: 1; }

.primary-btn-small {
  padding: 6px 16px;
  background: linear-gradient(135deg, var(--cyan), #81a1c1);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.primary-btn-small:hover {
  box-shadow: 0 4px 16px rgba(136, 192, 208, 0.3);
}

.secondary-btn-small {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.secondary-btn-small:hover {
  border-color: var(--text2);
  color: var(--text2);
}

/* ===== Image Preview Bar ===== */
.image-preview-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: rgba(136, 192, 208, 0.03);
  flex-shrink: 0;
}

.image-preview-wrapper {
  position: relative;
  display: inline-block;
}

.image-preview-img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid var(--border);
  display: block;
}

.image-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pink);
  border: 2px solid var(--surface);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s;
}

.image-preview-remove:hover {
  transform: scale(1.15);
}

.image-preview-actions {
  display: flex;
  gap: 8px;
}

/* ===== Chat Image ===== */
.chat-image {
  max-width: 280px;
  max-height: 320px;
  border-radius: 10px;
  cursor: zoom-in;
  display: block;
  object-fit: contain;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.chat-image:hover {
  border-color: var(--cyan);
  box-shadow: 0 4px 20px rgba(136, 192, 208, 0.2);
}

/* ===== Voice Message ===== */
.voice-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 20px;
  border: 1px solid var(--border);
  max-width: 260px;
}

.voice-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #81A1C1, #88C0D0);
  color: #2E3440;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.voice-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(136, 192, 208, 0.4);
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  flex: 1;
}

.voice-waveform span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--cyan);
  opacity: 0.6;
  animation: waveform-idle 1.6s ease-in-out infinite;
}

.voice-waveform span:nth-child(1)  { height: 6px; animation-delay: 0s; }
.voice-waveform span:nth-child(2)  { height: 10px; animation-delay: 0.08s; }
.voice-waveform span:nth-child(3)  { height: 16px; animation-delay: 0.16s; }
.voice-waveform span:nth-child(4)  { height: 20px; animation-delay: 0.24s; }
.voice-waveform span:nth-child(5)  { height: 14px; animation-delay: 0.32s; }
.voice-waveform span:nth-child(6)  { height: 18px; animation-delay: 0.40s; }
.voice-waveform span:nth-child(7)  { height: 22px; animation-delay: 0.48s; }
.voice-waveform span:nth-child(8)  { height: 16px; animation-delay: 0.56s; }
.voice-waveform span:nth-child(9)  { height: 12px; animation-delay: 0.64s; }
.voice-waveform span:nth-child(10) { height: 18px; animation-delay: 0.72s; }
.voice-waveform span:nth-child(11) { height: 10px; animation-delay: 0.80s; }
.voice-waveform span:nth-child(12) { height: 6px; animation-delay: 0.88s; }
.voice-waveform span:nth-child(13) { height: 8px; animation-delay: 0.96s; }
.voice-waveform span:nth-child(14) { height: 14px; animation-delay: 1.04s; }
.voice-waveform span:nth-child(15) { height: 20px; animation-delay: 1.12s; }
.voice-waveform span:nth-child(16) { height: 16px; animation-delay: 1.20s; }
.voice-waveform span:nth-child(17) { height: 10px; animation-delay: 1.28s; }
.voice-waveform span:nth-child(18) { height: 14px; animation-delay: 1.36s; }
.voice-waveform span:nth-child(19) { height: 8px; animation-delay: 1.44s; }
.voice-waveform span:nth-child(20) { height: 6px; animation-delay: 1.52s; }

@keyframes waveform-idle {
  0%, 100% { opacity: 0.35; transform: scaleY(0.7); }
  50% { opacity: 0.8; transform: scaleY(1); }
}

.voice-duration {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ===== Emoji Reactions ===== */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.reaction-btn:hover {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

.reaction-btn.reaction-mine {
  border-color: rgba(136, 192, 208, 0.5);
  background: rgba(136, 192, 208, 0.12);
  color: var(--cyan);
}

.reaction-btn span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.reaction-mine span {
  color: var(--cyan);
}

.reaction-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, border-color 0.2s, color 0.2s, background 0.2s;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

.chat-msg:hover .reaction-add-btn {
  opacity: 1;
  pointer-events: auto;
}

.reaction-add-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
}

/* Touch devices — always show reaction add button */
@media (hover: none) {
  .reaction-add-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ===== Emoji Picker ===== */
.emoji-picker {
  position: fixed;
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(216,222,233,0.06);
  z-index: 900;
  opacity: 0;
  transform: scale(0.9) translateY(6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emoji-picker.active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.emoji-opt {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.emoji-opt:hover {
  background: var(--surface2);
  transform: scale(1.2);
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

.lightbox-img {
  position: relative;
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lightbox.active .lightbox-img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(59, 66, 82, 0.85);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1;
}

.lightbox-close:hover {
  background: var(--surface2);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ===== Drag-drop overlay ===== */
.chat-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(136, 192, 208, 0.08);
  border: 2px dashed var(--cyan);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  z-index: 10;
}

.chat-drop-overlay svg {
  opacity: 0.5;
}

/* ===== Clickable Links ===== */
.chat-link {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  transition: var(--transition);
}

.chat-link:hover {
  color: #8FBCBB;
  text-decoration-color: var(--cyan);
}

/* ===== Sprint 2: DM Panel ===== */
.dm-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dm-panel.active {
  opacity: 1;
  pointer-events: auto;
}

.dm-panel-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border-left: 1px solid rgba(136, 192, 208, 0.1);
  border-right: 1px solid rgba(136, 192, 208, 0.1);
  transform: translateX(60px);
  transition: transform 0.25s cubic-bezier(0.34, 1.1, 0.64, 1);
}

.dm-panel.active .dm-panel-inner {
  transform: translateX(0);
}

.dm-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface2);
  border-bottom: 1px solid rgba(136, 192, 208, 0.08);
  flex-shrink: 0;
}

.dm-back-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.dm-back-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.dm-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.dm-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dm-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-header-status {
  font-size: 11px;
  color: var(--muted);
}

.dm-header-status.online {
  color: var(--green);
}

.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dm-msg {
  display: flex;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s;
  animation: fade-up 0.15s ease both;
}

.dm-msg:hover {
  background: rgba(136, 192, 208, 0.04);
}

.dm-msg-mine {
  position: relative;
}

.dm-msg-mine::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: linear-gradient(to bottom, var(--cyan), transparent);
  border-radius: 2px;
  opacity: 0.4;
}

.dm-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}

.dm-msg-content {
  flex: 1;
  min-width: 0;
}

.dm-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.dm-msg-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.dm-msg-mine .dm-msg-author {
  color: var(--cyan);
}

.dm-msg-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.dm-msg-body {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.dm-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface2);
  border-top: 1px solid rgba(136, 192, 208, 0.08);
  align-items: center;
  flex-shrink: 0;
}

.dm-input-area input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(136, 192, 208, 0.15);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.dm-input-area input:focus {
  border-color: rgba(136, 192, 208, 0.4);
}

/* ===== Sprint 2: DM Unread Badge ===== */
.dm-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #BF616A;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* ===== Sprint 2: Friend actions layout ===== */
.friend-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ===== Sprint 1: Reply bar ===== */
.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(136, 192, 208, 0.07);
  border-left: 3px solid var(--cyan);
  border-radius: 0;
  margin: 0;
  flex-shrink: 0;
  animation: fade-up 0.15s ease both;
}

.reply-bar-content {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.reply-bar-icon {
  color: var(--cyan);
  flex-shrink: 0;
  opacity: 0.8;
}

.reply-bar-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.reply-bar-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-bar-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-cancel-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.reply-cancel-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Sprint 1: Reply quote in message ===== */
.msg-reply-quote {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  background: rgba(136, 192, 208, 0.07);
  border-left: 2px solid var(--cyan);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: background 0.15s;
  max-width: 100%;
}

.msg-reply-quote:hover {
  background: rgba(136, 192, 208, 0.13);
}

.msg-reply-quote svg {
  color: var(--cyan);
  flex-shrink: 0;
  opacity: 0.7;
}

.msg-reply-quote span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Sprint 1: Message action buttons (hover) ===== */
.chat-msg-content {
  position: relative;
}

.msg-actions {
  position: absolute;
  top: -4px;
  right: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  background: var(--surface2);
  border: 1px solid rgba(136, 192, 208, 0.12);
  border-radius: 8px;
  padding: 3px 4px;
  z-index: 5;
  box-shadow: var(--shadow-card);
}

.chat-msg:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
}

/* Touch devices — always show message actions (no hover available) */
@media (hover: none) {
  .msg-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.msg-action-btn:hover {
  background: rgba(136, 192, 208, 0.1);
  color: var(--text);
}

.msg-reply-btn:hover { color: var(--cyan); }
.msg-edit-btn:hover { color: #EBCB8B; }
.msg-delete-btn:hover { color: #BF616A; }

/* ===== Sprint 1: Edited label ===== */
.msg-edited-label {
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
  flex-shrink: 0;
}

/* ===== Sprint 1: Deleted message ===== */
.chat-msg-deleted .chat-msg-body {
  opacity: 0.5;
}

.msg-deleted-text {
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Sprint 1: Friend online dot in room panel ===== */
.rp-friend-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  border: 1.5px solid var(--surface2);
  flex-shrink: 0;
  transition: background 0.3s;
}

.rp-friend-online.online {
  background: var(--green);
}

/* ===== Sprint 3: Pinned message bar ===== */
.chat-pinned-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(136, 192, 208, 0.06);
  border-bottom: 1px solid rgba(136, 192, 208, 0.1);
  border-left: 3px solid #EBCB8B;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.chat-pinned-bar:hover {
  background: rgba(235, 203, 139, 0.08);
}

.pinned-bar-icon {
  color: #EBCB8B;
  flex-shrink: 0;
}

.pinned-bar-content {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.pinned-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: #EBCB8B;
  flex-shrink: 0;
}

.pinned-bar-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-bar-unpin {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s;
}

.pinned-bar-unpin:hover { color: #BF616A; }

/* ===== Sprint 3: Search panel ===== */
.chat-search-panel {
  border-bottom: 1px solid rgba(136, 192, 208, 0.08);
  flex-shrink: 0;
  background: var(--surface);
}

.chat-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
}

.chat-search-input-wrap svg {
  color: var(--muted);
  flex-shrink: 0;
}

.chat-search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  min-width: 0;
}

.chat-search-input-wrap input::placeholder { color: var(--muted); }

.chat-search-results {
  max-height: 260px;
  overflow-y: auto;
  border-top: 1px solid rgba(136, 192, 208, 0.06);
}

.search-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.search-result-item {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(136, 192, 208, 0.04);
}

.search-result-item:hover {
  background: rgba(136, 192, 208, 0.05);
}

.search-result-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-right: 6px;
}

.search-result-time {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.search-result-text {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

mark.search-highlight {
  background: rgba(235, 203, 139, 0.3);
  color: #EBCB8B;
  border-radius: 2px;
  padding: 0 1px;
}

/* ===== Sprint 3: Message highlight (after click from search/pin) ===== */
@keyframes msg-highlight-pulse {
  0%, 100% { background: transparent; }
  30% { background: rgba(235, 203, 139, 0.12); }
}

.chat-msg-highlight {
  animation: msg-highlight-pulse 1.8s ease both !important;
}

/* ===== Sprint 3: Pin button in msg actions ===== */
.msg-pin-btn:hover { color: #EBCB8B; }

/* ============================================================
   Phase 2A: App Shell + Sidebar + Views Layout
   ============================================================ */

/* ----- App Shell ----- */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ----- Left Sidebar ----- */
.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px 12px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 0 8px 4px;
  border-radius: var(--radius);
  background: var(--surface2);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-tag {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px;
  flex: 1;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  text-align: left;
  width: 100%;
}

.sidebar-nav-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.sidebar-nav-btn.active {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.sidebar-nav-btn.danger {
  color: var(--pink);
}

.sidebar-nav-btn.danger:hover {
  background: var(--pink-dim);
}

.sidebar-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--pink);
  color: #fff;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

.sidebar-room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 4px 8px;
  border-radius: var(--radius);
  background: var(--cyan-dim);
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-room-info:hover {
  background: rgba(92, 224, 216, 0.15);
}

.sidebar-room-icon {
  color: var(--cyan);
  display: flex;
  align-items: center;
}

.sidebar-room-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 90;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ----- Main Content Area ----- */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ----- View System ----- */
.view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.view-header h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.view-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ----- Room View Layout ----- */
#room-screen {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  height: 100%;
}

.room-view-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.room-view-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-peer-count {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.room-header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.room-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.room-participants-area {
  flex-shrink: 0;
  max-height: 40vh;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#participants {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.room-controls-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

/* Chat area is now part of the room layout, not an overlay */
.room-chat-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  background: var(--bg);
  position: relative;
}

/* Override old chat-panel styles */
#chat-panel {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  max-width: none;
  height: auto;
  border-radius: 0;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: auto;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 16px;
}

.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  flex-shrink: 0;
}

/* ----- Rooms Grid (Phase 2C) ----- */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.rooms-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* ----- Friends View ----- */
#friends-screen .view-body {
  max-width: 600px;
}

/* ===== Mobile Responsive (<=768px) ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-content {
    width: 100%;
  }

  .view-header {
    padding-left: 56px; /* space for hamburger button */
  }

  .room-view-header {
    padding-left: 56px;
  }

  .room-participants-area {
    max-height: 30vh;
    padding: 8px;
  }

  .rooms-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Phase 3B-E: Glassmorphism, Buttons, Branding, Polish
   ============================================================ */

/* ----- Glassmorphism on surfaces ----- */
.auth-box {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
}

.sidebar {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.view-header {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.room-view-header {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.room-controls-bar {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.participant {
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
}

.participant:hover {
  background: rgba(20, 22, 48, 0.85);
  border-color: rgba(92, 224, 216, 0.15);
}

.modal-content {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

.control-btn {
  background: var(--surface2);
  border: 1px solid var(--glass-border);
}

/* ----- Gradient primary buttons ----- */
.primary-btn {
  background: linear-gradient(135deg, var(--cyan), #48b8e0);
  color: var(--bg);
  font-weight: 700;
  border: none;
  box-shadow: 0 2px 12px rgba(92, 224, 216, 0.2);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #6eeee6, #5cc8f0);
  box-shadow: 0 4px 20px rgba(92, 224, 216, 0.35);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn-small {
  background: linear-gradient(135deg, var(--cyan), #48b8e0);
  color: var(--bg);
  font-weight: 600;
  border: none;
}

.primary-btn-small:hover {
  background: linear-gradient(135deg, #6eeee6, #5cc8f0);
}

/* ----- Room cards polish ----- */
.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}

.room-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 4px 20px rgba(92, 224, 216, 0.08);
  transform: translateY(-2px);
}

.room-card-banner {
  height: 60px;
  background: linear-gradient(135deg, rgba(92, 224, 216, 0.08), rgba(180, 142, 173, 0.08));
}

.room-card-body {
  padding: 12px 14px;
}

.room-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.room-card-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-card-lock {
  color: var(--yellow);
}

.room-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

/* ----- Chat input polish ----- */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
}

#chat-input, #dm-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  flex: 1;
}

#chat-input:focus, #dm-input:focus {
  border-color: var(--cyan);
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 224, 216, 0.1);
}

.chat-send-btn {
  background: linear-gradient(135deg, var(--cyan), #48b8e0);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 12px rgba(92, 224, 216, 0.3);
}

/* ----- Branding in auth screen ----- */
.auth-box h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.auth-box .logo {
  color: var(--cyan);
}

/* ----- Avatar small helper ----- */
.avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

/* ----- Friend items polish ----- */
.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.friend-item:last-child {
  border-bottom: none;
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.friend-status {
  font-size: 12px;
  color: var(--muted);
}

.friend-status.online {
  color: var(--green);
}

.friend-actions {
  display: flex;
  gap: 4px;
}

/* ===== Personal Calls ===== */

/* Incoming call overlay */
.call-incoming-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 7, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.call-incoming-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
  background: var(--glass-bg, rgba(59, 66, 82, 0.95));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--glass-border, rgba(136, 192, 208, 0.12));
  animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
}

.call-incoming-pulse {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(92, 242, 144, 0.15);
  top: 24px;
  animation: call-pulse 1.5s ease-in-out infinite;
}

@keyframes call-pulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.4); opacity: 0; }
}

.call-incoming-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.call-incoming-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.call-incoming-label {
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.call-incoming-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.call-incoming-actions {
  display: flex;
  gap: 24px;
  margin-top: 8px;
}

.call-action-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.call-action-btn.call-accept {
  background: var(--green);
  color: #07071a;
  box-shadow: 0 4px 20px rgba(92, 242, 144, 0.3);
}

.call-action-btn.call-accept:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(92, 242, 144, 0.4);
}

.call-action-btn.call-decline {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 4px 20px rgba(224, 85, 114, 0.3);
}

.call-action-btn.call-decline:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(224, 85, 114, 0.4);
}

/* Call view */
.call-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.call-view-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.call-duration {
  font-size: 14px;
  color: var(--green);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.call-participants-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 0;
  overflow-y: auto;
}

.call-participants-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: center;
}

.call-participant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  background: var(--surface2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  min-width: 120px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.call-participant-card.speaking {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(92, 242, 144, 0.15);
}

.call-participant-card .participant-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
}

.call-participant-card .participant-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-participant-card .participant-status {
  display: flex;
  gap: 8px;
  min-height: 16px;
}

.call-controls-bar {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  justify-content: center;
  align-items: center;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.call-calling-status {
  font-size: 18px;
  color: var(--muted);
  padding: 40px;
  text-align: center;
}

/* Call friend button in friend list */
.call-friend-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.call-friend-btn:hover {
  color: var(--green);
  background: rgba(92, 242, 144, 0.1);
}

/* Add friend to call modal */
.call-add-friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.call-add-friend-item:hover {
  background: var(--surface2);
}

.call-add-friend-item .friend-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* Mobile responsive */
@media (max-width: 600px) {
  .call-participant-card {
    min-width: 100px;
    padding: 14px;
  }
  .call-participant-card .participant-avatar {
    width: 48px;
    height: 48px;
  }
  .call-incoming-card {
    padding: 28px 24px;
    margin: 0 16px;
  }
  .call-controls-bar {
    gap: 12px;
    padding: 12px;
  }
}

/* ===== Soundboard ===== */
.soundboard-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.soundboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.soundboard-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.soundboard-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.soundboard-volume-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.soundboard-volume {
  width: 60px;
  height: 4px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.sb-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.sb-action-btn:hover {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.sb-clips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  max-height: 260px;
}

.sb-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

.sb-clip-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 56px;
  overflow: hidden;
}

.sb-clip-btn:hover {
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

.sb-clip-btn:active,
.sb-clip-btn.sb-clip-playing {
  transform: scale(0.95);
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-dim);
}

.sb-clip-name {
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  text-align: center;
}

.sb-clip-key {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 3px;
  padding: 1px 4px;
  line-height: 1;
}

.sb-clip-delete {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
  padding: 0;
}

.sb-clip-btn:hover .sb-clip-delete {
  opacity: 1;
}

.sb-clip-delete:hover {
  color: #f04747;
}

@media (max-width: 600px) {
  .soundboard-panel {
    bottom: 70px;
    width: calc(100vw - 16px);
    border-radius: 12px;
  }
  .sb-clips-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== Chess Panel ===== */
.chess-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px);
}
.chess-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.chess-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.chess-lobby {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 200px;
}
.chess-players-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chess-player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text);
}
.chess-player-item:hover {
  background: var(--hover);
}
.chess-player-item .player-name {
  font-size: 14px;
  font-weight: 500;
}
.chess-player-item .challenge-btn {
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.chess-player-item .challenge-btn:hover {
  background: var(--accent-hover);
}
.chess-time-select {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 13px;
}
.chess-time-select select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
}
.chess-challenge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 0 12px 8px;
  background: rgba(88,101,242,0.15);
  border: 1px solid rgba(88,101,242,0.3);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  gap: 8px;
}
.chess-challenge-bar .accept-btn {
  padding: 4px 12px;
  border-radius: 6px;
  background: #57f287;
  color: #000;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
}
.chess-challenge-bar .decline-btn {
  padding: 4px 12px;
  border-radius: 6px;
  background: #ed4245;
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
}
.chess-game-area {
  display: flex;
  flex-direction: column;
  padding: 8px 12px 12px;
  gap: 4px;
}
.chess-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}
.chess-player-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.chess-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 50px;
  text-align: right;
}
.chess-timer.low-time {
  color: #ed4245;
  animation: chess-pulse 1s infinite;
}
@keyframes chess-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--border);
  user-select: none;
}
.chess-square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.1s;
}
.chess-square.light {
  background: #f0d9b5;
}
.chess-square.dark {
  background: #b58863;
}
.chess-square.selected {
  box-shadow: inset 0 0 0 3px #5865f2;
}
.chess-square.last-move {
  background: rgba(255, 255, 0, 0.35) !important;
}
.chess-square.last-move.light {
  background: #f5f682 !important;
}
.chess-square.last-move.dark {
  background: #baca44 !important;
}
.chess-square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0,0,0,0.2);
  pointer-events: none;
}
.chess-square.legal-capture::after {
  content: '';
  position: absolute;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.2);
  background: transparent;
  pointer-events: none;
}
.chess-square.check {
  background: radial-gradient(circle, #ff0000 0%, rgba(255,0,0,0.3) 60%, transparent 100%) !important;
}
.chess-piece {
  font-size: min(5vw, 38px);
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
  z-index: 1;
}
.chess-actions {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}
.chess-action-btn {
  flex: 1;
  padding: 6px 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.chess-action-btn:hover {
  background: rgba(255,255,255,0.14);
}
.chess-action-btn.danger {
  color: #ed4245;
  border-color: rgba(237,66,69,0.3);
}
.chess-action-btn.danger:hover {
  background: rgba(237,66,69,0.15);
}
.chess-status {
  text-align: center;
  padding: 6px;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  min-height: 20px;
}
.chess-moves-list {
  max-height: 60px;
  overflow-y: auto;
  padding: 4px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
.chess-promotion {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 10;
  border-radius: 6px;
}
.chess-promotion-piece {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: transform 0.15s, border-color 0.15s;
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}
.chess-promotion-piece:hover {
  transform: scale(1.15);
  border-color: var(--accent);
}

@media (max-width: 600px) {
  .chess-panel {
    bottom: 70px;
    width: calc(100vw - 16px);
    border-radius: 12px;
  }
  .chess-piece {
    font-size: min(10vw, 32px);
  }
}
