:root {
  --red: #ff5a6e; --blue: #3fa9ff; --ink: #2a1f3d; --card: rgba(30, 18, 58, .82);
  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #140b2b; color: #fff; font-family: var(--font); }
body {
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(255, 90, 110, .28), transparent 60%),
    radial-gradient(900px 500px at 90% 90%, rgba(63, 169, 255, .28), transparent 60%),
    linear-gradient(160deg, #241247, #140b2b);
}
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.screen.active { display: flex; }
#game { padding: 0; background: #0c0620; }
#game canvas { display: block; max-width: 100vw; max-height: 100vh; }
#game canvas.hidden { display: none; }

.card {
  width: min(480px, 100%); background: var(--card); backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, .14); border-radius: 28px; padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 0 60px rgba(120, 80, 255, .18);
}
.card.wide { width: min(780px, 100%); }
h1 { margin: 0 0 6px; font-size: 54px; font-weight: 900; letter-spacing: -1px; text-align: center; text-shadow: 0 4px 0 var(--ink), 0 0 30px rgba(255, 255, 255, .15); }
h1 .r { color: var(--red); } h1 .b { color: var(--blue); }
h2 { margin: 0 0 6px; font-size: 40px; text-align: center; font-weight: 900; }
.tag { text-align: center; opacity: .8; margin: 0 0 22px; line-height: 1.5; }
.lbl { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .65; margin-bottom: 6px; }
input {
  width: 100%; padding: 13px 16px; border-radius: 16px; border: 2px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08); color: #fff; font: 700 17px var(--font); outline: none;
}
input:focus { border-color: #ffe14d; box-shadow: 0 0 0 4px rgba(255, 225, 77, .18); }
input.code { text-align: center; letter-spacing: .3em; text-transform: uppercase; font-weight: 900; font-size: 20px; }
.row { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.row.end { justify-content: space-between; margin-top: 22px; }
.or { text-align: center; opacity: .5; margin: 16px 0 0; font-size: 13px; font-weight: 700; }

.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 16px; padding: 13px 20px; color: #2a1f3d; font: 900 16px var(--font);
  background: #ffe14d; box-shadow: 0 5px 0 #c9a21a, 0 8px 24px rgba(255, 225, 77, .25); transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9a21a; }
.btn.big { width: 100%; font-size: 19px; padding: 16px; }
.row.end .btn.big { width: auto; padding: 16px 34px; }
.btn.small { padding: 9px 14px; font-size: 14px; border-radius: 12px; box-shadow: 0 3px 0 #c9a21a; }
.btn.ghost { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.msg { min-height: 22px; margin: 12px 0 0; font-weight: 700; color: #ffb3bd; font-size: 14px; }
.help { margin-top: 18px; opacity: .9; font-size: 14px; }
.help summary { cursor: pointer; font-weight: 800; }
.help ul { padding-left: 18px; line-height: 1.55; }

.lobbyTop { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 10px; flex-wrap: wrap; }
.lobbyBtns { display: flex; gap: 8px; }
.roomCode { font-size: 46px; font-weight: 900; letter-spacing: .22em; line-height: 1; color: #ffe14d; text-shadow: 0 3px 0 var(--ink); }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.vs { font-weight: 900; opacity: .5; }
.team { border-radius: 20px; padding: 14px; border: 2px solid; }
.team.t0 { border-color: rgba(255, 90, 110, .6); background: rgba(255, 90, 110, .12); }
.team.t1 { border-color: rgba(63, 169, 255, .6); background: rgba(63, 169, 255, .12); }
.team h3 { margin: 0 0 10px; font-size: 15px; }
.t0 h3 { color: var(--red); } .t1 h3 { color: var(--blue); }
.slot {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; margin-bottom: 8px;
  background: rgba(0, 0, 0, .25); font-weight: 800; min-height: 46px; border: 2px solid transparent;
}
.slot.free { opacity: .6; cursor: pointer; border-style: dashed; border-color: rgba(255, 255, 255, .25); font-weight: 700; }
.slot.free:hover { opacity: 1; }
.slot.me { border-color: #ffe14d; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.t0 .dot { background: var(--red); } .t1 .dot { background: var(--blue); }
.tagHost { margin-left: auto; font-size: 11px; background: #ffe14d; color: var(--ink); padding: 2px 8px; border-radius: 99px; }

.settings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 22px; }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt {
  padding: 9px 12px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .15); background: rgba(255, 255, 255, .06);
  font: 800 14px var(--font); color: #fff; cursor: pointer; text-align: left;
}
.opt.on { background: #ffe14d; color: var(--ink); border-color: #ffe14d; }
.opt[disabled] { cursor: default; }
.opt:not(.on)[disabled] { opacity: .5; }
.desc { font-size: 12.5px; opacity: .7; margin-top: 8px; line-height: 1.4; min-height: 34px; }

.leaveBtn { position: absolute; top: 12px; right: 12px; z-index: 5; }
#pingbox { position: absolute; left: 12px; top: 12px; font-size: 12px; font-weight: 800; opacity: .7; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 4, 30, .55); backdrop-filter: blur(4px); z-index: 4; }
.hidden { display: none !important; }
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; transition: .3s; z-index: 20;
  background: rgba(30, 18, 58, .95); border: 2px solid rgba(255, 255, 255, .2); padding: 12px 20px; border-radius: 16px; font-weight: 800; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  h1 { font-size: 40px; }
  .teams { grid-template-columns: 1fr; } .vs { display: none; }
  .settings { grid-template-columns: 1fr; }
  .roomCode { font-size: 34px; }
}

/* ---------- 3D oyun ---------- */
#cv3 { display: block; width: 100vw; height: 100vh; }
.dimSel { display: flex; gap: 8px; margin-top: 14px; }
.dimSel .opt { flex: 1; text-align: center; padding: 11px; font-size: 16px; }
.hud3d { position: absolute; inset: 0; pointer-events: none; font-family: var(--font); }
.sb3 {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); min-width: 300px; padding: 8px 22px 10px; border-radius: 24px;
  background: rgba(24, 14, 48, .55); border: 2px solid rgba(255, 255, 255, .18); text-align: center; backdrop-filter: blur(6px);
}
.sb3 .n { font-size: 46px; font-weight: 900; -webkit-text-stroke: 6px #2a1f3d; paint-order: stroke fill; display: inline-block; min-width: 60px; }
.sb3 .n0 { color: #ff5a6e; } .sb3 .n1 { color: #3fa9ff; }
.sb3 .col { font-size: 40px; font-weight: 900; margin: 0 14px; }
.sb3 .pips { display: flex; justify-content: space-between; margin: -4px 20px 4px; }
.sb3 .p { display: flex; gap: 5px; }
.sb3 .p i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .18); border: 1.5px solid rgba(255, 255, 255, .35); }
.sb3 .p0 i.on { background: #ff5a6e; border-color: #fff; } .sb3 .p1 i.on { background: #3fa9ff; border-color: #fff; }
.sb3 .info { font-size: 13px; font-weight: 700; opacity: .75; }
.hud3d .ctr {
  position: absolute; top: 24%; left: 0; right: 0; text-align: center; font-size: 40px; font-weight: 900; opacity: 0;
  -webkit-text-stroke: 8px #2a1f3d; paint-order: stroke fill;
}
.hud3d .ctr.big { font-size: 64px; }
.hud3d .ctr.pop { animation: pop3 1.6s ease-out forwards; }
@keyframes pop3 { 0% { opacity: 0; transform: scale(1.6); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.hud3d .hint3 { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-weight: 700; font-size: 15px; transition: opacity 1.2s; text-shadow: 0 2px 6px #000; }
.hud3d .ballArrow { display: none; position: absolute; top: 4px; width: 0; height: 0; margin-left: -12px; border-left: 12px solid transparent; border-right: 12px solid transparent; border-bottom: 20px solid #ffe14d; filter: drop-shadow(0 2px 0 #2a1f3d); }
