*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #1b4332;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  touch-action: manipulation;
}

/* 1. ÜST PANEL */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 8px 12px;
  height: 50px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  z-index: 100;
}

.brand {
  font-size: 1rem;
  font-weight: bold;
  color: #d8f3dc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn {
  background: #2d6a4f;
  color: #fff;
  border: 1px solid #52b788;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn:hover {
  background: #40916c;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-badge {
  background-color: #74c69d;
  color: #081c15;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 0.75rem;
}

/* 2. OYUN ALANI */
.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  width: 100vw;
  height: calc(100vh - 50px);
  max-width: 1200px;
  margin: 0 auto;
}

.board-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.stock-waste-group, .foundations-group {
  display: flex;
  gap: 6px;
}

.tableau-container {
  display: flex;
  justify-content: space-between;
  width: 100%;
  flex: 1;
  margin-top: 10px;
  gap: 4px;
}

.tableau-column {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 3. MOBİL ODAKLI DİNAMİK KART ÖLÇEKLENDİRMESİ */
.card-wrapper,
.card,
.foundation-slot {
  width: clamp(38px, 12.5vw, 110px);
  height: clamp(54px, 17.5vw, 154px);
  border-radius: 5px;
  position: relative;
}

.foundation-slot {
  border: 1px dashed rgba(255, 255, 255, 0.4);
  background-color: rgba(0, 0, 0, 0.15);
}

.stock-empty {
  opacity: 0.3;
}

/* Sütun Kart Sıkıştırma (Mobilde Taşmayı Önler) */
.tableau-column .card-wrapper {
  margin-top: calc(clamp(54px, 17.5vw, 154px) * -0.78);
}

.tableau-column .card-wrapper:first-child {
  margin-top: 0;
}

/* Kart Tasarımı */
.card {
  background-color: #ffffff;
  color: #111111;
  border: 1px solid #bbbbbb;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  display: flex;
  justify-content: space-between;
  padding: 3px;
  user-select: none;
  cursor: pointer;
  position: relative; /* Merkez simgenin doğru hizalanması için */
  overflow: hidden;
}

.card.face-down {
  background: linear-gradient(135deg, #1d3557 25%, #457b9d 100%);
  border: 1px solid #ffffff;
}

/* Kapalı Kartlarda İki Köşe ve Orta Simgeyi Gizleme */
.card.face-down .card-corner,
.card.face-down .card-center {
  display: none;
}

.card.red { color: #d62828; }
.card.black { color: #003049; }

.card.selected {
  outline: 3px solid #ffb703;
  box-shadow: 0 0 8px #ffb703;
}

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: bold;
  line-height: 1;
  z-index: 2; /* Simgelerin üstünde kalması için */
}

.card-rank { font-size: clamp(0.65rem, 2.2vw, 1.1rem); }
.card-suit { font-size: clamp(0.6rem, 2vw, 1rem); }

.card-corner-br {
  transform: rotate(180deg);
  align-self: flex-end;
}
/* Kırmızı-Beyaz Mini Damalı Kart Arkası */
.card.face-down {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(45deg, #d32f2f 25%, transparent 25%), 
    linear-gradient(-45deg, #d32f2f 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #d32f2f 75%), 
    linear-gradient(-45deg, transparent 75%, #d32f2f 75%);
  background-size: 10px 10px; /* Dama karelerinin boyutu */
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
  border: 2px solid #b71c1c !important;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #ffffff; /* Şık bir iç çerçeve */
}

/* Balon Efekti İçin CSS Animasyonu */
.balloon {
  position: fixed;
  bottom: -100px;
  width: 40px;
  height: 55px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  z-index: 10000;
  pointer-events: none;
  animation: floatUp 4s ease-in forwards;
}

.balloon::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 18px;
  width: 4px;
  height: 10px;
  background: rgba(255, 255, 255, 0.7);
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-120vh) scale(1.2) rotate(15deg);
    opacity: 0;
  }
}
/* Ortadaki Büyük Simge */
.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.4rem, 5.2vw, 3.2rem);
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

/* MOBİL İNCE AYARLARI */
@media (max-width: 480px) {
  .top-bar { padding: 4px 8px; }
  .brand { font-size: 0.85rem; }
  .btn { padding: 4px 6px; font-size: 0.7rem; }
  .game-container { padding: 5px; }
  .tableau-column .card-wrapper {
    margin-top: calc(clamp(54px, 17.5vw, 154px) * -0.80);
  }
}
/* Otomatik Tamamla Butonu Stili */
.auto-complete-btn {
  background-color: #28a745 !important;
  color: white !important;
  font-weight: bold;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Kartların Düzgün Kayması İçin Animasyon */
.card-wrapper {
  transition: all 0.3s ease-in-out;
}

/* Kazanma Modalı (Tebrik Ekranı) */
.win-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  font-family: sans-serif;
  animation: fadeIn 0.5s ease-in-out;
}

.win-modal h1 {
  font-size: 3rem;
  color: #f1c40f;
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
}

.win-modal p {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.win-modal button {
  padding: 12px 24px;
  font-size: 1.2rem;
  background-color: #27ae60;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.win-modal button:hover {
  background-color: #219653;
}

/* CSS Havai Fişek Efektleri */
.pyro > .before, .pyro > .after {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: -120px -218.66667px blue, 248px -50.66667px #00ff2b, 190px -212.66667px #ff00b4, -115px -260.66667px #a6ff00, -55px -248.66667px #ffb300, -18px -260.66667px #e600ff, 170px -23.66667px #ff0066, 15px -125.66667px #00ccff, -167px -18.66667px #a600ff, -145px -230.66667px #00ff55, 120px -315.66667px #ff2200, -13px -38.66667px rgba(255, 255, 255, 0.5), 230px -368.66667px #0002ff, 12px -248.66667px #b300ff, 210px -305.66667px #ff0066, 212px -198.66667px #f200ff;
  animation: 1s bang infinite alternate, 2s gravity infinite, 5s position infinite;
}
.pyro > .after {
  animation-delay: 0.4s, 0.4s, 0.4s;
  animation-duration: 1.25s, 1.25s, 6.25s;
}

@keyframes bang {
  to { box-shadow: -70px -388.66667px rgba(0, 0, 0, 0), -238px -186.66667px rgba(0, 0, 0, 0), -120px -330.66667px rgba(0, 0, 0, 0), -215px -380.66667px rgba(0, 0, 0, 0), -155px -348.66667px rgba(0, 0, 0, 0), -18px -360.66667px rgba(0, 0, 0, 0), 170px -123.66667px rgba(0, 0, 0, 0), -15px -225.66667px rgba(0, 0, 0, 0), -267px -118.66667px rgba(0, 0, 0, 0), -145px -330.66667px rgba(0, 0, 0, 0), 220px -415.66667px rgba(0, 0, 0, 0), -33px -138.66667px rgba(0, 0, 0, 0), 330px -468.66667px rgba(0, 0, 0, 0), 112px -348.66667px rgba(0, 0, 0, 0), 310px -405.66667px rgba(0, 0, 0, 0), 312px -298.66667px rgba(0, 0, 0, 0); }
}
@keyframes gravity { to { transform: translateY(200px); opacity: 0; } }
@keyframes position {
  0%, 19.9% { margin-top: 10%; margin-left: 40%; }
  20%, 39.9% { margin-top: 40%; margin-left: 30%; }
  40%, 59.9% { margin-top: 20%; margin-left: 70%; }
  60%, 79.9% { margin-top: 30%; margin-left: 20%; }
  80%, 99.9% { margin-top: 10%; margin-left: 80%; }
}