:root {
  --bg: #1b1530;
  --panel: #2a2147;
  --panel-2: #372b5c;
  --text: #f6f1ff;
  --muted: #a99cc9;
  --accent: #ffcc33;
  --good: #3ddc84;
  --bad: #ff5a6e;
  --table: #7a4b2a;
  --table-rim: #5a3418;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, #3a2b6b 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 12px; padding: 10px 16px; background: var(--panel-2);
  cursor: pointer; transition: transform .08s;
}
button:active { transform: scale(.96); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #2a1a00; font-weight: 700; }
button.small { padding: 6px 10px; font-size: 14px; }
input, select {
  background: var(--bg); border: 2px solid var(--panel-2); border-radius: 10px; padding: 8px 10px; width: 100%;
}
label { display: block; color: var(--muted); font-size: 14px; margin: 6px 0; }
label input, label select { margin-top: 4px; color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; margin: 0; }
h2 { margin: 0 0 8px; font-size: 18px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; text-align: center; margin: 4px 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row.between { justify-content: space-between; }
.row.between > * { flex: 0 0 auto; }

/* ---- Giriş ---- */
#home { max-width: 460px; margin: 0 auto; padding: 20px 16px 40px; }
.logo { font-family: "Bangers", "Impact", "Arial Black", sans-serif; font-weight: 400; font-size: clamp(34px, 10vw, 50px); line-height: 1;
  margin: 12px 0 6px; text-align: center; letter-spacing: 1px; color: #fff;
  text-shadow: -2px -2px 0 #1d163a, 2px -2px 0 #1d163a, -2px 2px 0 #1d163a, 2px 2px 0 #1d163a, 0 4px 0 #1d163a; }
.logo span { color: #ffcb2e; }
.tag { text-align: center; color: var(--muted); margin-top: 0; }
.card { background: var(--panel); border-radius: 18px; padding: 14px; margin: 12px 0; }
.card button.primary { width: 100%; margin-top: 10px; }
.chars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; max-height: 240px; overflow-y: auto; }
.chars button { font-size: 24px; padding: 6px 0 4px; border: 3px solid transparent; display: grid; }
.chars button small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chars button.on { border-color: var(--accent); background: var(--panel-2); }
.code-input { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }
.room-list { list-style: none; margin: 0; padding: 0; }
.room-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--panel-2); }
.room-list li:first-child { border-top: 0; }

/* ---- Oda ---- */
#room { display: flex; flex-direction: column; height: 100%; max-width: 1000px; margin: 0 auto; padding: 8px 12px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.code-chip { font-weight: 800; letter-spacing: 3px; background: var(--panel); }
.phase { flex: 1; text-align: center; font-weight: 700; }
.net { color: var(--muted); font-size: 12px; text-align: right; }

.question { background: var(--panel); border-radius: 16px; padding: 10px 12px; margin: 8px 0; }
.q-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.timer { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 6px 0; }
#timerBar { height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
#qText { font-size: 20px; font-weight: 700; margin: 6px 0 10px; min-height: 1.4em; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.options button { min-height: 52px; font-weight: 600; background: var(--panel-2); border: 3px solid transparent; }
.options button.picked { border-color: var(--accent); }
.options button.correct { background: var(--good); color: #062; }
.options button.wrong { background: var(--bad); }

.stage { position: relative; flex: 1; min-height: 300px; }
.table {
  position: absolute; left: 50%; top: 50%; width: 46%; aspect-ratio: 1; transform: translate(-50%, -50%);
  max-height: 60%; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #9a6a42, var(--table) 60%);
  box-shadow: 0 0 0 10px var(--table-rim), 0 18px 30px #0008;
  display: grid; place-items: center;
}
@media (max-aspect-ratio: 1/1) { .table { width: auto; height: 42%; } }
.table-center { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 80%; font-size: 15px; text-align: center; }
.weapon {
  font-size: 34px; width: 64px; height: 64px; border-radius: 16px; background: #0003; display: grid; place-items: center;
  border: 3px solid transparent;
}
.weapon.on { border-color: var(--accent); background: #fff3; }
.weapons { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; width: 100%; }
.weapons .weapon { width: auto; height: auto; font-size: 26px; padding: 4px 2px; }
.weapon small { display: block; font-size: 10px; line-height: 1.1; color: var(--muted); }
.weapon.pickable { animation: bob 1s ease-in-out infinite; }

.seat {
  position: absolute; width: 90px; transform: translate(-50%, -50%); text-align: center; transition: opacity .3s;
}
.avatar {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; font-size: 40px; display: grid; place-items: center;
  background: var(--panel); box-shadow: 0 0 0 4px var(--ring, #888); position: relative;
}
.seat .name { font-size: 13px; font-weight: 700; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .badge { position: absolute; top: -10px; right: -12px; font-size: 18px; }
.seat .lives { font-size: 12px; color: var(--bad); min-height: 1.2em; letter-spacing: 1px; }
.seat .shield.ready { opacity: .45; }
.seat.shielded .avatar { box-shadow: 0 0 0 4px var(--ring), 0 0 0 9px #7fd3ff; }
.seat.ready .avatar::after { content: "✓"; position: absolute; bottom: -6px; right: -6px; background: var(--good); color: #062; border-radius: 50%; width: 22px; height: 22px; font-size: 14px; display: grid; place-items: center; font-weight: 900; }
.seat.answered .avatar { box-shadow: 0 0 0 4px var(--ring), 0 0 0 8px #fff6; }
.seat.ghost { opacity: .45; }
.seat.ghost .avatar { filter: grayscale(1); }
.seat.offline { opacity: .3; }
.seat.target-able { cursor: pointer; }
.seat.target-able .avatar { animation: pulse .8s ease-in-out infinite; }
.seat.me .name { color: var(--accent); }
.seat .bubble {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #fff; color: #222; border-radius: 12px;
  padding: 4px 8px; font-size: 14px; white-space: nowrap; animation: pop 2.2s forwards; pointer-events: none;
}
.seat .bubble.big { font-size: 30px; padding: 2px 8px; }

.falling .avatar { animation: fall 1.6s cubic-bezier(.3,.1,.6,1) forwards; }
.hit-shake .avatar { animation: shake .3s; }

.projectile { position: absolute; font-size: 40px; transform: translate(-50%, -50%); pointer-events: none; z-index: 5; }
.onomato {
  position: absolute; transform: translate(-50%, -50%) rotate(-8deg); font-size: 40px; font-weight: 900; color: var(--accent);
  -webkit-text-stroke: 2px #2a1a00; z-index: 6; animation: boom 1.2s forwards; pointer-events: none;
}

.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8; text-align: center;
  background: var(--accent); color: #2a1a00; font-weight: 900; font-size: 26px; padding: 14px 22px; border-radius: 18px;
  box-shadow: 0 10px 30px #0009; animation: slam .35s ease-out; max-width: 90%; pointer-events: none;
}
.banner small { display: block; font-size: 15px; font-weight: 700; }
.banner.big { font-size: 64px; padding: 6px 30px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 6px 0; min-height: 48px; }
.controls .stars button { font-size: 22px; padding: 4px 6px; background: none; }
.ranking { margin: 0; padding-left: 22px; text-align: left; }

.social { display: flex; flex-direction: column; gap: 4px; padding-bottom: env(safe-area-inset-bottom); }
.emoji-bar { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.emoji-extra { display: flex; gap: 4px; justify-content: center; flex-basis: 100%; }
.emoji-bar button { flex: 1 1 0; min-width: 0; max-width: 52px; font-size: 20px; padding: 4px 0; background: var(--panel); }
.hint { font-weight: 700; color: var(--accent); }
details { text-align: center; color: var(--muted); font-size: 14px; }
.quick-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.quick-list button { font-size: 13px; padding: 6px 10px; }

/* Yatay telefon: solda soru ve kontroller, sağda masa. */
@media (orientation: landscape) and (max-height: 600px) {
  #room {
    display: grid; gap: 0 14px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "top top" "q stage" "ctl stage" "soc stage" "err stage";
  }
  .topbar { grid-area: top; }
  .question { grid-area: q; align-self: start; margin: 4px 0; }
  .stage { grid-area: stage; min-height: 0; }
  .controls { grid-area: ctl; }
  .social { grid-area: soc; }
  #roomError { grid-area: err; }
  #qText { font-size: 17px; margin: 4px 0 6px; }
  .options button { min-height: 42px; }
  .avatar { width: 48px; height: 48px; font-size: 30px; }
  .seat .name { margin-top: 2px; }
  .table { max-height: 58%; }
}

@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--ring), 0 0 0 10px var(--bad); } }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 6px); } 10%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-6px) rotate(-8deg); } 75% { transform: translateX(6px) rotate(8deg); } }
@keyframes fall {
  0% { transform: rotate(0); }
  15% { transform: translateY(-20px) rotate(-30deg) scale(1.1, .9); }
  45% { transform: translateY(-34px) rotate(200deg); }
  80% { transform: translateY(26px) rotate(340deg) scale(1.15, .7); }
  100% { transform: translateY(22px) rotate(360deg) scale(1.2, .6); }
}
@keyframes boom { 0% { transform: translate(-50%, -50%) scale(.2) rotate(-8deg); } 20% { transform: translate(-50%, -50%) scale(1.3) rotate(-8deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1) rotate(-8deg); } }
@keyframes slam { 0% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .falling .avatar, .weapon.pickable, .seat.target-able .avatar { animation-duration: .01s; }
}

/* Kalıcı profil (K52) */
.profile { margin: 6px 0 0; font-size: 14px; color: var(--muted, #c9c0ea); }
.xpbar { display: block; height: 6px; margin-top: 4px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.xpbar > span { display: block; height: 100%; background: #ffcb2e; }
.ranking .xp { color: #ffcb2e; margin-left: 6px; }
