:root {
  --bg-dark: #07090e;
  --bg-card: rgba(18, 24, 38, 0.94);
  --accent-gold: #f59e0b;
  --accent-red: #ef4444;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --border-glow: rgba(245, 158, 11, 0.35);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: fixed;
  inset: 0;
}

/* ================= 1. 3D DÜNYA LOBİSİ ================= */
#globe-lobby {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, #0c1424 0%, #03060a 100%);
  z-index: 50;
  overflow: hidden;
}

#three-canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.globe-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: linear-gradient(180deg, rgba(7, 9, 14, 0.95) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 60;
}

.lobby-brand h1 {
  font-family: 'Bungee', cursive;
  font-size: 1.05rem;
  letter-spacing: 0.8px;
  background: linear-gradient(to right, #fff, #fef08a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-live {
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 2px;
}

.lobby-center-tip {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.3);
  backdrop-filter: blur(8px);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lobby-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-lang-pill {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.btn-return-portal {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 16px;
}

/* Hologram Bilgi Kartı */
.hologram-card {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 320px;
  max-width: calc(100vw - 30px);
  background: rgba(11, 16, 26, 0.95);
  backdrop-filter: blur(14px);
  border: 2px solid var(--accent-cyan);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: 0 10px 40px rgba(6, 182, 212, 0.35);
  z-index: 60;
}

.holo-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
}

.holo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.holo-flag-img {
  width: 52px;
  height: 35px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--accent-gold);
}

.holo-header h2 {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.45rem;
  color: #fff;
}

.holo-tag {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent-gold);
}

.input-player-name {
  margin-bottom: 10px;
}

.input-player-name label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.input-player-name input {
  width: 100%;
  padding: 8px 12px;
  background: #090e18;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.btn-warp-enter {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* ================= 2. CANLI SAVAŞ ARENASI ================= */
#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  background: #070a10;
  position: relative;
  overflow: hidden;
}

#game-header {
  height: 48px;
  background: rgba(11, 15, 24, 0.96);
  border-bottom: 2px solid #1f293d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.8rem;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-indicator-pill {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 800;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-block;
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.5px;
}

.btn-back-portal {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.game-title {
  font-family: 'Bungee', cursive;
  font-size: 0.9rem;
  color: #fff;
}

.header-center {
  flex: 1;
  max-width: 320px;
  margin: 0 0.8rem;
}

.race-progress-bar {
  position: relative;
  background: #0f172a;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #334155;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4, #f59e0b);
  transition: width 0.1s linear;
}

.progress-lbl {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.army-status-pill {
  background: #141b2a;
  border: 1.5px solid var(--accent-cyan);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
}

.army-status-pill.danger {
  border-color: #ef4444;
  color: #f87171;
  animation: pulseRed 0.4s ease-in-out;
}

@keyframes pulseRed {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); background: #7f1d1d; }
  100% { transform: scale(1); }
}

.btn-icon {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  font-size: 0.95rem;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
}

#canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #070a10;
  width: 100%;
  height: calc(100% - 48px);
}

#race-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Kulvar Etiketleri */
.lane-overlay {
  position: absolute;
  top: 0;
  left: 8px;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  z-index: 10;
}

.lane-tag {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  padding: 2px 7px;
  border-radius: 5px;
  backdrop-filter: blur(4px);
  width: max-content;
}

.lane-tag.top {
  background: rgba(14, 165, 233, 0.25);
  border: 1px solid #0ea5e9;
  color: #38bdf8;
}

.lane-tag.mid {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #f87171;
}

.lane-tag.bottom {
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid #f59e0b;
  color: #fbbf24;
}

/* Liderlik Tablosu */
#leaderboard {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 160px;
  background: rgba(11, 16, 26, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px;
  z-index: 10;
  pointer-events: none;
}

.lb-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 800;
  font-size: 0.68rem;
  color: var(--accent-gold);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 2px;
  margin-bottom: 3px;
  text-align: center;
}

.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  border-radius: 4px;
  margin-bottom: 2px;
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.04);
}

.lb-row.first {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.lb-country {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lb-dist {
  color: var(--accent-cyan);
  font-size: 0.65rem;
  font-weight: 800;
}

/* ================= MOBİL DOKUNMATİK OYUN KUMANDASI (ERGONOMİK ÇİFT EL DÜZENİ) ================= */
#mobile-gamepad {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px 12px 16px;
  pointer-events: none;
  z-index: 30;
}

.gamepad-side {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.gamepad-side.left {
  align-items: flex-end;
}

.gamepad-side.right {
  align-items: flex-end;
}

.gamepad-btn {
  background: rgba(20, 29, 46, 0.92);
  border: 2px solid #38bdf8;
  color: #fff;
  border-radius: 50%;
  width: 62px;
  height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), inset 0 2px 6px rgba(255, 255, 255, 0.15);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s, background-color 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.gamepad-btn:active, .gamepad-btn.pressed {
  transform: scale(0.90);
  background: #0284c7;
  border-color: #fff;
}

.gamepad-btn.forward {
  width: 72px;
  height: 72px;
  border-color: #06b6d4;
  background: rgba(6, 182, 212, 0.25);
}

.gamepad-btn.jump-btn {
  width: 66px;
  height: 66px;
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.25);
}

.gamepad-btn.jump-btn:active, .gamepad-btn.jump-btn.pressed {
  background: #10b981;
}

.gamepad-btn.shoot-btn {
  width: 78px;
  height: 78px;
  border-color: #ef4444;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.85), rgba(185, 28, 28, 0.95));
  box-shadow: 0 6px 25px rgba(239, 68, 68, 0.5), inset 0 2px 8px rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.gamepad-btn.shoot-btn:active, .gamepad-btn.shoot-btn.pressed {
  transform: scale(0.88);
  background: #b91c1c;
}

.shoot-cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.btn-symbol {
  font-size: 1.4rem;
  line-height: 1;
}

.btn-label {
  font-size: 0.62rem;
  font-weight: 900;
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Zafer / Yenilgi Ekranı */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 15, 0.94);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.hidden {
  display: none !important;
}

.victory-card {
  background: linear-gradient(145deg, #131b2c, #0a0f19);
  border: 2px solid var(--accent-gold);
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  padding: 1.6rem;
  text-align: center;
}

.trophy-bounce {
  font-size: 3.2rem;
}

#winner-country-title {
  font-family: 'Bungee', cursive;
  font-size: 1.5rem;
  color: #fff;
  margin: 0.5rem 0;
}

.sub-lead {
  color: var(--accent-gold);
  font-weight: 800;
  font-size: 0.85rem;
}

.btn-giant {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border: none;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 12px;
  border-radius: 20px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 6px;
}

.btn-back-giant {
  background: #1e293b;
  color: #fff;
  border: none;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px;
  border-radius: 20px;
  cursor: pointer;
  width: 100%;
}

/* ================= PROFESYONEL MOBİL VE YATAY EKRAN (LANDSCAPE) UYUMU ================= */
@media (max-width: 900px) {
  .lobby-center-tip {
    display: none;
  }
  .hologram-card {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 12px;
    padding: 1.1rem;
    border-radius: 16px;
  }
  .holo-header h2 {
    font-size: 1.25rem;
  }
  .btn-warp-enter {
    padding: 10px;
    font-size: 1.05rem;
  }
  #mobile-gamepad {
    padding: 0 12px 10px 12px;
    height: 100px;
  }
  .gamepad-btn {
    width: 54px;
    height: 54px;
  }
  .gamepad-btn.forward {
    width: 62px;
    height: 62px;
  }
  .gamepad-btn.jump-btn {
    width: 58px;
    height: 58px;
  }
  .gamepad-btn.shoot-btn {
    width: 68px;
    height: 68px;
  }
  .btn-symbol {
    font-size: 1.2rem;
  }
  .btn-label {
    font-size: 0.55rem;
  }
  #leaderboard {
    width: 120px;
    padding: 5px;
  }
  .lb-title {
    font-size: 0.6rem;
  }
  .lb-row {
    font-size: 0.68rem;
    padding: 2px 4px;
  }
}

/* ================= TELEFON YATAY DÖNDÜĞÜNDE (LANDSCAPE MODU - FULLSCREEN GAMING) ================= */
@media (orientation: landscape) and (max-height: 560px) {
  /* Üst Header: İnce, şeffaf HUD bandına dönüşür; sahneden yer çalmaz */
  #game-header {
    height: 36px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(6, 10, 18, 0.88), rgba(6, 10, 18, 0));
    border-bottom: none;
    z-index: 25;
    padding: 0 14px;
  }
  
  .game-title {
    font-size: 0.75rem;
  }
  
  .level-indicator-pill {
    font-size: 0.58rem;
    padding: 1px 4px;
  }
  
  .btn-back-portal {
    font-size: 0.65rem;
    padding: 2px 6px;
  }
  
  .header-center {
    max-width: 220px;
    margin: 0 0.5rem;
  }
  
  .race-progress-bar {
    height: 12px;
  }
  
  .progress-lbl {
    font-size: 0.55rem;
  }
  
  .army-status-pill {
    font-size: 0.68rem;
    padding: 2px 6px;
  }
  
  .btn-icon {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
  }

  /* Canvas Sahnesi: Tüm ekranı %100 kaplar (Sıfır taşma, sıfır siyah boşluk) */
  #canvas-area {
    height: 100% !important;
    width: 100% !important;
  }

  #race-canvas {
    width: 100% !important;
    height: 100% !important;
  }

  /* Kulvar Etiketleri: Yatay modda görseli engellemesin diye gizlenir */
  .lane-overlay {
    display: none !important;
  }

  /* Liderlik Tablosu: Ekranı kapatmasın diye sağ üstte minik ikonik pill olur */
  #leaderboard {
    top: 40px;
    right: 10px;
    width: 110px;
    max-height: 85px;
    overflow: hidden;
    opacity: 0.75;
    transition: opacity 0.2s;
  }
  #leaderboard:hover {
    opacity: 1;
  }

  /* Oyun Kumandası: Başparmakların altına tam oturur, yarı saydam ve ergonomik */
  #mobile-gamepad {
    position: absolute;
    bottom: 6px;
    left: 10px;
    right: 10px;
    height: auto;
    padding: 0;
    pointer-events: none;
    z-index: 30;
  }

  .gamepad-side {
    gap: 10px;
  }

  .gamepad-btn {
    width: 50px;
    height: 50px;
    background: rgba(15, 23, 42, 0.60);
    backdrop-filter: blur(8px);
    border-width: 1.5px;
  }

  .gamepad-btn.forward {
    width: 58px;
    height: 58px;
  }

  .gamepad-btn.jump-btn {
    width: 54px;
    height: 54px;
  }

  .gamepad-btn.shoot-btn {
    width: 64px;
    height: 64px;
  }

  .btn-symbol {
    font-size: 1.15rem;
  }

  .btn-label {
    font-size: 0.52rem;
    margin-top: 1px;
  }

  /* 3D Dünya Lobisinde Yatay Mod Düzeni */
  .globe-topbar {
    height: 40px;
    padding: 0 1rem;
  }
  .globe-topbar h1 {
    font-size: 0.85rem;
  }
  .badge-live {
    font-size: 0.58rem;
    padding: 1px 4px;
  }
  .btn-lang-pill, .btn-return-portal {
    font-size: 0.65rem;
    padding: 3px 6px;
  }

  /* Ülke Seçim Kartı: Ekranı kaplamaz, sağ tarafa şık bir panel olarak yerleşir */
  .hologram-card {
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
    right: 14px;
    width: 270px;
    max-height: 90vh;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    overflow-y: auto;
  }
  .holo-header {
    margin-bottom: 6px;
  }
  .holo-flag-img {
    width: 44px;
    height: 29px;
  }
  .holo-header h2 {
    font-size: 1.1rem;
  }
  .input-player-name {
    margin-bottom: 6px;
  }
  .input-player-name input {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .btn-warp-enter {
    padding: 8px;
    font-size: 0.95rem;
    border-radius: 10px;
  }

  /* Zafer / Seviye Geçiş Ekranı: Yatay modda taşma yapmaz */
  .victory-card {
    max-height: 94dvh;
    overflow-y: auto;
    padding: 0.9rem 1.4rem;
    max-width: 380px;
  }
  .trophy-bounce {
    font-size: 2.2rem;
  }
  #winner-country-title {
    font-size: 1.15rem;
    margin: 0.3rem 0;
  }
  .btn-giant {
    padding: 9px;
    font-size: 1rem;
    margin-top: 6px;
    margin-bottom: 4px;
  }
  .btn-back-giant {
    padding: 7px;
    font-size: 0.82rem;
  }
}
