:root {
  --bg-0: #0b0417;
  --bg-1: #150a2e;
  --bg-2: #1e0f42;
  --panel: rgba(30, 15, 66, 0.55);
  --panel-solid: #1b0e3a;
  --border: rgba(168, 120, 255, 0.22);
  --purple: #a878ff;
  --purple-bright: #c8a6ff;
  --pink: #ff8fe0;
  --text: #ece7ff;
  --muted: #9a8fc7;
  --danger: #ff6b8a;
}

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

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 700px at 70% -10%, #2a1560 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text);
  overflow: hidden;
}

#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.confetti-canvas {
  position: fixed; inset: 0;
  z-index: 60; pointer-events: none;
}

/* Ust header: kayan yazi (sol) + sosyal ikonlar (sag) */
.marquee-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 54px;
  z-index: 30; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: linear-gradient(90deg, rgba(30,15,66,0.94), rgba(42,21,96,0.88), rgba(20,10,46,0.94));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 14px rgba(80,30,160,0.35);
  overflow: hidden; max-width: 100vw; box-sizing: border-box;
}
.marquee-viewport {
  flex: 1; min-width: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}
.marquee-track {
  display: block; padding-left: 100%; white-space: nowrap; will-change: transform;
  /* kayar (~20sn) sonra ~10sn bekler -> toplam 30sn */
  animation: marquee 30s linear infinite;
}
.marquee-track span {
  font-size: 13px; font-weight: 600; letter-spacing: .6px;
  color: var(--purple-bright);
  text-shadow: 0 0 8px rgba(200,166,255,0.5);
}
@keyframes marquee {
  0%   { transform: translateX(0); }        /* metin sagda, ekran disi */
  66%  { transform: translateX(-100%); }     /* tamamen sola kaydi */
  100% { transform: translateX(-100%); }     /* ~10sn bekle, sonra bastan */
}
.marquee-bar:hover .marquee-track { animation-play-state: paused; }

.hidden { display: none !important; }

/* Sag ust: sosyal linkler + admin tilkisi */
.topright {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.tr-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(20,10,46,0.7);
  display: grid; place-items: center; cursor: pointer;
  text-decoration: none; line-height: 0;
  color: #ececf2;
  box-shadow: 0 6px 20px rgba(80,30,160,0.35);
  transition: transform .15s, box-shadow .2s, background .2s;
  backdrop-filter: blur(6px);
}
.tr-btn:hover { transform: scale(1.1); box-shadow: 0 8px 26px rgba(168,120,255,0.5); background: rgba(42,21,96,0.8); }
.tr-btn:active { transform: scale(0.96); }
.tr-btn svg { display: block; }
.admin-fox { font-size: 22px; line-height: 1; }
#visitorsBtn { display: none; font-size: 20px; }
body.admin-mode #visitorsBtn { display: grid; }

/* Ziyaretci paneli */
.visitors-card {
  position: relative;
  width: min(96vw, 760px);
  max-height: 82vh;
  background: linear-gradient(160deg, rgba(42,21,96,0.95), rgba(20,10,46,0.97));
  border: 1px solid var(--border);
  border-radius: 18px; padding: 22px;
  box-shadow: 0 20px 60px rgba(80,30,160,0.4);
  display: flex; flex-direction: column;
}
.visitors-card h2 {
  font-size: 18px; color: var(--purple-bright); margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.visitors-card .vcount {
  font-size: 12px; background: rgba(168,120,255,0.18); color: var(--purple-bright);
  padding: 1px 9px; border-radius: 999px;
}
.vrefresh {
  margin-left: auto; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: rgba(10,4,26,0.6); color: var(--purple-bright);
  font-size: 15px;
}
.vrefresh:hover { background: rgba(168,120,255,0.2); }
.visitors-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.visitors-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
.visitors-table th, .visitors-table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid rgba(168,120,255,0.12);
  white-space: nowrap;
}
.visitors-table th {
  position: sticky; top: 0; background: #1b0e3a; color: var(--purple-bright);
  font-size: 11px; letter-spacing: .5px; z-index: 1;
}
.visitors-table td { color: var(--text); }
.visitors-table td .vtag {
  font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-left: 6px;
  border: 1px solid var(--border); color: var(--muted);
}
.visitors-table td .vtag.admin { color: #ffd766; border-color: rgba(255,199,64,0.5); }
.visitors-table tr:hover td { background: rgba(168,120,255,0.06); }
.visitors-empty { text-align: center; color: var(--muted); padding: 20px; }
.visitors-table .v-on { color: #3ef2a3; text-shadow: 0 0 6px rgba(62,242,163,0.6); }
.visitors-table .v-off { color: #6b6486; }
.admin-fox:hover { transform: scale(1.1) rotate(-6deg); }
.ig-link:hover { filter: drop-shadow(0 0 6px rgba(214,41,118,0.6)); }
.x-link:hover { filter: drop-shadow(0 0 6px rgba(255,255,255,0.5)); }
.tt-link:hover { filter: drop-shadow(0 0 6px rgba(37,244,238,0.6)); }
.muted { color: var(--muted); font-weight: 400; }

/* ---------- Giris ekrani ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(6, 2, 16, 0.7);
  backdrop-filter: blur(6px);
}
.login-card {
  position: relative;
  width: min(92vw, 420px);
  background: linear-gradient(160deg, rgba(42,21,96,0.9), rgba(20,10,46,0.95));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(80, 30, 160, 0.35), 0 0 0 1px rgba(200,166,255,0.08) inset;
}
.login-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(10,4,26,0.6);
  color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1;
  display: grid; place-items: center; transition: color .15s, background .15s;
}
.login-close:hover { color: #fff; background: rgba(168,120,255,0.25); }
.login-error {
  margin-top: 14px; padding: 9px 12px; border-radius: 10px;
  font-size: 13px; color: #ffb3c1;
  background: rgba(255,107,138,0.12); border: 1px solid rgba(255,107,138,0.4);
}
.login-card h1, .login-card h2 {
  font-size: 26px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--purple-bright), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.login-card label { display: block; font-size: 13px; color: var(--purple-bright); margin: 14px 0 6px; }
.login-card input, .login-card textarea, .chat-form input {
  width: 100%;
  background: rgba(10, 4, 26, 0.7);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  resize: vertical;
}
.login-card input:focus, .login-card textarea:focus, .chat-form input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(168,120,255,0.18);
}
/* Avatar secici (giris) - dikey (portre) kutular, yuz tam otursun */
.avatar-picker { display: flex; gap: 14px; margin-top: 6px; }
.avatar-choice {
  position: relative;
  width: 76px; height: 96px; border-radius: 16px;
  border: 2px solid var(--border);
  background: rgba(10,4,26,0.7);
  cursor: pointer; overflow: hidden; padding: 0;
  display: block;
  transition: border-color .15s, transform .12s, box-shadow .2s;
}
.avatar-choice:hover { transform: translateY(-2px); }
.avatar-choice.selected {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(168,120,255,0.25);
}
.avatar-choice .ac-emoji { font-size: 30px; line-height: 1; }
.avatar-choice img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  display: block;
}

#loginBtn {
  margin-top: 22px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(90deg, #7b3ff2, #b44ce0);
  box-shadow: 0 8px 24px rgba(123,63,242,0.4);
  transition: transform .12s, box-shadow .2s;
}
#loginBtn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(123,63,242,0.55); }
#loginBtn:active { transform: translateY(0); }

/* ---------- Ana yerlesim (sketch'e gore grid) ---------- */
.app {
  position: relative;
  z-index: 1;
  height: calc(100vh - 54px);
  margin-top: 54px;
  padding: 14px;
  display: grid;
  gap: 14px;
  grid-template-columns: 190px 1fr 320px;
  grid-template-rows: minmax(260px, 46%) 1fr;
  grid-template-areas:
    "online playlist playlist"
    "online chat     profile";
}

.online   { grid-area: online; }
.playlist { grid-area: playlist; }
.chat     { grid-area: chat; }
.profile  { grid-area: profile; }

.online, .playlist, .chat, .profile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(20, 6, 50, 0.4);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--purple-bright);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.panel-head .count {
  margin-left: auto;
  background: rgba(168,120,255,0.18);
  color: var(--purple-bright);
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
}
.panel-head .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #3ef2a3;
  box-shadow: 0 0 10px #3ef2a3;
  animation: pulse 1.8s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ---------- Online liste ---------- */
.online-list { list-style: none; overflow-y: auto; padding: 8px; flex: 1; }
.online-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.online-item:hover { background: rgba(168,120,255,0.12); }
.online-item.active { background: rgba(168,120,255,0.22); box-shadow: inset 0 0 0 1px var(--purple); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #120823;
  flex-shrink: 0; overflow: hidden;
}
.avatar .emoji { font-size: 20px; line-height: 1; }
.avatar img, .big-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; display: block; }
.big-avatar .emoji { font-size: 46px; line-height: 1; }
.online-item .uname {
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.online-item .you-badge {
  margin-left: auto; font-size: 10px; color: var(--muted);
  border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px;
}
.online-item .you-badge.bot {
  color: var(--purple-bright);
  border-color: rgba(168,120,255,0.5);
  background: rgba(168,120,255,0.14);
}
.online-item .you-badge.admin {
  color: #ffd766;
  border-color: rgba(255,199,64,0.6);
  background: rgba(255,199,64,0.14);
}
.online-item .you-badge.queen {
  color: #ff8fe0;
  border-color: rgba(255,143,224,0.6);
  background: rgba(255,143,224,0.16);
}

/* Imza (Baron G) */
.credit {
  flex-shrink: 0;
  text-align: center;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px;
  color: #ffd766;
  text-shadow: 0 0 8px rgba(255,199,64,0.45);
  display: flex; flex-direction: column; gap: 1px; line-height: 1.3;
}
.credit span { color: var(--muted); font-weight: 500; font-size: 10px; text-shadow: none; }

/* ---------- Playlist ---------- */
.playlist-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.playlist-head .brand {
  font-size: 19px; font-weight: 800; letter-spacing: 1.5px;
  color: #fff;
  text-shadow:
    0 0 4px #fff,
    0 0 9px #ff6ec7,
    0 0 16px #d62976,
    0 0 28px #d62976,
    0 0 42px #a020f0;
  animation: neonFlicker 3s infinite alternate;
}
@keyframes neonFlicker {
  0%, 18%, 22%, 25%, 53%, 57%, 100% {
    text-shadow: 0 0 4px #fff, 0 0 9px #ff6ec7, 0 0 16px #d62976, 0 0 28px #d62976, 0 0 42px #a020f0;
    opacity: 1;
  }
  20%, 24%, 55% { text-shadow: 0 0 4px #fff, 0 0 8px #ff6ec7; opacity: 0.86; }
}
.playlist-head .brand-sub { font-size: 12px; color: var(--muted); }
.player-wrap { flex: 1; padding: 12px; position: relative; }
.player-wrap iframe, .player-wrap #ytPlayer { width: 100%; height: 100%; border: 0; border-radius: 12px; }
.unmute-btn {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 5; border: none; cursor: pointer;
  padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(90deg, #7b3ff2, #b44ce0);
  box-shadow: 0 8px 24px rgba(123,63,242,0.5);
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100%{ transform: translateX(-50%) translateY(0);} 50%{ transform: translateX(-50%) translateY(-4px);} }
.sync-badge {
  position: absolute; right: 20px; top: 20px; z-index: 5;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(10,4,26,0.75); color: #3ef2a3;
  border: 1px solid var(--border);
}
.sync-badge.leader { color: var(--purple-bright); }

/* ---------- Chat ---------- */
.chat-head { justify-content: space-between; }
.cooldown { color: var(--danger); font-size: 12px; letter-spacing: 0; font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; padding-left: 2px; display: flex; align-items: center; gap: 5px; }
.msg.mine .meta { flex-direction: row-reverse; }
.mini-avatar {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-grid; place-items: center; overflow: hidden;
  font-size: 8px; font-weight: 700; color: #120823; flex-shrink: 0;
}
.mini-avatar .emoji { font-size: 11px; line-height: 1; }
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; display: block; }
.msg .meta .who { font-weight: 700; }
.msg-del {
  display: none;
  margin-left: 4px; border: none; background: none; cursor: pointer;
  color: var(--danger); font-size: 12px; line-height: 1; padding: 0 2px;
  opacity: 0; transition: opacity .15s;
}
body.admin-mode .msg-del { display: inline; }
body.admin-mode .msg:hover .msg-del { opacity: 1; }
.msg-del:hover { transform: scale(1.2); }
.msg .bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  padding: 9px 13px;
  border-radius: 4px 14px 14px 14px;
  font-size: 14px; line-height: 1.45; word-wrap: break-word;
}
.msg.mine { align-self: flex-end; }
.msg.mine .meta { text-align: right; padding-right: 2px; }
.msg.mine .bubble {
  background: linear-gradient(135deg, rgba(123,63,242,0.5), rgba(180,76,224,0.4));
  border-color: rgba(200,166,255,0.35);
  border-radius: 14px 4px 14px 14px;
}
.msg.system {
  align-self: center; max-width: 100%;
  font-size: 12px; color: var(--muted); font-style: italic;
}
.chat-warn {
  margin: 0 12px; padding: 8px 12px; border-radius: 10px;
  font-size: 12.5px; color: #ffb3c1;
  background: rgba(255,107,138,0.12); border: 1px solid rgba(255,107,138,0.4);
}
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }
.chat-form button {
  padding: 0 20px; border: none; border-radius: 12px; cursor: pointer;
  font-weight: 600; color: #fff;
  background: linear-gradient(90deg, #7b3ff2, #b44ce0);
  transition: transform .12s, opacity .2s;
}
.chat-form button:hover:not(:disabled) { transform: translateY(-1px); }
.chat-form button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Profil ---------- */
.profile-body { flex: 1; overflow-y: auto; padding: 20px; }
.profile-empty { color: var(--muted); text-align: center; margin-top: 40px; font-size: 14px; line-height: 1.6; }
.profile-card { text-align: center; }
.profile-card .big-avatar {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto 14px;
  font-size: 34px; font-weight: 800; color: #120823;
  box-shadow: 0 0 0 4px rgba(168,120,255,0.15), 0 10px 30px rgba(80,30,160,0.4);
}
.profile-card .p-name { font-size: 20px; font-weight: 700; }
.profile-card .p-status { color: #3ef2a3; font-size: 12px; margin-top: 4px; }
.profile-card .p-bio {
  margin-top: 18px; text-align: left;
  background: rgba(10,4,26,0.5);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
  font-size: 14px; line-height: 1.6; color: #d8d0f5;
  white-space: pre-wrap; word-wrap: break-word;
}
.profile-card .admin-info {
  margin-top: 16px; text-align: left;
  background: rgba(255,199,64,0.07);
  border: 1px solid rgba(255,199,64,0.3);
  border-radius: 12px; padding: 12px 14px;
}
.admin-info .ai-title { font-size: 11px; font-weight: 800; letter-spacing: .5px; color: #ffd766; margin-bottom: 8px; }
.admin-info .ai-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.admin-info .ai-row span { color: var(--muted); }
.admin-info .ai-row b { color: var(--text); font-weight: 600; text-align: right; word-break: break-all; }

.profile-card .edit-btn {
  margin-top: 14px; width: 100%; padding: 9px;
  background: rgba(168,120,255,0.14); color: var(--purple-bright);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-size: 13px; transition: background .15s;
}
.profile-card .edit-btn:hover { background: rgba(168,120,255,0.25); }
.profile-card textarea {
  width: 100%; margin-top: 12px;
  background: rgba(10,4,26,0.7); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); padding: 11px; font-family: inherit;
  font-size: 14px; resize: vertical; outline: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(168,120,255,0.3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  /* Mobilde sayfa dogal olarak kaysin (body overflow:hidden'i ez) */
  html, body {
    height: auto;
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;             /* her satir icerige gore */
    grid-template-areas:
      "playlist"
      "chat"
      "online"
      "profile";                          /* sira: video, chat, online, kisi profili */
    height: auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100vw;
    padding: 12px;
  }

  /* Panellerin yuksekligi cokmesin (vh yerine sabit px -> iOS'ta olcek zicramasin) */
  .playlist { height: auto; min-width: 0; }
  .player-wrap { height: 210px; padding: 10px; }
  .profile { min-height: 150px; min-width: 0; }
  .profile-body { max-height: 260px; }
  .chat { height: 460px; min-width: 0; }
  .online { height: 240px; min-width: 0; }

  /* Header ikonlari kucuk ekranda sigsin */
  .marquee-bar { gap: 8px; padding: 0 10px; }
  .topright { gap: 7px; }
  .tr-btn { width: 38px; height: 38px; }
  .admin-fox { font-size: 19px; }

  /* iOS Safari input'a odaklaninca zoom yapmasin (>=16px sart) */
  .login-card input, .login-card textarea,
  .chat-form input, .profile-card textarea {
    font-size: 16px;
  }
}

/* Cok dar ekran: bir ikonu gizlemeden daha da kucult */
@media (max-width: 420px) {
  .tr-btn { width: 34px; height: 34px; }
  .marquee-track span { font-size: 12px; }
}
