:root {
  --bg: #f4f1ff;
  --card: #fff;
  --ink: #23194a;
  --muted: #6f6890;
  --line: #e5e0f7;
  --pri: #6c3cf0;
  --pri2: #8f6bff;
  --ok: #10a36a;
  --bad: #e2554f;
  --warn: #f2a516;
  --r: 16px;
  --sh: 0 6px 24px rgba(52, 30, 120, .09);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: env(safe-area-inset-bottom); background: radial-gradient(1200px 600px at 10% -10%, #e2d9ff, transparent), var(--bg); min-height: 100vh; }
[hidden] { display: none !important; }
a { color: var(--pri); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
.muted { color: var(--muted); }
.center { text-align: center; }
small { color: var(--muted); }

/* üst bar */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 12px; }
.logo { font-size: 1.35rem; text-decoration: none; color: var(--ink); font-weight: 600; }
.logo b { color: var(--pri); }
.ear { display: inline-block; animation: wig 3s ease-in-out infinite; }
@keyframes wig { 0%, 90%, 100% { transform: rotate(0) } 94% { transform: rotate(-14deg) } 97% { transform: rotate(10deg) } }
.top-right { display: flex; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; cursor: pointer; color: var(--ink); white-space: nowrap; }
.chip.warn { border-color: var(--warn); background: #fff7e6; }
.chip.ghost { cursor: default; }

/* düğmeler & formlar */
.btn { border: 0; border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 700; cursor: pointer; background: #ece7ff; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff; box-shadow: 0 4px 14px rgba(108, 60, 240, .3); }
.btn.big { font-size: 1.15rem; padding: 14px 26px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.danger { color: var(--bad) !important; }
.mini { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 9px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--ink); }
.mini.playing { background: #ffe9a8; }
.big-play.playing { animation: pulse 1s infinite; }
label { display: block; font-weight: 700; font-size: .9rem; margin: 0 0 12px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fbfaff; color: var(--ink); margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri2); background: #fff; }
input[type=checkbox] { width: auto; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg { margin-top: 10px; min-height: 1.2em; color: var(--muted); }

/* ana sayfa */
.home { max-width: 1150px; margin: 0 auto; padding: 8px 20px 40px; }
.hero { text-align: center; padding: 18px 0 26px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
.hero p { max-width: 640px; margin: 0 auto; color: var(--muted); font-size: 1.05rem; }
.hl { background: linear-gradient(120deg, #ffd166 0 100%) no-repeat 0 85%/100% 35%; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--sh); }
.card h2 { font-size: 1.1rem; display: flex; justify-content: space-between; align-items: center; }
.join-row { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.code-in { width: 130px; text-transform: uppercase; letter-spacing: 3px; font-weight: 800; margin: 0; }
.room-list, .leader { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow: auto; }
.room-list a { display: flex; justify-content: space-between; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.room-list a:hover { background: #f3efff; }
.leader { counter-reset: l; }
.leader li { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid var(--line); counter-increment: l; }
.leader li span::before { content: counter(l) ". "; color: var(--muted); }
.leader li.me { background: #fff7e0; }
.leader li.muted::before, .leader li.muted span::before { content: none; }
.rules { margin-top: 16px; }
.rules li { margin: 6px 0; }
.voice-box p { margin: 6px 0 10px; }
.warn-txt { color: #a86b00; }

/* oda */
.room { display: grid; grid-template-columns: 250px 1fr 280px; gap: 14px; padding: 0 14px 14px; height: calc(100vh - 62px); }
.panel { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 14px; overflow: auto; }
.players-panel { display: flex; flex-direction: column; gap: 10px; }
.room-name { font-weight: 800; font-size: 1.1rem; }
.room-code b { letter-spacing: 2px; color: var(--pri); }
.share { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.players { list-style: none; padding: 0; margin: 0; flex: 1; }
.players li { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 10px; }
.players li.me { background: #f6f3ff; }
.players li.cur { background: #fff3cf; box-shadow: inset 3px 0 0 var(--warn); }
.players li.off { opacity: .45; }
.pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc { min-width: 30px; text-align: right; }
.kick { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0 2px; }
.kick:hover { color: var(--bad); }
.av { --c: #999; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--c); color: #fff; display: inline-grid; place-items: center; font-weight: 800; box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.av.done { opacity: .5; }
.av.now { outline: 3px solid var(--warn); outline-offset: 2px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.1) } }
.round-info { font-weight: 800; color: var(--pri); }

.stage { display: flex; flex-direction: column; gap: 14px; }
.timer { position: relative; height: 26px; background: #f0ecff; border-radius: 999px; overflow: hidden; flex: none; }
.timer-bar { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--pri2), var(--pri)); transition: width .25s linear; }
.timer.low .timer-bar { background: linear-gradient(90deg, #ff9a7a, var(--bad)); }
.timer span { position: relative; display: block; text-align: center; font-weight: 800; line-height: 26px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.turn { text-align: center; padding: 24px 10px; }
.me-turn { background: #fffaf0; border: 2px dashed var(--warn); border-radius: var(--r); }
.write { max-width: 560px; margin: 16px auto 0; text-align: left; }
.write textarea { font-size: 1.2rem; resize: none; }
.write .row { justify-content: space-between; margin-top: 8px; }
.big-play { font: inherit; font-size: 1.4rem; font-weight: 800; border: 0; border-radius: 999px; padding: 18px 34px; background: linear-gradient(135deg, #ffb347, #ff7b54); color: #fff; cursor: pointer; box-shadow: 0 6px 18px rgba(255, 123, 84, .35); }
.big-play small { color: #fff; opacity: .85; }
.big-play:disabled { filter: grayscale(1); opacity: .5; cursor: not-allowed; }
.hint-box { background: #fff0ef; border-radius: 12px; padding: 12px; display: inline-block; letter-spacing: 1px; }
.spinner { width: 42px; height: 42px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid #e7e0ff; border-top-color: var(--pri); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

.lobby .settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 4px 14px; }
.pw-set .row { flex-wrap: nowrap; }
.pw-set input { margin: 0; }
.banner { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: #fff4dc; flex-direction: column; align-items: stretch; }
.banner.ok { background: #e9f9f1; display: block; line-height: 2; }
.banner.info { background: #eef1ff; display: block; line-height: 1.6; }
.banner.ok .mini, .banner.info .btn { margin-left: 6px; }
.banner.info .btn { margin-top: 8px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.choice, .stock-pick { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stock-pick select { width: auto; margin: 0; padding: 6px 8px; }
.mine { color: var(--pri); font-weight: 600; }
.lobby-live { text-align: center; padding: 10px; border-top: 1px dashed var(--line); }
.history { padding-left: 18px; }
.history li { margin: 4px 0; }

.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; padding: 6px; }
.chain .link { color: var(--muted); font-weight: 800; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #faf8ff; border: 1px solid var(--line); transition: background .2s; }
.steps li.hl { background: #fff3cf; border-color: var(--warn); }
.st { flex: 1; min-width: 0; }
.st p { margin: 2px 0 0; font-size: 1.05rem; word-wrap: break-word; }
.st-act { display: flex; gap: 6px; align-items: center; }
.pts { color: var(--ok); min-width: 38px; text-align: right; }

.result h2, .finished h2 { text-align: center; }
.compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-bottom: 12px; }
.cmp { background: #f6f3ff; border-radius: 14px; padding: 14px; text-align: center; }
.cmp.final { background: #fff6e2; }
.cmp p { font-size: 1.25rem; font-weight: 700; margin: 6px 0 8px; }
.arrow { font-size: 1.6rem; color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.lost { color: var(--bad); text-decoration: line-through; opacity: .7; }
.surv { position: relative; height: 22px; background: #f0ecff; border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.surv div { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #6fe3b4, var(--ok)); }
.surv span { position: relative; display: block; text-align: center; font-weight: 800; line-height: 22px; font-size: .85rem; }
.result > .row { justify-content: center; margin-bottom: 14px; }
.finished { text-align: center; margin-bottom: 18px; }
.podium { list-style: none; padding: 0; margin: 0 auto 14px; max-width: 360px; }
.podium li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; font-size: 1.05rem; }
.podium li:first-child { background: #fff3cf; font-size: 1.25rem; }
.podium li span:not(.av) { flex: 1; text-align: left; }
.finished .row { justify-content: center; }

.chat-panel { display: flex; flex-direction: column; }
.chat-panel h3 { font-size: 1rem; }
.chat { list-style: none; padding: 0; margin: 0; flex: 1; overflow: auto; font-size: .93rem; }
.chat li { padding: 3px 0; word-wrap: break-word; }
.chat li.sys { color: var(--muted); font-style: italic; font-size: .85rem; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { margin: 0; }
.gone { max-width: 480px; margin: 40px auto; text-align: center; grid-column: 1 / -1; }

/* diyaloglar */
.dlg { border: 0; border-radius: 20px; padding: 22px; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(30, 10, 90, .3); color: var(--ink); }
.dlg::backdrop { background: rgba(35, 25, 74, .45); backdrop-filter: blur(2px); }
.dlg-x { position: absolute; right: 14px; top: 12px; }
.dlg-x button { border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
blockquote { margin: 12px 0; padding: 14px 16px; background: #f6f3ff; border-left: 4px solid var(--pri); border-radius: 10px; font-size: 1.1rem; line-height: 1.5; }
.rec { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.rec-btn.on { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
.meter { flex: 1; height: 10px; background: #eee9ff; border-radius: 999px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn), var(--bad)); transition: width .08s; }
.rec-time { font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }
#recPreview, .test-out audio { width: 100%; margin: 6px 0; }
.test-out { margin-top: 10px; display: grid; gap: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 99; box-shadow: var(--sh); max-width: 90vw; }

@media (max-width: 980px) {
  .room { grid-template-columns: 1fr; height: auto; padding: 0 8px 10px; gap: 10px; }
  .panel { padding: 12px; }
  /* Mobil: oda başlığı + oyuncular üstte yatay şerit, sonra sahne, en altta sohbet. */
  .players-panel { order: 0; gap: 8px; }
  .room-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .room-name { font-size: 1rem; }
  .share { margin: 0 0 0 auto; }
  .players { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .players li { flex: none; background: #f6f3ff; padding: 5px 10px 5px 5px; gap: 6px; }
  .players li.cur { box-shadow: inset 0 0 0 2px var(--warn); }
  .players .av { width: 28px; height: 28px; }
  .players .pn { max-width: 110px; }
  .players small { display: none; }
  /* Tur bilgisi ve çıkış aynı satırda */
  .players-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .room-head, .players { grid-column: 1 / -1; }
  .stage { order: 1; min-height: 55vh; }
  .chat-panel { order: 2; height: 280px; }
  .compare { grid-template-columns: 1fr; }
  .arrow { transform: rotate(90deg); text-align: center; }
  .lobby .settings { grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .lobby .settings .check, .lobby .settings .pw-set { grid-column: 1 / -1; }
  .turn { padding: 16px 6px; }
  .me-turn { padding: 16px 12px; }
  .steps li { flex-wrap: wrap; row-gap: 4px; }
  .st { flex: 1 1 calc(100% - 50px); }
  .st-act { width: 100%; justify-content: flex-end; }
}
@media (max-width: 600px) {
  .top { padding: 10px 12px; }
  .logo { font-size: 1.1rem; }
  #meName { display: none !important; }
  .home { padding: 4px 12px 30px; }
  .hero { padding: 8px 0 16px; }
  .hero p { font-size: .98rem; }
  .card { padding: 16px; }
  .big-play { font-size: 1.2rem; padding: 16px 26px; }
  .cmp p { font-size: 1.1rem; }
  .dlg { padding: 18px; }
  .rec { flex-wrap: wrap; }
  .row .btn { flex: 1 1 auto; justify-content: center; }
}
