/* ===== 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 ===== */
.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); }

/* ===== BOARD ===== */
.board {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.4rem;
  max-width: 860px;
  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;
  flex-direction: column;
  align-items: center;
}

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

/* ===== FREE CELLS ===== */
.cells-row {
  display: flex;
  gap: 0.4rem;
}

.free-cell {
  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.2rem;
  color: rgba(255,255,255,0.2);
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.free-cell:hover {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.04);
}
.free-cell.drop-target {
  border-color: #ffd700;
  background: rgba(255,215,0,0.1);
}
.free-cell .card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

/* ===== 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="\2660"]::before { content: '\2660'; }
.foundation[data-suit="\2665"]::before { content: '\2665'; color: rgba(220,50,50,0.3); }
.foundation[data-suit="\2666"]::before { content: '\2666'; color: rgba(220,50,50,0.3); }
.foundation[data-suit="\2663"]::before { content: '\2663'; }
.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(8, 1fr);
  gap: 5px;
  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-up {
  background: #fff;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 4px 5px;
  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 {
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
}
.card-br { transform: rotate(180deg); margin-top: auto; }
.card-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 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, .free-cell, .foundation {
    width: 42px;
    height: 60px;
  }
  .card-center { font-size: 1.3rem; }
  .card-tl, .card-br { font-size: 0.6rem; }
  .card.face-up { padding: 2px 3px; border-radius: 8px; }

  .tableau { gap: 3px; }
  .cells-row { 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; }
  .stats   { font-size: 0.74rem; gap: 0.3rem; }
  .free-cell { font-size: 0.9rem; }
  .foundation { font-size: 1.2rem; }
}

/* ===== NARROW PORTRAIT (<=380px) ===== */
@media (max-width: 380px) {
  .card, .free-cell, .foundation {
    width: 38px;
    height: 54px;
  }
  .card-center { font-size: 1.1rem; }
  .card-tl, .card-br { font-size: 0.52rem; }
  .tableau { gap: 2px; }
  .cells-row { gap: 2px; }
  .foundations-row { gap: 2px; }
  .btn { padding: 0.25rem 0.45rem; font-size: 0.72rem; }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .card, .free-cell, .foundation {
    width: 46px;
    height: 56px;
  }
  .card-center { font-size: 1.2rem; }
  .card-tl, .card-br { font-size: 0.55rem; }
  .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; }
  .cells-row { gap: 3px; }
  .foundations-row { gap: 3px; }
  .btn     { padding: 0.22rem 0.5rem; font-size: 0.75rem; }
  .stats   { font-size: 0.72rem; gap: 0.25rem; }
  .free-cell { font-size: 0.9rem; }
  .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; }
