body {
  font-family: 'Roboto', Arial, sans-serif;
  background: #1a472a;
  color: #e0e0e0;
  margin: 0;
  padding: 0 10px;
  height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  width: 100%;
  position: relative;
  box-sizing: border-box;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: left;
  min-height: 100vh;
  padding: 0;
  gap: 5px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  transform: translateZ(0);
  will-change: transform;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: auto;
  min-height: var(--device-header-min-height, 10px);
  padding: var(--device-header-padding, 0px 0);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

#menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
  max-width: 100vw;
  overflow: hidden;
}

.menu-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.title {
  font-size: clamp(16px, 2vw, 28px);
  font-weight: bold;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  margin-right: clamp(10px, 1vw, 20px);
  font-family: 'Poppins', sans-serif;
  letter-spacing: clamp(0.5px, 0.15vw, 1.5px);
}

#new-game,
#undo-move {
  text-decoration: none;
  color: white;
  font-weight: 600;
  background-color: #4CAF50;
  padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 12px);
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  font-size: clamp(11px, 0.9vw, 13px);
  letter-spacing: 0.5px;
  white-space: nowrap;
  min-width: max-content;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#undo-move {
  background-color: #3d8b40;
}

#new-game:hover,
#undo-move:hover {
  background-color: #45a049;
}

#new-game:active,
#undo-move:active {
  transform: translateY(0);
}

#stats-container {
  font-size: clamp(11px, 0.9vw, 14px);
  color: #ffffff;
  background: rgba(0, 0, 0, 0.2);
  padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 12px);
  border-radius: 30px;
  display: flex;
  gap: clamp(4px, 0.8vw, 12px);
  align-items: center;
  flex-wrap: nowrap;
  height: 28px;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100vw;
}

#timer,
#score,
#moves {
  font-weight: bold;
  color: #4CAF50;
}

/* Klondike mode switch button */
.klondike-switch-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  height: 32px;
  display: inline-flex;
  align-items: center;
  min-width: 110px;
  margin-right: 10px;
}

.klondike-switch-btn:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.3);
}

.switch-track {
  position: relative;
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.switch-option {
  font-size: clamp(9px, 0.8vw, 11px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  z-index: 2;
  padding: 0 8px;
  text-align: center;
  flex: 1;
}

.switch-option.active {
  color: white;
}

.switch-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 48%;
  height: 24px;
  background: #4CAF50;
  border-radius: 16px;
  z-index: 1;
}

.klondike-switch-btn.mode-3 .switch-slider {
  transform: translateX(100%);
}

/* Game Board Styles */
#game-board {
  /* Default desktop width */
  width: 70vw;
  height: 90vh;
  background: linear-gradient(145deg, #1e502f, #234a2f);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 20px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* Set initial stable dimensions to prevent CLS - based on 12% of board width */
  --card-width: calc(70vw * 0.08); /* 8% of desktop board width for 10 columns */
  --card-height: calc(var(--card-width) * 1.4);
  --card-spacing: clamp(6px, calc(70vw * 0.01), 12px); /* 1% of board width for tighter spacing */
  --tableau-offset-face-up: calc(var(--card-width) * 0.3); /* 30% of card width */
  --tableau-offset-face-down: calc(var(--card-width) * 0.08); /* 8% of card width */
  /* Performance optimizations to reduce CLS */
  contain: layout style;
  will-change: transform;
}

/* Responsive CSS custom properties - percentage-based to maintain proportions */
/*
@media (max-width: 767px) {
  #game-board {

    --card-width: calc(100vw * 0.08);
    --card-spacing: clamp(4px, calc(100vw * 0.01), 8px);
  }
}

@media (max-width: 767px) and (orientation: landscape) {
  #game-board {

    --card-width: calc(60vw * 0.08);
    --card-spacing: clamp(5px, calc(60vw * 0.01), 10px);
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  #game-board {

    --card-width: calc(70vw * 0.08);
    --card-spacing: clamp(6px, calc(70vw * 0.01), 12px);
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  #game-board {

    --card-width: calc(70vw * 0.08);
    --card-spacing: clamp(6px, calc(70vw * 0.01), 12px);
  }
}


@media (min-width: 1025px) and (max-width: 1399px) {
  #game-board {

    --card-width: calc(70vw * 0.08);
    --card-spacing: clamp(8px, calc(70vw * 0.012), 14px);
  }
}

@media (min-width: 1400px) and (max-width: 1799px) {
  #game-board {

    --card-width: calc(70vw * 0.08);
    --card-spacing: clamp(10px, calc(70vw * 0.012), 16px);
  }
}

@media (min-width: 1800px) {
  #game-board {

    --card-width: calc(70vw * 0.08);
    --card-spacing: clamp(12px, calc(70vw * 0.012), 18px);
  }
}
*/

/* Mobile portrait - full width */
@media (max-width: 767px) {
  #game-board {
    width: 100%;
    height: 70vh;
    margin: 10px 0;
    padding: 10px;
  }
}

/* Mobile landscape - narrower for better proportions */
@media (max-width: 767px) and (orientation: landscape) {
  #game-board {
    width: 60vw;
    height: 100vh;
    margin: 0;
    padding: 15px;
  }
}

/* Tablet - keep consistent width across orientations */
@media (min-width: 768px) and (max-width: 1024px) {
  #game-board {
    width: 70vw;
    height: 100vh;
    margin: 0;
    padding: 15px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  #game-board {
    padding: 18px;
  }
}

/* Top row containing stock, waste, and foundations */
.top-row {
  display: flex;
  justify-content: space-between;
  height: var(--card-height, 120px);
  position: relative;
}

.left-piles, .right-piles {
  display: flex;
  gap: var(--card-spacing, 15px);
}

.foundation-container {
  display: flex;
  gap: var(--card-spacing, 15px);
}

.tableau {
  height: calc(var(--card-height) * 3);
}

/* Tableau container */
.tableau-container {
  display: flex;
  gap: var(--card-spacing, 15px);
  align-items: flex-start;
  /* Add stable minimum height to prevent CLS - responsive to card size */
  min-height: calc(var(--card-height) * 3);
  /* Performance optimization */
  contain: layout;
  position: relative;
}

/* Pile styles */
.pile {
  position: relative;
  min-height: var(--card-height);
  width: var(--card-width);
  border-radius: 8px;
}

.tableau-pile {
  min-height: calc(var(--card-height) * 3);
  flex: 1;
  /* Add stable width to prevent horizontal shifts */
  min-width: var(--card-width);
  /* Performance optimization to contain layout changes */
  contain: layout style;
}

/* Pile background styles */
.pile-background {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--card-width);
  height: var(--card-height);
  border: 0.5px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(224, 224, 224, 0.2);
  pointer-events: none;
}

/* Hide pile background when there are cards (but not dragging cards) */
.pile:has(.card:not(.dragging)) .pile-background {
  opacity: 0;
}

.waste-pile .pile-background {
  opacity: 0;
}

.tableau-bg {
  height: var(--card-height);
}

/* Foundation pile backgrounds with suit symbols */
.foundation-bg.hearts::before,
.foundation-bg.diamonds::before,
.foundation-bg.clubs::before,
.foundation-bg.spades::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  opacity: 0.3;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.foundation-bg.hearts::before {
  color: #ff4444;
  font-size: 30px;
  width: auto;
  height: auto;
  background: none;
}

.foundation-bg.diamonds::before {
  color: #ff4444;
  font-size: 30px;
  width: auto;
  height: auto;
  background: none;
}

.foundation-bg.clubs::before {
  color: #333;
  font-size: 30px;
  width: auto;
  height: auto;
  background: none;
}

.foundation-bg.spades::before {
  color: #333;
  font-size: 30px;
  width: auto;
  height: auto;
  background: none;
}

/* Card element styles */
.card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: 8px;
  /* Use the new sprite sheet */
  background-image: url('/assets/card-sprite.svg');
  /* 13 cards wide, 5 cards high - use calc() for distortion-free scaling */
  background-size: calc(13 * var(--card-width)) calc(5 * var(--card-height));
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  will-change: transform;
  z-index: 1;
}

.card.face-down {
  /* Position for the card back (row 4, col 0) */
  background-position: 0% 100%;
}

/*
  Define positions for each card face.
  This is based on the 13x5 grid layout.
  Each step in background-position is 100% / (number of items - 1).
  x-position: 100% / 12 * (column index)
  y-position: 100% / 4  * (row index)
*/

/* Spades (Row 0) */
.card-AS { background-position: 0% 0%; }
.card-2S { background-position: 8.333% 0%; }
.card-3S { background-position: 16.666% 0%; }
.card-4S { background-position: 25% 0%; }
.card-5S { background-position: 33.333% 0%; }
.card-6S { background-position: 41.666% 0%; }
.card-7S { background-position: 50% 0%; }
.card-8S { background-position: 58.333% 0%; }
.card-9S { background-position: 66.666% 0%; }
.card-TS { background-position: 75% 0%; }
.card-JS { background-position: 83.333% 0%; }
.card-QS { background-position: 91.666% 0%; }
.card-KS { background-position: 100% 0%; }

/* Hearts (Row 1) */
.card-AH { background-position: 0% 25%; }
.card-2H { background-position: 8.333% 25%; }
.card-3H { background-position: 16.666% 25%; }
.card-4H { background-position: 25% 25%; }
.card-5H { background-position: 33.333% 25%; }
.card-6H { background-position: 41.666% 25%; }
.card-7H { background-position: 50% 25%; }
.card-8H { background-position: 58.333% 25%; }
.card-9H { background-position: 66.666% 25%; }
.card-TH { background-position: 75% 25%; }
.card-JH { background-position: 83.333% 25%; }
.card-QH { background-position: 91.666% 25%; }
.card-KH { background-position: 100% 25%; }

/* Clubs (Row 2) */
.card-AC { background-position: 0% 50%; }
.card-2C { background-position: 8.333% 50%; }
.card-3C { background-position: 16.666% 50%; }
.card-4C { background-position: 25% 50%; }
.card-5C { background-position: 33.333% 50%; }
.card-6C { background-position: 41.666% 50%; }
.card-7C { background-position: 50% 50%; }
.card-8C { background-position: 58.333% 50%; }
.card-9C { background-position: 66.666% 50%; }
.card-TC { background-position: 75% 50%; }
.card-JC { background-position: 83.333% 50%; }
.card-QC { background-position: 91.666% 50%; }
.card-KC { background-position: 100% 50%; }

/* Diamonds (Row 3) */
.card-AD { background-position: 0% 75%; }
.card-2D { background-position: 8.333% 75%; }
.card-3D { background-position: 16.666% 75%; }
.card-4D { background-position: 25% 75%; }
.card-5D { background-position: 33.333% 75%; }
.card-6D { background-position: 41.666% 75%; }
.card-7D { background-position: 50% 75%; }
.card-8D { background-position: 58.333% 75%; }
.card-9D { background-position: 66.666% 75%; }
.card-TD { background-position: 75% 75%; }
.card-JD { background-position: 83.333% 75%; }
.card-QD { background-position: 91.666% 75%; }
.card-KD { background-position: 100% 75%; }

/* Drag and drop states */
.pile.can-drop .pile-background {
  opacity: 1 !important;
  box-shadow: 0 0 40px rgba(76, 175, 80, 0.8);
}

/*
  When dragging a card, we need to solve two z-index problems:
  1. The container of the dragged card (e.g., .tableau-container) must be on top of other containers (e.g., .top-row).
  2. The pile of the dragged card (e.g., .tableau-pile) must be on top of other piles within its container.
*/

/* 1. Elevate the entire container that holds the dragged card */
.is-dragging .top-row:has(.card.dragging),
.is-dragging .tableau-container:has(.card.dragging) {
  z-index: 10;
}

/* 2. Elevate the specific pile being dragged from */
.is-dragging .pile:has(.card.dragging) {
  z-index: 100;
}

/* For tableau piles, create a beautiful drop zone that extends to the last card */
.tableau-pile.can-drop::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: var(--card-width);
  height: var(--drop-zone-height, calc(var(--card-height) * 2.5));
  pointer-events: none;
  z-index: 0;
  box-shadow: 0 0 40px rgba(76, 175, 80, 0.8);
}

/* Stock pile special styling */
.stock-pile.empty::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(var(--card-width) * 0.6);
  height: calc(var(--card-width) * 0.6);
  border: 8px solid #45a049;
  border-radius: 50%;
  opacity: 0.7;
}

/* Animation classes */
.card.flipping {
  animation: cardFlip 0.3s ease-in-out;
}

.card.stock-to-waste {
  animation: stockToWasteAnimation 0.3s ease-out forwards;
}

@keyframes cardFlip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

@keyframes stockToWasteAnimation {
  0% {
    transform: translateX(0) rotateY(0deg);
    z-index: 100;
  }
  50% {
    transform: translateX(calc(var(--card-width) / 2 + var(--card-spacing) / 2)) rotateY(90deg);
  }
  100% {
    transform: translateX(calc(var(--card-width) + var(--card-spacing))) rotateY(0deg);
    z-index: 1;
  }
}

/* Win animation */
.card.winning {
  animation: winBounce 0.6s ease-in-out;
}

@keyframes winBounce {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.1) rotate(5deg); }
  75% { transform: scale(1.1) rotate(-5deg); }
}

h2 {
  margin-top: 0;
}

p {
  margin-bottom: 15px;
}

.win-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.win-popup-content {
  background: linear-gradient(145deg, #1e502f, #234a2f);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  border: 2px solid #4CAF50;
  max-width: 90%;
  width: 400px;
}

.win-popup h2 {
  color: #4CAF50;
  margin-bottom: 1.5rem;
}

.win-popup p {
  color: #ffffff;
  line-height: 1.8;
  margin-bottom: 2rem;
}

.win-popup button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
}

.win-popup button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.menu-left {
  display: flex;
  align-items: center;
  gap: 3rem;
  flex: 1;
  min-width: 0;
}

.menu-right {
  display: flex;
  align-items: center;
  height: 100%;
  max-width: 60vw;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;
}

footer {
  order: 2;
  width: 100%;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 2vw, 20px);
  padding: 1rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
  z-index: 9999;
}

.footer-nav .nav-link {
  color: #ffffff;
  text-decoration: none;
  font-size: clamp(14px, 1.2vw, 16px);
  padding: 6px 12px;
  border-radius: 4px;
}

.footer-nav .nav-link:hover {
  background: rgba(76, 175, 80, 0.1);
}

.nav-link {
  color: #ffffff;
  text-decoration: none;
  font-size: clamp(14px, 1.2vw, 16px);
  padding: 6px 12px;
  border-radius: 4px;
  position: relative;
}

.nav-link:hover {
  background: rgba(76, 175, 80, 0.1);
}

.nav-link.active {
  color: #4CAF50;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #4CAF50;
  border-radius: 2px;
}

/* MOBILE STYLES - Using proper CSS media queries */
@media (max-width: 767px) {
  /* Game Container */
  #game-container {
    padding: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  header {
    padding: 0px 5px;
    min-height: 5px;
  }

  #menu {
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    height: auto;
    min-height: 40px;
    gap: 10px;
  }

  .menu-buttons {
    justify-content: center;
    display: none; /* Hide buttons in header on mobile */
  }

  .menu-left {
    width: 100%;
    text-align: center;
  }

  .menu-right {
    width: 100%;
  }

  .title {
    font-size: 16px;
    padding: 5px 0;
    line-height: 1.3;
    word-break: break-word;
  }

  #stats-container {
    width: 100%;
    justify-content: center;
    font-size: 12px;
    padding: 5px;
    height: auto;
    min-height: 24px;
  }

  /* Smaller switch button for mobile portrait */
  .klondike-switch-btn {
    height: 28px;
    min-width: 90px;
    margin-right: 8px;
  }

  .switch-track {
    height: 24px;
  }

  .switch-option {
    font-size: 9px;
    padding: 0 6px;
  }

  .switch-slider {
    top: 2px;
    left: 2px;
    height: 20px;
  }

  /* Mobile Buttons */
  .mobile-buttons {
    display: flex !important;
    gap: 10px;
    padding: 10px;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
  }

  #new-game-mobile,
  #undo-move-mobile {
    text-decoration: none;
    color: white;
    font-weight: 600;
    background-color: #4CAF50;
    padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 12px);
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    font-size: clamp(11px, 0.9vw, 13px);
    letter-spacing: 0.5px;
    white-space: nowrap;
    min-width: max-content;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #undo-move-mobile {
    background-color: #3d8b40;
  }

  /* Mobile switch button in mobile-buttons section */
  .mobile-buttons .klondike-switch-btn {
    height: 28px;
    min-width: 90px;
    margin-right: 0;
    margin-left: 0;
  }

  .mobile-buttons .switch-track {
    height: 24px;
  }

  .mobile-buttons .switch-option {
    font-size: 9px;
    padding: 0 6px;
  }

  .mobile-buttons .switch-slider {
    top: 2px;
    left: 2px;
    height: 20px;
  }

  .tableau-container {
    min-height: calc(var(--card-height) * 3);
  }

  .tableau-pile {
    min-height: calc(var(--card-height) * 3);
  }

  .card {
    border-radius: 4px;
  }

  /* Blog and Content */
  .game-layout {
    padding: 0;
  }

  .blog-post {
    padding: 15px;
  }

  .blog-preview {
    padding: 15px;
  }

  .blog-post h1 {
    font-size: 24px;
  }

  .post-content {
    font-size: 14px;
  }

  .blog-image {
    margin: 1rem 0;
    border-radius: 4px;
  }

  .back-link {
    margin: 10px;
    font-size: 14px;
    padding: 8px 15px;
  }

  /* CTA and Buttons */
  .cta-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    border-radius: 8px;
  }

  .cta-section p {
    font-size: 1rem;
    margin-bottom: 1.2rem;
  }

  .cta-button,
  .rules-link {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    justify-content: center;
    text-align: center;
    word-break: break-word;
    display: inline-block;
    max-width: 90%;
    box-sizing: border-box;
  }

  /* Content Container */
  #content-container {
    width: 95vw;
    padding: 10px 20px;
    border-radius: 8px;
    backdrop-filter: none;
  }

  .content-wrapper {
    font-size: 14px;
  }

  .content-wrapper h3 {
    font-size: 16px;
  }

  .content-wrapper ul {
    margin-left: 1rem;
  }

  /* FAQ */
  .faq-wrapper {
    padding-top: 2rem;
  }

  .faq-wrapper::before {
    width: 95%;
  }

  /* Floating Button */
  .floating-home-button {
    bottom: 15px;
    padding: 0 20px;
    height: 50px;
    font-size: 1.1rem;
    width: auto;
    max-width: none;
  }
}

.blog-index {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
}

.blog-posts {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.blog-preview {
  background: rgba(0, 0, 0, 0.2);
  padding: 1.5rem;
  border-radius: 8px;
}

.blog-preview h2 {
  margin: 0 0 1rem 0;
}

.blog-preview h2 a {
  color: #4CAF50;
  text-decoration: none;
}

.blog-preview h2 a:hover {
  text-decoration: underline;
}

.blog-preview h3 {
  margin: 0 0 1rem 0;
  font-size: 1.4rem;
  line-height: 1.3;
}

.blog-preview h3 a {
  color: #4CAF50;
  text-decoration: none;
}

.blog-preview h3 a:hover {
  color: #45a049;
  text-decoration: underline;
}

.post-meta {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.post-excerpt {
  margin-bottom: 1rem;
}

.read-more {
  display: inline-block;
  color: #4CAF50;
  text-decoration: none;
  margin-top: 1rem;
}

.read-more:hover {
  text-decoration: underline;
}

.blog-post {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.blog-post h1 {
  color: #4CAF50;
  margin-bottom: 2rem;
}

.blog-post img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
  display: block;
}

.post-content {
  line-height: 1.8;
}

.post-content h2,
.post-content h3 {
  color: #4CAF50;
  margin: 2rem 0 1rem;
}

.post-content ul {
  margin-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.cta-section {
  margin: 2.5rem 0;
  padding: 2rem;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(76, 175, 80, 0.2);
  backdrop-filter: blur(10px);
}

.cta-section p {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
  color: #ffffff;
  line-height: 1.6;
}

.cta-button,
.rules-link {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 2rem;
  background: linear-gradient(145deg, #4CAF50, #45a049);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
}

.cta-button:hover,
.rules-link:hover {
  background: linear-gradient(145deg, #45a049, #388e3c);
}

.email-link {
  color: #4CAF50 !important;
  text-decoration: none;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(76, 175, 80, 0.1);
}

.email-link:hover {
  color: #ffffff !important;
  background: rgba(76, 175, 80, 0.2);
  text-decoration: none;
}

.external-link {
  color: #4CAF50 !important;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.external-link:hover {
  color: #ffffff !important;
  text-decoration: none;
}

/* TABLET STYLES - Using proper CSS media queries */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Desktop-style header for all tablet orientations */
  #menu {
    flex-direction: row;
    align-items: center;
    padding: 5px 0;
    height: auto;
    min-height: 30px;
    gap: 15px;
  }

  .menu-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  .menu-left {
    width: auto;
    text-align: left;
    flex: 1;
  }

  .menu-right {
    width: auto;
    flex-shrink: 0;
  }

  .title {
    font-size: clamp(16px, 2vw, 24px);
    margin: 0;
    padding: 0;
    line-height: 1.2;
    word-break: normal;
  }

  #stats-container {
    width: auto;
    justify-content: flex-end;
    font-size: clamp(11px, 1vw, 13px);
    padding: 4px 8px;
    height: auto;
    min-height: 20px;
    gap: clamp(8px, 1.2vw, 12px);
    border-radius: 20px;
  }

  /* Hide mobile buttons for all tablet orientations */
  .mobile-buttons {
    display: none !important;
  }

  .tableau-container {
    /* Ensure stable height on tablet with good touch spacing */
    min-height: calc(var(--card-height) * 3);
  }

  .tableau-pile {
    min-height: calc(var(--card-height) * 3);
  }

  /* Switch button for tablet */
  .klondike-switch-btn {
    height: 30px;
    min-width: 105px;
    margin-right: 10px;
  }

  .switch-track {
    height: 26px;
  }

  .switch-option {
    font-size: clamp(10px, 0.9vw, 12px);
  }

  .switch-slider {
    top: 2px;
    left: 2px;
    height: 22px;
  }
}

/* MOBILE LANDSCAPE STYLES */
@media (max-width: 767px) and (orientation: landscape) {
  #menu {
    flex-direction: row;
    align-items: center;
    padding: 5px 0;
    height: auto;
    min-height: 30px;
    gap: 15px;
  }

  .menu-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  /* Smaller buttons for mobile landscape */
  #new-game,
  #undo-move {
    padding: clamp(1px, 0.2vw, 3px) clamp(4px, 0.6vw, 8px);
    font-size: clamp(9px, 0.7vw, 11px);
    height: 24px;
  }

  /* Smaller switch button for mobile landscape */
  .klondike-switch-btn {
    height: 26px;
    min-width: 95px;
    margin-right: 8px;
  }

  .switch-track {
    height: 22px;
  }

  .switch-option {
    font-size: clamp(8px, 0.7vw, 10px);
    padding: 0 6px;
  }

  .switch-slider {
    top: 2px;
    left: 2px;
    height: 18px;
  }

  .menu-left {
    width: auto;
    text-align: left;
    flex: 1;
  }

  .menu-right {
    width: auto;
    flex-shrink: 0;
  }

  .title {
    font-size: clamp(12px, 1.5vw, 16px);
    margin: 0;
    padding: 0;
    line-height: 1.2;
    word-break: normal;
  }

  #stats-container {
    width: auto;
    justify-content: flex-end;
    font-size: clamp(10px, 0.8vw, 11px);
    padding: 3px 6px;
    height: auto;
    min-height: 18px;
    gap: clamp(6px, 1vw, 10px);
    border-radius: 20px;
  }

  /* Hide mobile buttons in landscape since we show desktop buttons */
  .mobile-buttons {
    display: none !important;
  }
}

/* TABLET LANDSCAPE STYLES */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  /* Smaller buttons for tablet landscape */
  #new-game,
  #undo-move {
    padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 10px);
    font-size: clamp(10px, 0.8vw, 12px);
    height: 26px;
  }

  /* Switch button for tablet landscape */
  .klondike-switch-btn {
    height: 28px;
    min-width: 100px;
    margin-right: 8px;
  }

  .switch-track {
    height: 24px;
  }

  .switch-option {
    font-size: clamp(9px, 0.8vw, 11px);
  }

  .switch-slider {
    top: 2px;
    left: 2px;
    height: 20px;
  }

  .title {
    font-size: clamp(14px, 1.8vw, 20px);
  }

  #stats-container {
    font-size: clamp(10px, 0.9vw, 12px);
    padding: 3px 8px;
    min-height: 20px;
    gap: clamp(8px, 1.1vw, 12px);
  }
}





/* Hide mobile buttons on desktop and tablets */
@media (min-width: 768px) {
  .mobile-buttons {
    display: none;
  }
}

.icon-button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 5px;
  margin-right: 10px;
}

.icon-button:hover {
  opacity: 0.8;
}

#site-title a {
  text-decoration: none;
  color: inherit;
}

/* Add these new styles for blog images */
.blog-image {
  width: 100%;
  max-width: 800px;
  height: auto;
  margin: 1.5rem auto;
  display: block;
  border-radius: 8px;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  text-decoration: none;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  margin: 20px 0;
  width: fit-content;
}

.back-link:hover {
  background: rgba(0, 0, 0, 0.3);
}

.back-link svg {
  width: 20px;
  height: 20px;
}

/* Add these new styles */
.faq-section {
  margin: 2rem 0;
  position: relative;
  padding-top: 0;
}

.faq-wrapper {
  position: relative;
  padding-top: 3rem;
}

.faq-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 1px;
  background: linear-gradient(to right,
      transparent,
      rgba(76, 175, 80, 0.3),
      rgba(76, 175, 80, 0.5),
      rgba(76, 175, 80, 0.3),
      transparent);
}

.faq-item {
  margin-bottom: 1.5rem;
}

.faq-item h3 {
  color: #4CAF50;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.faq-item p {
  margin-top: 0.5rem;
  line-height: 1.6;
}



#content-container {
  /* Default desktop width */
  width: 70vw;
  margin: 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  order: 2;
}

/* Mobile portrait - full width content */
@media (max-width: 767px) {
  #content-container {
    width: 95vw;
    padding: 10px 20px;
    border-radius: 8px;
    backdrop-filter: none;
  }
}

/* Mobile landscape - narrower content */
@media (max-width: 767px) and (orientation: landscape) {
  #content-container {
    width: 60vw;
    padding: 15px 20px;
  }
}

/* Tablet - consistent width */
@media (min-width: 768px) and (max-width: 1024px) {
  #content-container {
    width: 70vw;
    padding: 15px 20px;
  }
}

.content-wrapper {
  padding: 1rem;
  width: 100%;
}

.content-wrapper .intro {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 2rem auto;
  font-size: 1.1rem;
  line-height: 1.8;
  color: #ffffff;
}

#content-container h1 {
  color: #4CAF50;
  font-size: 2rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.content-wrapper h2 {
  color: #4CAF50;
  margin: 2rem 0 1rem;
}

.content-wrapper h3 {
  color: #4CAF50;
  margin: 1.5rem 0 1rem;
}

.content-wrapper p {
  margin-bottom: 1rem;
  line-height: 1.6;
  max-width: 800px;
}

.content-wrapper ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
  max-width: 800px;
  text-align: left;
}

.floating-home-button {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) !important;
  background: #4CAF50;
  color: white;
  padding: 0 30px;
  height: 60px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  z-index: 9999;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.2rem;
  white-space: nowrap;
  margin: 0 !important;
}

.floating-home-button:hover {
  background: #45a049;
}

figure {
  margin: 1.5rem 0;
  width: 100%;
  max-width: 800px;
}

figure img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0;
}

figcaption {
  text-align: center;
  margin-top: 0.5rem;
  color: #999;
  font-size: 0.9rem;
}

/* Prevent any potential layout shifts during load */
#main-content {
  /* Ensure stable layout during initialization */
  visibility: visible;
  min-height: 60vh;
  order: 1;
}



.main-layout {
  display: flex;
  flex-direction: column;
  align-items: left;
  gap: 20px;
}

.game-area {
  display: block;
}

.contact-info {
  margin: 1rem 0;
}

/* ========== SPIDER SOLITAIRE SPECIFIC STYLES ========== */

/* Spider difficulty selector button */
.spider-difficulty-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  height: 32px;
  display: inline-flex;
  align-items: center;
  min-width: 170px;
  margin-right: 10px;
}

.spider-difficulty-btn:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.3);
}

.difficulty-track {
  position: relative;
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.difficulty-option {
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  z-index: 2;
  padding: 0 6px;
  text-align: center;
  flex: 1;
  white-space: nowrap;
}

.difficulty-option.active {
  color: white;
}

.difficulty-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 32%;
  height: 24px;
  background: #4CAF50;
  border-radius: 16px;
  z-index: 1;
  transition: transform 0.3s ease;
}

.spider-difficulty-btn.difficulty-2 .difficulty-slider {
  transform: translateX(98%);
}

.spider-difficulty-btn.difficulty-4 .difficulty-slider {
  transform: translateX(200%);
}

/* Spider game board layout - 10 columns instead of 7 */
.spider-tableau {
  display: flex;
  gap: var(--card-spacing, 12px);
  align-items: flex-start;
  min-height: calc(var(--card-height) * 3);
  contain: layout;
  position: relative;
}

/* Adjust card spacing for 10 columns */
.spider-tableau .pile {
  min-width: calc(var(--card-width) * 0.9);
  width: calc(var(--card-width) * 0.9);
}

/* Spider foundations - 8 piles for completed sequences */
.spider-foundation {
  width: var(--card-width);
  height: var(--card-height);
}

.spider-foundation .pile-background {
  width: var(--card-width);
  height: var(--card-height);
  background: rgba(76, 175, 80, 0.1);
  border: 1px dashed rgba(76, 175, 80, 0.3);
}

.spider-foundation .pile-background.completed::before {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #4CAF50;
  font-size: 18px;
  font-weight: bold;
  opacity: 0.7;
}

/* Adjust top row layout for Spider */
.spider-top {
  display: flex;
  justify-content: space-between;
  height: auto;
  min-height: var(--card-height);
  position: relative;
  align-items: flex-start;
}

.spider-foundations {
  display: flex;
  justify-content: flex-end;
  flex: 1;
}

/* Responsive adjustments for Spider Solitaire */
@media (max-width: 767px) {
  /* Mobile portrait - tighter spacing for 10 columns */
  .spider-tableau {
    gap: calc(var(--card-spacing) * 0.6);
  }

  .spider-tableau .pile {
    min-width: calc(var(--card-width) * 0.8);
    width: calc(var(--card-width) * 0.8);
  }

  .spider-foundation-container {
    gap: calc(var(--card-spacing) * 0.5);
  }

  /* Smaller difficulty button for mobile portrait */
  .spider-difficulty-btn {
    height: 28px;
    min-width: 130px;
    margin-right: 8px;
  }

  .difficulty-track {
    height: 24px;
  }

  .difficulty-option {
    font-size: 10px;
    padding: 0 4px;
    white-space: nowrap;
  }

  .difficulty-slider {
    top: 2px;
    left: 2px;
    height: 20px;
    width: 32%;
  }
}

@media (max-width: 767px) and (orientation: landscape) {
  /* Mobile landscape - smaller difficulty button */
  .spider-difficulty-btn {
    height: 26px;
    min-width: 145px;
    margin-right: 8px;
  }

  .difficulty-track {
    height: 22px;
  }

  .difficulty-option {
    font-size: clamp(10px, 0.8vw, 12px);
    padding: 0 5px;
    white-space: nowrap;
  }

  .difficulty-slider {
    top: 2px;
    left: 2px;
    height: 18px;
    width: 32%;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* Tablet - difficulty button */
  .spider-difficulty-btn {
    height: 30px;
    min-width: 160px;
    margin-right: 10px;
  }

  .difficulty-track {
    height: 26px;
  }

  .difficulty-option {
    font-size: clamp(11px, 1vw, 12px);
    white-space: nowrap;
  }

  .difficulty-slider {
    top: 2px;
    left: 2px;
    height: 22px;
    width: 32%;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  /* Tablet landscape - smaller difficulty button */
  .spider-difficulty-btn {
    height: 28px;
    min-width: 150px;
    margin-right: 8px;
  }

  .difficulty-track {
    height: 24px;
  }

  .difficulty-option {
    font-size: clamp(10px, 0.9vw, 12px);
    white-space: nowrap;
  }

  .difficulty-slider {
    top: 2px;
    left: 2px;
    height: 20px;
    width: 32%;
  }
}

/* Hide mobile buttons on desktop and tablets for Spider */
@media (min-width: 768px) {
  .mobile-buttons .spider-difficulty-btn {
    display: none;
  }
}

/* Device-specific styles that work with JavaScript device detection */
/* These have higher specificity to override media queries */
body.device-tablet #menu {
  gap: 8px;
}

body.device-tablet .menu-right {
  gap: 6px;
}

body.device-tablet #stats-container {
  font-size: clamp(11px, 0.9vw, 13px);
  gap: clamp(4px, 0.8vw, 10px);
  padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 10px);
}

body.device-tablet .title {
  font-size: clamp(16px, 2vw, 22px);
}

/* Ensure mobile devices get proper compact styling */
body.device-mobile #stats-container {
  font-size: 12px;
  gap: 4px;
  padding: 4px 8px;
}

/* Tablet portrait mode - use mobile-like layout for narrow tablets */
body.device-tablet.landscape #menu {
  /* Landscape tablets use horizontal layout */
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

body.device-tablet.landscape .menu-left {
  width: auto;
  text-align: left;
  flex: 1;
}

body.device-tablet.landscape .menu-right {
  width: auto;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

/* Tablet portrait mode - use vertical layout like mobile */
body.device-tablet:not(.landscape) #menu {
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  height: auto;
  min-height: 40px;
  gap: 10px;
}

body.device-tablet:not(.landscape) .menu-left {
  width: 100%;
  text-align: center;
}

body.device-tablet:not(.landscape) .menu-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

body.device-tablet:not(.landscape) .icon-button {
  margin-right: 0;
}

body.device-tablet:not(.landscape) #stats-container {
  width: 100%;
  justify-content: center;
  font-size: 13px;
  padding: 5px;
  height: auto;
  min-height: 24px;
  order: 2;
}

body.device-tablet:not(.landscape) .title {
  font-size: 18px;
  padding: 5px 0;
  line-height: 1.3;
}

/* Complete sequence highlighting for Spider Solitaire */
.card.complete-sequence {
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.8);
  border: 2px solid rgba(76, 175, 80, 0.9);
}

.card.complete-sequence::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border: 2px solid #4CAF50;
  border-radius: 8px;
  pointer-events: none;
  animation: completeSequencePulse 2s infinite;
}

@keyframes completeSequencePulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Foundation pile improvements for Spider */
.spider-foundation .pile-background.completed {
  background: rgba(76, 175, 80, 0.3);
  border: 2px solid rgba(76, 175, 80, 0.6);
}

.spider-foundation .pile-background.completed::before {
  animation: foundationComplete 1s ease-out;
}

@keyframes foundationComplete {
  0% { transform: translate(-50%, -50%) scale(0); }
  50% { transform: translate(-50%, -50%) scale(1.3); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* Animation for stock dealing in Spider */
.stock-deal-animation {
  animation: stockDealFly 0.3s ease-out forwards;
}

@keyframes stockDealFly {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.1) rotate(180deg);
    opacity: 0.8;
  }
  100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}
