/* ── CSS custom properties (set by JS on load + resize) ────────────────────── */

:root {
  --card-w: 80px;
  --card-h: 112px;
}

/* ── Card base ─────────────────────────────────────────────────────────────── */

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: clamp(6px, calc(var(--card-w) * 0.1), 10px);
  border: 1px solid rgba(0, 0, 0, 0.15);
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  background: #fff;
  flex-shrink: 0;
  user-select: none;
  cursor: default;
}

/* ── Card face ─────────────────────────────────────────────────────────────── */

.card-face {
  background: #ffffff;
}

/* Rank — top-left */
.card-rank-tl {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: clamp(18px, calc(var(--card-w) * 0.38), 32px);
  font-weight: 400;
  line-height: 1;
}

/* Suit symbol — top-right, slightly smaller than rank */
.card-suit-tr {
  position: absolute;
  top: 6px;
  right: 7px;
  font-size: clamp(14px, calc(var(--card-w) * 0.28), 24px);
  line-height: 1;
}

/* Large suit — centered in the bottom half */
.card-suit-bottom {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(30px, calc(var(--card-w) * 0.82), 68px);
  line-height: 1;
}

/* ── Suit colors ───────────────────────────────────────────────────────────── */

.suit-red  { color: #d0131a; }
.suit-black { color: #1a1f3a; }

/* ── Card back ─────────────────────────────────────────────────────────────── */

.card-back {
  background-color: #2558a8;
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.07) 0px, rgba(255,255,255,0.07) 2px, transparent 2px, transparent 50%),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.07) 0px, rgba(255,255,255,0.07) 2px, transparent 2px, transparent 50%);
  background-size: 12px 12px;
  cursor: default;
}

/* ── Waste fan (draw 3) ────────────────────────────────────────────────────── */

.waste-fan {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  flex-shrink: 0;
}

.waste-fan-card {
  position: absolute;
  top: 0;
}

/* ── Empty slot ────────────────────────────────────────────────────────────── */

.card-slot {
  width: var(--card-w);
  height: var(--card-h);
  flex-shrink: 0;
}

.card-empty {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.15);
  border-radius: clamp(6px, calc(var(--card-w) * 0.1), 10px);
  width: var(--card-w);
  height: var(--card-h);
}

/* ── Tableau column ────────────────────────────────────────────────────────── */

.card-column {
  width: var(--card-w);
  position: relative;
  flex-shrink: 0;
  min-height: var(--card-h);
}

/* ── Card transitions ──────────────────────────────────────────────────────── */

.card-face,
.card-back {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

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

/* ── Draggable ─────────────────────────────────────────────────────────────── */

.card[draggable="true"] {
  cursor: grab;
}

.card[draggable="true"]:active {
  cursor: grabbing;
}

/* ── Selected card highlight (tap-to-move) ─────────────────────────────────── */

.card-selected {
  outline: 2px solid #facc15;
  outline-offset: 1px;
  transform: translateY(-4px);
  z-index: 10;
  position: relative;
}

/* ── Drop target highlight ─────────────────────────────────────────────────── */

.drop-target {
  outline: 2px solid rgba(250, 204, 21, 0.8);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Win overlay ───────────────────────────────────────────────────────────── */

.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.4s ease;
}

.win-card {
  background: #1e3a5f;
  border: 2px solid #facc15;
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  animation: scaleIn 0.35s ease;
  max-width: 90vw;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Stats overlay ─────────────────────────────────────────────────────────── */

.stats-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
  padding: 12px;
}

.stats-modal {
  background: #14532d;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  animation: scaleIn 0.25s ease;
  color: #fff;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.stats-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.stats-close:hover { background: rgba(255,255,255,0.2); }

/* Summary tiles */
.stats-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px 8px;
  flex-shrink: 0;
}

.stat-tile {
  flex: 1 1 calc(25% - 8px);
  min-width: 70px;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  color: #fde68a;
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.55);
}

/* Win rate bar */
.stats-bar-wrap {
  padding: 4px 20px 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.stats-bar-track {
  height: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* History table */
.stats-table-wrap {
  overflow-y: auto;
  flex: 1;
  padding: 0 12px 12px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.stats-table thead tr {
  position: sticky;
  top: 0;
  background: #14532d;
}

.stats-table th {
  text-align: left;
  padding: 8px 8px 6px;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stats-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.row-won td { color: #fff; }
.row-lost td { color: rgba(255,255,255,0.5); }

.result-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-won  { background: rgba(74, 222, 128, 0.2); color: #4ade80; }
.badge-lost { background: rgba(248, 113, 113, 0.15); color: #f87171; }

/* ── Navbar responsive ─────────────────────────────────────────────────────── */

.navbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

@media (max-width: 480px) {
  .navbar-controls .hide-mobile {
    display: none;
  }
}

/* ── Waste fan behind-card rank: semi-bold so J doesn't look like 1 ─────────── */

.waste-peek-rank {
  font-weight: 600;
}

/* ── Hint highlight ────────────────────────────────────────────────────────── */

@keyframes hint-pulse {
  from { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.6); }
  to   { box-shadow: 0 0 0 8px rgba(167, 139, 250, 0); }
}

.hint-source {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
  animation: hint-pulse 0.7s ease-in-out infinite alternate;
  position: relative;
  z-index: 15;
}

.hint-target {
  outline: 2px dashed #a78bfa;
  outline-offset: 3px;
  border-radius: 8px;
}

/* ── No-moves banner ───────────────────────────────────────────────────────── */

.no-moves-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #7c3aed;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 50;
  white-space: nowrap;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
