:root {
  /* Sayfa zaten koyu tasarlandı: tarayıcının zorla koyu modu (avatarları bozan) uygulanmasın.
     "only": tarayıcı renkleri kendisi değiştirmesin (CSS standardı) */
  color-scheme: only dark;
  --bg: #1a1040;
  --surface: rgba(255, 255, 255, .08);
  --surface-solid: #2f2363;
  --line: rgba(255, 255, 255, .12);
  --text: #fff;
  --dim: rgba(255, 255, 255, .7);
  --accent: #facc15;
  --primary: #22c55e;   --primary-sh: #15803d;
  --blue: #6366f1;      --blue-sh: #4338ca;
  --danger: #ef4444;    --danger-sh: #b91c1c;
  --ghost: rgba(255, 255, 255, .14); --ghost-sh: rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
/* iPhone: butona hızlı art arda basınca çift dokunma sanıp yakınlaştırmasın (iki parmakla yakınlaştırma çalışır) */
button, input, select, a, .picker { touch-action: manipulation; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 1.05rem;
  background:
    radial-gradient(circle at 15% 10%, rgba(236, 72, 153, .35), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(56, 189, 248, .3), transparent 45%),
    linear-gradient(160deg, #1e1b4b, #4c1d95 60%, #6d28d9);
  background-attachment: fixed;
}
main { max-width: 640px; margin: 0 auto; padding: 24px 16px 120px; }
/* Ana menü ve quiz listesinde köşe butonları yok: alttaki 120 px boşluğa gerek yok, ekrana kaydırmasız sığsın */
body.host main:has(> .menu), body.host main:has(> .topbar) { padding-bottom: 24px; }
body.host main { max-width: 1200px; }
h1, h2, h3 { line-height: 1.2; margin: .4em 0; font-weight: 800; }
label { display: block; margin: 10px 0; font-weight: 700; }
input, select, button { font: inherit; padding: 12px 14px; border-radius: 14px; border: 2px solid transparent; width: 100%; }
input, select { background: #fff; color: #1e1b4b; }
input::placeholder { color: #8b84a8; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
label input, label select { margin-top: 6px; font-weight: 500; }

/* Oyun butonu: alttaki gölge basınca içeri gömülür */
button {
  --c: var(--blue); --sh: var(--blue-sh);
  background: var(--c); color: #fff; margin-top: 12px; cursor: pointer; font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 5px 0 var(--sh); transition: transform .08s, box-shadow .08s, filter .15s;
}
button:hover { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--sh); }
button.inline { width: auto; margin: 0; padding: 10px 18px; }
button.primary { --c: var(--primary); --sh: var(--primary-sh); }
button.secondary { --c: var(--ghost); --sh: var(--ghost-sh); }
button.danger { --c: var(--danger); --sh: var(--danger-sh); }
button:disabled { opacity: .45; cursor: default; }
.muted { color: var(--dim); }
.error { color: #fca5a5; min-height: 1.2em; margin: 6px 0 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; margin: 14px 0; backdrop-filter: blur(6px); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
/* Quiz listesi başlığı: "Yeni quiz" butonu ilk quizin butonlarından çizgiyle ayrılır */
.list-head { padding-bottom: 12px; margin-bottom: 6px; border-bottom: 2px solid var(--line); }
.row.win { color: #4ade80; font-weight: 800; }
.row.me { color: var(--accent); font-weight: 800; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.big { font-size: clamp(1.6rem, 5vw, 2.4rem); text-align: center; font-weight: 800; }
.qrow { display: flex; gap: 8px; margin: 8px 0; }
/* Soru sırası: tutamaktan sürükle */
.grip { display: flex; align-items: center; padding: 0 6px; font-size: 1.6rem; color: var(--dim); cursor: grab; touch-action: none; user-select: none; }
.grip:hover { color: var(--text); }
.qrow.dragging { opacity: .7; }
.qrow.dragging .grip { cursor: grabbing; color: var(--accent); }
.qrow.dragging input { border-color: var(--accent); }
.corner { position: fixed; right: 24px; bottom: 24px; display: flex; gap: 12px; }
.corner button { font-size: 1.2rem; padding: 14px 24px; }
.topbar { display: flex; align-items: center; gap: 14px; }
.topbar h1 { font-size: 2rem; margin: .2em 0; }

/* Ana menü */
.menu { max-width: 860px; margin: 2vh auto 0; text-align: center; }
/* Logo: kutusuz koyun, hafifçe sallanır; basınca büzülüp meler */
.logo-badge { display: inline-block; width: 96px; height: 96px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; animation: bob 3.2s ease-in-out infinite; }
.logo-badge img { display: block; width: 100%; height: 100%; pointer-events: none; filter: drop-shadow(0 6px 0 rgba(15, 10, 50, .35)); transition: transform .1s; }
.logo-badge:active { animation-play-state: paused; }
.logo-badge:active img { transform: translateY(6px) scale(.92, .86); }
@keyframes bob { 50% { transform: translateY(-6px); } }
.title { font-size: clamp(2.4rem, 7vw, 3.8rem); margin: 4px 0 2px; text-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.tag { color: var(--dim); font-size: 1.1rem; max-width: 760px; margin: 0 auto 18px; }
.tag b { color: var(--accent); }
.menu-grid { display: grid; gap: 18px; margin-top: 12px; }
.tile { display: flex; flex-direction: column; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 20px; }
.tile h2 { font-size: 1.6rem; margin: 4px 0 2px; }
.tile p { margin: 0 0 14px; }
.tile > button { margin-top: auto; }
.tile-ic { height: 88px; margin: -4px 0 4px; }
.tile-ic svg { display: block; height: 100%; width: auto; }
.big-btn { font-size: 1.2rem; padding: 14px; }
.code-input { text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; }
.code-input::placeholder { letter-spacing: .1em; color: #c4b5fd; }
.resume { text-align: left; }
@media (min-width: 720px) { .menu-grid { grid-template-columns: 1fr 1fr; } }

/* Projeksiyon */
.question { font-size: clamp(1.8rem, 4.5vw, 3.6rem); text-align: center; margin: 8vh 0 4vh; text-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.timer { font-size: clamp(1.6rem, 4vw, 3rem); font-weight: 800; color: var(--accent); }
/* Lobi: üstte logo + quiz adı; solda katılma kartı (site adı, kod, QR), sağda oyuncular kartı */
.lobby { display: grid; gap: 16px; }
.lobby-head { display: flex; align-items: center; gap: 16px; min-width: 0; padding-right: 160px; }
.lobby-head .logo-badge { width: 60px; height: 60px; flex: none; }
.head-txt { flex: 1; min-width: 0; }
.kicker { font-size: .9rem; line-height: 1.2; font-weight: 700; color: var(--dim); letter-spacing: .12em; }
/* Tek satır: sığmazsa JS (fitLobby) küçültür, en küçük boyutta da sığmazsa … ile kesilir */
.lobby-title { margin: 0; font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 1.05; text-shadow: 0 4px 0 rgba(0, 0, 0, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 24px; backdrop-filter: blur(8px); }
.join-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.join-how { margin: 0; color: var(--dim); font-size: 1.25rem; }
.join-how b { color: var(--text); }
/* Oda kodu: tek sarı kutu, harfler arasında ince çizgi */
.code-box { display: flex; background: var(--accent); border-radius: 18px; box-shadow: 0 6px 0 #ca8a04; overflow: hidden; }
.code-box span { width: 1.1em; padding: .06em 0 0; font-size: clamp(2.8rem, 5vw, 4.4rem); font-weight: 800; line-height: 1.2; color: #1e1b4b; text-align: center; }
.code-box span + span { border-left: 2px solid rgba(30, 27, 75, .2); }
.qr-box { width: 100%; margin-top: 10px; display: flex; justify-content: center; align-items: center; }
#qr { background: #fff; padding: 14px; border-radius: 20px; box-shadow: 0 8px 0 rgba(0, 0, 0, .25); line-height: 0; }
#qr img, #qr canvas { display: block; }
/* Davet linkini kopyala: arka plansız ikon + yazı */
.copy-link { width: auto; margin: 0; padding: 4px 12px; display: inline-flex; align-items: center; gap: 8px; background: none; color: var(--dim); font-size: 1rem; }
.copy-link:hover { color: var(--text); }
.copy-link, .copy-link:active:not(:disabled) { box-shadow: none; }
.players-card { display: flex; flex-direction: column; min-height: 0; }
.players-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.players-head h2 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.6rem); }
.count-pill { min-width: 2.2em; padding: 0 .5em; text-align: center; font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 800; color: #1e1b4b; background: var(--accent); border-radius: 999px; }
/* Oyuncular: satırda 4 kart, avatar üstte isim altta. Tıklayınca atma onayı; üzerine gelince kırmızı + ✕ */
.ptiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-content: start; }
.ptiles > span { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 18px;
  background: rgba(255, 255, 255, .08); font-weight: 700; font-size: 1.25rem; cursor: pointer; animation: pop .3s ease; transition: background .15s; }
.ptiles .av { width: 100px; height: 100px; max-width: 100%; }
.ptiles .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptiles .kick { position: absolute; top: 6px; right: 10px; opacity: 0; transition: opacity .15s; }
.ptiles > span:hover { background: rgba(239, 68, 68, .45); }
.ptiles > span:hover .kick { opacity: 1; }
.waiting { flex: 1; display: grid; place-items: center; align-content: center; gap: 8px; padding: 24px 0; color: var(--dim); font-size: 1.3rem; text-align: center; }
.waiting img { width: 96px; animation: bob 3.2s ease-in-out infinite; }
.ptiles[hidden], .waiting[hidden] { display: none; }
.lobby-actions { display: flex; gap: 12px; align-items: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.lobby-actions .grow { flex: 1; }
.lobby-actions button { font-size: 1.1rem; }
.lobby-actions #go { font-size: 1.4rem; padding: 14px 34px; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
.grid { display: grid; gap: 16px; }
.answers .row { font-size: 1.3rem; }
@media (min-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  /* Lobi tam ekrana sığar; sadece oyuncu listesi kayar */
  body.host main:has(> .lobby) { max-width: none; padding: 16px 40px 24px; }
  .lobby { height: calc(100dvh - 40px); grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: auto minmax(0, 1fr); }
  .lobby-head { grid-column: 1 / -1; }
  .join-card { min-height: 0; justify-content: center; }
  /* QR, site adı/kod/kopyala butonundan kalan alana sığan en büyük kare olur (boyutu JS: fitLobby) */
  .qr-box { flex: 1 1 auto; min-height: 0; }
  .ptiles { flex: 1; min-height: 0; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .3) transparent; }
}


/* Animasyonlu sıralama */
.board { --row: 48px; position: relative; height: calc(var(--row) * 10); overflow: hidden; }
.lb { position: absolute; top: 0; left: 0; right: 0; height: var(--row); display: flex; align-items: center; gap: 12px;
  padding: 0 8px; font-size: 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface-solid);
  transition: transform .8s ease, opacity .8s ease; }
.lb .rk { width: 2em; font-weight: 800; color: var(--accent); }
.lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .sc { font-weight: 800; }
.lb.up .sc::after { content: " +1"; color: #4ade80; }

/* Oyuncu: oyun sonu özeti */
.row.summary { align-items: flex-start; }
.row.summary > span:last-child { text-align: right; flex: none; max-width: 45%; overflow-wrap: anywhere; }

/* Oyuncu: odadan çık */
.leave-btn { --c: var(--ghost); --sh: var(--ghost-sh); width: auto; margin: 0; padding: 4px 12px; font-size: .85rem; box-shadow: 0 3px 0 var(--sh); }

/* Host: oyun sırasında üst satır (müzik butonunun altında kalmasın diye sağda boşluk) */
.game-head { padding-right: 160px; }
.code-mini { font-size: 1.4rem; font-weight: 800; }
.code-mini b { color: var(--accent); letter-spacing: .12em; }

/* Host: köşedeki müzik aç/kapat */
.music-btn { --c: var(--ghost); --sh: var(--ghost-sh); position: fixed; top: 16px; right: 16px; z-index: 10;
  width: 52px; height: 52px; margin: 0; padding: 12px; border-radius: 50%; }
.music-btn svg { display: block; width: 100%; height: 100%; }
.music-btn.off { opacity: .6; }

/* Avatar */
.av { display: inline-block; width: 1.8em; height: 1.8em; flex: none; vertical-align: middle; }
.av img, .picker .stage img { display: block; width: 100%; height: 100%; object-fit: contain; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.lb { cursor: pointer; }
.lb .kick { opacity: 0; transition: opacity .15s; }
.lb:hover { background: #6b2450; }
.lb:hover .kick { opacity: 1; }
.lb .av { width: 38px; height: 38px; }
/* Avatar seçici: üst oklar aksesuar, alt oklar kafa */
.picker { display: grid; grid-template-columns: 64px 1fr 64px; grid-template-rows: 1fr 1fr; gap: 10px; align-items: center; max-width: 340px; margin: 6px auto 14px; }
.picker .stage { grid-area: 1 / 2 / 3 / 3; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; aspect-ratio: 1; padding: 8px; }
.picker .arrow { margin: 0; padding: 6px 0; height: 76px; font-size: 1.5rem; line-height: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.picker .arrow small { font-size: .65rem; font-weight: 700; opacity: .85; }

/* Şıklar: A kırmızı, B mavi, C turuncu, D yeşil */
.c0 { --c: #e11d48; --sh: #9f1239; }
.c1 { --c: #2563eb; --sh: #1e40af; }
.c2 { --c: #d97706; --sh: #92400e; }
.c3 { --c: #16a34a; --sh: #166534; }
.choices { display: grid; gap: 14px; margin: 16px 0 4px; }
.choice { display: flex; align-items: center; gap: 12px; margin: 0; padding: 16px; text-align: left; font-size: 1.25rem; font-weight: 800; border-radius: 16px; overflow-wrap: anywhere; }
div.choice { background: var(--c); box-shadow: 0 5px 0 var(--sh); }
.choice b { flex: none; display: grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 10px; background: rgba(0, 0, 0, .22); }
.choices .choice.sel { outline: 4px solid #fff; outline-offset: 3px; }
.choices:has(.sel) .choice:not(.sel) { opacity: .45; }
@media (min-width: 480px) { .choices { grid-template-columns: 1fr 1fr; } }
/* Projeksiyonda büyük */
.choices.show { max-width: 1100px; margin: 0 auto; gap: 20px; }
.choices.show .choice { font-size: clamp(1.4rem, 3vw, 2.4rem); padding: 20px 24px; }

/* Quiz düzenleyici: şıklar sorunun altında */
.qrow { flex-wrap: wrap; }
.qrow > .qtext { flex: 1 1 0; width: auto; min-width: 0; }
.opts { flex-basis: 100%; min-width: 0; padding-left: 40px; }
@media (max-width: 520px) { .opts { padding-left: 0; } }
.opts:empty { display: none; }
.opt { display: flex; gap: 8px; margin: 6px 0; }
.opt input { flex: 1 1 0; width: auto; min-width: 0; padding: 8px 12px; }
.opt button { padding: 6px 14px; }
.letter { flex: none; display: grid; place-items: center; width: 40px; border-radius: 12px; background: var(--c); font-weight: 800; }

/* Host: müzik butonunun yanında dil seçimi (TR / EN) */
.lang-btn { --c: var(--ghost); --sh: var(--ghost-sh); position: fixed; top: 16px; right: 80px; z-index: 10;
  width: auto; height: 52px; margin: 0; padding: 0 14px; border-radius: 26px; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.lang-btn span { opacity: .45; }
.lang-btn span.on { opacity: 1; color: var(--accent); }

/* Oyuncu: oyun sonu özeti renkleri — sürünün cevabı mavi, senin cevabın tuttuysa yeşil, tutmadıysa kırmızı */
.herd { color: #7dd3fc; }
.ok { color: #4ade80; }
.bad { color: #f87171; }

/* Oyuncu: müzik butonu yok, dil butonu en sağda; içerik butonun altından başlar */
body:not(.host) .lang-btn { right: 16px; top: 12px; height: 40px; padding: 0 12px; font-size: .9rem; box-shadow: 0 3px 0 var(--sh); }
body:not(.host) main { padding-top: 64px; }

/* Samsung Internet: sitenin kendi karanlık teması olduğunu ancak bu kuralı görünce anlar.
   Görmezse kendi karanlık modunu uygular ve avatarları soldurur. Görünümü değiştirmez. */
@media (prefers-color-scheme: dark) {
  :root { color-scheme: only dark; }
  html { background: var(--bg); }
}
