:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-b: rgba(255, 255, 255, 0.12);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --red: #ff3b5c;
  --yellow: #ffc61a;
  --green: #1fc46a;
  --blue: #2f7cff;
  --accent: #ffc61a;
  --cw: 92px;
  --ch: calc(var(--cw) * 1.48);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Rubik', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }

#bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(47, 124, 255, .25), transparent 60%),
    radial-gradient(800px 600px at 90% 90%, rgba(255, 59, 92, .22), transparent 60%),
    radial-gradient(700px 500px at 80% 10%, rgba(255, 198, 26, .12), transparent 60%),
    var(--bg);
}
#bg::after {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ---------- ortak ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; border-radius: 14px; font-weight: 800; letter-spacing: .3px;
  transition: transform .12s, filter .15s, box-shadow .15s, opacity .15s;
  user-select: none;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }
.btn-primary { background: linear-gradient(180deg, #ffd84d, #ffb800); color: #2a1d00; box-shadow: 0 6px 0 #b77f00, 0 12px 24px rgba(255, 184, 0, .3); }
.btn-primary:active { box-shadow: 0 3px 0 #b77f00; }
.btn-red { background: linear-gradient(180deg, #ff5c78, #e8203f); color: #fff; box-shadow: 0 6px 0 #9c0f28, 0 12px 24px rgba(255, 59, 92, .3); }
.btn-blue { background: linear-gradient(180deg, #4d91ff, #1f63e0); color: #fff; box-shadow: 0 6px 0 #11408f; }
.btn-ghost { background: var(--panel); border: 1px solid var(--panel-b); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-sm { padding: 8px 14px; border-radius: 10px; font-size: 14px; }
.btn-block { width: 100%; }

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  border: 1px solid var(--panel-b);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 60px rgba(0,0,0,.35);
}
.field {
  width: 100%; padding: 15px 16px; border-radius: 14px;
  background: rgba(0,0,0,.3); border: 2px solid rgba(255,255,255,.1);
  outline: none; font-size: 17px; font-weight: 600; transition: border-color .15s;
}
.field:focus { border-color: var(--accent); }
.label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px 2px; display: block; text-transform: uppercase; letter-spacing: 1px; }
.muted { color: var(--muted); }
.hint { margin-top: 14px; font-size: 14px; }

.warn { padding: 16px 18px; border-radius: 14px; background: rgba(255,198,26,.1); border: 1px solid rgba(255,198,26,.4); color: #ffe08a; font-weight: 600; text-align: left; line-height: 1.5; }
.warn small { display: block; color: #d9c98d; font-weight: 500; margin-top: 4px; font-size: 13px; }

.loading { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); font-weight: 600; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--panel-b); border-top-color: var(--yellow); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- logo ---------- */
.logo { display: flex; align-items: center; gap: 14px; justify-content: center; }
.logo-cards { position: relative; width: 70px; height: 80px; }
.logo-cards span {
  position: absolute; left: 14px; top: 4px; width: 46px; height: 68px; border-radius: 9px;
  border: 3px solid #fff; box-shadow: 0 6px 14px rgba(0,0,0,.4);
}
.logo-cards span:nth-child(1) { background: var(--blue); transform: rotate(-22deg) translateX(-10px); }
.logo-cards span:nth-child(2) { background: var(--green); transform: rotate(-8deg) translateX(-3px); }
.logo-cards span:nth-child(3) { background: var(--red); transform: rotate(8deg) translateX(4px); display: grid; place-items: center; font-weight: 900; font-size: 30px; }
.logo-text { font-weight: 900; font-size: 46px; line-height: .9; letter-spacing: -1px; font-style: italic; }
.logo-text b { color: var(--accent); display: block; font-size: 52px; text-shadow: 0 4px 0 #b77f00; }
.logo-sm .logo-cards { transform: scale(.55); width: 40px; height: 46px; transform-origin: left top; }
.logo-sm .logo-text { font-size: 20px; }
.logo-sm .logo-text b { font-size: 22px; text-shadow: 0 2px 0 #b77f00; display: inline; }

/* ---------- ana menü ---------- */
.menu { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; overflow: hidden; }
.floaters { position: absolute; inset: 0; pointer-events: none; }
.floaters .card { position: absolute; transform: rotate(var(--r)); animation: floaty 7s ease-in-out infinite, fadeUp .8s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes floaty { 50% { transform: translateY(-18px) rotate(calc(var(--r) + 6deg)); } }
@keyframes fadeUp { from { opacity: 0; margin-top: 60px; } }
.menu-center { position: relative; z-index: 1; width: min(440px, 100%); display: flex; flex-direction: column; align-items: center; }
.menu-center .logo { margin: 8px 0 14px; transform: scale(1.25); }
.tagline { color: var(--muted); font-size: 16px; text-align: center; margin-bottom: 26px; line-height: 1.4; }
.menu-list { width: 100%; display: grid; gap: 14px; }
.menu-btn {
  position: relative; overflow: hidden; width: 100%; display: flex; align-items: center; gap: 16px;
  padding: 14px 18px; border-radius: 20px; border: 4px solid #fff; color: #fff; text-align: left;
  box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 16px 30px rgba(0,0,0,.35);
  transition: transform .15s cubic-bezier(.2,.9,.3,1.3), box-shadow .15s, filter .15s;
  animation: menuIn .5s cubic-bezier(.2,.9,.3,1.3) both;
}
.menu-btn:nth-child(2) { animation-delay: .06s; }
.menu-btn:nth-child(3) { animation-delay: .12s; }
.menu-btn:nth-child(4) { animation-delay: .18s; }
@keyframes menuIn { from { opacity: 0; transform: translateY(24px) scale(.94); } }
.menu-btn::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.09) 0 6px, transparent 6px 14px); }
.menu-btn:hover { transform: translateY(-3px) scale(1.02); filter: brightness(1.08); box-shadow: 0 9px 0 rgba(0,0,0,.35), 0 20px 36px rgba(0,0,0,.4); }
.menu-btn:active { transform: translateY(3px) scale(.99); box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 6px 12px rgba(0,0,0,.3); }
.menu-btn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.menu-btn .mi { position: relative; width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #111; font-size: 26px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.menu-btn .mt { position: relative; display: flex; flex-direction: column; min-width: 0; }
.menu-btn .mt b { font-size: 22px; font-weight: 900; font-style: italic; letter-spacing: .5px; text-shadow: 0 2px 0 rgba(0,0,0,.28); }
.menu-btn .mt small { font-size: 13px; font-weight: 500; opacity: .92; overflow-wrap: anywhere; }
.menu-btn.big { padding: 18px 20px; }
.menu-btn.big .mi { width: 60px; height: 60px; font-size: 30px; }
.menu-btn.big .mt b { font-size: 28px; }
.mb-yellow { background: linear-gradient(160deg, #ffd640, #f0a800); color: #2a1d00; }
.mb-yellow .mt b { text-shadow: 0 2px 0 rgba(255,255,255,.35); }
.mb-red { background: linear-gradient(160deg, #ff5a76, #e3183a); }
.mb-blue { background: linear-gradient(160deg, #4f93ff, #1a5bd6); }
.mb-green { background: linear-gradient(160deg, #36d67e, #0f9e50); }
.menu-foot { margin-top: 26px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- parti kur / kodla katıl ---------- */
.entry { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.entry .join-box { width: min(480px, 100%); }
.back { margin-bottom: 18px; }
.switch { display: block; width: 100%; margin-top: 16px; color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; text-decoration: underline; text-underline-offset: 3px; }
.switch:hover { color: var(--text); }

.join-box { padding: 30px; }
.join-box h2 { font-size: 24px; font-weight: 800; margin-bottom: 20px; }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 18px; }
.avatars button {
  aspect-ratio: 1; border-radius: 12px; font-size: 22px; background: rgba(0,0,0,.25);
  border: 2px solid transparent; transition: transform .1s, border-color .1s;
}
.avatars button:hover { transform: scale(1.08); }
.avatars button.sel { border-color: var(--accent); background: rgba(255,198,26,.15); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; margin: 22px 0; text-transform: uppercase; letter-spacing: 1px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--panel-b); }
.code-row { display: flex; gap: 10px; }
.code-input { text-transform: uppercase; letter-spacing: 8px; font-weight: 900; font-size: 22px; text-align: center; }
.code-input::placeholder { letter-spacing: 4px; font-weight: 600; font-size: 16px; color: rgba(255,255,255,.3); }

/* ---------- lobi ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; gap: 12px; }
.top-actions { display: flex; gap: 8px; }
.lobby { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.lobby-main { padding: 28px; }
.invite { text-align: center; padding: 10px 0 26px; border-bottom: 1px solid var(--panel-b); margin-bottom: 24px; }
.invite .label { text-align: center; }
.code-tiles { display: flex; gap: 8px; justify-content: center; margin: 10px 0 18px; }
.code-tiles span {
  width: 56px; height: 70px; display: grid; place-items: center; border-radius: 12px;
  font-size: 36px; font-weight: 900; background: #fff; color: #111;
  box-shadow: 0 5px 0 #b9bfd6, 0 10px 20px rgba(0,0,0,.3);
  animation: tileIn .5s cubic-bezier(.2,.9,.3,1.4) both;
}
.code-tiles span:nth-child(6n+1) { color: var(--red); }
.code-tiles span:nth-child(6n+2) { color: #e0a800; }
.code-tiles span:nth-child(6n+3) { color: var(--green); }
.code-tiles span:nth-child(6n+4) { color: var(--blue); }
.code-tiles span:nth-child(6n+5) { color: var(--red); }
.code-tiles span:nth-child(6n+6) { color: var(--green); }
@keyframes tileIn { from { transform: translateY(-30px) rotateX(90deg); opacity: 0; } }
.invite-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.players-head { margin-bottom: 14px; }
.players-head h3 { font-size: 18px; font-weight: 800; }
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pcard {
  position: relative; padding: 18px 12px 14px; border-radius: 16px; text-align: center;
  background: rgba(0,0,0,.25); border: 1px solid var(--panel-b);
}
.pcard.new { animation: pop .35s cubic-bezier(.2,.9,.3,1.4) both; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.pcard .av { font-size: 38px; width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, rgba(255,255,255,.15), rgba(255,255,255,.04)); }
.pcard .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .tag { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; display: inline-block; margin-top: 6px; background: rgba(255,255,255,.08); color: var(--muted); }
.pcard .tag.host { background: rgba(255,198,26,.18); color: var(--yellow); }
.pcard .kick { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px; background: rgba(255,59,92,.15); color: var(--red); font-weight: 900; }
.pcard.empty { border-style: dashed; display: grid; place-items: center; color: var(--muted); min-height: 140px; font-weight: 600; background: transparent; }
.pcard.offline { opacity: .5; }

.start-wrap { margin-top: 26px; text-align: center; }
.btn-play { font-size: 24px; padding: 20px 56px; }
.gamefile { margin-top: 14px; font-size: 14px; color: var(--muted); }

/* ---------- oyun başladı / indirme ---------- */
.dl-head { text-align: center; padding: 6px 0 14px; }
.dl-ico { font-size: 64px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
.dl-head h2 { font-size: 34px; font-weight: 900; letter-spacing: -.5px; margin: 6px 0; }
.code-mini { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 24px; color: var(--muted); font-weight: 600; flex-wrap: wrap; }
.code-mini b { font-size: 24px; letter-spacing: 6px; color: var(--text); background: rgba(0,0,0,.3); padding: 6px 14px; border-radius: 10px; border: 1px solid var(--panel-b); }
.dl-zone { text-align: center; margin: 4px 0 28px; }
.btn-dl { font-size: 24px; padding: 22px 46px; flex-direction: column; gap: 4px; animation: glow 1.8s ease-in-out infinite; max-width: 100%; }
.btn-dl small { font-size: 13px; font-weight: 600; opacity: .75; letter-spacing: 0; overflow-wrap: anywhere; }
@keyframes glow { 50% { box-shadow: 0 6px 0 #b77f00, 0 0 0 10px rgba(255,198,26,.15), 0 12px 40px rgba(255,184,0,.55); } }
.dl-note { color: var(--muted); font-size: 14px; margin-top: 16px; }
.dl-note.ok { color: #6ee7a8; font-weight: 600; }
.steps { list-style: none; display: grid; gap: 10px; margin: 0 0 24px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(0,0,0,.22); border: 1px solid var(--panel-b); font-weight: 600; }
.steps li::before { content: counter(s); width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); color: #2a1d00; font-weight: 900; }
.mini-players { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mini-players span { padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.25); border: 1px solid var(--panel-b); font-size: 14px; font-weight: 600; }

/* ---------- sohbet ---------- */
.side { display: flex; flex-direction: column; gap: 20px; }
.chatbox { padding: 18px; display: flex; flex-direction: column; min-height: 0; }
.chatbox h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 160px; max-height: 360px; padding-right: 4px; }
.chat-list .msg { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.chat-list .msg b { color: var(--yellow); }
.chat-list .sys { font-size: 12.5px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid var(--panel-b); outline: none; min-width: 0; }

/* ---------- süs kartları (ana sayfa) ---------- */
.card {
  --c: #333;
  --ch: calc(var(--cw) * 1.48);
  width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .13);
  background: #fff; padding: calc(var(--cw) * .06);
  box-shadow: 0 2px 0 rgba(0,0,0,.15), 0 8px 18px rgba(0,0,0,.35);
  position: relative; flex-shrink: 0; user-select: none;
}
.card .face {
  position: absolute; inset: calc(var(--cw) * .06); border-radius: calc(var(--cw) * .09);
  background: var(--c); overflow: hidden;
}
.card .face::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 6px, transparent 6px 14px);
}
.card .face::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 76%; height: 58%;
  transform: translate(-50%, -50%);
  border: calc(var(--cw) * .035) solid rgba(255,255,255,.9); border-radius: 50% 10% 50% 10%;
}
.card .big {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 900; color: #fff; font-size: calc(var(--cw) * .5); line-height: 1;
  text-shadow: calc(var(--cw) * -.02) calc(var(--cw) * .03) 0 rgba(0,0,0,.35);
  z-index: 1; font-style: italic;
}
.card .big.sym { font-size: calc(var(--cw) * .42); font-style: normal; }
.card .corner {
  position: absolute; z-index: 2; color: #fff; font-weight: 900; font-size: calc(var(--cw) * .17); line-height: 1;
  text-shadow: 0 1px 0 rgba(0,0,0,.35); font-style: italic;
}
.card .corner.tl { top: calc(var(--cw) * .1); left: calc(var(--cw) * .11); }
.card .corner.br { bottom: calc(var(--cw) * .1); right: calc(var(--cw) * .11); transform: rotate(180deg); }
.card.red { --c: linear-gradient(160deg, #ff5a76, #e3183a); }
.card.yellow { --c: linear-gradient(160deg, #ffd640, #f0a800); }
.card.green { --c: linear-gradient(160deg, #36d67e, #0f9e50); }
.card.blue { --c: linear-gradient(160deg, #4f93ff, #1a5bd6); }
.card.wild { --c: #161616; }
.card.wild .face::after { display: none; }
.wheel {
  position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 50%; border: calc(var(--cw) * .035) solid #fff;
  background: conic-gradient(var(--red) 0 25%, var(--blue) 0 50%, var(--yellow) 0 75%, var(--green) 0);
  box-shadow: 0 4px 10px rgba(0,0,0,.5);
}
.card.wild .big { font-size: calc(var(--cw) * .3); font-style: italic; }

/* ---------- pencere ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2,4,12,.7); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { padding: 28px; max-width: 520px; width: 100%; text-align: center; animation: pop .3s cubic-bezier(.2,.9,.3,1.3); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 26px; font-weight: 900; margin-bottom: 6px; }
.rules { text-align: left; font-size: 14px; line-height: 1.6; color: #cfd5ef; }
.rules li { margin: 0 0 8px 18px; }

/* ---------- bildirimler ---------- */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1d2547; border: 1px solid var(--panel-b); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toast 3s ease forwards; }
.toast.err { background: #4a1020; border-color: rgba(255,59,92,.5); }
.toast.ok { background: #0f3a26; border-color: rgba(31,196,106,.5); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-20px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- mobil ---------- */
@media (max-width: 980px) {
  .lobby { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .floaters .card { opacity: .35; }
  .menu-center .logo { transform: scale(1.1); }
  .menu-btn .mt b { font-size: 19px; }
  .menu-btn.big .mt b { font-size: 24px; }
  .join-box { padding: 20px; }
  .avatars { gap: 5px; }
  .avatars button { font-size: 17px; border-radius: 9px; }
  .code-tiles span { width: 42px; height: 54px; font-size: 26px; }
  .lobby { padding: 0 12px 30px; }
  .lobby-main { padding: 18px; }
  .topbar { padding: 12px 14px; }
  .top-actions .btn { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  .btn-play { padding: 18px 36px; }
  .btn-dl { padding: 18px 28px; font-size: 20px; }
  .dl-head h2 { font-size: 28px; }
}
