/* ═══════════════════════════════════════════════════════════════════
   RA'VEN ULTIMATE — css/responsive-patch.css
   Mobil & Masaüstü Tam Uyumluluk Yaması
   v1.0.0
   
   Bu dosya main.css'den SONRA yüklenir.
   Tüm ekran taşma, kesme ve uyumluluk sorunlarını çözer.
   ═══════════════════════════════════════════════════════════════════ */

/* ============================================================
   GLOBAL OVERFLOW KORUMALARI
   ============================================================ */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* Tüm view section'lar ekrandan taşmasın */
.view-section {
  max-width: 100vw;
  overflow-x: hidden;
}

/* ============================================================
   HEADER — KÜÇÜK EKRAN OPTİMİZASYONU
   ============================================================ */

/* 360px ve altı: Header çok dar ekranlarda */
@media (max-width: 360px) {
  .app-header {
    padding-left: 8px;
    padding-right: 8px;
    gap: 6px;
  }

  .header-inner {
    gap: 4px;
  }

  .player-chip {
    padding: 4px 8px 4px 4px;
    gap: 4px;
  }

  .player-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .player-info {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .btn-primary {
    padding: 0 10px;
    height: 34px;
    font-size: 11px;
    gap: 3px;
  }

  .btn-primary span[aria-hidden="true"] {
    display: none;
  }
}

/* 400px: Player info gizle ama butonlar görünür kalsın */
@media (max-width: 400px) and (min-width: 361px) {
  .player-info {
    display: none;
  }
  
  .btn-primary {
    padding: 0 12px;
    font-size: var(--text-xs);
  }
}

/* ============================================================
   DASHBOARD — MODES GRID TAM RESPONSIVE
   ============================================================ */
@media (max-width: 340px) {
  .modes-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .mode-card {
    min-height: 160px;
  }
  
  .main-inner {
    padding: 16px 10px;
  }
}

@media (min-width: 341px) and (max-width: 479px) {
  .modes-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mode-card {
    min-height: 170px;
  }
}

@media (min-width: 480px) and (max-width: 599px) {
  .modes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .mode-card {
    min-height: 180px;
  }
}

/* Tablet dikey */
@media (min-width: 600px) and (max-width: 767px) {
  .modes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Tablet yatay / küçük laptop */
@media (min-width: 768px) and (max-width: 1023px) {
  .modes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* ============================================================
   STATS STRIP — YATAY KAYDIRMA KORUASI
   ============================================================ */
.stats-strip {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.stats-strip::-webkit-scrollbar {
  display: none;
}

@media (max-width: 400px) {
  .stats-strip {
    gap: 6px;
    padding: 0 2px;
  }
  
  .stat-item {
    min-width: 70px;
    flex-shrink: 0;
  }
}

/* ============================================================
   LOBİ — TAB VE İÇERİK OPTİMİZASYONU
   ============================================================ */
@media (max-width: 400px) {
  .lobby-wrapper {
    padding: 16px 10px 32px;
  }

  .lobby-tabs {
    gap: 0;
  }

  .lobby-tab {
    font-size: 11px;
    padding: 10px 8px;
  }

  .lobby-generate-row {
    flex-direction: column;
    gap: 8px;
  }
}

/* Lobby panel içerik: textarea ve butonlar taşmasın */
.lobby-panel {
  max-width: 100%;
  overflow-x: hidden;
}

.lobby-paste-textarea,
#lobby-paste-textarea {
  max-width: 100%;
  box-sizing: border-box;
}

/* ============================================================
   MODALLER — MOBİL TAM GENİŞLİK
   ============================================================ */
@media (max-width: 479px) {
  .modal-sheet {
    max-width: 100%;
    border-radius: var(--modal-radius) var(--modal-radius) 0 0;
    max-height: 95dvh;
    max-height: 95vh;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  .modal-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .modal-tabs::-webkit-scrollbar { display: none; }
}

/* Klan modalleri */
@media (max-width: 400px) {
  .clan-modal-box {
    width: calc(100% - 20px);
    margin: 10px;
    padding: 20px 16px;
    max-height: 90dvh;
    max-height: 90vh;
    overflow-y: auto;
  }

  .clan-modal-input {
    font-size: 16px; /* iOS zoom'u engellemek için */
  }
}

/* ============================================================
   OYUN MOTORU — GAME VIEW TAM EKRAN
   ============================================================ */
#view-game {
  height: calc(100dvh - var(--header-height));
  height: calc(100vh - var(--header-height));
}

/* Game card: metin taşması engeli */
.game-card {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Game options: küçük ekranlarda padding azalt */
@media (max-width: 400px) {
  .game-option {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
  }

  .game-question-text {
    font-size: 15px;
    line-height: 1.5;
  }

  .game-hud {
    gap: 4px;
    padding: 0 8px;
  }

  .game-nav-btn {
    padding: 0 10px;
    font-size: 12px;
    height: 34px;
  }
}

/* Game viewport scroll */
.game-viewport {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   SENARYO MODU — MOBİL UYUMLULUK
   ============================================================ */
@media (max-width: 479px) {
  #view-scenario {
    overflow-x: hidden;
  }

  .scenario-story-text {
    font-size: 14px;
    line-height: 1.65;
    padding: 12px;
  }

  .scenario-action-panel {
    padding: 10px;
  }

  .scenario-option-btn {
    font-size: 13px;
    padding: 10px 12px;
  }

  .scenario-history-panel {
    width: 85vw;
    max-width: 320px;
  }
}

/* ============================================================
   ARENA MODU — TAM EKRAN DÜZELTMESİ
   ============================================================ */
#view-arena {
  height: 100dvh;
  height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

@media (max-width: 479px) {
  #view-arena {
    touch-action: none;
  }
}

/* ============================================================
   CROSSWORD MODU — MOBİL BOARD SIĞDIRMA
   ============================================================ */
@media (max-width: 360px) {
  #view-crossword {
    --cw-tile-inner: 28px;
    --cw-tile-font: 12px;
    --cw-tray-btn: 32px;
    --cw-tray-font: 13px;
  }
}

#view-crossword .cw-board-section {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* ============================================================
   KLAN MERKEZI — MOBİL DÜZEN
   ============================================================ */
@media (max-width: 479px) {
  .clan-dashboard {
    padding: 12px 8px;
  }

  .clan-members-list {
    gap: 6px;
  }

  .clan-profile-name {
    max-width: 120px;
  }
}

/* ============================================================
   ANTRENMAN MODU
   ============================================================ */
@media (max-width: 479px) {
  #view-training {
    padding: 12px;
  }
}

/* ============================================================
   MODULE HUB — RESPONSIVE GRID
   ============================================================ */
@media (max-width: 400px) {
  .hub-modules-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hub-module-card {
    padding: 14px;
  }
}

@media (min-width: 401px) and (max-width: 599px) {
  .hub-modules-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* ============================================================
   INPUT ZOOM KORUMASI (iOS Safari)
   ============================================================ */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ============================================================
   LANDSCAPE MOBİL — GENEL DÜZEN
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header {
    --header-height: calc(48px + var(--safe-top));
  }

  .main-inner {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .dashboard-hero {
    margin-bottom: 12px;
  }

  .dashboard-hero-title {
    font-size: 1.4rem;
  }

  .modes-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .mode-card {
    min-height: 120px;
  }

  .mode-card-icon {
    font-size: 28px;
  }

  .mode-card-desc {
    display: none;
  }
}

/* ============================================================
   TABLET LANDSCAPE — GENİŞ EKRAN OPTİMİZASYONU
   ============================================================ */
@media (min-width: 1024px) and (max-width: 1366px) {
  .main-inner {
    max-width: 1200px;
  }

  .lobby-wrapper {
    max-width: 960px;
  }
}

@media (min-width: 1367px) {
  .main-inner {
    max-width: 1400px;
  }

  .modes-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

/* ============================================================
   SAFE AREA — NOTCH/ISLAND CİHAZLAR
   ============================================================ */
@supports (padding: max(0px)) {
  .app-header {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .main-inner {
    padding-left: max(clamp(12px, 4vw, 32px), env(safe-area-inset-left));
    padding-right: max(clamp(12px, 4vw, 32px), env(safe-area-inset-right));
  }

  .lobby-wrapper {
    padding-left: max(clamp(12px, 4vw, 32px), env(safe-area-inset-left));
    padding-right: max(clamp(12px, 4vw, 32px), env(safe-area-inset-right));
  }
}

/* ============================================================
   METIN TAŞMA KORUMALARI — GLOBAL
   ============================================================ */
.mode-card-title,
.mode-card-desc,
.player-name,
.lobby-module-name,
.hub-module-title,
.game-question-text,
.scenario-story-text {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* Uzun URL / kod gibi kırılmayan metinler için */
pre, code, .game-option, .scenario-option-btn {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ============================================================
   JETON MAĞAZASI — YENİ ÖDEME EKRANI STİLLERİ
   ============================================================ */
.token-shop-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-smooth);
}

.token-shop-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.token-shop-card {
  width: 100%;
  max-width: 420px;
  background: var(--modal-bg);
  border-radius: var(--modal-radius);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  max-height: 90dvh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(20px);
  transition: transform var(--duration-slow) var(--ease-spring);
}

.token-shop-overlay.active .token-shop-card {
  transform: scale(1) translateY(0);
}

.token-shop-header {
  padding: 20px;
  text-align: center;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-premium) 100%);
  color: white;
}

.token-shop-header h2 {
  font-size: var(--text-xl);
  font-weight: 800;
  font-family: var(--font-display);
  margin-bottom: 4px;
}

.token-shop-header p {
  font-size: var(--text-sm);
  opacity: 0.85;
}

.token-balance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--divider);
  font-family: var(--font-mono);
}

.token-balance-count {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-accent);
}

.token-balance-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.token-packages {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.token-package {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--card-radius);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-smooth);
}

.token-package:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.token-package.popular {
  border-color: var(--color-premium);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.04) 0%, rgba(37, 99, 235, 0.04) 100%);
}

.token-package-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  border-radius: 12px;
  flex-shrink: 0;
}

.token-package-info {
  flex: 1;
}

.token-package-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
}

.token-package-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.token-package-price {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-accent);
  white-space: nowrap;
}

.token-shop-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--divider);
  text-align: center;
}

.token-shop-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: var(--bg-sunken);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--btn-radius);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.token-shop-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Jeton bakiye göstergesi — header */
.token-hud {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-accent);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.token-hud:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

@media (max-width: 360px) {
  .token-hud {
    padding: 3px 7px;
    font-size: 10px;
  }
}

/* ============================================================
   PRINT STİLLERİ
   ============================================================ */
@media print {
  .app-header,
  .header-actions,
  .modal-overlay,
  .token-shop-overlay {
    display: none !important;
  }

  .app-main {
    padding-top: 0;
  }

  body {
    background: white;
    color: black;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   SCROLL FIX — En son yüklenen CSS olarak tüm override'ları geçersiz kılar
   ═══════════════════════════════════════════════════════════════════ */
html {
  height: 100% !important;
  overflow: hidden !important;
}
body {
  height: 100% !important;
  margin: 0 !important;
  overflow: hidden !important;
}
.app-shell {
  display: flex !important;
  flex-direction: column !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 0 !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
}
.app-main {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}
