/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: #1a6b3c;
  background-image: radial-gradient(circle at 20% 80%, #155e33 0%, #1a6b3c 60%);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: #fff;
  user-select: none;
  touch-action: none;
}

/* ===== TOP BAR (single row) ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.btn-back {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.15);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-back:hover { background: rgba(255,255,255,0.3); }

.topbar-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.game-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.9;
  white-space: nowrap;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 0.35rem 0.9rem;
  border: none;
  border-radius: 999px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-orange { background: #ff6b35; color: #fff; }
.btn-orange:hover:not(:disabled) { opacity: 0.88; }
.btn-gray { background: rgba(255,255,255,0.2); color: #fff; }
.btn-gray:hover:not(:disabled) { background: rgba(255,255,255,0.32); }

.draw-selector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
}
.draw-selector select {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}
.draw-selector select option { background: #1a6b3c; }

/* ===== BOARD ===== */
.board {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.4rem;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.board::-webkit-scrollbar { display: none; }

/* ===== TOP ROW ===== */
.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.7rem;
  gap: 0.4rem;
}

.area-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 2px;
  text-align: center;
}

.top-left {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.top-right {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== STOCK & WASTE ===== */
.stock-pile, .waste-pile {
  width: 72px;
  height: 100px;
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
}

.stock-pile {
  background: linear-gradient(135deg, #1a4a8a, #2563c7);
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  transition: transform 0.15s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.stock-pile:hover { transform: scale(1.04); }
.stock-pile::before { content: '🂠'; }
.stock-pile.empty {
  background: rgba(255,255,255,0.08);
  border: 2px dashed rgba(255,255,255,0.3);
}
.stock-pile.empty::before { content: '↺'; font-size: 1.8rem; color: rgba(255,255,255,0.5); }

.waste-pile {
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 10px;
}
.waste-pile .card {
  position: absolute;
  top: 0; left: 0;
}

/* ===== FOUNDATIONS ===== */
.foundations-row {
  display: flex;
  gap: 0.4rem;
}

.foundation {
  width: 72px;
  height: 100px;
  border: 2px dashed rgba(255,255,255,0.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: rgba(255,255,255,0.35);
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.foundation:hover {
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.05);
}
.foundation[data-suit="♠"]::before { content: '♠'; }
.foundation[data-suit="♥"]::before { content: '♥'; color: rgba(220,50,50,0.3); }
.foundation[data-suit="♦"]::before { content: '♦'; color: rgba(220,50,50,0.3); }
.foundation[data-suit="♣"]::before { content: '♣'; }
.foundation .card {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 2px solid rgba(0,128,0,0.4);
  box-shadow: 0 0 6px rgba(0,128,0,0.2);
}
.foundation.drop-target {
  border-color: #ffd700;
  background: rgba(255,215,0,0.1);
}

/* ===== TABLEAU ===== */
.tableau {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-items: start;
}

.column {
  position: relative;
  min-height: 100px;
}

.column.empty-slot {
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  height: 100px;
}

.column.drop-target {
  outline: 2px dashed rgba(255,255,255,0.55);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
}

/* ===== CARDS ===== */
.card {
  width: 72px;
  height: 100px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
  -webkit-touch-callout: none;
}

.card.face-down {
  background-color: #1055a8;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.12) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.12) 75%),
    linear-gradient(-45deg, rgba(255,255,255,0.12) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.12) 75%);
  background-size: 10px 10px;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: inset 0 0 0 2px #0b3d91, 0 2px 8px rgba(0,0,0,0.3);
  cursor: default;
}

.card.face-up {
  background: #fff;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 3px 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: box-shadow 0.12s;
}
.card.face-up:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.card.face-up.selected {
  box-shadow: 0 0 0 2px #ff6b35, 0 4px 14px rgba(255,107,53,0.5);
  z-index: 200;
}
.card.face-up.dragging { opacity: 0.45; }

/* Card content */
.card-tl, .card-br {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  gap: 0;
}
.card-br { transform: rotate(180deg); margin-top: auto; }
.corner-rank { font-size: 0.95rem; font-weight: 800; line-height: 1.1; }
.corner-suit  { font-size: 0.8rem;  font-weight: 700; line-height: 1.1; }
.card-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  line-height: 1;
}

/* Suit colors */
.red  { color: #cc0000; }
.black{ color: #111;    }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  color: #333;
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: popIn 0.3s ease;
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-icon  { font-size: 3.5rem; margin-bottom: 0.5rem; }
.modal h2    { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.4rem; color: #ff6b35; }
.modal p     { font-size: 0.95rem; color: #666; margin-bottom: 0.4rem; }
.modal .btn  { margin-top: 1rem; padding: 0.7rem 2rem; font-size: 1rem; }

/* ===== RESPONSIVE HELPERS ===== */
.hide-mobile { display: inline; }

/* ===== PORTRAIT MOBILE (≤580px) ===== */
@media (max-width: 580px) {
  .hide-mobile { display: none; }
  .game-title  { display: none; }

  .card, .stock-pile, .waste-pile, .foundation {
    width: 50px;
    height: 70px;
  }
  .card-center { font-size: 1.5rem; }
  .corner-rank { font-size: 0.75rem; }
  .corner-suit { font-size: 0.68rem; }
  .card.face-up { padding: 3px 4px; border-radius: 8px; }

  .tableau { gap: 3px; }
  .foundations-row { gap: 3px; }
  .top-row { gap: 0.25rem; margin-bottom: 0.4rem; }
  .topbar  { padding: 0.35rem 0.5rem; gap: 0.3rem; }
  .board   { padding: 0.35rem 0.25rem; }
  .btn     { padding: 0.28rem 0.55rem; font-size: 0.76rem; }
  .draw-selector select { font-size: 0.74rem; padding: 0.2rem 0.3rem; }
  .stats   { font-size: 0.74rem; gap: 0.3rem; }
}

/* ===== NARROW PORTRAIT (≤380px) ===== */
@media (max-width: 380px) {
  .card, .stock-pile, .waste-pile, .foundation {
    width: 44px;
    height: 62px;
  }
  .card-center { font-size: 1.3rem; }
  .corner-rank { font-size: 0.65rem; }
  .corner-suit { font-size: 0.58rem; }
  .tableau { gap: 2px; }
  .foundations-row { gap: 2px; }
  .btn { padding: 0.25rem 0.45rem; font-size: 0.72rem; }
}

/* ===== LANDSCAPE MOBILE (tela deitada) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .card, .stock-pile, .waste-pile, .foundation {
    width: 50px;
    height: 60px;
  }
  .card-center { font-size: 1.3rem; }
  .corner-rank { font-size: 0.7rem; }
  .corner-suit { font-size: 0.63rem; }
  .card.face-up { padding: 2px 3px; border-radius: 7px; }

  .hide-mobile { display: none; }
  .game-title  { display: none; }

  .topbar  { padding: 0.25rem 0.5rem; gap: 0.25rem; }
  .board   { padding: 0.25rem 0.25rem; }
  .top-row { margin-bottom: 0.3rem; gap: 0.2rem; }
  .tableau { gap: 3px; }
  .foundations-row { gap: 3px; }
  .btn     { padding: 0.22rem 0.5rem; font-size: 0.75rem; }
  .draw-selector select { font-size: 0.72rem; padding: 0.18rem 0.28rem; }
  .stats   { font-size: 0.72rem; gap: 0.25rem; }

  .stock-pile::before { font-size: 1.4rem; }
  .stock-pile.empty::before { font-size: 1.3rem; }
  .foundation { font-size: 1.2rem; }
}

/* ===== SEO GAME INFO SECTION ===== */
.game-info {
  max-width: 780px;
  margin: 1rem auto;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  line-height: 1.6;
}
.game-info h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-info h3 { font-size: 0.95rem; font-weight: 700; margin: 0.8rem 0 0.3rem; }
.game-info ul { padding-left: 1.2rem; }
.game-info li { margin-bottom: 0.2rem; }
