:root {
  --bg: #0b2a20;
  --felt: #14634a;
  --felt-dark: #0d4634;
  --ink: #16202a;
  --ivory: #f6f0dc;
  --ivory-edge: #b9ad8a;
  --gold: #f2c14e;
  --gold-dim: #c99a2e;
  --wood: #5a3b21;
  --wood-light: #7a5230;
  --green: #35d07f;
  --red: #ff6b6b;
  --text: #eef5f0;
  --muted: #9bb8aa;
  --panel: rgba(0, 0, 0, .32);
  --display-font: "Fraunces", ui-serif, Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(ellipse at top, #12503d 0%, var(--bg) 70%);
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }
button, input { font: inherit; }

/* ---------- ortak ---------- */
.view { height: 100%; }
.center-view { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; overflow: auto; }
.card {
  background: linear-gradient(180deg, rgba(20,30,25,.55), rgba(0,0,0,.4));
  border: 1px solid rgba(255,255,255,.1);
  border-top: 2px solid var(--wood-light);
  border-radius: 20px;
  padding: 28px;
  width: min(440px, 100%);
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.65), 0 0 0 1px rgba(0,0,0,.2);
  position: relative;
  z-index: 1;
}
h1 { margin: 0 0 4px; font-size: 34px; }
h2 { margin: 0 0 10px; }
h3 { margin: 20px 0 10px; font-size: 15px; font-weight: 600; color: var(--text); }
.sub { color: var(--muted); margin: 0 0 18px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.35); color: var(--text); font-size: 17px; transition: border-color .15s, background .15s; }
input:focus { outline: none; border-color: var(--gold); background: rgba(0,0,0,.45); }
.row { display: flex; gap: 8px; }
.btn { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); color: var(--text); padding: 11px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; transition: background .15s, transform .1s, filter .15s; }
.btn:hover { background: rgba(255,255,255,.16); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: #2a2100; border-color: transparent; box-shadow: 0 8px 24px -8px rgba(242,193,78,.55); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; padding: 15px; font-size: 17px; margin-top: 4px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; padding: 8px 0; font-weight: 400; }
.btn.link:hover { color: var(--text); }
.or { text-align: center; color: var(--muted); margin: 14px 0; font-size: 13px; position: relative; }
.hint { color: var(--muted); font-size: 13px; }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .18em; background: rgba(0,0,0,.4); padding: 2px 10px; border-radius: 8px; color: var(--gold); }

/* ---------- ana ekran: kimlik ---------- */
.home-card { text-align: center; }
.wordmark {
  font-family: var(--display-font);
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -.01em;
  margin: 4px 0 2px;
  color: var(--ivory);
  text-shadow: 0 2px 20px rgba(242,193,78,.25);
}
.tagline { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; }
.home-card label { text-align: left; }
.home-card .row { text-align: left; }

.hero-tiles {
  position: relative;
  flex: none;
  width: min(420px, 90vw); height: 90px;
  pointer-events: none;
}
.hero-tiles svg { position: absolute; top: 50%; left: 50%; width: 60px; filter: drop-shadow(0 12px 14px rgba(0,0,0,.4)); opacity: 0; animation: dealTile .75s cubic-bezier(.2,.8,.2,1) forwards; }
.hero-tiles svg:nth-child(1) { animation-delay: .05s; --tx: -138px; --ty: 8px; --tr: -11deg; }
.hero-tiles svg:nth-child(2) { animation-delay: .16s; --tx: -46px; --ty: -8px; --tr: -4deg; }
.hero-tiles svg:nth-child(3) { animation-delay: .27s; --tx: 46px; --ty: -8px; --tr: 4deg; }
.hero-tiles svg:nth-child(4) { animation-delay: .38s; --tx: 138px; --ty: 8px; --tr: 11deg; }
@keyframes dealTile {
  0% { opacity: 0; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty) - 40px)) rotate(var(--tr)) scale(.85); }
  100% { opacity: 1; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--tr)) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-tiles svg { animation: none; opacity: 1; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--tr)); }
}
@media (max-width: 640px) { .hero-tiles { display: none; } }

/* özel onay kutusu */
.check-row { display: flex; align-items: center; gap: 10px; margin: 16px 0; font-size: 14px; color: var(--text); cursor: pointer; }
.check-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 19px; height: 19px; flex: none; border-radius: 6px; border: 1.5px solid rgba(255,255,255,.3); background: rgba(0,0,0,.3); position: relative; transition: background .15s, border-color .15s; }
.check-box::after { content: ""; position: absolute; inset: 0; margin: auto; width: 10px; height: 6px; border-left: 2px solid #2a2100; border-bottom: 2px solid #2a2100; transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform .15s; }
.check-row input:checked + .check-box { background: var(--gold); border-color: var(--gold); }
.check-row input:checked + .check-box::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check-row input:focus-visible + .check-box { outline: 2px solid var(--gold); outline-offset: 2px; }

.conn { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: var(--red); color: #2a0000; text-align: center; padding: 6px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 190px; transform: translateX(-50%); background: rgba(0,0,0,.85); padding: 10px 16px; border-radius: 12px; z-index: 90; max-width: 90vw; text-align: center; border: 1px solid rgba(255,255,255,.2); }
.toast.score { background: var(--gold); color: #2a2100; font-weight: 800; font-size: 20px; bottom: auto; top: 30%; animation: pop 1.6s ease-out forwards; }
@keyframes pop { 0% { transform: translate(-50%, 10px) scale(.7); opacity: 0; } 20% { transform: translate(-50%, 0) scale(1.1); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -30px); opacity: 0; } }

/* ---------- lobi ---------- */
.share { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 6px; }
.share .hint { margin: 0 0 2px; }
.share .lnk {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid rgba(255,255,255,.16); border-radius: 12px; overflow: hidden;
  background: rgba(0,0,0,.28);
}
.share input {
  flex: 1; min-width: 0; font-size: 13px; padding: 11px 12px; border: none; border-radius: 0;
  background: none; color: var(--ivory); font-family: ui-monospace, Consolas, monospace;
}
.share input:focus { outline: none; background: rgba(255,255,255,.05); }
.share .lnk button {
  flex: none; border: none; border-left: 1px solid rgba(255,255,255,.14);
  border-radius: 0; padding: 0 16px; background: rgba(242,193,78,.12); color: var(--gold); font-weight: 700;
}
.share .lnk button:hover { background: rgba(242,193,78,.22); }
/* 4 oyunculu lobi koltuk seçici: 2 sol + 2 sağ, aralarında boşluk —
   gelecekteki 2v2 takım modunun görsel temeli. Herhangi bir (boş ya da
   dolu) koltuğa tıklayıp geçilebilir; dolu bir koltuğa geçmek yer takas
   eder, böylece yanlış geçilirse kolayca geri dönülebilir. */
.seat-picker { display: flex; align-items: stretch; gap: 16px; margin: 8px 0 4px; }
.seat-pair { flex: 1; display: grid; gap: 8px; }
.seat-gap { width: 1px; background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.18), rgba(255,255,255,0)); }
.seat-slot {
  display: flex; align-items: center; gap: 9px; padding: 13px; border-radius: 12px;
  border: 1.5px dashed rgba(255,255,255,.16); background: rgba(255,255,255,.03);
  color: var(--text); font: inherit; cursor: pointer; text-align: left; min-height: 46px;
  transition: background .15s, border-color .15s, transform .1s;
}
.seat-slot:hover:not(:disabled) { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.3); }
.seat-slot:active:not(:disabled) { transform: scale(.98); }
.seat-slot.filled { border-style: solid; border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.06); box-shadow: 0 6px 16px -8px rgba(0,0,0,.5); }
.seat-slot.mine { border-color: var(--gold); background: rgba(242,193,78,.1); box-shadow: 0 0 0 1px var(--gold) inset; }
.seat-slot:disabled { cursor: default; opacity: .9; }
.seat-slot .empty-lbl { color: var(--muted); font-size: 13px; }
.seat-slot .nm { font-weight: 700; }

.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255,255,255,.07); border-radius: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex: none; }
.dot.off { background: #777; }
.badge { font-size: 10.5px; background: var(--gold); color: #2a2100; padding: 3px 8px; border-radius: 99px; font-weight: 700; margin-left: auto; white-space: nowrap; }
.spectator-hdr { background: none !important; padding: 10px 2px 2px !important; font-size: 11px; letter-spacing: .08em; color: var(--muted); }
.spectator-li { opacity: .8; }

/* Ana ekran: "sadece izleyeceğim" onay kutusu */


/* ---------- oyun düzeni (minimalist: tahta mümkün olduğunca büyük) ---------- */
#game { display: flex; flex-direction: column; height: 100%; }
.gbar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: rgba(0,0,0,.35); font-size: 13px; gap: 8px; }
.gbar-btns { display: flex; gap: 6px; flex: none; position: relative; }
.more-wrap { position: relative; }
.more-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 6px; min-width: 110px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.more-item { background: none; border: none; color: var(--text); text-align: left; padding: 7px 10px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.more-item:hover, .more-item:active { background: rgba(255,255,255,.08); }
/* Rakip özet çubuğu: sol üst köşede, oda kodu/el/hedef yerine — kompakt tek satır */
.opp-bar { display: flex; gap: 8px; overflow-x: auto; min-width: 0; }
.opp-chip { display: flex; align-items: center; gap: 5px; flex: none; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.3); border: 1.5px solid transparent; white-space: nowrap; }
.opp-chip.turn { border-color: var(--gold); box-shadow: 0 0 8px rgba(242,193,78,.5); }
.opp-chip .dot { width: 7px; height: 7px; }
.opp-chip .nm { font-weight: 700; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-chip.pair .nm { max-width: 130px; }
.opp-chip .sc { color: var(--gold); font-weight: 800; }
.opp-chip .cnt { color: var(--muted); font-size: 11px; }

.layout { flex: 1; min-height: 0; display: flex; gap: 6px; padding: 4px; }
.table {
  flex: 1; min-width: 0; min-height: 0;
  display: flex;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  border: 6px solid #5a3b21; border-radius: 22px; padding: 8px;
  box-shadow: inset 0 0 40px rgba(0,0,0,.5);
}
.board-area { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.board-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; }
#boardSvg { margin: auto; flex: none; user-select: none; }
.lastmove { text-align: center; min-height: 18px; font-size: 12px; color: var(--muted); flex: none; }
.lastmove .pts { color: var(--gold); font-weight: 800; }

/* ---------- skor tablosu ---------- */
.scoreboard { width: 220px; flex: none; background: var(--panel); border-radius: 14px; padding: 12px; overflow: auto; }
.scoreboard h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .1em; color: var(--muted); display: flex; justify-content: space-between; }
.srow { padding: 8px 6px; border-radius: 8px; margin-bottom: 4px; }
.srow.turn { background: rgba(242,193,78,.18); }
.srow .l { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.srow .l span:last-child { color: var(--gold); font-variant-numeric: tabular-nums; }
.srow .bar { height: 4px; border-radius: 3px; background: rgba(255,255,255,.12); margin-top: 6px; overflow: hidden; }
.srow .bar i { display: block; height: 100%; background: var(--green); }
.srow .winner { color: var(--gold); font-weight: 900; letter-spacing: .1em; }

/* ---------- benim alanım (minimalist: yalnızca gerekince görünen aksiyon düğmeleri + el) ---------- */
.me { background: rgba(0,0,0,.4); padding: 4px 10px calc(6px + env(safe-area-inset-bottom)); }
.actions { display: flex; gap: 8px; justify-content: center; }
.actions:empty { display: none; }
/* Taş sayısı artınca (deste çekince) yatay kaydırmak yerine ALT SATIRA
   kayar — böylece hiçbir taşı kaydırmadan görürsün; tahta zaten kalan
   yüksekliğe göre otomatik ölçekleniyor. max-height + overflow-y yalnızca
   gerçekten çok fazla taş olduğu (nadir) durumda son çare olarak devreye
   girer, tek satırlık kaydırmadan çok daha okunaklı bir sonuç verir. */
.hand { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px; justify-content: center; max-height: 46vh; overflow-y: auto; }
.htile { flex: none; width: 54px; height: 108px; border: none; background: none; padding: 0; cursor: grab; transition: transform .12s, opacity .12s; touch-action: none; }
.htile svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.htile.playable { transform: translateY(-4px); }
.htile.playable svg .tb { stroke: var(--green); stroke-width: .07; }
.htile.dim { opacity: .5; }
.htile.selected { transform: translateY(-16px) scale(1.06); }
.htile.selected svg .tb { stroke: var(--gold); stroke-width: .1; }
/* Çoklu çift taş önerisi: birlikte oynanınca puan yazan kombinasyon — kırmızı nabız. */
.htile.combo-hint svg .tb { stroke: var(--red); stroke-width: .1; animation: comboPulse 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.htile.combo-hint.selected svg .tb { stroke: var(--gold); animation: none; }
@keyframes comboPulse { 0%, 100% { filter: drop-shadow(0 0 0 rgba(255,107,107,0)); } 50% { filter: drop-shadow(0 0 6px rgba(255,107,107,.85)); } }
.htile.dragging { opacity: .2; }

/* Sürüklenen taşın parmak/imleç altında beliren kopyası */
.drag-ghost {
  position: fixed; left: 0; top: 0; width: 62px; height: 124px; pointer-events: none; z-index: 300;
  transform: translate(-50%, -78%) scale(1.12); filter: drop-shadow(0 10px 16px rgba(0,0,0,.6));
}
.drag-ghost svg { width: 100%; height: 100%; display: block; }
.drag-ghost svg .tb { stroke: var(--gold); stroke-width: .1; }

/* ---------- tahta SVG ---------- */
.tb { fill: var(--ivory); stroke: var(--ivory-edge); stroke-width: .05; }
.tm { stroke: #8a7f5f; stroke-width: .04; }
.pip { fill: var(--ink); }
.tile.last .tb { stroke: var(--gold); stroke-width: .09; }

/* Yeni oynanan taş: yukarıdan fırlayıp hafif sekerek yerine oturur (§ ses efektiyle eşzamanlı) */
@keyframes tileDrop {
  0%   { transform: translate(0px, -2.6px) rotate(-14deg) scale(1.35); opacity: 0; }
  55%  { transform: translate(0px, .25px) rotate(4deg) scale(1.04); opacity: 1; }
  78%  { transform: translate(0px, -.08px) rotate(-1.5deg) scale(.98); }
  100% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
}
.tile-drop-inner { transform-box: fill-box; transform-origin: center; animation: tileDrop .38s cubic-bezier(.25,.7,.3,1.25) both; }
.tile.hub .tb { stroke: #ff9f43; stroke-width: .1; }
.port circle { fill: rgba(255,255,255,.1); stroke: rgba(255,255,255,.55); stroke-width: .05; stroke-dasharray: .12 .1; }
.port.small circle { fill: rgba(255,255,255,.3); stroke: none; }
.port.elig { cursor: pointer; }
.port.elig circle { fill: rgba(53,208,127,.35); stroke: var(--green); stroke-width: .09; stroke-dasharray: none; animation: pulse 1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
/* Sürüklenen taş bu ucun üstüne yeterince yaklaştığında (DROP_RADIUS içinde) beliren "buraya bırak" vurgusu */
.port.elig.dropHover circle { animation: none; fill: rgba(242,193,78,.6); stroke: var(--gold); stroke-width: .13; transform: scale(1.5); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.frozen-x { fill: rgba(255,255,255,.35); font-size: .6px; text-anchor: middle; dominant-baseline: central; font-weight: 700; }
.empty-msg { fill: rgba(255,255,255,.6); font-size: .38px; text-anchor: middle; }

/* ---------- overlay / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; overflow: auto; }
.modal { background: #12372b; border: 1px solid rgba(255,255,255,.2); border-radius: 18px; padding: 22px; width: min(560px, 100%); max-height: 92vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.rules-text p { margin: 8px 0; line-height: 1.45; font-size: 14px; }
.big-winner { font-size: 44px; font-weight: 900; color: var(--gold); letter-spacing: .12em; text-align: center; margin: 4px 0; }
.res-hand { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.res-hand .n { min-width: 90px; font-weight: 700; }
.res-hand svg { width: 42px; height: 22px; }
.res-hand .pp { color: var(--muted); font-size: 12px; }
.modal .btn { margin-top: 12px; }
table.st { width: 100%; border-collapse: collapse; margin-top: 10px; }
table.st th { text-align: left; color: var(--muted); font-size: 12px; letter-spacing: .1em; }
table.st th:last-child, table.st td:last-child { text-align: right; }
table.st td, table.st th { padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,.1); }

/* ---------- mobil ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; padding: 4px; gap: 4px; }
  .scoreboard { width: 100%; display: none; }
  .scoreboard.open { display: block; }
  .table { padding: 6px; border-width: 4px; border-radius: 16px; }
  .opp-chip .nm { max-width: 56px; font-size: 12px; }
  .htile { width: 44px; height: 88px; }
}
@media (min-width: 861px) { #btnScoreToggle { display: none; } }
@media (max-height: 640px) { .htile { width: 40px; height: 80px; } }
