/* ============ Tema değişkenleri ============ */
:root {
  --primary: #8b5cf6;
  --primary-2: #c084fc;
  --primary-soft: rgba(139, 92, 246, .18);
  --glow: rgba(139, 92, 246, .45);
  --radius: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
body.dark {
  --bg: #0b0716;
  --card: rgba(24, 17, 46, .72);
  --card-solid: #181130;
  --text: #f3effe;
  --muted: #a79fc4;
  --border: rgba(167, 139, 250, .18);
  --input: rgba(12, 8, 26, .65);
  --bubble: rgba(255, 255, 255, .07);
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, .7);
}
body:not(.dark) {
  --bg: #f5f1ff;
  --card: rgba(255, 255, 255, .78);
  --card-solid: #ffffff;
  --text: #1f1537;
  --muted: #6b6485;
  --border: rgba(124, 58, 237, .16);
  --input: rgba(245, 241, 255, .9);
  --bubble: rgba(124, 58, 237, .07);
  --shadow: 0 30px 70px -25px rgba(91, 33, 182, .35);
}
body[data-accent="blue"]    { --primary: #3b82f6; --primary-2: #60a5fa; --primary-soft: rgba(59,130,246,.18); --glow: rgba(59,130,246,.45); }
body[data-accent="emerald"] { --primary: #10b981; --primary-2: #34d399; --primary-soft: rgba(16,185,129,.18); --glow: rgba(16,185,129,.45); }
body[data-accent="rose"]    { --primary: #f43f5e; --primary-2: #fb7185; --primary-soft: rgba(244,63,94,.18);  --glow: rgba(244,63,94,.45); }
body[data-accent="amber"]   { --primary: #f59e0b; --primary-2: #fbbf24; --primary-soft: rgba(245,158,11,.18); --glow: rgba(245,158,11,.45); }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background .4s var(--ease), color .4s var(--ease);
  overflow-x: hidden;
}

/* ============ Animasyonlu arka plan ============ */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
  background: radial-gradient(circle at 30% 30%, var(--primary-2), var(--primary));
  animation: float 18s ease-in-out infinite;
  transition: background .6s;
}
.b1 { width: 46vmax; height: 46vmax; top: -15vmax; left: -12vmax; }
.b2 { width: 38vmax; height: 38vmax; bottom: -14vmax; right: -10vmax; animation-delay: -6s; opacity: .4; }
.b3 { width: 26vmax; height: 26vmax; top: 35%; left: 55%; animation-delay: -11s; opacity: .28; }
body:not(.dark) .blob { opacity: .32; }
.grid {
  position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(6vmax, 4vmax) scale(1.08); }
  66% { transform: translate(-4vmax, 7vmax) scale(.94); }
}

/* ============ Yerleşim / kart ============ */
.stage { min-height: 100vh; display: grid; place-items: center; padding: 20px; }

.card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  animation: rise .7s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(26px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.auth { max-width: 420px; padding: 38px 30px 30px; text-align: center; }
.auth > * { animation: rise .7s var(--ease) both; }
.auth > *:nth-child(2) { animation-delay: .05s; }
.auth > *:nth-child(3) { animation-delay: .1s; }
.auth > *:nth-child(4) { animation-delay: .15s; }
.auth > *:nth-child(5) { animation-delay: .2s; }
.auth > *:nth-child(6) { animation-delay: .25s; }

.logo {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px;
  display: grid; place-items: center; font-size: 28px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 34px -6px var(--glow);
  animation: pop 4s ease-in-out infinite;
}
@keyframes pop { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(-3deg); } }

h1 {
  font-size: 28px; font-weight: 800; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* ============ Form elemanları ============ */
.field { position: relative; display: block; margin-bottom: 14px; }
input, textarea, .select {
  width: 100%; padding: 13px 16px; font: inherit; font-size: 15px; color: var(--text);
  background: var(--input); border: 1.5px solid var(--border); border-radius: 12px; outline: none;
  transition: border-color .25s, box-shadow .25s, transform .25s var(--ease);
}
input:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); transform: translateY(-1px);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

.btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 18px; font: inherit; font-size: 15px; font-weight: 700;
  border: 0; border-radius: 12px; cursor: pointer; text-decoration: none; overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .3s, background .3s, opacity .2s;
}
.btn.primary {
  color: #fff; background: linear-gradient(120deg, var(--primary), var(--primary-2), var(--primary));
  background-size: 200% 100%; box-shadow: 0 10px 26px -8px var(--glow);
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -8px var(--glow); }
.btn.primary:active { transform: translateY(0) scale(.98); }
.btn.ghost {
  margin-top: 12px; color: var(--primary); background: transparent; border: 1.5px solid var(--primary);
}
.btn.ghost:hover { background: var(--primary-soft); transform: translateY(-1px); }
.btn.soccer {
  margin-top: 12px; color: var(--text); background: var(--input); border: 1.5px solid var(--border);
}
.btn.soccer:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 12px 24px -10px var(--glow); }
.btn.soccer .ball { display: inline-block; transition: transform .6s var(--ease); }
.btn.soccer:hover .ball { transform: rotate(360deg) translateX(3px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn .spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff6; border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  color: #fecaca; background: rgba(239, 68, 68, .16); border: 1px solid rgba(239, 68, 68, .35);
  animation: shake .4s;
}
body:not(.dark) .alert { color: #991b1b; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.ts-slot { display: flex; justify-content: center; margin-bottom: 14px; min-height: 65px; }

/* ============ Oyun Kütüphanesi ============ */
.library { max-width: 680px; padding: 26px 28px; display: flex; flex-direction: column; gap: 18px; }
.library-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.lib-title-box { display: flex; align-items: center; gap: 14px; text-align: left; }
.logo-small { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 8px 20px -6px var(--glow); }

.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 4px 0; }
.game-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px;
  background: var(--input); border: 1.5px solid var(--border); cursor: pointer; text-decoration: none; color: inherit;
  transition: all .25s var(--ease); position: relative; overflow: hidden;
}
.game-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 14px 28px -10px var(--glow); background: var(--card-solid); }
.game-card:active { transform: translateY(-1px) scale(.99); }
.game-icon { font-size: 32px; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); flex-shrink: 0; transition: transform .25s var(--ease); }
.game-card:hover .game-icon { transform: scale(1.1) rotate(5deg); }
.game-info { flex: 1; min-width: 0; }
.game-title { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.game-cat { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.game-meta { display: flex; gap: 8px; font-size: 11px; font-weight: 600; color: var(--primary); }
.game-dl-btn {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 16px; flex-shrink: 0; transition: all .2s var(--ease);
  box-shadow: 0 4px 12px -4px var(--glow);
}
.game-card:hover .game-dl-btn { transform: scale(1.1); background: var(--primary-2); }
.library-footer { padding-top: 10px; border-top: 1px solid var(--border); }

/* ============ Sohbet ============ */
.chat { max-width: 800px; height: min(780px, 92vh); display: flex; flex-direction: column; padding: 16px 20px; position: relative; }

.chat-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.title-box { display: flex; align-items: center; gap: 10px; }
.chat h2 { font-size: 21px; font-weight: 800; background: linear-gradient(90deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.pill.online { color: #10b981; background: rgba(16, 185, 129, .14); }
.pill.admin { color: #fb7185; background: rgba(244, 63, 94, .16); animation: rise .4s var(--ease); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 #10b98188; animation: ping 1.8s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px #10b98100; } 100% { box-shadow: 0 0 0 0 #10b98100; } }

.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.select { width: auto; padding: 6px 10px; font-size: 12px; border-radius: 9px; cursor: pointer; }
.chip {
  padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--text);
  background: var(--input); border: 1px solid var(--border); border-radius: 9px; transition: all .2s var(--ease);
}
.chip:hover { border-color: var(--primary); transform: translateY(-1px); }
.chip.accent { color: var(--primary); background: var(--primary-soft); }
.chip.danger { color: #fb7185; }
.chip.danger:hover { background: rgba(244, 63, 94, .14); border-color: #fb7185; }

.tabs { display: flex; gap: 6px; padding: 9px 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  color: var(--muted); background: var(--input); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; user-select: none;
  transition: all .25s var(--ease); animation: rise .35s var(--ease) both;
}
.tab:hover { color: var(--text); border-color: var(--primary); transform: translateY(-1px); }
.tab.active { color: #fff; border-color: transparent; background: linear-gradient(120deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 16px -6px var(--glow); }
.tab .x { font-size: 11px; opacity: .7; padding: 1px 5px; border-radius: 50%; }
.tab .x:hover { opacity: 1; background: #0003; }
.badge { background: #ef4444; color: #fff; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 99px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

.messages { flex: 1; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 3px; scroll-behavior: smooth; }
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--primary-soft); border-radius: 8px; }
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 13.5px; animation: rise .5s var(--ease); }
.empty .big { font-size: 38px; display: block; margin-bottom: 6px; animation: pop 3s ease-in-out infinite; }

.group { display: flex; flex-direction: column; margin-top: 8px; }
.group.mine { align-items: flex-end; }
.group.other { align-items: flex-start; }
.sender { font-size: 11px; font-weight: 800; color: var(--primary); padding: 0 6px 2px; cursor: pointer; }
.sender:hover { text-decoration: underline; }
.sender.bot { background: linear-gradient(90deg, #60a5fa, #a78bfa, #f472b6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; cursor: default; text-decoration: none; }

.bubble {
  position: relative; width: fit-content; max-width: 82%; padding: 7px 11px 6px; font-size: 14px; line-height: 1.4;
  word-wrap: break-word; color: var(--text); background: var(--bubble); border-radius: 14px; box-shadow: 0 1px 2px #0002;
  animation: bubble-in .35s var(--ease) both; transition: transform .2s var(--ease);
}
.bubble:hover { transform: translateY(-1px); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }
.group.other .bubble { border-top-left-radius: 4px; transform-origin: left bottom; }
.group.mine .bubble { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-top-right-radius: 4px; transform-origin: right bottom; box-shadow: 0 8px 20px -10px var(--glow); }
.bubble.bot { background: linear-gradient(135deg, rgba(96, 165, 250, .14), rgba(167, 139, 250, .18)); border: 1px solid rgba(167, 139, 250, .38); }
.bubble.removing { animation: bubble-out .25s forwards; }
@keyframes bubble-out { to { opacity: 0; transform: scale(.85); height: 0; padding: 0; margin: 0; } }

.text { white-space: pre-wrap; word-break: break-word; }
.reply-tag { display: block; margin-bottom: 4px; padding: 3px 7px; font-size: 11px; border-left: 3px solid var(--primary); border-radius: 4px; background: #0000001f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.group.mine .reply-tag { border-left-color: #fff; background: #ffffff2e; }
.meta { display: inline-flex; align-items: center; gap: 6px; float: right; margin: 5px 0 0 10px; font-size: 10.5px; opacity: .75; user-select: none; }
.b-actions { display: none; gap: 6px; }
.bubble:hover .b-actions { display: inline-flex; }
.b-actions button { background: none; border: 0; color: inherit; font-size: 10.5px; text-decoration: underline; cursor: pointer; }

.typing { height: 20px; padding: 0 4px; font-size: 11.5px; font-style: italic; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); animation: bounce 1.2s infinite ease-in-out both; }
.dots i:nth-child(1) { animation-delay: -.32s; } .dots i:nth-child(2) { animation-delay: -.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); background: var(--input); border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0; animation: rise .25s var(--ease); }
.bar button { background: none; border: 0; color: #fb7185; font-weight: 800; cursor: pointer; }

.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 8px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: none; height: 46px; min-height: 46px; max-height: 120px; line-height: 1.4; }
.icon-btn { height: 46px; padding: 0 13px; font-size: 18px; cursor: pointer; color: var(--text); background: var(--input); border: 1.5px solid var(--border); border-radius: 12px; transition: all .2s var(--ease); }
.icon-btn:hover { border-color: var(--primary); transform: translateY(-1px) rotate(-6deg); }
.send { width: auto; height: 46px; padding: 0 22px; }

.emoji-picker {
  position: absolute; left: 20px; bottom: 82px; z-index: 20; width: 264px; padding: 10px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
  background: var(--card-solid); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  animation: rise .25s var(--ease);
}
.emoji-picker span { font-size: 21px; text-align: center; padding: 5px; border-radius: 9px; cursor: pointer; user-select: none; transition: transform .15s var(--ease), background .15s; }
.emoji-picker span:hover { background: var(--primary-soft); transform: scale(1.25); }

.conn { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 5px 14px; font-size: 12px; font-weight: 700; color: #fff; background: #f59e0b; border-radius: 99px; animation: rise .3s var(--ease); }

/* ============ Modal / toast ============ */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: #0009; backdrop-filter: blur(4px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { max-width: 380px; padding: 24px; background: var(--card-solid); }
.modal h3 { margin-bottom: 14px; font-size: 18px; }
.modal .field { margin-bottom: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { margin: 0; }
.modal-msg { margin-bottom: 12px; font-size: 14px; color: var(--muted); }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 320px; padding: 11px 16px; font-size: 13.5px; font-weight: 600; color: var(--text); background: var(--card-solid); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 12px; box-shadow: var(--shadow); animation: slide-in .35s var(--ease) both; }
.toast.error { border-left-color: #ef4444; }
.toast.out { animation: slide-out .3s forwards; }
@keyframes slide-in { from { opacity: 0; transform: translateX(30px); } }
@keyframes slide-out { to { opacity: 0; transform: translateX(30px); } }

@media (max-width: 560px) {
  .chat { height: 96vh; padding: 12px; }
  .bubble { max-width: 92%; }
  .stage { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
