/* =========================================================
   PERİŞAN OKEY - KAHVEHANE & KIRAATHANE TEMASI (CSS)
   ========================================================= */

:root {
  --felt-green: #0d4a2d;
  --felt-dark: #072a19;
  --felt-light: #16653e;
  --wood-dark: #2a160d;
  --wood-mid: #4a2916;
  --wood-light: #6e3e23;
  --wood-trim: #b8860b;
  --gold-glow: #ffd700;
  --tile-bg: #fcf9f2;
  --tile-shadow: rgba(0, 0, 0, 0.45);

  --color-red: #d32f2f;      /* Net Yakut Kırmızısı */
  --color-yellow: #f59e0b;   /* Canlı Altın Kehribar Sarısı (Kırmızıdan Belirgin Farklı) */
  --color-blue: #1565c0;     /* Kraliyet Mavisi */
  --color-black: #1e1e1e;    /* Mat Siyah */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #186e42 0%, #0d4a2d 50%, #062616 100%) !important;
  color: #fff;
  touch-action: none;
  margin: 0;
  padding: 0;
}

/* ================== OTOMATİK YATAY EKRAN & DÖNME MOTORU ================== */
.app-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* ================== DİKEY EKRAN UYARISI ================== */
.orientation-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999999;
  background: radial-gradient(circle at center, #186e42 0%, #0d4a2d 60%, #062616 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffd700;
  text-align: center;
  padding: 24px;
}

@media (orientation: portrait) {
  .orientation-warning {
    display: flex !important;
  }
}

@media (orientation: landscape) {
  .orientation-warning {
    display: none !important;
  }
}

.orientation-box {
  background: rgba(22, 12, 7, 0.95);
  border: 2px solid var(--wood-trim);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(184, 134, 11, 0.4);
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.phone-rotate-icon {
  font-size: 46px;
  animation: phoneRotateAnim 2s infinite ease-in-out;
  color: #ffd700;
}

@keyframes phoneRotateAnim {
  0% { transform: rotate(0deg); }
  35% { transform: rotate(-90deg); }
  65% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

.orientation-box h2 {
  font-size: 18px;
  font-weight: 800;
  color: #ffd700;
}

.orientation-box p {
  font-size: 13px;
  color: #e2cba6;
  line-height: 1.4;
}


/* ================== YUKARIDAN KAYAN BİLDİRİM BANNERI ================== */
.toast-banner {
  position: fixed;
  top: -70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 12, 7, 0.96);
  border: 1.5px solid var(--wood-trim);
  color: #ffd700;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8), 0 0 12px rgba(184, 134, 11, 0.5);
  z-index: 999999999;
  pointer-events: none;
  transition: top 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s;
  opacity: 0;
  white-space: nowrap;
}

.toast-banner.show {
  top: max(12px, env(safe-area-inset-top));
  opacity: 1;
}

/* ================== LOBİ EKRANI ================== */
.lobby-screen {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #186e42 0%, #0d4a2d 50%, #062616 100%);
  padding: 12px;
}

.lobby-card {
  width: 100%;
  max-width: 380px;
  background: rgba(30, 20, 15, 0.92);
  backdrop-filter: blur(12px);
  border: 2px solid var(--wood-trim);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  padding: 16px 20px;
  text-align: center;
  margin: auto;
}

.lobby-header h1 {
  font-size: 22px;
  color: #ffd700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 10px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 11px;
  color: #e2cba6;
  margin-bottom: 4px;
  font-weight: 600;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  background: rgba(10, 10, 10, 0.6);
  color: #fff;
  font-size: 13px;
  outline: none;
}

.name-suggestions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  align-items: center;
}

.name-suggestion-label {
  font-size: 10px;
  color: rgba(255, 215, 0, 0.7);
  font-weight: 600;
  margin-right: 2px;
}

.name-suggestion-badge {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.35);
  color: #ffd700;
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.name-suggestion-badge:hover,
.name-suggestion-badge:active {
  background: rgba(255, 215, 0, 0.35);
  border-color: #ffd700;
  transform: translateY(-1px);
}

.btn-primary {
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(135deg, #b8860b, #e6b800);
  border: none;
  border-radius: 10px;
  color: #1e1104;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.4);
  transition: transform 0.1s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.divider {
  display: flex;
  align-items: center;
  margin: 12px 0;
  color: #a08c75;
  font-size: 11px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.divider span {
  padding: 0 8px;
}

.btn-secondary {
  width: 100%;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ================== OYUN MASASI ================== */
.game-container {
  display: none;
  width: 100%;
  height: 100%;
  flex: 1;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, #186e42 0%, #0d4a2d 50%, #062616 100%) !important;
  position: relative;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

/* Üst Bilgi Barı */
.table-header {
  height: calc(38px + max(4px, env(safe-area-inset-top)));
  padding-top: max(4px, env(safe-area-inset-top));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(20, 12, 8, 0.92);
  border-bottom: 1px solid var(--wood-trim);
  z-index: 50;
  flex-shrink: 0;
  overflow: hidden;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 900px), (pointer: coarse) {
  #btn-fullscreen-game {
    font-size: 11px;
    padding: 3px 6px;
  }
}

.room-badge {
  background: rgba(184, 134, 11, 0.25);
  border: 1px solid var(--wood-trim);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  color: #ffd700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-badge, .multiplier-badge {
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-badge {
  background: rgba(255, 255, 255, 0.1);
}

.round-badge {
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  border: 1px solid #81c784;
  color: #fff;
}

.multiplier-badge {
  background: #c62828;
  color: #fff;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.btn-leave {
  background: rgba(198, 40, 40, 0.28) !important;
  border-color: rgba(239, 83, 80, 0.45) !important;
  color: #ffcdd2 !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.btn-leave:active {
  background: rgba(198, 40, 40, 0.55) !important;
}

/* ================== MASA ORTA ALANI ================== */
.table-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible !important;
}

.center-table-display {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  display: none !important; /* Oyun başlamadan önce gizli, otur butonuyla çakışmaz */
  align-items: center !important;
  justify-content: center !important;
  gap: 16px !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  z-index: 10;
}

.game-playing .center-table-display {
  display: flex !important;
}

.center-table-display,
.center-table-display * {
  outline: none !important;
}

.indicator-tile-slot,
#indicator-tile-slot {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  transition: transform 0.15s;
}

.indicator-tile-slot.drag-target-hover {
  transform: scale(1.15);
  filter: drop-shadow(0 0 12px #ffd700);
}

.deck-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.deck-tile-visual {
  width: 32px !important;
  height: 46px !important;
  background: linear-gradient(135deg, #ffffff 0%, #f7f3ec 100%) !important;
  border-radius: 5px !important;
  border: 1px solid #d4c5a9 !important;
  box-shadow: 1px 2px 3px var(--tile-shadow), inset 0 1px 1px #fff, inset 0 -1.5px 2px rgba(0, 0, 0, 0.15) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab !important;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.deck-number-on-tile {
  font-size: 19px;
  font-weight: 900;
  color: #212121;
  transform: translateY(-2px);
  pointer-events: none;
}

/* ================== OYUNCU KOLTUKLARI ================== */
.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.seat-top {
  top: max(4px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

/* Sol Oyuncu Sola Yatık (-90 derece dikey) - Kenara yaslı, sadece çentik payı kadar içeri */
.seat-left {
  left: calc(-26px + env(safe-area-inset-left, 0px));
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center center;
  align-items: center;
}

/* Sağ Oyuncu Sağa Yatık (90 derece dikey) - Kenara yaslı, sadece çentik payı kadar içeri */
.seat-right {
  right: calc(-26px + env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  transform-origin: center center;
  align-items: center;
}

/* Tüm oyuncu kutuları aynı tip, koyu arka planlı ve yuvarlatılmış köşeli */
.seat-player-card {
  border-radius: 8px;
  background: rgba(20, 10, 5, 0.94);
  border: 1.5px solid rgba(255, 215, 0, 0.4);
  padding: 3px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  transition: border-color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.seat.active-turn .seat-player-card {
  border-color: #ffd700;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.8);
}

/* Boş Koltuk Görünümü - Sadece Otur ve Bot Butonları */
.seat-empty .seat-info,
.seat-empty .seat-avatar {
  display: none !important;
}

.seat-empty .seat-player-card {
  padding: 3px 5px !important;
  background: rgba(18, 9, 4, 0.82) !important;
  border: 1px dashed rgba(255, 215, 0, 0.35) !important;
  box-shadow: none !important;
}

.seat-empty .seat-actions {
  margin-left: 0 !important;
}

.seat-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3e2723;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffd700;
  flex-shrink: 0;
}

.seat-info {
  display: flex;
  flex-direction: column;
}

.seat-name {
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-score {
  font-size: 9px;
  color: #ff9800;
  font-weight: 600;
}

/* Koltuk İçi Aksiyon Butonları (Otur / Bot) - Kartın içine gömülü */
.seat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.btn-seat-sit {
  background: linear-gradient(135deg, #ffd700, #ffb300);
  border: 1px solid #ffd700;
  color: #1a0e03;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  margin: 0;
  line-height: 1.3;
}

.btn-seat-sit:active {
  transform: scale(0.95);
}

.btn-add-bot {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #eee;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
  line-height: 1.3;
}

.btn-add-bot:active {
  transform: scale(0.95);
}

/* Rakip Oyuncu Süre Barı */
.seat-timer-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
  display: none;
  border: 0.5px solid rgba(255, 215, 0, 0.3);
}

.seat.active-turn .seat-timer-bar {
  display: block;
}

.seat-timer-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ff9800);
  transition: width 0.1s linear;
}

/* Masa İçi Atılan Taş Tablaları */
.table-discard {
  position: absolute;
  width: 32px;
  height: 46px;
  box-sizing: border-box;
  border: 1px dashed rgba(255, 215, 0, 0.35);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: transform 0.15s;
}

.table-discard.has-tile,
.table-discard:has(.okey-tile) {
  border: none !important;
  background: transparent !important;
}

.discard-top {
  top: max(10px, env(safe-area-inset-top));
  left: calc(50% - 265px);
}

.discard-right-player {
  top: max(10px, env(safe-area-inset-top));
  left: auto;
  right: calc(50% - 265px);
}

.mini-discard-hint {
  font-size: 8px;
  font-weight: 800;
  color: rgba(255, 215, 0, 0.5);
  pointer-events: none;
  letter-spacing: 0.5px;
}

/* ================== OKEY TAŞLARI (TILES) ================== */
.okey-tile {
  width: 32px;
  height: 46px;
  background: linear-gradient(135deg, #fffdfa 0%, #f6edd9 100%);
  border-radius: 5px;
  box-shadow: 1px 2px 3px var(--tile-shadow), inset 0 1px 1px rgba(255, 255, 255, 0.9), inset 0 -1.5px 2px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}

.okey-tile:active {
  cursor: grabbing;
}

.okey-tile.selected {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6), 0 0 10px #ffd700;
  border: 2px solid #ffd700;
}

/* Ters Çevrilmiş Taş Görünümü - Düz Beyaz / Sade Melamin Sırtı */
.okey-tile.is-flipped {
  background: linear-gradient(135deg, #ffffff 0%, #f7f3ec 100%) !important;
  border: 1px solid #d4c5a9 !important;
  box-shadow: 1px 2px 3px var(--tile-shadow), inset 0 1px 1px #fff, inset 0 -1.5px 2px rgba(0, 0, 0, 0.15) !important;
}

.okey-tile.is-flipped .tile-number,
.okey-tile.is-flipped .tile-dot,
.okey-tile.is-flipped .fake-icon,
.okey-tile.is-flipped .fake-star-icon,
.okey-tile.is-flipped::after,
.okey-tile.is-flipped::before {
  display: none !important;
  content: none !important;
}

/* Sayılar Bir Tık Yukarıda */
.tile-number {
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-3.5px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

/* Çukur Efektli Nokta (Gömülü / Oyuk Çözünümü) */
.tile-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 1px;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.85), inset -1px -1px 1px rgba(255, 255, 255, 0.45), 0 1px 1px rgba(255, 255, 255, 0.7);
  border: 0.5px solid rgba(0, 0, 0, 0.2);
}

.tile-red .tile-number { color: var(--color-red); }
.tile-red .tile-dot { background-color: var(--color-red); }

.tile-yellow .tile-number { color: var(--color-yellow); }
.tile-yellow .tile-dot { background-color: var(--color-yellow); }

.tile-blue .tile-number { color: var(--color-blue); }
.tile-blue .tile-dot { background-color: var(--color-blue); }

.tile-black .tile-number { color: var(--color-black); }
.tile-black .tile-dot { background-color: var(--color-black); }

.tile-fake {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tile-emblem {
  font-size: 21px;
  line-height: 1;
  transform: translateY(-2.5px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
  pointer-events: none;
  font-family: serif;
}

.tile-red .tile-emblem { color: var(--color-red); }
.tile-yellow .tile-emblem { color: var(--color-yellow); }
.tile-blue .tile-emblem { color: var(--color-blue); }
.tile-black .tile-emblem { color: var(--color-black); }

.tile-real-okey {
  position: relative;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.95), inset 0 0 5px rgba(255, 215, 0, 0.6) !important;
  border: 2px solid #ffd700 !important;
}

.tile-real-okey::after {
  content: '★';
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 10px;
  line-height: 1;
  color: #e6a100;
  text-shadow: 0 0 3px rgba(255, 215, 0, 0.95);
  pointer-events: none;
  z-index: 5;
}

.tile-real-okey.is-flipped {
  box-shadow: 1px 2px 3px var(--tile-shadow), inset 0 1px 1px #fff, inset 0 -1.5px 2px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid #d4c5a9 !important;
}

.tile-real-okey.is-flipped::after {
  display: none !important;
  content: none !important;
}

.tile-dragging {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* ================== ISTAKA VE YAN TABLALAR ================== */
.bottom-rack-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, transparent 0%, rgba(20, 10, 5, 0.85) 30%, #150a04 100%);
  padding: 2px 8px max(6px, env(safe-area-inset-bottom, 6px)) 8px;
  margin-bottom: 0;
  z-index: 40;
  flex-shrink: 0;
}

/* Kendi Sıra Süremiz Barı */
.rack-timer-bar {
  width: 100%;
  max-width: 530px;
  height: 5px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
  opacity: 0;
  transition: opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.rack-timer-bar.active {
  opacity: 1;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

.rack-timer-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ff9800);
  transition: width 0.1s linear;
}

.rack-dock-wrapper {
  position: relative;
  width: auto;
  max-width: calc(100vw - 10px);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
}

.rack-center-wrapper {
  position: relative;
  width: 530px;
  max-width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* Istaka ile Aynı Yükseklikte Hızlı Dizici Düğmeler (Çift Diz & Seri Diz) */
.sort-tile-btn {
  width: 34px;
  height: auto;
  align-self: stretch;
  box-sizing: border-box;
  background: linear-gradient(180deg, #442414 0%, #2f170b 50%, #1f0d04 100%);
  border: 2px solid #734325;
  border-top-color: #8c522f;
  border-bottom-color: #1a0c05;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffd700;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  flex-shrink: 0;
  padding: 4px 2px;
}

.sort-tile-btn:hover {
  border-color: #ffd700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 0 0 12px rgba(255, 215, 0, 0.45);
}

.sort-tile-btn:active {
  transform: scale(0.97);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.9);
  background: linear-gradient(180deg, #281206 0%, #1b0a02 100%);
}

.sort-tile-btn span {
  pointer-events: none;
  letter-spacing: 0.6px;
}

.docked-discard {
  position: absolute;
  bottom: calc(100% + 12px);
  width: 32px;
  height: 46px;
  box-sizing: border-box;
  border: 1px dashed rgba(255, 215, 0, 0.35);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
  z-index: 30;
}

/* Soldaki taşın solu ıstakanın soluyla hizalı, ıstakanın üstünde */
.docked-left {
  left: 0;
}

/* Sağdaki taşın sağı ıstakanın sağıyla hizalı, ıstakanın üstünde */
.docked-right {
  right: 0;
}

.docked-discard.has-tile,
.docked-discard:has(.okey-tile) {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

.docked-discard.drag-target-hover {
  transform: scale(1.1);
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.25);
}

.dock-hint {
  font-size: 7.5px;
  font-weight: 800;
  color: #ffd700;
  text-align: center;
  line-height: 1.1;
  pointer-events: none;
  opacity: 0.8;
}

/* 2 Sıralı Ahşap Istaka (Birbirine Yapışık Slotlar - Kesikli Çizgisiz) */
.wooden-rack {
  width: 530px;
  max-width: 100%;
  flex-shrink: 0;
  background: linear-gradient(180deg, #5b331b 0%, #3e2110 50%, #281408 100%);
  border: 2px solid #734325;
  border-top-color: #8c522f;
  border-bottom-color: #1a0c05;
  border-radius: 8px;
  padding: 2px 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rack-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  background: rgba(15, 7, 3, 0.65);
  border-radius: 5px;
  padding: 1px 2px;
  min-height: 48px;
  gap: 1px; /* Birbirine yapışık taşlar */
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.rack-slot {
  width: 33px;
  height: 47px;
  flex: 0 0 33px;
  border-radius: 4px;
  border: none !important; /* Kesikli çizgiler kaldırıldı */
  background: rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.rack-slot.drag-over {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
}

.touch-drag-ghost,
.touch-drag-ghost * {
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.touch-drag-ghost {
  position: fixed !important;
  z-index: 99999999 !important;
  transform: translate(-50%, -50%) rotate(var(--stage-rotation, 0deg)) scale(1.15) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.9), 0 2px 8px rgba(0, 0, 0, 0.6) !important;
  border-radius: 6px !important;
  opacity: 0.96 !important;
}

.touch-drag-ghost.group-drag-ghost,
.group-drag-ghost {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 2px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: rotate(var(--stage-rotation, 0deg)) !important;
  transform-origin: 0 0 !important;
  filter: none !important;
}

.group-drag-ghost .okey-tile {
  margin: 0 !important;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.5) !important;
}

/* ================== CANLI SOHBET ÇEKMECESİ ================== */
.chat-drawer {
  position: fixed;
  top: 40px;
  right: -320px;
  width: 290px;
  max-width: 92vw;
  bottom: 0;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  background: rgba(25, 15, 10, 0.98);
  border-left: 2px solid var(--wood-trim);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.chat-drawer.open {
  right: 0;
}

/* Sohbet butonu okunmamış mesaj animasyonu */
#btn-chat-toggle.has-unread {
  position: relative;
  border-color: #ffd700 !important;
  color: #ffd700 !important;
  animation: chatPulse 1.2s infinite;
}

#btn-chat-toggle.has-unread::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  background: #ff3b30;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 6px #ff3b30;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4); }
  50% { box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.75); }
}

/* Canlı Masa İçi Sohbet Bildirim Hapı (Drawer kapalıyken bile anında görünür) */
.chat-floating-toast {
  position: absolute;
  top: calc(42px + max(4px, env(safe-area-inset-top)));
  left: 50%;
  transform: translateX(-50%) translateY(-25px) scale(0.9);
  background: rgba(22, 11, 5, 0.96);
  border: 1.5px solid #ffd700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.85), 0 0 12px rgba(255, 215, 0, 0.4);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11.5px;
  color: #fff;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  white-space: nowrap;
  max-width: 85vw;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-floating-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.chat-floating-toast .toast-sender {
  font-weight: 800;
  color: #ffd700;
  flex-shrink: 0;
}

.chat-floating-toast .toast-text {
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobil sanal klavye açıldığında sohbet çekmecesinin davranışı */
.chat-drawer.keyboard-open {
  transition: none !important;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.9) !important;
  position: fixed !important;
  z-index: 99999 !important;
}

.chat-drawer.keyboard-open .quick-replies-grid {
  display: none !important;
}

.chat-drawer.keyboard-open .chat-messages {
  flex: 1 1 0px !important;
  min-height: 20px !important;
  padding: 4px 8px !important;
}

.chat-drawer.keyboard-open .chat-header {
  padding: 4px 10px !important;
  font-size: 11px !important;
  height: 26px !important;
  min-height: 26px !important;
}

.chat-drawer.keyboard-open .chat-input-area {
  padding: 4px 6px !important;
  background: #140903 !important;
  border-top: 2px solid #ffd700 !important;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.9) !important;
  flex-shrink: 0 !important;
  position: relative !important;
  z-index: 20 !important;
}

.chat-drawer.keyboard-open .chat-input-area input {
  padding: 4px 8px !important;
  font-size: 14px !important;
}

.chat-drawer.keyboard-open .chat-input-area button {
  padding: 4px 10px !important;
  font-size: 11px !important;
}

.chat-header {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffd700;
  font-weight: bold;
  font-size: 13px;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1 1 0px;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.chat-msg {
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
}

.chat-msg .sender {
  font-weight: bold;
  color: #ffd700;
  margin-right: 4px;
}

.chat-msg.quick-phrase {
  background: rgba(184, 134, 11, 0.2);
  border-left: 2.5px solid #ffd700;
  font-style: italic;
}

.quick-replies-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.btn-quick {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0d0b8;
  padding: 5px;
  border-radius: 5px;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-input-area {
  padding: 8px;
  display: flex;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 6px;
  padding: 6px 8px;
  color: #fff;
  font-size: 16px; /* Mobil tarayıcılarda istenmeyen otomatik zoom'u engeller */
  outline: none;
  box-sizing: border-box;
}

.chat-input-area button {
  background: #b8860b;
  border: none;
  color: #1a0e03;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ================== TUR BİTİŞ & CEZA MODALI ================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 14px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  max-height: 94vh;
  overflow: hidden;
  background: #2a160d;
  border: 2px solid #b8860b;
  border-radius: 14px;
  padding: 12px 16px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.95);
}

.compact-end-card {
  max-width: 520px;
  background: linear-gradient(145deg, #24140b 0%, #150a05 100%);
  border: 1.5px solid #d4af37;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.compact-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  text-align: left;
}

.modal-titles-col {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffd700;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-subtitle {
  font-size: 11px;
  color: #ccc;
  margin: 2px 0 0 0;
  line-height: 1.2;
}

.modal-countdown-box {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 215, 0, 0.45);
  padding: 3px 8px;
  border-radius: 16px;
  font-size: 11px;
  color: #ffd700;
  white-space: nowrap;
  font-weight: bold;
  flex-shrink: 0;
}

.modal-countdown-box #countdown-seconds {
  font-size: 13px;
  color: #ffeb3b;
  font-weight: 900;
}

.modal-rounds-strip {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  margin-bottom: 6px;
  padding-bottom: 2px;
}

.round-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ddd;
  white-space: nowrap;
  flex-shrink: 0;
}

.round-chip.current {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.22);
  color: #ffd700;
  font-weight: bold;
}

.compact-penalty-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 11px;
}

.compact-penalty-table th, .compact-penalty-table td {
  padding: 5px 6px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  line-height: 1.2;
}

.compact-penalty-table th {
  color: #ffd700;
  font-size: 10px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.compact-penalty-table th:first-child, .compact-penalty-table td:first-child {
  text-align: left;
  font-weight: 700;
}

.compact-penalty-table tr.winner-row {
  background: rgba(76, 175, 80, 0.16);
}

.score-cell-minus {
  color: #69f0ae;
  font-weight: 800;
}

.score-cell-penalty {
  color: #ff5252;
  font-weight: 800;
}

.score-cell-total {
  color: #fff;
  font-weight: 800;
}

.modal-footer-compact {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
}

/* ================== ALT OYUNCU (SİZ) VE SOHBET BALONLARI ================== */
.seat-bottom {
  position: relative !important;
  margin: 0 auto 4px auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 25;
}

.seat-bottom .seat-player-card {
  border-radius: 8px;
  background: rgba(20, 10, 5, 0.94);
  border: 1.5px solid rgba(255, 215, 0, 0.55);
  padding: 2px 12px;
}

.seat-anchor-wrapper {
  position: relative;
  display: inline-block;
}

.speech-bubble-anchor {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 100;
  display: flex;
  justify-content: center;
}

/* Üst koltuğun konuşma balonu kartın altına (masaya) doğru açılsın */
#seat-top .speech-bubble-anchor {
  top: calc(100% + 4px) !important;
  bottom: auto !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
}

#seat-top .chat-speech-bubble {
  position: relative !important;
  bottom: auto !important;
  top: 0 !important;
}

#seat-top .chat-speech-bubble::after {
  bottom: auto !important;
  top: -6px !important;
  border-width: 0 6px 6px !important;
  border-color: transparent transparent #ffffff transparent !important;
}

/* Yan koltukların konuşma balonları içeri (masaya) doğru açılsın ve düz dursun */
#seat-left .speech-bubble-anchor {
  top: 50% !important;
  left: 100% !important;
  transform: translateY(-50%) !important;
  justify-content: flex-start !important;
  margin-left: 10px !important;
}

#seat-left .chat-speech-bubble {
  position: relative !important;
  bottom: auto !important;
  left: 0 !important;
  transform: rotate(90deg) !important;
  transform-origin: left center !important;
}

#seat-left .chat-speech-bubble::after {
  top: 50% !important;
  bottom: auto !important;
  left: -6px !important;
  transform: translateY(-50%) !important;
  border-width: 6px 6px 6px 0 !important;
  border-color: transparent #ffffff transparent transparent !important;
}

#seat-right .speech-bubble-anchor {
  top: 50% !important;
  left: auto !important;
  right: 100% !important;
  transform: translateY(-50%) !important;
  justify-content: flex-end !important;
  margin-right: 10px !important;
}

#seat-right .chat-speech-bubble {
  position: relative !important;
  bottom: auto !important;
  right: 0 !important;
  transform: rotate(-90deg) !important;
  transform-origin: right center !important;
}

#seat-right .chat-speech-bubble::after {
  top: 50% !important;
  bottom: auto !important;
  left: auto !important;
  right: -6px !important;
  transform: translateY(-50%) !important;
  border-width: 6px 0 6px 6px !important;
  border-color: transparent transparent transparent #ffffff !important;
}

/* Konuşma Balonu */
.chat-speech-bubble {
  position: absolute;
  bottom: 8px;
  background: #ffffff;
  color: #1a1a1a;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.1);
  animation: speechPopIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
  z-index: 999;
}

.chat-speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #ffffff transparent transparent;
  display: block;
  width: 0;
}

@keyframes speechPopIn {
  0% { transform: scale(0.6) translateY(8px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes speechFadeOut {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.8) translateY(-6px); opacity: 0; }
}

/* Rakip Oyuncu Taş Çekme / Atma Uçan Taş Animasyonu */
.flying-tile-animation {
  position: fixed;
  z-index: 99999;
  width: 32px;
  height: 46px;
  border-radius: 5px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75);
  transition: all 0.38s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Per Grubu Taşıma */
.rack-slot.group-selected {
  outline: none !important;
  background: transparent !important;
}

.rack-slot.group-selected .okey-tile {
  transform: none !important;
  filter: none !important;
}

