/* =====================================================================
   51 OKEY — Mobil öncelikli arayüz (claude.ai/design "Okey Masası Mobil
   Tasarımı" temel alınarak uyarlandı). Tüm oyun mantığı main.js'te; burada
   yalnızca görünüm var. İşlevsel sınıflar (hidden, selected, drop-target,
   drag-ghost, tier-*, undo-draw-here ...) KORUNMUŞTUR.
   ===================================================================== */

:root {
  --bg: #0f1c1c;
  --bg-deep: #0b1514;
  --bg-2: #172625;
  --bg-3: #1d2e2e;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f3f1ea;
  --muted: #a7b6ae;
  --muted-2: #8a9a93;
  --gold: #efb84a;
  --gold-soft: #f3cf7c;
  --gold-ink: #3a2a0f;
  --danger: #e0664f;
  --felt-1: #2f6a50;
  --felt-2: #22553f;
  --felt-3: #163a2b;
  --tile-hi: #fdf9ef;
  --tile-lo: #ebe2cd;
  --tile-edge: #d2c6ab;
  --tile-foot: #a8977a;
  --t-red: #c93a2f;
  --t-blue: #1f58b3;
  --t-yellow: #c98712;
  --t-black: #23262d;
  --wood-hi: #9a6532;
  --wood-lo: #74461f;
  --wood-rail: #4d2d14;
  --radius: 14px;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--bg-deep); color: var(--text);
  font-family: Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; color: inherit; }
button:disabled { cursor: default; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* Tüm uygulama çerçevesi: telefonda tam ekran, geniş ekranda ortalanmış sütun.
   height: 100vh -> 100dvh sırası ÖNEMLİ (sonraki kazanır; dvh adres çubuğunu hesaba katar). */
#appFrame {
  position: fixed; inset: 0; margin: 0 auto; width: 100%; max-width: 640px;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden; background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Ortak butonlar ---------- */
.btn-primary {
  border: none; border-radius: 12px; background: var(--gold); color: var(--gold-ink);
  font-weight: 700; font-size: 16px; min-height: var(--tap);
  box-shadow: 0 2px 0 #b98522, 0 6px 14px rgba(0, 0, 0, 0.25);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 #b98522; }
.btn-primary:disabled { opacity: 0.4; box-shadow: none; }
.btn-lg { height: 56px; font-size: 17px; border-radius: 14px; }
.soft-btn {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3);
  color: var(--text); font-weight: 600; font-size: 14px; min-height: var(--tap); padding: 0 14px;
}
.soft-btn:disabled { opacity: 0.4; }
.outline-btn {
  height: 48px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent; color: var(--text); font-size: 15px; font-weight: 600;
}
.icon-btn {
  width: var(--tap); height: var(--tap); border: none; border-radius: 12px; background: transparent;
  color: var(--text); font-size: 26px; line-height: 1; flex-shrink: 0;
}
.icon-btn.solid { background: var(--bg-3); font-size: 22px; }
.chip {
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px;
  border-radius: 99px; background: var(--bg-2); white-space: nowrap;
}
.chip-btn {
  border: 1px solid rgba(255, 255, 255, 0.14); background: var(--bg-2); color: var(--text);
  font-size: 11px; font-weight: 700; border-radius: 99px; height: 30px; padding: 0 10px; flex-shrink: 0;
}
.chip-btn:active { background: var(--bg-3); }

/* =============================== TAŞ =============================== */
/* Tek bir .tile bileşeni her yerde kullanılır: rakam + altında renkli nokta
   (nokta ::after ile, rengi currentColor'dan). Boyutu bağlama göre değişir. */
.tile {
  position: relative; width: 34px; height: 48px; border-radius: 5px;
  background: linear-gradient(170deg, var(--tile-hi), var(--tile-lo));
  border: 1px solid var(--tile-edge);
  box-shadow: 0 2px 0 var(--tile-foot), 0 3px 5px rgba(0, 0, 0, 0.3);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 0.26em; font-weight: 700; font-size: 20px; line-height: 1; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; color: var(--t-black); cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.tile::after {
  content: ''; width: 0.3em; height: 0.3em; border-radius: 50%; margin-top: 0.22em;
  background: currentColor; flex-shrink: 0;
}
.tile.color-black { color: var(--t-black); }
.tile.color-red { color: var(--t-red); }
.tile.color-yellow { color: var(--t-yellow); }
.tile.color-blue { color: var(--t-blue); }
/* Sahte okey (joker): altın zemin, mor yazı, yıldız noktası */
.tile.okey {
  background: linear-gradient(170deg, #ffe7a3, #f4c55a); border-color: #d9a53b;
  color: #6b2a8f; font-size: 0.8em; letter-spacing: 0;
}
.tile.okey::after { content: '★'; width: auto; height: auto; background: none; font-size: 0.9em; margin-top: 0.1em; }
.tile[data-draggable="true"] { touch-action: none; }
.tile.selected {
  transform: translateY(-14%);
  box-shadow: 0 0 0 2.5px #ef233c, 0 8px 12px rgba(0, 0, 0, 0.45) !important; z-index: 2;
}
.tile.drag-original-hidden { opacity: 0.2; }
.tile.drag-ghost {
  position: fixed; z-index: 1000; pointer-events: none; margin: 0 !important;
  transform: rotate(-4deg) scale(1.08); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5) !important;
}
.tile.risky::before {
  content: '✕'; position: absolute; top: -5px; right: -5px; color: #fff; font-size: 10px;
  background: var(--danger); border-radius: 50%; width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center; letter-spacing: 0;
}

/* =============================== LOBİ =============================== */
#lobby {
  padding: 24px 20px 20px;
  background: radial-gradient(120% 70% at 50% 22%, #2c5a45, var(--bg) 72%);
}
.lobby-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.hero-tiles { display: flex; gap: 10px; }
.hero-tile {
  width: 66px; height: 92px; border-radius: 10px; display: flex; flex-direction: column; align-items: center;
  padding-top: 12px; background: linear-gradient(170deg, var(--tile-hi), var(--tile-lo));
  border: 1px solid var(--tile-edge); box-shadow: 0 4px 0 var(--tile-foot), 0 10px 20px rgba(0, 0, 0, 0.4);
}
.hero-tile span { font-size: 46px; font-weight: 700; line-height: 1; }
.hero-tile i { width: 12px; height: 12px; border-radius: 50%; margin-top: 8px; background: currentColor; }
.hero-tile.red { color: var(--t-red); }
.hero-tile.blue { color: var(--t-blue); }
.lobby-brand { font-size: 18px; letter-spacing: 0.5em; padding-left: 0.5em; font-weight: 800; color: var(--gold); }
.lobby-sub { font-size: 14px; line-height: 1.5; color: var(--muted); text-align: center; max-width: 270px; }
.lobby-form { display: flex; flex-direction: column; gap: 10px; }
.lobby-form label { font-size: 13px; font-weight: 600; color: var(--muted); }
#nameInput {
  height: 54px; border-radius: 14px; border: 1.5px solid #34504c; background: var(--bg-2);
  color: var(--text); font-size: 17px; font-weight: 500; padding: 0 16px; outline: none;
}
#nameInput:focus { border-color: var(--gold); }
.conn-status { font-size: 11px; color: var(--muted-2); text-align: center; min-height: 14px; }

/* ============================ MASA SEÇİM ============================ */
.screen-header { height: 52px; display: flex; align-items: center; gap: 6px; padding: 0 8px; flex-shrink: 0; }
.screen-title { flex: 1; font-size: 17px; font-weight: 700; }
.ts-help { margin: 0; padding: 0 20px 8px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.ts-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px 12px 16px; }
#tsGrid {
  position: relative; width: 100%; max-width: 400px; max-height: 100%; aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr));
  grid-template-areas: '. n .' 'w c e' '. s .'; gap: 4px;
}
.ts-felt {
  position: absolute; inset: 17%; border-radius: 26px;
  background: radial-gradient(ellipse at 50% 45%, var(--felt-1), #1e4a37 70%);
  box-shadow: 0 0 0 6px #5b3a1c, 0 0 0 7px #3e2712, inset 0 0 30px rgba(0, 0, 0, 0.4);
}
.ts-center { grid-area: c; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ts-51 { font-size: 30px; font-weight: 800; color: rgba(239, 184, 74, 0.9); }
.ts-label { font-size: 10px; letter-spacing: 0.14em; font-weight: 700; color: #cfe0d6; }
.ts-seat {
  position: relative; align-self: center; justify-self: center; width: 100%; max-width: 124px;
  padding: 8px 6px; border-radius: 16px; background: var(--bg-2); border: 1.5px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
}
.ts-top { grid-area: n; } .ts-left { grid-area: w; } .ts-right { grid-area: e; } .ts-bottom { grid-area: s; }
.ts-seat-occupied { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.ts-seat .seat-avatar { width: 40px; height: 40px; font-size: 14px; }
.ts-seat .seat-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; word-break: break-word; }
.ts-status { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted-2); }
.ts-empty-avatar { width: 40px; height: 40px; border-radius: 50%; border: 1.5px dashed rgba(255, 255, 255, 0.3); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 16px; }
.ts-sit-btn {
  width: 100%; min-height: 40px; margin-top: 2px; border: none; border-radius: 10px;
  background: var(--gold); color: var(--gold-ink); font-size: 12.5px; font-weight: 700; line-height: 1.15; padding: 4px 6px;
}
.ts-sit-btn-takeover { background: transparent; color: var(--gold-soft); border: 1.5px solid rgba(239, 184, 74, 0.6); }

/* ============================ OYUN MASASI ============================ */
#game { touch-action: manipulation; -webkit-user-select: none; user-select: none; position: relative; }
#topBar { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.menu-btn { background: var(--bg-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.menu-btn span { width: 18px; height: 2px; border-radius: 2px; background: var(--text); }
.top-center { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; }
#handTitle { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
#handSubtitle { font-size: 11px; font-weight: 600; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---- Çuha masa ---- */
#felt {
  position: relative; flex: 1; min-height: 0; margin: 0 6px; border-radius: 22px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 42%, var(--felt-1), var(--felt-2) 58%, var(--felt-3));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45), inset 0 0 44px rgba(0, 0, 0, 0.45);
}
#feltGrid {
  height: 100%; display: grid; gap: 8px; padding: 10px 8px;
  grid-template-columns: 66px minmax(0, 1fr) 66px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'dt top dr' 'left mid right' 'dl deck dm';
}
.area-dt { grid-area: dt; } .area-top { grid-area: top; } .area-dr { grid-area: dr; }
.area-left { grid-area: left; } .area-mid { grid-area: mid; } .area-right { grid-area: right; }
.area-dl { grid-area: dl; } .area-deck { grid-area: deck; } .area-dm { grid-area: dm; }

/* ---- Rakip kartları ---- */
.seat-slot { display: flex; align-items: center; justify-content: center; min-width: 0; }
.seat-card { display: flex; align-items: center; gap: 6px; min-width: 0; }
.area-left .seat-card, .area-right .seat-card { flex-direction: column; text-align: center; }
.seat-avatar {
  position: relative; width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff;
  transition: box-shadow 0.2s;
}
.seat-card.active-turn .seat-avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(239, 184, 74, 0.7); }
.avatar-hue-0 { background: #7c4a9e; }
.avatar-hue-1 { background: #2f7d5b; }
.avatar-hue-2 { background: #2d5fa6; }
.avatar-hue-3 { background: #a4602a; }
.bot-badge {
  position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%); font-size: 8px; font-weight: 800;
  letter-spacing: 0.06em; padding: 1px 4px; border-radius: 4px; background: var(--bg-2);
  color: #cfe0d6; border: 1px solid rgba(255, 255, 255, 0.18);
}
.seat-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.area-left .seat-meta, .area-right .seat-meta { align-items: center; }
/* KURAL: isim ASLA kırpılmaz - sığmazsa alt satıra sarar. */
.seat-name { font-size: 12px; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; max-width: 100%; }
.area-top .seat-name { max-width: 150px; }
.seat-score {
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: rgba(0, 0, 0, 0.35);
  color: var(--gold-soft); font-variant-numeric: tabular-nums;
}
.seat-tiles { font-size: 9.5px; font-weight: 600; color: #cfe0d6; opacity: 0.8; }
/* Boş koltuk davetiyesi */
.invite-card { flex-direction: column; text-align: center; gap: 4px; }
.invite-avatar { border: 1.5px dashed rgba(255, 255, 255, 0.4); background: rgba(0, 0, 0, 0.2); color: #cfe0d6; }
.invite-bot-btn {
  border: none; border-radius: 10px; background: var(--gold); color: var(--gold-ink);
  font-size: 11px; font-weight: 700; min-height: 32px; padding: 0 8px;
  animation: invite-pulse 1.6s ease-in-out infinite;
}
@keyframes invite-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 184, 74, 0.0); }
  50% { box-shadow: 0 0 0 5px rgba(239, 184, 74, 0.25); }
}

/* ---- Köşe atık kutuları ("kim ne attı") ---- */
.corner-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; justify-self: center; min-width: 0; }
.area-dt, .area-dr { align-self: start; }
.area-dl, .area-dm { align-self: end; }
.corner-discard {
  position: relative; width: 50px; height: 64px; border-radius: 10px;
  border: 1.5px dashed rgba(255, 255, 255, 0.28); background: rgba(0, 0, 0, 0.15);
  display: flex; align-items: center; justify-content: center; font-size: 10px; color: rgba(255, 255, 255, 0.45);
  text-align: center; transition: background 0.15s, border-color 0.15s;
}
.corner-discard:not(.empty) { border-style: solid; border-color: rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.22); }
.corner-discard .tile { width: 36px; height: 50px; font-size: 21px; }
.corner-label { font-size: 10px; font-weight: 600; color: #cfe0d6; text-align: center; line-height: 1.15; overflow-wrap: anywhere; max-width: 66px; }
.corner-label-gold { color: var(--gold-soft); }
#game.phase-draw #discardBottomLeft:not(.empty):not(.undo-draw-here) { border-color: rgba(239, 184, 74, 0.8); box-shadow: 0 0 0 3px rgba(239, 184, 74, 0.18); }
#discardBottomRight.drop-target { border: 2px solid var(--danger); background: rgba(224, 102, 79, 0.3); }
/* Soldan çekilen taşı geri bırakma: aynı kutunun kendisi buton olur */
.corner-discard.undo-draw-here {
  white-space: pre-line; font-size: 11px; font-weight: 800; line-height: 1.1; cursor: pointer;
  color: var(--gold-ink); background: var(--gold); border: 2px solid #ffe3a0;
  animation: invite-pulse 1.2s ease-in-out infinite;
}

/* ---- Orta pano (Seri / Çift alanı) ---- */
#board {
  position: relative; min-height: 0; display: flex; flex-direction: column; border-radius: 14px;
  background: rgba(0, 0, 0, 0.2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
#boardScroll { flex: 1; min-height: 0; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.board-area { display: flex; flex-direction: column; gap: 5px; }
.board-head { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.1em; font-weight: 700; color: #cfe0d6; }
#pairArea { margin-top: 4px; }
.board-empty { font-size: 12px; color: #a9c2b5; }
.meld-list { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; }
.meld-wrap {
  display: flex; align-items: center; gap: 3px; padding: 4px 5px 4px 4px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
#seriesList .meld-wrap { box-shadow: inset 0 0 0 1.5px rgba(6, 214, 160, 0.45); }
#pairList .meld-wrap { box-shadow: inset 0 0 0 1.5px rgba(76, 170, 240, 0.5); }
.meld-owner {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; background: #5f6f6a;
  font-size: 8px; font-weight: 800; color: #fff; display: flex; align-items: center; justify-content: center;
  letter-spacing: 0; overflow: hidden;
}
.meld-owner.mine { background: var(--gold); color: var(--gold-ink); }
.meld-group { display: flex; gap: 2px; border-radius: 6px; }
.meld-group .tile { box-shadow: 0 1.5px 0 var(--tile-foot); border-radius: 3px; cursor: default; }
.meld-list.tier-lg .meld-group .tile { width: 26px; height: 36px; font-size: 16.5px; }
.meld-list.tier-md .meld-group .tile { width: 22px; height: 31px; font-size: 14px; }
.meld-list.tier-sm .meld-group .tile { width: 19px; height: 27px; font-size: 12.5px; }
.meld-list.tier-xs .meld-group .tile { width: 16px; height: 23px; font-size: 10.5px; }
.meld-group.row-selected { box-shadow: 0 0 0 2px var(--gold); }
.meld-group.drop-target { box-shadow: 0 0 0 2px var(--gold); background: rgba(239, 184, 74, 0.2); }
.tile.okey-drop-target { box-shadow: 0 0 0 2.5px #06d6a0 !important; }
.tile.board-okey { cursor: grab; }

.toast {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); max-width: 92%; z-index: 5;
  padding: 8px 12px; border-radius: 10px; background: rgba(23, 38, 37, 0.96);
  border: 1px solid rgba(239, 184, 74, 0.6); font-size: 12.5px; font-weight: 600; text-align: center;
  color: var(--text); pointer-events: none; text-wrap: balance; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.toast.error { border-color: rgba(224, 102, 79, 0.8); }

/* ---- Deste + katlama ---- */
.area-deck { display: flex; align-items: center; justify-content: center; gap: 18px; }
.deck-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.deck-label { font-size: 10px; font-weight: 600; color: #cfe0d6; white-space: nowrap; }
#game.phase-draw .deck-label#deckLabel { color: var(--gold-soft); }
.wall-slot { position: relative; width: 46px; height: 62px; }
.wall-stack { position: absolute; width: 38px; height: 54px; border-radius: 6px; }
.wall-stack.s3 { left: 6px; top: 6px; background: #bfae8e; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35); }
.wall-stack.s2 { left: 3px; top: 3px; background: #d6c8aa; }
.wall-tile-back {
  position: absolute; left: 0; top: 0; width: 38px; height: 54px; border-radius: 6px; cursor: grab;
  background: linear-gradient(170deg, #f5efe0, #ddd0b4);
  display: flex; align-items: center; justify-content: center; transition: box-shadow 0.2s;
}
.wall-tile-back::before { content: ''; position: absolute; inset: 6px 6px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px #c8b78f; }
#game.phase-draw .wall-tile-back { box-shadow: 0 0 0 2.5px var(--gold), 0 0 14px rgba(239, 184, 74, 0.6); }
#wallCountBadge {
  position: absolute; top: -7px; right: -9px; min-width: 20px; height: 18px; padding: 0 4px; border-radius: 99px;
  background: var(--bg-2); border: 1px solid rgba(255, 255, 255, 0.15); font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; color: #d6e3dc; font-variant-numeric: tabular-nums;
}
.katlama-badge {
  width: 42px; height: 42px; border-radius: 12px; background: #fff; color: #111;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}
.katlama-value { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ============================ ALT BÖLÜM (ben) ============================ */
#handArea { flex-shrink: 0; display: flex; flex-direction: column; }
#meBar { display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; min-width: 0; }
.me-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #8a6420; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff;
  transition: box-shadow 0.2s;
}
#game.my-turn .me-avatar { box-shadow: 0 0 0 2.5px var(--gold), 0 0 12px rgba(239, 184, 74, 0.7); }
.my-score-pill { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.my-score-name { font-size: 13px; font-weight: 600; white-space: nowrap; line-height: 1.1; }
.my-score-value {
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--bg-3);
  color: var(--gold-soft); font-variant-numeric: tabular-nums;
}
.turn-hint {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); text-align: right;
  line-height: 1.15; min-width: 0;
}
#game.my-turn .turn-hint { color: var(--gold-soft); }
#rackMeldInfo { padding: 0 12px 4px; font-size: 11px; color: #9fd9c2; min-height: 0; line-height: 1.2; }
#rackMeldInfo:empty { display: none; }

/* ---- Ahşap istaka: 2 satır x 15 göz, tamamen oransal ---- */
#rackWrap {
  margin: 0 4px; padding: 6px 4px 3px; border-radius: 14px 14px 10px 10px;
  background:
    repeating-linear-gradient(91deg, rgba(55, 25, 5, 0.13) 0 1px, transparent 1px 7px, rgba(255, 220, 170, 0.05) 7px 8px, transparent 8px 13px),
    linear-gradient(180deg, var(--wood-hi), var(--wood-lo));
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.25), 0 6px 14px rgba(0, 0, 0, 0.35);
}
.hand-tiles { display: flex; flex-direction: column; gap: 5px; }
.rack-row {
  display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 1.5px;
  padding-bottom: 5px; border-bottom: 4px solid var(--wood-rail); box-shadow: 0 1px 0 rgba(255, 220, 170, 0.15);
}
.rack-slot {
  position: relative; aspect-ratio: 0.62; border-radius: 4px; container-type: inline-size;
  transition: background 0.12s;
}
.rack-slot.drop-target { background: rgba(255, 230, 160, 0.35); box-shadow: inset 0 0 0 1.5px var(--gold-soft); }
.rack-slot .tile {
  position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 14cqw;
  font-size: 60cqw; padding-top: 14cqw;
}
/* Konteyner sorgusu desteklemeyen eski tarayıcılar için yedek */
@supports not (container-type: inline-size) {
  .rack-slot .tile { font-size: clamp(10px, 3.4vw, 24px); border-radius: 4px; padding-top: 0.26em; }
}

/* ---- Faz bazlı kontrol alanı ---- */
#controls { padding: 8px 10px 10px; min-height: 66px; }
.ctrl-row { display: none; gap: 8px; }
#game.phase-draw .ctrl-draw { display: flex; }
#game.phase-act .ctrl-act { display: grid; }
#game.phase-wait .ctrl-wait { display: flex; }
.big { height: 50px; font-size: 15px; }
.grow { flex: 1.2; }
#drawDiscardBtn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.mini-tile {
  width: 18px; height: 25px; border-radius: 3px; background: linear-gradient(170deg, var(--tile-hi), var(--tile-lo));
  font-size: 12px; font-weight: 700; line-height: 25px; text-align: center; color: var(--t-black);
}
.mini-tile:empty { display: none; }
.mini-tile.color-red { color: var(--t-red); } .mini-tile.color-blue { color: var(--t-blue); }
.mini-tile.color-yellow { color: var(--t-yellow); } .mini-tile.okey { color: #6b2a8f; background: #f4c55a; }
.ctrl-act { grid-template-columns: repeat(4, minmax(0, 1fr)) 76px; }
.action-buttons { display: contents; }
.action-buttons button {
  height: 50px; padding: 0 2px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, 0.12);
  background: var(--bg-3); color: var(--text); font-size: 12.5px; font-weight: 600; line-height: 1.1;
}
.action-buttons button[data-action="openSeries"] { border-color: rgba(6, 214, 160, 0.55); }
.action-buttons button[data-action="openPairs"] { border-color: rgba(76, 170, 240, 0.6); }
.action-buttons button:active:not(:disabled) { background: #26393a; }
.action-buttons button:disabled { opacity: 0.4; }
#discardBtn { font-size: 17px; }
.wait-box {
  flex: 1; height: 50px; border-radius: 12px; background: var(--bg-2); display: flex; align-items: center;
  justify-content: center; gap: 8px; font-size: 13.5px; color: #c3d2ca; padding: 0 10px; text-align: center;
}
.wait-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex-shrink: 0; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ============================ ALT SAYFALAR (menü / skor) ============================ */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.55);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.sheet {
  border-radius: 20px 20px 0 0; background: var(--bg-2); padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; max-height: 88%; animation: sheet-up 0.18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); align-self: center; margin-bottom: 6px; }
.sheet-item {
  height: 52px; border: none; border-radius: 12px; background: var(--bg-3); color: var(--text);
  font-size: 15px; font-weight: 600; text-align: left; padding: 0 16px;
}
.sheet-item.danger { color: #f08a74; }
.sheet-item.ghost { background: transparent; text-align: center; color: var(--muted); height: 48px; }
.sheet-tall { min-height: 60%; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font-size: 18px; font-weight: 700; }
#handProgress { font-size: 13px; color: var(--gold); font-weight: 600; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.score-section-title { margin: 16px 0 8px; font-size: 13px; color: #cfe0d6; }
.score-hint { font-size: 10.5px; color: var(--muted-2); font-weight: 400; }

#scoreTableWrap, #penaltyTableWrap { overflow-x: auto; max-width: 100%; border-radius: 10px; }
#scoreTable, #penaltyTable { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
#scoreTable th, #scoreTable td, #penaltyTable th, #penaltyTable td {
  padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); text-align: right;
}
#scoreTable thead th, #penaltyTable thead th {
  position: sticky; top: 0; background: var(--bg-2); font-size: 11px; color: #cfe0d6; font-weight: 700;
  white-space: normal; overflow-wrap: normal; word-break: normal; line-height: 1.2;
}
#scoreTable td.hand-col, #scoreTable th.hand-col { text-align: left; font-weight: 600; color: var(--muted); }
#scoreTable td.mult-col, #scoreTable th.mult-col { text-align: left; color: var(--gold); font-size: 11.5px; font-weight: 600; }
#scoreTable tr.finish-row td.player-cell { color: #7fe3b8; }
#scoreTable .cell-main { font-weight: 600; }
#scoreTable .cell-sub { font-size: 10px; color: var(--muted-2); display: block; }
#scoreTable tr.cumulative-row td { font-weight: 800; font-size: 14px; border-top: 2px solid rgba(239, 184, 74, 0.5); }
#scoreTable tr.cumulative-row td.leader-cell { color: var(--gold); }
#penaltyTable td.reason-name { text-align: left; }
#penaltyTable tr.penalty-total-row td { font-weight: 800; color: #f08a74; }
#penaltyTable .no-penalty { color: var(--muted-2); font-style: italic; text-align: left; }
#projectedTotalsWrap { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(239, 184, 74, 0.1); border: 1px solid rgba(239, 184, 74, 0.3); }
#projectedTotalsWrap:empty { display: none; }
#projectedTotalsWrap .proj-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#projectedTotalsWrap .proj-row { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; font-variant-numeric: tabular-nums; }
#projectedTotalsWrap .proj-row.leader { color: var(--gold); font-weight: 700; }

/* ============================ OYUN SONU ============================ */
#gameOverScreen {
  position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; padding: 20px 16px 16px;
  background: radial-gradient(110% 60% at 50% 12%, #2b5642, var(--bg) 70%);
}
.go-head { text-align: center; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; }
.go-kicker { font-size: 12px; letter-spacing: 0.18em; font-weight: 700; color: var(--gold); }
.go-title { font-size: 28px; font-weight: 800; }
.go-winner:empty { display: none; }
.go-winner {
  margin: 22px 0 14px; padding: 18px; border-radius: 18px; background: var(--gold); color: var(--gold-ink);
  display: flex; align-items: center; gap: 14px;
}
.go-win-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--gold-ink); color: var(--gold-soft); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; flex-shrink: 0; }
.go-win-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.go-win-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.go-win-name { font-size: 22px; font-weight: 800; overflow-wrap: anywhere; line-height: 1.1; }
.go-win-score { display: flex; flex-direction: column; align-items: flex-end; }
.go-win-score b { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.go-win-score span { font-size: 11px; font-weight: 600; }
.go-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.game-over-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg-2); }
.go-rank { width: 22px; font-size: 15px; font-weight: 800; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.go-name { flex: 1; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.go-diff { font-size: 12px; color: var(--muted-2); }
.go-total { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.go-note { font-size: 12px; color: var(--muted-2); text-align: center; padding: 8px 0; }
.go-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }

/* ============================ GÜNLÜK (geliştirici) ============================ */
#log {
  position: absolute; left: 8px; right: 8px; top: 56px; z-index: 30; max-height: 30%; overflow-y: auto;
  font-size: 10.5px; line-height: 1.35; background: rgba(0, 0, 0, 0.8); border-radius: 10px; padding: 6px 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5); pointer-events: auto;
}

/* ============================ DUYARLI AYARLAR ============================ */
/* Çok dar telefonlar (≤360px) */
@media (max-width: 360px) {
  #feltGrid { grid-template-columns: 58px minmax(0, 1fr) 58px; gap: 6px; padding: 8px 6px; }
  .corner-discard { width: 44px; height: 57px; }
  .corner-discard .tile { width: 32px; height: 44px; font-size: 18px; }
  .seat-avatar { width: 34px; height: 34px; font-size: 12px; }
  .ctrl-act { grid-template-columns: repeat(4, minmax(0, 1fr)) 64px; gap: 5px; }
  .action-buttons button { font-size: 11.5px; }
  .chip-btn { padding: 0 7px; font-size: 10px; }
}
/* Kısa ekranlar (ör. iPhone SE, klavye açıkken) */
@media (max-height: 700px) {
  #topBar { height: 46px; }
  #meBar { padding-top: 5px; }
  .big, .action-buttons button, .wait-box { height: 44px; }
  #controls { min-height: 58px; padding: 6px 10px 8px; }
  .corner-discard { width: 44px; height: 57px; }
  .corner-discard .tile { width: 32px; height: 44px; font-size: 18px; }
}
/* Yatay telefon: masa solda, istaka + kontroller sağda */
@media (orientation: landscape) and (max-height: 540px) {
  #appFrame { max-width: none; }
  #game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-rows: auto minmax(0, 1fr); }
  #topBar { grid-column: 1 / -1; height: 42px; }
  #felt { margin: 0 4px 6px 6px; }
  #feltGrid { grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 4px; padding: 6px; }
  .corner-discard { width: 40px; height: 52px; }
  .corner-discard .tile { width: 29px; height: 41px; font-size: 17px; }
  .seat-avatar { width: 30px; height: 30px; font-size: 11px; }
  .seat-tiles { display: none; }
  #handArea { justify-content: flex-end; min-height: 0; padding-bottom: 4px; }
  .big, .action-buttons button, .wait-box { height: 42px; }
}
/* Geniş ekran (tablet / PC): biraz daha ferah */
@media (min-width: 700px) and (min-height: 760px) {
  #appFrame { max-width: 760px; }
  #feltGrid { grid-template-columns: 90px minmax(0, 1fr) 90px; gap: 12px; padding: 14px 12px; }
  .corner-discard { width: 60px; height: 78px; }
  .corner-discard .tile { width: 44px; height: 62px; font-size: 26px; }
  .seat-avatar { width: 48px; height: 48px; font-size: 16px; }
  .seat-name { font-size: 14px; }
  .corner-label { max-width: 90px; font-size: 11px; }
  .meld-list.tier-lg .meld-group .tile { width: 34px; height: 48px; font-size: 22px; }
  .meld-list.tier-md .meld-group .tile { width: 28px; height: 40px; font-size: 18px; }
  .meld-list.tier-sm .meld-group .tile { width: 24px; height: 34px; font-size: 15px; }
  .meld-list.tier-xs .meld-group .tile { width: 20px; height: 28px; font-size: 12.5px; }
  .rack-row { gap: 4px; }
}

/* ============================ BOT DEVRALDI UYARISI ============================ */
#botTakeoverBanner {
  position: absolute; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 14px 0; background: rgba(0, 0, 0, 0.35); cursor: pointer;
}
.bt-card {
  display: flex; align-items: center; gap: 12px; max-width: 420px; padding: 14px 16px; border-radius: 16px;
  background: var(--gold); color: var(--gold-ink); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  animation: invite-pulse 1.4s ease-in-out infinite;
}
.bt-icon { font-size: 24px; }
.bt-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.3; }
.bt-text b { font-size: 15px; }

/* ============================ SESLİ SOHBET ============================ */
.mic-btn {
  position: relative; width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.18); background: var(--bg-2); color: var(--muted);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.mic-icon { width: 18px; height: 18px; fill: currentColor; }
.mic-slash {
  position: absolute; width: 22px; height: 2.5px; border-radius: 2px; background: var(--danger);
  transform: rotate(-45deg); box-shadow: 0 0 0 1.5px var(--bg-2);
}
.mic-btn.on { background: #1f9d6b; border-color: #56e0a8; color: #fff; box-shadow: 0 0 0 3px rgba(86, 224, 168, 0.25); }
.mic-btn.on .mic-slash { display: none; }
.mic-btn:active { transform: scale(0.94); }
/* Avatar göstergeleri: mikrofonu açık olana küçük 🎤 rozeti, konuşana yeşil halka */
.mic-badge {
  display: none; position: absolute; top: -4px; right: -6px; width: 17px; height: 17px; border-radius: 50%;
  background: #1f9d6b; font-size: 9px; line-height: 17px; text-align: center; box-shadow: 0 0 0 1.5px var(--bg);
}
.voice-mic-on .mic-badge { display: block; }
.me-avatar { position: relative; }
.seat-avatar.voice-speaking, .me-avatar.voice-speaking {
  box-shadow: 0 0 0 3px #56e0a8, 0 0 16px rgba(86, 224, 168, 0.85) !important;
  animation: voice-pulse 0.9s ease-in-out infinite;
}
@keyframes voice-pulse { 50% { box-shadow: 0 0 0 5px #56e0a8, 0 0 22px rgba(86, 224, 168, 0.6); } }
@media (max-width: 360px) { .mic-btn { width: 32px; height: 32px; } }

/* ============================ İZLEYİCİ MODU ============================ */
.ts-watch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 20px 18px; flex-shrink: 0; }
.ts-watch .outline-btn { width: 100%; max-width: 360px; }
.ts-watch-hint { font-size: 11.5px; color: var(--muted-2); text-align: center; max-width: 320px; line-height: 1.35; }

#spectatorStrip { display: flex; align-items: center; gap: 6px; padding: 0 10px 6px; flex-shrink: 0; min-width: 0; }
.spec-eye { font-size: 13px; opacity: 0.8; }
#spectatorList { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
#spectatorList::-webkit-scrollbar { display: none; }
.spec-chip { display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 2px; border-radius: 99px; background: var(--bg-2); flex-shrink: 0; }
.spec-chip .seat-avatar { width: 22px; height: 22px; font-size: 9px; background: #4b5a57; }
.spec-chip .mic-badge { width: 12px; height: 12px; font-size: 7px; line-height: 12px; top: -3px; right: -4px; }
.spec-chip span.spec-name { font-size: 11px; font-weight: 600; white-space: nowrap; color: #cfe0d6; }
.spec-chip.me span.spec-name { color: var(--gold-soft); }

#spectatorBar {
  flex-shrink: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'player ctrl' 'actions actions';
  gap: 10px; padding: 10px 12px 12px;
}
.spec-bottom-player { grid-area: player; display: flex; align-items: center; gap: 8px; min-width: 0; }
.spec-bottom-player.active-turn .seat-avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(239, 184, 74, 0.7); }
.spec-controls { grid-area: ctrl; display: flex; align-items: center; gap: 8px; }
.spec-badge { font-size: 11px; font-weight: 700; color: var(--gold-soft); background: rgba(239, 184, 74, 0.12); border: 1px solid rgba(239, 184, 74, 0.35); padding: 4px 8px; border-radius: 99px; white-space: nowrap; }
.spec-actions { grid-area: actions; display: flex; gap: 8px; }
.spec-actions .btn-primary { flex: 1.4; height: 46px; }
.spec-actions .soft-btn { flex: 1; height: 46px; }

/* İzleyicide: istaka/kişisel kontroller yok, bot çağırma yok */
#game.spectator #handArea { display: none; }
#game.spectator .invite-bot-btn { display: none; }
#game.spectator .wall-tile-back { cursor: default; }
#game.spectator #discardBottomLeft { box-shadow: none !important; border-color: rgba(255, 255, 255, 0.2) !important; }
#game.spectator .corner-label-gold { color: #cfe0d6; }
