/* ============================================================
   CSS Variables & Reset
   ============================================================ */
:root {
  --card-w: 93px;
  --card-h: 130px;
  --card-radius: 7px;
  --felt: #1a6b3a;
  --felt-dark: #154f2c;
  --red: #cc2200;
  --black: #111111;
  --gold: #FFD700;
  --nav-bg: rgba(0,0,0,0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f0f0;
  color: #222;
  line-height: 1.6;
}

/* ============================================================
   HERO
   ============================================================ */
#hero {
  background: linear-gradient(135deg, #1a6b3a 0%, #0e4423 100%);
  color: #fff;
  padding: 40px 20px 32px;
  text-align: center;
}

.hero-inner {
  max-width: 700px;
  margin: 0 auto;
}

#hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.tagline {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  opacity: 0.88;
  margin-bottom: 14px;
  font-style: italic;
}

.intro {
  font-size: 0.97rem;
  opacity: 0.82;
  max-width: 580px;
  margin: 0 auto;
}

/* ============================================================
   GAME SHELL
   ============================================================ */
#game-shell {
  background: var(--felt);
  padding: 0 0 24px;
  position: relative;
}

#game-wrap {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 10px;
}

/* --- NAV BAR --- */
#game-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--nav-bg);
  padding: 8px 14px;
  border-radius: 0 0 8px 8px;
  margin-bottom: 14px;
  min-height: 48px;
}

#game-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-right: 4px;
  white-space: nowrap;
}

#mode-btns {
  display: flex;
  gap: 4px;
}

#mode-btns button,
#action-btns button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

#mode-btns button:hover,
#action-btns button:hover {
  background: rgba(255,255,255,0.28);
}

#mode-btns button.active {
  background: var(--gold);
  color: #111;
  border-color: var(--gold);
  font-weight: 700;
}

#stats-bar {
  display: flex;
  gap: 12px;
  color: #fff;
  font-size: 0.85rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

#stats-bar strong {
  font-size: 0.95rem;
}

#action-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* --- BOARD --- */
#board {
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

/* --- TOP ROW --- */
#top-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  min-width: calc(var(--card-w) * 7 + 8px * 6);
}

#top-row .spacer {
  flex: 1;
  min-width: 8px;
}

/* --- PILE SLOTS (empty outlines) --- */
.pile-slot {
  width: var(--card-w);
  height: var(--card-h);
  border: 2px dashed rgba(255,255,255,0.35);
  border-radius: var(--card-radius);
  background: rgba(0,0,0,0.18);
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  user-select: none;
}

.found-slot {
  font-size: 2.2rem;
}

/* --- TABLEAU --- */
#tableau {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-width: calc(var(--card-w) * 7 + 8px * 6);
}

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

/* ============================================================
   CARDS
   ============================================================ */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  position: absolute;
  cursor: pointer;
  user-select: none;
  border: 1px solid #bbb;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.28);
  transition: transform 0.08s, box-shadow 0.08s;
  overflow: hidden;
}

/* Card face */
.card-face {
  background: #fff;
  width: 100%;
  height: 100%;
  position: relative;
}

.card-corner {
  position: absolute;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  padding: 3px 4px;
}

.card-corner-tl {
  top: 0;
  left: 0;
}

.card-corner-br {
  bottom: 0;
  right: 0;
  transform: rotate(180deg);
}

.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.4rem;
  line-height: 1;
  pointer-events: none;
}

.suit-red  { color: var(--red); }
.suit-black { color: var(--black); }

/* Card back — diagonal blue stripe pattern */
.card-back {
  background-color: #1a3a8f;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 6px,
      rgba(255,255,255,0.18) 6px,
      rgba(255,255,255,0.18) 8px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 6px,
      rgba(255,255,255,0.10) 6px,
      rgba(255,255,255,0.10) 8px
    );
  width: 100%;
  height: 100%;
  border-radius: calc(var(--card-radius) - 1px);
  border: 3px solid #2a5bcf;
}

/* Stock redeal button inside stock slot */
.redeal-btn {
  font-size: 2rem;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: var(--card-radius);
  transition: color 0.15s;
}
.redeal-btn:hover { color: rgba(255,255,255,0.9); }

/* Selection highlight */
.card-selected {
  outline: 3px solid var(--gold);
  outline-offset: -2px;
  transform: translateY(-6px) !important;
  box-shadow: 0 8px 20px rgba(0,0,0,0.45) !important;
  z-index: 500 !important;
}

/* Hint highlight */
.hint-highlight {
  outline: 3px solid #00e676;
  outline-offset: -2px;
  animation: hint-pulse 0.8s ease-in-out 2;
}

@keyframes hint-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,230,118,0.6); }
  50%  { box-shadow: 0 0 0 8px rgba(0,230,118,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,230,118,0); }
}

/* Waste fan — Turn 3 offset cards */
.waste-fan-card {
  position: absolute;
  top: 0;
}

/* ============================================================
   WIN OVERLAY
   ============================================================ */
#win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 8px;
}

.win-box {
  background: #fff;
  border-radius: 12px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  max-width: 360px;
  width: 90%;
}

.win-box h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: var(--felt-dark);
}

#win-stats {
  color: #444;
  margin-bottom: 20px;
  font-size: 1rem;
}

.win-box button {
  background: var(--felt);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.win-box button:hover {
  background: var(--felt-dark);
}

/* ============================================================
   DRAG GHOST
   ============================================================ */
#drag-ghost {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  display: none;
  transform-origin: top left;
}

#drag-ghost .card {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  margin-top: -20px;
}
#drag-ghost .card:first-child {
  margin-top: 0;
}

/* ============================================================
   BELOW-GAME SECTIONS
   ============================================================ */
#reviews,
#rules,
#faq {
  background: #fff;
  padding: 48px 20px;
}

#reviews {
  background: #f8f8f8;
}

.section-inner {
  max-width: 780px;
  margin: 0 auto;
}

#reviews h2,
#rules h2,
#faq h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  margin-bottom: 24px;
  color: #1a3a1a;
  text-align: center;
}

/* Reviews */
.reviews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.review-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 20px 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stars {
  color: #f5a623;
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.review-card p {
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 10px;
  line-height: 1.5;
}

.review-card cite {
  font-size: 0.85rem;
  color: #777;
}

/* Rules */
#rules h3 {
  font-size: 1.1rem;
  color: #1a3a1a;
  margin: 22px 0 8px;
}

#rules p, #rules dd, #rules li {
  font-size: 0.97rem;
  color: #444;
  margin-bottom: 8px;
}

#rules dl {
  margin-left: 0;
}

#rules dt {
  font-weight: 700;
  color: #1a3a1a;
  margin-top: 12px;
}

#rules dd {
  margin-left: 18px;
}

#rules ul {
  padding-left: 20px;
}

#rules li {
  margin-bottom: 4px;
}

/* FAQ */
#faq details {
  border-bottom: 1px solid #e0e0e0;
  padding: 14px 0;
}

#faq details:first-of-type {
  border-top: 1px solid #e0e0e0;
}

#faq summary {
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  color: #1a3a1a;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#faq summary::-webkit-details-marker { display: none; }

#faq summary::after {
  content: '+';
  font-size: 1.3rem;
  color: #888;
  transition: transform 0.2s;
}

#faq details[open] summary::after {
  transform: rotate(45deg);
}

#faq details p {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #555;
}

/* ============================================================
   FOOTER
   ============================================================ */
#site-footer {
  background: #1a2a1a;
  color: #ccc;
  padding: 30px 20px 20px;
}

.footer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
}

.footer-games,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.footer-games strong {
  color: #aaa;
}

.footer-games a,
.footer-links a {
  color: #9ec;
  text-decoration: none;
  transition: color 0.15s;
}

.footer-games a:hover,
.footer-links a:hover {
  color: #fff;
}

.copyright {
  font-size: 0.8rem;
  color: #777;
}

/* ============================================================
   RESPONSIVE — 760px
   ============================================================ */
@media (max-width: 760px) {
  :root {
    --card-w: 70px;
    --card-h: 98px;
  }

  .card-center { font-size: 1.7rem; }
  .card-corner { font-size: 0.6rem; padding: 2px 3px; }

  #game-nav {
    gap: 6px;
    padding: 6px 10px;
  }

  #stats-bar {
    gap: 8px;
    font-size: 0.78rem;
    width: 100%;
  }

  #top-row,
  #tableau {
    min-width: calc(70px * 7 + 7px * 6);
    gap: 7px;
  }
}

/* ============================================================
   RESPONSIVE — 540px
   ============================================================ */
@media (max-width: 540px) {
  :root {
    --card-w: 52px;
    --card-h: 73px;
  }

  .card-center { font-size: 1.2rem; }
  .card-corner { font-size: 0.5rem; padding: 1px 2px; }

  #game-nav {
    gap: 4px;
    padding: 5px 8px;
  }

  #game-title { font-size: 0.9rem; }

  #mode-btns button,
  #action-btns button {
    font-size: 0.72rem;
    padding: 3px 7px;
  }

  #stats-bar {
    font-size: 0.72rem;
    gap: 6px;
  }

  #top-row,
  #tableau {
    min-width: calc(52px * 7 + 6px * 6);
    gap: 6px;
  }

  .win-box {
    padding: 24px 20px;
  }

  .win-box h2 {
    font-size: 1.5rem;
  }
}
