/* ===========================
   Base
   =========================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: #222;
  line-height: 1.6;
}

/* ===========================
   Layout
   =========================== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ===========================
   Header
   =========================== */
.site-header,
header {
  background: #111;
  color: white;
  padding: 0.75rem 1rem;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  margin: 0;
  font-size: 1.4rem;
  font-weight: bold;
}

.logo a {
  color: white;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 0.95rem;
}

nav a:hover {
  text-decoration: underline;
}

/* Homepage plain header (no .container) */
header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

header nav {
  margin-top: 0.25rem;
}

/* ===========================
   Main content
   =========================== */
main {
  padding: 2rem 1rem;
}

main.container {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* ===========================
   Game container
   =========================== */
#game-container {
  margin: 2rem 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  background: #f9f9f9;
  overflow: hidden;
}

#sudoku-canvas {
  display: block;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 0 auto;
}

/* ===========================
   Homepage game cards
   =========================== */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.game-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.25rem;
  text-align: center;
  text-decoration: none;
  color: #222;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.game-card:hover {
  border-color: #111;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.game-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}

.game-card p {
  margin: 0;
  font-size: 0.875rem;
  color: #555;
}

/* ===========================
   SEO content
   =========================== */
article h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

article h2 {
  font-size: 1.25rem;
  margin-top: 2rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.25rem;
}

article p, article li {
  max-width: 720px;
}

/* ===========================
   Footer
   =========================== */
.site-footer,
footer {
  background: #f5f5f5;
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: #555;
  margin-top: 2rem;
}

/* ===========================
   Ad slots (uncomment ins tags in HTML when AdSense approved)
   =========================== */
.ad-slot {
  margin: 1.5rem 0;
  text-align: center;
  min-height: 90px; /* reserve space to prevent CLS */
}

.ad-slot--in-article {
  min-height: 250px;
}

/* ===========================
   Solitaire Game Board
   =========================== */

/* Container override — green felt only on solitaire */
.solitaire-board {
  background: #2d7a40;
  border: none !important;
  border-radius: 8px;
  padding: 0.75rem;
  margin: 2rem 0;
  position: relative;
  overflow: visible;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Controls bar */
#game-ui {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

#move-counter {
  color: rgba(255,255,255,0.85);
  font-size: 0.875rem;
}

#btn-new-game,
#btn-play-again {
  background: #111;
  color: #fff;
  border: none;
  padding: 0.35rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
}

#btn-new-game:hover,
#btn-play-again:hover {
  background: #333;
}

/* Game grid: 7 equal columns */
#game-area {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: auto;
  gap: 5px;
}

/* Empty pile slots */
.card-zone {
  position: relative;
  border-radius: 6px;
  overflow: visible;
}

/* Fixed-shape zones (stock / waste / foundation) */
.stock-zone,
.waste-zone,
.foundation-zone {
  border: 2px dashed rgba(255,255,255,0.3);
  aspect-ratio: 5 / 7;
  cursor: pointer;
}

/* Tableau columns: height is set by JS */
.tableau-zone {
  border: none;
  min-height: 60px;
}

.zone-spacer { /* gap between waste and foundations */ }

/* Empty zone labels (↺ on stock, suits on foundations) */
.empty-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.45);
  font-size: clamp(14px, 2.5vw, 28px);
  cursor: pointer;
  border-radius: 4px;
}

.empty-label.full {
  position: relative;
  width: 100%;
  min-height: 60px;
}

/* ── Cards ── */
.card {
  position: absolute;
  left: 0;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 5px;
  box-sizing: border-box;
  cursor: pointer;
  overflow: hidden;
}

/* Face-up */
.card.face-up {
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.25);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 3px 4px;
}

.card.face-up.red  { color: #cc0000; }
.card.face-up.black { color: #111; }

/* Card content */
.c-tl {
  font-size: clamp(9px, 1.7vw, 17px);
  font-weight: bold;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.c-tl span {
  font-size: 0.88em;
}

.c-ctr {
  font-size: clamp(14px, 3vw, 34px);
  text-align: center;
  align-self: center;
}

.c-br {
  font-size: clamp(9px, 1.7vw, 17px);
  font-weight: bold;
  line-height: 1.15;
  transform: rotate(180deg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: end;
}

.c-br span { font-size: 0.88em; }

/* Face-down */
.card.face-down {
  background-color: #1a4fa0;
  background-image:
    repeating-linear-gradient( 45deg, rgba(255,255,255,0.08) 0, rgba(255,255,255,0.08) 2px, transparent 2px, transparent 10px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.08) 0, rgba(255,255,255,0.08) 2px, transparent 2px, transparent 10px);
  border: 2px solid #0d3578;
  cursor: default;
}

/* Selected highlight */
.card.selected {
  outline: 3px solid #FFD700;
  outline-offset: -2px;
  filter: brightness(1.08);
}

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

#win-overlay.hidden { display: none; }

#win-box {
  background: #fff;
  padding: 2rem 2.5rem;
  border-radius: 10px;
  text-align: center;
}

#win-box h2 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
}

#win-moves {
  margin: 0 0 1.25rem;
  color: #555;
}

/* Responsive tweaks for very small screens */
@media (max-width: 420px) {
  #game-area { gap: 3px; }
  .solitaire-board { padding: 0.4rem; }
  .c-ctr { display: none; } /* hide centre symbol on tiny cards */
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 600px) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  article h1 {
    font-size: 1.4rem;
  }

  #game-container {
    padding: 0.5rem;
  }
}
