/* === TT FULLSCREEN (BAŞLANGIÇ) =============================================
   Bu blok tools/apply-webview-fullscreen.py tarafından files/main.css başına
   eklenir. Elle düzenlenecekse tools/c3-fullscreen.css güncellenip
   `python tools/apply-webview-fullscreen.py` yeniden çalıştırılmalıdır.

   Canvas'ın WebView'ın tamamını kaplaması için sayfa seviyesindeki her şey
   kapatılır: kenar boşluğu, kaydırma çubuğu, overscroll bounce, seçim ve
   dokunma vurgusu. `dvh` adres çubuğu açılıp kapanırken bile sayfanın gerçek
   yüksekliğini verir; `100%` ve `svh` eski WebView'lar için yedektir.
============================================================================ */

html, body {
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  touch-action: none;
  outline: none;
  /* Ortalama: "scale outer" modunda canvas zaten pencere kadar olduğu için
     bu genelde etkisizdir; canvas pencereden küçük kalırsa sağa sola yaslanmak
     yerine ortada durur. Kalan piksel farkı scripts/main.js içindeki
     ttCenterCanvas() ile ölçülüp düzeltilir. */
  margin: auto;
}

/* --------------------------------------------------------------- portrait
   Oyunlar yalnızca dik oynanır. Ekran kilidi WebView'ların çoğunda kabul
   edilmediği için yatay çevrildiğinde oyunun üstü bu uyarıyla kapatılır.
   `pointer: coarse` + `hover: none` koşulu sayesinde masaüstü tarayıcıda ve
   Construct önizlemesinde asla görünmez. */

#tt-rotate-notice {
  display: none;
}

@media (orientation: landscape) and (pointer: coarse) and (hover: none) {
  #tt-rotate-notice {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;

    padding: calc(20px + env(safe-area-inset-top, 0px))
             calc(20px + env(safe-area-inset-right, 0px))
             calc(20px + env(safe-area-inset-bottom, 0px))
             calc(20px + env(safe-area-inset-left, 0px));

    background: #000;
    color: #fff;
    font-family: 'Mulish', sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;

    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  #tt-rotate-notice svg {
    width: 76px;
    height: 76px;
    animation: tt-rotate-hint 2.4s ease-in-out infinite;
  }

  #tt-rotate-notice p {
    margin: 0;
  }
}

@keyframes tt-rotate-hint {
  0%, 55%, 100% { transform: rotate(0deg); }
  25%, 40%      { transform: rotate(-90deg); }
}

/* === TT FULLSCREEN (BİTİŞ) ================================================ */

/* ================================
   FONTS
================================ */

@font-face {
  font-family: 'Mulish';
  src: url('../assets/fonts/Mulish-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Mulish';
  src: url('../assets/fonts/Mulish-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Mulish';
  src: url('../assets/fonts/Mulish-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Mulish';
  src: url('../assets/fonts/Mulish-Black.woff') format('woff');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}


/* ================================
   GLOBAL
================================ */

html, body {
  font-family: 'Mulish', sans-serif !important;
  margin: 0;
  padding: 0;
}


/* ==========================================================================
   LİDERLİK TABLOSU

   ÖLÇÜLER TASARIM PİKSELİ. Tablo DOM katmanında (#tt-dom) 1080 birimlik
   tasarım genişliğinde çizilip ekrana ölçekleniyor (375 px'lik telefonda
   ~0,35). Eskiden satırlar gerçek CSS pikseliyle ve ekran genişliğine bakan
   media query'lerle ölçülüyordu; ölçek bir kez daha uygulanınca yazılar
   telefonda ~4 px kalıyordu. Artık her şey tasarım biriminde: satır
   112 birim (~39 px), yazı 40 birim (~14 px) ve ekranla orantılı büyüyor —
   media query'ye gerek yok.
========================================================================== */

/* ================================
   TABLE CONTAINER
================================ */

.table-container {
  position: relative;
  width: 100%;
  height: 100%;
  /* Yukseklik sinirini kapsayici veriyor: liste tasarim biriminde olculuyor ve
     uzun ekranlarda ekranin altina kadar uzuyor (bkz. LeaderboardScene.fitTable).
     Kaydirma ICERIDEKI .table-scroll'da: dis kutu kaydirilinca satirlar
     kutunun ic boslugunda da gorunuyor, yapiskan satirin altinda ince bir
     mavi serit kaliyordu. Artik bosluk her kenarda bos kalir. */
  overflow: hidden;
  background: #00000050;
  padding: 18px;
  border-radius: 28px;
  box-sizing: border-box;
}

.table-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.table-scroll::-webkit-scrollbar {
  width: 0;
}


/* ================================
   TABLE BASE
================================ */

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.leaderboard-results {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.leaderboard-results thead {
  display: none;
}


/* ================================
   ROW (TR)
================================ */

.leaderboard-results tr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;

  background: linear-gradient(180deg, #15a2e0 0%, #0a85db 100%);
  color: #fff;

  border-radius: 30px;

  margin: 0 0 16px 0;
  padding: 12px 22px 12px 12px;
  min-height: 112px;

  font-size: 40px;
  font-weight: 700;

  box-shadow:
    inset 0 6px 0 rgba(255, 255, 255, 0.1),   /* bevel üst */
    inset 0 -6px 0 rgba(0, 0, 0, 0.1),        /* bevel alt */
    0 8px 12px rgba(0, 0, 0, 0.25);           /* alt drop shadow */
}


/* ================================
   CELL (TD)
================================ */

.leaderboard-results td {
  display: flex;
  align-items: center;
  justify-content: center;

  padding: 8px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  min-width: 0;
  line-height: 1.2;
}


/* ================================
   COLUMN SETTINGS
================================ */

/* Sıra: koyu hap, sabit genişlik — 3 haneye kadar sığar. */
#rankings td:nth-child(1) {
  flex: 0 0 132px;
  height: 84px;
  padding: 0;
  box-sizing: border-box;

  background: #00000040;
  color: #fff;
  border-radius: 20px;
  font-size: 38px;
}

/* İsim: kalan alan; uzun isim üç noktayla kısalır. */
#rankings td:nth-child(2) {
  flex: 1 1 auto;
  justify-content: flex-start;
  padding-left: 26px;
}

/* Skor: sağa yaslı, içeriği kadar. */
#rankings td:nth-child(3) {
  flex: 0 0 auto;
  max-width: 34%;
  justify-content: flex-end;
}


/* ================================
   SCORE CELL
================================ */

.score_cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.score_icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
}


/* ================================
   USER STATES
================================ */

#user-rank-selected {
  border: 4px solid #ffffff;
  background: linear-gradient(180deg, #16defd 0%, #01b2cb 100%);
}

#user-rank-sticky {
  position: sticky;
  bottom: 0;
  z-index: 999;
  /* Kutunun alt boslugu yeterli; satirin kendi alt payi yapiskan satiri
     kaydirma alaninin kenarindan yukari itmesin. */
  margin-bottom: 0;

  border: 4px solid #ffffff;
  background: linear-gradient(180deg, #16defd 0%, #01b2cb 100%);
  font-weight: 900;
}


/* ================================
   BOŞ LİSTE
   Tablo boşsa kutunun tam ortasında (bkz. leaderboard-dom.ts setEmpty).
================================ */

.lb-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;

  color: #ffffff;
  font-weight: 700;
  font-size: 48px;   /* tasarım pikseli: 375 px genişlikte ~17 px */
  text-align: center;

  pointer-events: none;
}


/* ================================
   SKELETON (yükleniyor)
   Satırlar gerçek kayıtlarla BİREBİR aynı: aynı arka plan, yükseklik ve sıra
   hücresi — yalnız yazıların yerinde parlayan çubuklar var. Kayıt yoksa hiç
   çizilmez (bkz. LeaderboardScene.updateLeaderboard).
================================ */

.lb-skeleton .sk {
  display: block;
  /* Gerçek satırdaki yazının satır yüksekliği (line-height 1.2): satır
     yüksekliği kayıtlarla aynı kalır. */
  height: 1.2em;
  border-radius: 999px;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.36) 50%,
    rgba(255, 255, 255, 0.14) 100%);
  background-size: 200% 100%;
  animation: lb-shimmer 1.2s linear infinite;
}

.lb-skeleton .sk-rank  { width: 60%; }
.lb-skeleton .sk-name  { width: 70%; }
.lb-skeleton .sk-score { width: 180px; }

@keyframes lb-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .lb-skeleton .sk { animation: none; }
}
