:root {
  --bg: #0f1116;
  --bg-elev: #171a21;
  --bg-elev-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #98a1b3;
  --accent: #ffc107;
  --primary: #3b82f6;
  --danger: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}

button, input { font-family: inherit; font-size: inherit; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--bg-elev-2);
  color: var(--text);
  transition: filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #1a1206; font-weight: 600; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; font-weight: 600; }

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--primary); }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #1a1206;
  display: grid; place-items: center; font-weight: 800;
}
.badge {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; color: var(--text-dim); font-size: 12px;
}
.count {
  background: var(--bg-elev-2); border-radius: 999px;
  padding: 1px 7px; font-size: 12px; color: var(--text-dim);
}

/* ---------- Landing ---------- */
.landing { display: flex; flex-direction: column; min-height: 100%; }
.landing-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
}
.landing-main { flex: 1; max-width: 780px; margin: 0 auto; padding: 72px 24px; text-align: center; }
.landing-main h1 { font-size: 44px; margin: 0 0 14px; letter-spacing: -.02em; }
.accent { color: var(--accent); }
.lead { color: var(--text-dim); font-size: 17px; line-height: 1.6; margin: 0 auto 34px; max-width: 540px; }
.landing-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.join-form { display: flex; gap: 8px; }
.join-form input { width: 280px; }
.error-text { color: var(--danger); margin-top: 16px; }
.feature-grid {
  list-style: none; padding: 0; margin: 60px 0 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; text-align: left;
}
.feature-grid li {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.feature-grid strong { display: block; margin-bottom: 6px; }
.feature-grid span { color: var(--text-dim); line-height: 1.5; }
.landing-footer { padding: 22px; text-align: center; color: var(--text-dim); border-top: 1px solid var(--border); }

/* ---------- Room ----------
   Tum arayuz tek ekrana sigar: sayfa kaydirilmaz, sadece playlist / katilimci
   / sohbet listeleri kendi icinde kayar. Video kalan bosluga gore buyur. */
.room { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
}
.add-form { flex: 1; display: flex; gap: 8px; max-width: 620px; }
.add-form input { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.sync-badge { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.sync-badge.good { color: #22c55e; }
.sync-badge.bad { color: var(--danger); }

/* Ust satir: video | sira. Alt satir: ikisinin altinda katilimcilar.
   Sohbet en sagda iki satir boyunca uzanir. */
.layout {
  flex: 1 1 auto; min-height: 0; display: grid; gap: 10px; padding: 10px;
  /* Video sutunu icerige (16:9) gore daralir, fazla genislik siraya gider. */
  grid-template-columns: max-content minmax(400px, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) 168px;
}
.stage {
  grid-column: 1; grid-row: 1;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0; min-height: 0; overflow: hidden;
  justify-self: start;
  width: max-content;
  height: 100%;
}
.player-stage {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
}
.player-area { flex: 1 1 auto; min-height: 0; }
.player-wrap {
  position: relative; background: #000;
  border-radius: 8px 8px 0 0;
  overflow: hidden; height: 100%; aspect-ratio: 16 / 9;
}
#player {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  pointer-events: auto;
}
#player iframe { width: 100%; height: 100%; border: 0; pointer-events: auto; }
.player-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(10, 12, 16, .92); text-align: center; padding: 24px;
  z-index: 4;
}
.player-overlay[hidden] { display: none; }
.overlay-card h2 { margin: 0 0 8px; }
.overlay-card p { color: var(--text-dim); margin: 0; }

.controls {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  background: #16191f;
  border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 5px 10px;
  min-height: 38px;
}
.controls .icon-btn {
  width: 30px; height: 30px; border-radius: 6px;
  border: 0; background: transparent; color: #e8ecf4;
}
.controls .icon-btn.primary { font-size: 13px; }
.controls .icon-btn.skip-btn {
  width: auto; min-width: 34px; padding: 0 6px;
  font-size: 11px; font-weight: 700; color: #c7cdda;
}
.controls .icon-btn:hover { background: rgba(255, 255, 255, .06); filter: none; }
.time-label {
  color: #f3f5f8; font-variant-numeric: tabular-nums;
  min-width: 96px; font-size: 12px; white-space: nowrap; font-weight: 500;
}
.playlist-panel { grid-column: 2; grid-row: 1; }
.people { grid-column: 1 / 3; grid-row: 2; }
.chat-panel { grid-column: 3; grid-row: 1 / 3; }

.playlist-panel, .people, .chat-panel {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
}

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elev-2);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { filter: brightness(1.2); }
.icon-btn.skip-btn {
  width: auto; min-width: 36px; border-radius: 8px; padding: 0 8px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.seek { flex: 1; display: flex; align-items: center; min-width: 80px; }
.seek input {
  width: 100%; height: 6px; cursor: pointer;
  accent-color: var(--primary);
}
.vol-bar { width: 72px; height: 5px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }

.player-stage:fullscreen,
.player-stage:-webkit-full-screen {
  width: 100%; height: 100%; padding: 12px; box-sizing: border-box;
  background: #000; flex-direction: column; justify-content: center;
}
.player-stage:fullscreen .player-area,
.player-stage:-webkit-full-screen .player-area {
  flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center;
}
.player-stage:fullscreen .player-wrap,
.player-stage:-webkit-full-screen .player-wrap {
  max-width: 100%; max-height: 100%;
}
.player-stage:fullscreen .controls,
.player-stage:-webkit-full-screen .controls {
  width: 100%;
}

.switch { display: flex; align-items: center; gap: 6px; color: var(--text-dim); white-space: nowrap; cursor: pointer; font-size: 12px; }
.switch input { accent-color: var(--accent); }

.panel-head {
  flex: 0 0 auto; padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel-head h3 { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.head-hint { color: var(--text-dim); font-size: 11px; }

.playlist {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.playlist li {
  display: flex; align-items: center; gap: 8px; padding: 6px;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.playlist li:hover { background: var(--bg-elev-2); }
.playlist li.active {
  background: rgba(245, 165, 36, .1);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.pl-thumb { position: relative; flex-shrink: 0; }
.playlist img { width: 88px; height: 50px; object-fit: cover; border-radius: 5px; display: block; background: #000; }
.now-badge {
  position: absolute; left: 4px; bottom: 4px;
  background: var(--accent); color: #1a1206;
  font-size: 9px; font-weight: 800; letter-spacing: .04em;
  padding: 2px 5px; border-radius: 4px; line-height: 1.1;
}
.pl-body { min-width: 0; flex: 1; }
.pl-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.pl-meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-yt {
  flex-shrink: 0; color: var(--text-dim); text-decoration: none;
  font-size: 11px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border);
  white-space: nowrap;
}
.pl-yt:hover { color: var(--text); border-color: var(--text-dim); }
.pl-remove {
  background: transparent; border: 0; color: var(--text-dim);
  cursor: pointer; padding: 4px; border-radius: 6px; font-size: 14px; opacity: 0;
}
.playlist li:hover .pl-remove { opacity: 1; }
.pl-remove:hover { color: var(--danger); background: var(--bg); }
.empty-hint { color: var(--text-dim); padding: 10px 14px; margin: 0; }
.empty-hint[hidden] { display: none; }

/* Oylama: basparmak + sayi, yan yana */
.vote {
  display: flex; flex-direction: column; gap: 4px; flex-shrink: 0;
}
.vote button {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; line-height: 1; padding: 4px 7px; border-radius: 999px;
  font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600;
}
.vote button svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }
.vote button:hover { color: var(--text); border-color: var(--text-dim); }
.vote button.on.up { color: #22c55e; border-color: #22c55e; background: rgba(34, 197, 94, .12); }
.vote button.on.down { color: var(--danger); border-color: var(--danger); background: rgba(239, 68, 68, .12); }

.chat {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.chat li { line-height: 1.45; word-break: break-word; }
.chat .msg-name { font-weight: 600; margin-right: 6px; }
.chat .msg-time { color: var(--text-dim); font-size: 11px; margin-left: 6px; }
.chat .system { color: var(--text-dim); font-size: 12.5px; font-style: italic; }
.chat-form { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; min-width: 0; }

/* Katilimcilar kare avatar dosemesi olarak dizilir. */
.users {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  list-style: none; margin: 0; padding: 11px 12px;
  display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start;
}
.user-tile {
  position: relative; width: 92px; height: 92px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden; background: var(--bg-elev-2);
}
.tile-img {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 32px; font-weight: 800; color: #10121a;
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-name {
  position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px);
  padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 600; color: #10121a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-badge { position: absolute; top: 3px; left: 5px; font-size: 14px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .7)); }
.tile-edit {
  position: absolute; top: 3px; right: 3px; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff; border-radius: 6px;
  padding: 2px 6px; font-size: 11px; opacity: 0; transition: opacity .15s ease;
}
.user-tile.me:hover .tile-edit { opacity: 1; }
.user-tile.me { outline: 2px solid var(--accent); outline-offset: -2px; cursor: pointer; }
.user-tile.offline { opacity: .45; }

/* Avatar secici (giris ekrani ve profil penceresi) */
.avatar-pick {
  width: 46px; height: 46px; flex-shrink: 0; padding: 0; overflow: hidden;
  border-radius: 10px; border: 1px dashed var(--border); cursor: pointer;
  background: var(--bg-elev-2); color: var(--text-dim);
  font-size: 18px; font-weight: 800; display: grid; place-items: center;
}
.avatar-pick:hover { border-color: var(--accent); color: var(--text); }
.avatar-pick img { width: 100%; height: 100%; object-fit: cover; }
.avatar-pick.filled { border-style: solid; }
.hint-line { color: var(--text-dim); font-size: 12px; margin: 8px 0 0; }
.modal-actions.spread { justify-content: space-between; }
.modal-actions.spread span { display: flex; gap: 8px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #10121a; flex-shrink: 0;
}

/* ---------- Modal & toasts ---------- */
.modal { position: fixed; inset: 0; background: rgba(6, 8, 12, .7); display: grid; place-items: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; width: min(460px, 92vw);
}
.modal-card h2 { margin: 0 0 6px; font-size: 18px; }
.modal-sub { color: var(--text-dim); margin: 0 0 16px; }
.gate { background: rgba(6, 8, 12, .88); backdrop-filter: blur(3px); }
.gate-row { display: flex; align-items: center; gap: 10px; }
.gate-row input { flex: 1; }
.gate-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.gate-room { color: var(--text-dim); }
.gate-room code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toast-in .18s ease;
}
.toast.warn { border-color: var(--accent); color: var(--accent); }
.toast.error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dar ekranda tek sutuna in ve sayfa kaydirmasina izin ver. */
@media (max-width: 1100px) {
  .room { height: auto; min-height: 100dvh; overflow: auto; }
  .layout { grid-template-columns: 1fr; grid-template-rows: auto; }
  .stage, .playlist-panel, .people, .chat-panel { grid-column: 1; grid-row: auto; }
  .stage { overflow: visible; width: auto; justify-self: stretch; }
  .player-stage { width: 100%; }
  .player-area { flex: 0 0 auto; }
  .player-wrap { height: auto; width: 100% !important; }
  .playlist-panel { height: 320px; }
  .people { height: 190px; }
  .chat-panel { height: 60vh; }
  .topbar { flex-wrap: wrap; }
  .brand-text { display: none; }
}
