/* ═══════════════════ BASE ═══════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(ellipse at 50% 30%, #1f8044 0%, #145a2b 60%, #0e3f1e 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  touch-action: manipulation;
}

/* ═══════════════════ HEADER BUTTONS ═══════════════════ */
.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border-radius: 0.5rem;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 32px;
  min-height: 32px;
}
.header-btn:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.25);
}
.header-btn:active {
  transform: scale(0.93);
}

/* ═══════════════════ FOUNDATION BAR ═══════════════════ */
#foundation-bar {
  background: linear-gradient(180deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.08) 100%);
}

/* ═══════════════════ COLUMN ═══════════════════ */
.column {
  position: relative;
  min-height: 60px;
  border-radius: 6px;
  transition: background 0.2s;
}
.column.drop-target {
  background: rgba(255,255,200,0.12);
  box-shadow: inset 0 0 0 2px rgba(255,255,200,0.3);
  border-radius: 6px;
}
.column-empty-slot {
  position: absolute;
  top: 0; left: 3%; right: 3%;
  aspect-ratio: 2.5/3.5;
  border: 1.5px dashed rgba(255,255,255,0.12);
  border-radius: 5px;
}

/* ═══════════════════ CARD ═══════════════════ */
.card {
  position: absolute;
  left: 3%;
  width: 94%;
  aspect-ratio: 2.5/3.5;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
  will-change: transform;
  -webkit-user-select: none;
  user-select: none;
}

.card:hover:not(.face-down) {
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

/* Face Up Card - container for Cardmeister card */
.card.face-up {
  background: none;
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18), 0 0.5px 1px rgba(0,0,0,0.08);
  overflow: hidden;
}
.card.face-up playing-card {
  display: block;
  width: 100%;
  height: 100%;
}
.card.face-up playing-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

/* Face Down Card */
.card.face-down {
  background: linear-gradient(135deg, #1e56a0 0%, #163d7a 100%);
  border: 1px solid rgba(0,0,0,0.25);
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  cursor: default;
  overflow: hidden;
}
.card.face-down::before {
  content: '';
  position: absolute;
  inset: 2.5px;
  border-radius: 3px;
  border: 1.5px solid rgba(255,255,255,0.2);
  background:
    repeating-linear-gradient(
      45deg, transparent, transparent 3px,
      rgba(255,255,255,0.06) 3px, rgba(255,255,255,0.06) 6px
    ),
    repeating-linear-gradient(
      -45deg, transparent, transparent 3px,
      rgba(255,255,255,0.06) 3px, rgba(255,255,255,0.06) 6px
    );
}

/* ═══════════════════ DRAG STATE ═══════════════════ */
.card.dragging {
  opacity: 0.35;
}
.card.drag-ghost {
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  transform: rotate(1.5deg);
  pointer-events: none;
}

/* Hint Highlight */
.card.hint-source {
  box-shadow: 0 0 0 2.5px #fbbf24, 0 0 12px rgba(251,191,36,0.5) !important;
  z-index: 10;
}
.card.hint-target,
.column.hint-target {
  box-shadow: 0 0 0 2.5px #34d399, 0 0 12px rgba(52,211,153,0.5) !important;
}

/* ═══════════════════ STOCK PILE ═══════════════════ */
.stock-btn {
  width: clamp(36px, 8vw, 56px);
  aspect-ratio: 2.5/3.5;
  border-radius: 5px;
  background: linear-gradient(135deg, #1e56a0 0%, #163d7a 100%);
  border: 1.5px solid rgba(255,255,255,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
}
.stock-cards-visual {
  position: absolute;
  inset: 2.5px;
  border-radius: 3px;
  border: 1.5px solid rgba(255,255,255,0.2);
  background:
    repeating-linear-gradient(
      45deg, transparent, transparent 3px,
      rgba(255,255,255,0.06) 3px, rgba(255,255,255,0.06) 6px
    ),
    repeating-linear-gradient(
      -45deg, transparent, transparent 3px,
      rgba(255,255,255,0.06) 3px, rgba(255,255,255,0.06) 6px
    );
}
.stock-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
.stock-btn:active {
  transform: translateY(0);
}
.stock-btn.empty {
  background: transparent;
  border: 1.5px dashed rgba(255,255,255,0.12);
  box-shadow: none;
  cursor: default;
}
.stock-btn.empty .stock-cards-visual { display: none; }
.stock-btn.empty:hover { transform: none; box-shadow: none; }

/* ═══════════════════ COMPLETED AREA ═══════════════════ */
.completed-slot {
  width: clamp(26px, 6vw, 44px);
  aspect-ratio: 2.5/3.5;
  border-radius: 4px;
  border: 1.5px dashed rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(0,0,0,0.08);
}
.completed-slot .slot-placeholder {
  color: rgba(255,255,255,0.15);
  font-size: 1.2em;
  line-height: 1;
}
.completed-slot.filled {
  background: none;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  padding: 0;
  overflow: hidden;
}
.completed-slot.filled playing-card {
  display: block;
  width: 100%;
  height: 100%;
}
.completed-slot.filled playing-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

/* ═══════════════════ MODALS ═══════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem 1.75rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.3s ease;
}

.difficulty-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1.5px solid #e5e7eb;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}
.difficulty-btn:hover { border-color: #22c55e; background: #f0fdf4; }
.difficulty-btn:active { transform: scale(0.98); }

.stat-card {
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid;
  text-align: center;
}

/* ═══════════════════ TOAST ═══════════════════ */
.toast {
  background: rgba(30,30,30,0.92);
  backdrop-filter: blur(8px);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
  pointer-events: none;
}

/* ═══════════════════ ANIMATIONS ═══════════════════ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ═══════════════════ RESPONSIVE ═══════════════════ */
@media (max-width: 480px) {
  .card { border-radius: 3px; }
  .column-empty-slot { border-radius: 3px; }
}
@media (min-width: 1024px) {
  .card { border-radius: 6px; }
  .column-empty-slot { border-radius: 6px; }
}

#tableau-wrapper::-webkit-scrollbar { width: 4px; }
#tableau-wrapper::-webkit-scrollbar-track { background: transparent; }
#tableau-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
