:root {
  color-scheme: dark;
  --bg: #070b18;
  --panel: rgba(17, 24, 46, 0.82);
  --panel-strong: #11182e;
  --line: rgba(255, 255, 255, 0.10);
  --text: #f7f8ff;
  --muted: #9aa6c5;
  --primary: #7c5cff;
  --primary-2: #b84cff;
  --success: #35d89b;
  --danger: #ff5470;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --radius: 24px;
}

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

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(124, 92, 255, 0.28), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(184, 76, 255, 0.20), transparent 31%),
    linear-gradient(145deg, #070b18 0%, #0b1022 48%, #090d1b 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.14;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(124, 92, 255, 0.38);
  outline-offset: 3px;
}

.hidden,
.is-hidden,
[hidden] {
  display: none !important;
}

.app-shell,
.page-shell,
main {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 28px 0 34px;
}

.brand,
.brand-row,
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand-mark,
.logo-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 34px rgba(124, 92, 255, 0.34);
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  letter-spacing: -0.035em;
}

.eyebrow,
.kicker {
  margin-bottom: 8px;
  color: #b8adff;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted,
.subtitle,
.helper-text {
  color: var(--muted);
}

#status-text {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c9d1e9;
  background: rgba(8, 13, 28, 0.7);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

#status-text::before {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: #ffc857;
  box-shadow: 0 0 14px rgba(255, 200, 87, 0.72);
}

#status-text.connected::before,
#status-text.success::before,
#status-text.is-connected::before {
  background: var(--success);
  box-shadow: 0 0 14px rgba(53, 216, 155, 0.72);
}

#status-text.error::before,
#status-text.is-error::before {
  background: var(--danger);
  box-shadow: 0 0 14px rgba(255, 84, 112, 0.72);
}

#join-panel,
#room-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#join-panel {
  width: min(560px, 100%);
  margin: clamp(48px, 10vh, 110px) auto 0;
  padding: clamp(26px, 5vw, 48px);
  text-align: center;
}

#join-panel h1,
#join-panel h2 {
  margin-bottom: 12px;
  font-size: clamp(1.75rem, 5vw, 2.75rem);
}

#join-panel p {
  margin-bottom: 28px;
  line-height: 1.65;
}

#join-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

#join-form label {
  color: #dbe1f5;
  font-size: 0.86rem;
  font-weight: 750;
}

#display-name {
  width: 100%;
  min-height: 54px;
  padding: 0 17px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 15px;
  color: var(--text);
  caret-color: #b9aaff;
  background: rgba(6, 10, 23, 0.7);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#display-name::placeholder {
  color: #6f7b9d;
}

#display-name:hover,
#display-name:focus {
  border-color: rgba(145, 119, 255, 0.72);
  background: rgba(7, 11, 25, 0.92);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.10);
}

#join-button {
  min-height: 54px;
  margin-top: 4px;
  padding: 0 20px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 13px 30px rgba(124, 92, 255, 0.28);
  font-weight: 850;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

#join-button:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 17px 38px rgba(124, 92, 255, 0.38);
}

#join-button:disabled,
button:disabled {
  opacity: 0.58;
  cursor: wait;
}

#room-panel {
  min-height: calc(100vh - 88px);
  min-height: calc(100dvh - 88px);
  padding: clamp(16px, 3vw, 26px);
}

.room-header,
.room-topbar,
#room-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

#room-name {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  overflow-wrap: anywhere;
}

#participant-count {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid rgba(53, 216, 155, 0.22);
  border-radius: 999px;
  color: #a8f3d4;
  background: rgba(53, 216, 155, 0.09);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

#media-grid {
  display: grid;
  min-height: clamp(360px, 63vh, 720px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

#media-grid:empty {
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 20px;
  background: rgba(5, 9, 20, 0.38);
}

#media-grid:empty::before {
  content: "Diğer katılımcı bekleniyor…";
  color: var(--muted);
  font-weight: 700;
}

#media-grid > *,
.participant-tile,
.participant-card,
.video-tile,
.media-tile {
  position: relative;
  min-width: 0;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 36%, rgba(124, 92, 255, 0.23), transparent 36%),
    #090e20;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

#media-grid video,
.participant-tile video,
.participant-card video,
.video-tile video,
.media-tile video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  background: #060916;
}

.video-slot {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: inherit;
  place-items: center;
}

.participant-avatar {
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 40px rgba(124, 92, 255, 0.3);
  font-size: 1.45rem;
  font-weight: 900;
}

.participant-tile.has-video .participant-avatar {
  display: none;
}

.participant-info {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  width: fit-content;
  max-width: calc(100% - 24px);
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 11px;
  background: rgba(5, 8, 18, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.participant-info strong {
  overflow: hidden;
  color: #fff;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-state {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}

.participant-tile.is-speaking {
  border-color: rgba(53, 216, 155, 0.76);
  box-shadow: 0 0 0 3px rgba(53, 216, 155, 0.13),
    0 16px 42px rgba(0, 0, 0, 0.3);
}

#media-grid audio {
  display: none;
}

.participant-name,
.participant-label,
.identity,
.tile-label,
#media-grid [data-participant-name] {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 3;
  width: fit-content;
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 11px;
  color: #fff;
  background: rgba(5, 8, 18, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls,
.media-controls,
.room-controls,
.control-bar,
#room-panel > footer {
  position: sticky;
  bottom: 14px;
  z-index: 10;
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px auto 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(7, 11, 24, 0.82);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#mic-button,
#camera-button,
#music-button,
#leave-button {
  min-height: 48px;
  padding: 0 17px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  color: #eef1ff;
  background: rgba(255, 255, 255, 0.075);
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

#mic-button:hover:not(:disabled),
#camera-button:hover:not(:disabled),
#music-button:hover:not(:disabled) {
  border-color: rgba(145, 119, 255, 0.54);
  background: rgba(124, 92, 255, 0.17);
  transform: translateY(-1px);
}

#mic-button.off,
#mic-button.muted,
#mic-button.is-muted,
#camera-button.off,
#camera-button.is-off,
#mic-button[aria-pressed="false"],
#camera-button[aria-pressed="false"] {
  color: #ffcad3;
  border-color: rgba(255, 84, 112, 0.30);
  background: rgba(255, 84, 112, 0.12);
}

#music-button.is-active {
  color: #d6fff0;
  border-color: rgba(53, 216, 155, 0.42);
  background: rgba(53, 216, 155, 0.16);
}

#leave-button {
  color: #fff;
  border-color: rgba(255, 84, 112, 0.34);
  background: linear-gradient(135deg, #e94362, #ff5470);
}

#leave-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #f04c6b, #ff6680);
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .app-shell,
  .page-shell,
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .brand,
  .brand-row,
  .site-header,
  .room-header,
  .room-topbar,
  #room-panel > header {
    align-items: flex-start;
  }

  #join-panel {
    margin-top: 28px;
    border-radius: 20px;
  }

  #room-panel {
    min-height: calc(100dvh - 30px);
    border-radius: 20px;
  }

  #media-grid {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  #media-grid > *,
  .participant-tile,
  .participant-card,
  .video-tile,
  .media-tile {
    min-height: min(54vh, 440px);
  }
}

@media (max-width: 520px) {
  #status-text {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .controls,
  .media-controls,
  .room-controls,
  .control-bar,
  #room-panel > footer {
    width: 100%;
  }

  #mic-button,
  #camera-button,
  #music-button,
  #leave-button {
    min-width: 0;
    flex: 1 1 0;
    padding: 0 10px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
