/* =============================================
   SOLITAIRE-ONLINE.COM  —  Main Stylesheet
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
  --green:        #3a6b3a;
  --green-dark:   #2e5430;
  --green-light:  #4a7d4a;
  --green-found:  rgba(0,0,0,0.18);
  --green-hover:  #4caf50;
  --white:        #ffffff;
  --gray-50:      #f8f9fa;
  --gray-100:     #f0f0f0;
  --gray-300:     #cccccc;
  --gray-500:     #888888;
  --gray-700:     #444444;
  --black:        #111111;
  --red:          #cc1111;
  --card-w:       190px;
  --card-h:       266px;
  --card-radius:  8px;
  --card-border:  rgba(18, 27, 20, 0.28);
  --card-shadow:  0 3px 10px rgba(0,0,0,0.26), 0 10px 24px rgba(0,0,0,0.12);
  --card-shadow-hover: 0 10px 24px rgba(0,0,0,0.28), 0 18px 42px rgba(0,0,0,0.18);
  --peek-down:    42px;
  --peek-up:      62px;
  --header-h:     46px;
  --footer-h:     52px;
  --sidebar-w:    300px;
  --anim-speed:   0.18s;
}

html, body {
  height: 100%;
  font-family: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 14px;
  /* Prevent rubber-band overscroll on iOS for the body */
  overscroll-behavior: none;
}

/* iOS momentum scrolling for scrollable content */
#seo-content, .modal-box, #sidebar, .dropdown-menu {
  -webkit-overflow-scrolling: touch;
}

/* ---- APP WRAPPER ---- */
#app { min-height: 100vh; }

/* ---- GAME WRAPPER ---- */
#game-wrapper {
  background-color: #2d6b2d;
  background-image: radial-gradient(circle, rgba(0,0,0,0.18) 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* =============================================
   HEADER
   ============================================= */
#game-header {
  height: var(--header-h);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  border-bottom: none;
}

.header-left { display: flex; align-items: center; gap: 6px; }
.header-right { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.94); font-size: 12px; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,0.2); }

.logo { display: flex; align-items: center; gap: 6px; margin-right: 6px; }
.logo-icon { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.22)); }
.logo-text { color: #fff; font-size: 16px; font-weight: 700; letter-spacing: 0; }

/* Mode buttons (Turn 1, Turn 3, All games) */
.mode-btn {
  background: rgba(113, 191, 98, 0.88);
  border: 1px solid rgba(113, 191, 98, 0.88);
  color: #fff;
  border-radius: 6px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--anim-speed), border-color var(--anim-speed);
  white-space: nowrap;
}
.mode-btn:hover { background: rgba(103, 181, 88, 0.96); border-color: rgba(103, 181, 88, 0.96); }
.mode-btn.active { background: rgba(93, 171, 78, 1); border-color: rgba(93, 171, 78, 1); color: #fff; }

/* =============================================
   MAIN AREA
   ============================================= */
#main-area {
  display: flex;
  flex: 1;
  gap: 0;
  padding: 12px 14px 0 14px;
  min-height: 0;
  max-width: 1920px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* =============================================
   GAME BOARD
   ============================================= */
#game-board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Top row — same 7-column grid as tableau so piles align with columns */
#top-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  align-items: flex-start;
}
.pile-spacer { /* col 3 empty gap */ }
/* foundation piles sit in cols 4-7, stock/waste in cols 1-2 */

/* Tableau — CSS Grid spreads 7 columns evenly across full board width */
#tableau {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  align-items: flex-start;
}
.tab-col {
  position: relative;
  min-height: var(--card-h);
  width: 100%;
}
/* Cards inside tableau columns always fill column width exactly */
.tab-col .card { width: 100%; }

/* =============================================
   PILES (empty slots)
   ============================================= */
.pile {
  width: 100%;
  max-width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  border: 1px solid rgba(255,255,255,0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)),
    rgba(255,255,255,0.03);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 0 1px rgba(255,255,255,0.02);
  position: relative;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.pile.drag-over {
  border-color: rgba(255,255,255,0.44);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04)),
    rgba(255,255,255,0.05);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 10px 22px rgba(0,0,0,0.12);
}

/* Foundation piles */
.foundation-pile {
  display: flex;
  align-items: center;
  justify-content: center;
}
.found-hint {
  font-size: 36px;
  opacity: 0.18;
  color: #fff;
  pointer-events: none;
}

/* Stock pile */
.stock-pile { cursor: pointer; }
.stock-pile:hover {
  border-color: rgba(255,255,255,0.56);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    rgba(0,0,0,0.2);
}

/* Waste pile — wider to fan 3 cards */
.waste-pile {
  width: calc(var(--card-w) + 44px);
  max-width: none;
  border: none;
  background: transparent;
  position: relative;
}

/* =============================================
   CARDS
   ============================================= */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244,246,245,0.98));
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  position: absolute;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.14s ease, transform 0.14s ease, filter 0.14s ease;
  overflow: hidden;
  isolation: isolate;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0) 28%, rgba(0,0,0,0.02) 100%);
  pointer-events: none;
  z-index: 1;
}

/* Card image — fills the entire card div */
.card-img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: var(--card-radius);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: -webkit-optimize-contrast;
  transform: translateZ(0);
}
.card:hover {
  box-shadow: var(--card-shadow-hover);
  filter: saturate(1.02) contrast(1.01);
}

/* CSS fallback card rendering (used when CDN images fail) */
.card-back {
  background:
    linear-gradient(180deg, #ffffff, #fbfbf8);
  background-image:
    repeating-linear-gradient(135deg, rgba(36, 54, 112, 0.68) 0px, rgba(36, 54, 112, 0.68) 2px, transparent 2px, transparent 11px);
  border-color: rgba(57, 73, 128, 0.45);
}
.card-red, .card-black { background: linear-gradient(180deg, #ffffff, #f6f6f3); }
.card-face { width: 100%; height: 100%; position: relative; overflow: hidden; }
.card-tl { position: absolute; top: 4px; left: 5px; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.card-br { position: absolute; bottom: 4px; right: 5px; display: flex; flex-direction: column; align-items: center; line-height: 1; transform: rotate(180deg); }
.card-rank { font-size: 17px; font-weight: 800; line-height: 1; }
.card-suit-sm { font-size: 12px; line-height: 1.1; margin-top: 1px; }
.card-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 36px; line-height: 1; pointer-events: none; }
.card-face-art { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); display: flex; flex-direction: column; align-items: center; font-size: 36px; font-weight: 700; pointer-events: none; }
.card-face-sym { font-size: 13px; line-height: 1.2; }
.card-red .card-rank, .card-red .card-suit-sm, .card-red .card-center, .card-red .card-face-art { color: #cc1111; }
.card-black .card-rank, .card-black .card-suit-sm, .card-black .card-center, .card-black .card-face-art { color: #111; }
.card.dragging {
  opacity: 0.96;
  box-shadow: 0 18px 36px rgba(0,0,0,0.34), 0 28px 56px rgba(0,0,0,0.2);
  z-index: 1000;
  transform: scale(1.03);
}
.card.hint-highlight { box-shadow: 0 0 0 3px #ffe600, 0 3px 10px rgba(0,0,0,0.4); }



/* Waste pile */
.waste-pile { overflow: visible; }

/* =============================================
   SIDEBAR
   ============================================= */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 14px;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h) - var(--footer-h) - 24px);
}

.sidebar-panel {
  background: rgba(58, 107, 58, 0.14);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 6px;
  margin-bottom: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.sidebar-panel:first-child { border-radius: 6px; }

.panel-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.panel-title {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex: 1;
}

.badge-playing {
  background: rgba(245, 197, 24, 0.92);
  color: #2f3b16;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.btn-show {
  background: rgba(108, 191, 97, 0.88);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* Challenge calendar */
.challenge-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.no-wins-label { color: var(--gray-500); }
.sidebar-panel .no-wins-label,
.sidebar-panel .milestone,
.sidebar-panel .cal-table th,
.sidebar-panel .lb-table th,
.sidebar-panel .lb-table td {
  color: rgba(255,255,255,0.78);
}
.sidebar-panel .cal-table td:hover {
  background: rgba(255,255,255,0.08);
}
.milestones { display: flex; gap: 8px; margin-left: auto; }
.milestone { font-size: 12px; font-weight: 600; }

#challenge-calendar { }
.cal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.cal-table th {
  text-align: center;
  padding: 2px;
  color: var(--gray-500);
  font-weight: 600;
}
.cal-table td {
  text-align: center;
  padding: 4px 2px;
  border-radius: 3px;
  cursor: pointer;
}
.cal-table td:hover { background: var(--gray-100); }
.cal-today {
  background: var(--green-hover) !important;
  color: #fff;
  border-radius: 50% !important;
  font-weight: 700;
}
.cal-play { color: var(--green-dark); font-weight: 700; }
.cal-win  { color: #f5a623; }
.cal-won  {
  background: #f0ad00 !important;
  color: #fff !important;
  border-radius: 50% !important;
  font-weight: 700;
  cursor: default;
}

/* Leaderboard */
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.lb-table th, .lb-table td {
  padding: 5px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.lb-table th { color: rgba(255,255,255,0.68); font-weight: 600; }
.lb-table td:nth-child(2) { text-align: left; }
.lb-hint { font-size: 11px; color: var(--gray-500); text-align: center; margin-top: 6px; }

/* Achievements */
.ach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.ach-item { text-align: center; }
.ach-label { font-size: 11px; color: var(--gray-500); }
.ach-val { font-size: 14px; font-weight: 700; color: #222; }

.btn-signup {
  width: 100%;
  background: var(--green-hover);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-signup:hover { background: var(--green-dark); }
.btn-signup.btn-signed-in { background: #2a5298; }
.btn-signup.btn-signed-in:hover { background: #1e3c72; }

/* =============================================
   FOOTER BAR
   ============================================= */
#game-footer {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
}

.footer-left, .footer-right { display: flex; align-items: center; gap: 6px; }

.foot-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.foot-btn:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.34); }

.foot-btn.primary-btn {
  background: #3a9e3a;
  color: #fff;
  border-color: #2e7d2e;
}
.foot-btn.primary-btn:hover { background: #2e7d2e; }
.foot-btn.icon-btn { display: flex; align-items: center; gap: 5px; }

.foot-btn.hint-btn {
  background: rgba(255,200,50,0.2);
  border-color: rgba(255,200,50,0.5);
  color: #ffe066;
  display: flex;
  align-items: center;
  gap: 5px;
}
.foot-btn.hint-btn:hover { background: rgba(255,200,50,0.32); border-color: rgba(255,200,50,0.75); }

.foot-btn.undo-btn {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.28);
  color: #e0e0e0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.foot-btn.undo-btn:hover { background: rgba(255,255,255,0.22); }

.foot-btn.bookmark-btn {
  background: #f0c040;
  color: #333;
  border-color: #e0a800;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.foot-btn.bookmark-btn:hover { background: #f5cc50; }
.foot-btn.bookmark-btn .btn-icon { font-size: 15px; }

.foot-btn.download-btn {
  background: #3a8fd4;
  color: #fff;
  border-color: #2e78b8;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.foot-btn.download-btn:hover { background: #2e78b8; }
.foot-btn.download-btn .btn-icon { font-size: 15px; }

/* =============================================
   DROPDOWNS
   ============================================= */
.dropdown { position: relative; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 500;
  min-width: 200px;
  padding: 6px 0;
}
.dropdown-menu.dropdown-up { top: auto; bottom: calc(100% + 4px); }
.dropdown-menu.dropdown-right { left: auto; right: 0; }
.dropdown-menu.open { display: block; }

.dd-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 14px 3px;
}
.dd-item {
  display: block;
  padding: 6px 14px;
  font-size: 13px;
  color: #333;
  text-decoration: none;
  cursor: pointer;
}
.dd-item:hover { background: var(--gray-50); }
.dd-item.dd-active { font-weight: 700; color: var(--green-dark); }
.dd-hr { border: none; border-top: 1px solid var(--gray-100); margin: 4px 0; }

/* =============================================
   MODALS
   ============================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
#modal-win { background: rgba(0,0,0,0.72); }

/* ── PAUSE BUTTON ── */
.pause-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.pause-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.header-account-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.9);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 6px;
  line-height: 1.6;
  transition: background 0.15s, color 0.15s;
  min-width: 32px;
}
.header-account-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.header-dashboard-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}
.header-dashboard-btn:hover { background: rgba(255,255,255,0.28); }
.hidden { display: none !important; }

/* ── PAUSE OVERLAY ── */
.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}
.pause-overlay.hidden { display: none; }
.pause-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px 48px;
  width: 520px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  position: relative;
}
.pause-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  font-size: 20px; color: #888;
  cursor: pointer; line-height: 1;
}
.pause-close:hover { color: #333; }
.pause-title {
  font-size: 26px;
  font-weight: 700;
  color: #111;
  margin: 0;
}
.pause-sub {
  font-size: 15px;
  color: #555;
  margin: 0;
}
.pause-resume-btn {
  margin-top: 8px;
  width: 100%;
  padding: 16px;
  background: #5cb85c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.pause-resume-btn:hover { background: #4cae4c; }

.modal-box {
  background: #fff;
  border-radius: 8px;
  width: 560px;
  max-width: 96vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.modal-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-tabs { display: flex; gap: 16px; flex: 1; }
.mtab {
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
}
.mtab.active { color: #222; border-bottom-color: #222; }
.modal-x {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 2px 6px;
}
.modal-x:hover { color: #111; }

.modal-body { padding: 8px 0; }
.mtab-content { display: none; }
.mtab-content.active { display: block; }
.mtab-content.hidden { display: none; }

/* Settings rows */
.srow {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
  font-size: 14px;
}
.srow > span { flex: 1; color: #333; }

.tgroup { display: flex; gap: 3px; }
.tbtn {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #555;
  font-weight: 500;
}
.tbtn:hover { background: var(--gray-300); }
.tbtn.active {
  background: #222;
  border-color: #222;
  color: #fff;
}

.reset-btn {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.lang-sel {
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  background: #fff;
}

/* Color picker */
#bg-picker {
  width: 36px;
  height: 30px;
  border-radius: 4px;
  border: 1px solid var(--gray-300);
  cursor: pointer;
  padding: 2px;
}

/* Deck grid */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 16px;
}
.deck-option {
  border: 2px solid var(--gray-300);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  font-size: 28px;
  transition: border-color 0.15s;
}
.deck-option:hover { border-color: var(--green-hover); }
.deck-option.selected { border-color: var(--green-hover); border-width: 3px; }

/* Win modal */
@keyframes winBoxIn {
  0%   { opacity: 0; transform: scale(0.6) translateY(40px); }
  70%  { transform: scale(1.04) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes trophyBounce {
  0%,100% { transform: scale(1) rotate(0deg); }
  20%     { transform: scale(1.25) rotate(-8deg); }
  40%     { transform: scale(1.25) rotate(8deg); }
  60%     { transform: scale(1.1) rotate(-4deg); }
  80%     { transform: scale(1.1) rotate(4deg); }
}
@keyframes starsIn {
  0%   { opacity: 0; transform: scale(0) rotate(-20deg); letter-spacing: -8px; }
  100% { opacity: 1; transform: scale(1) rotate(0deg);   letter-spacing: 4px; }
}
.win-box {
  text-align: center;
  padding: 36px 44px 28px;
  max-width: 380px;
  background: linear-gradient(160deg, #fff 60%, #f0faf0);
  border-top: 5px solid #4caf50;
  animation: winBoxIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.win-trophy {
  font-size: 68px;
  margin-bottom: 4px;
  display: inline-block;
  animation: trophyBounce 1s ease-in-out 0.4s both;
}
.win-stars {
  font-size: 26px;
  letter-spacing: 4px;
  margin-bottom: 10px;
  display: block;
  animation: starsIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s both;
}
.win-box h2 {
  font-size: 28px;
  margin-bottom: 4px;
  color: #1a5c1a;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.win-sub {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 22px;
}
.win-stats {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  background: var(--gray-50);
  border-radius: 10px;
  padding: 12px 8px;
  border: 1px solid var(--gray-100);
}
.win-stats div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  border-right: 1px solid var(--gray-100);
  padding: 0 8px;
}
.win-stats div:last-child { border-right: none; }
.win-stats label { font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; }
.win-stats strong { font-size: 22px; color: #222; font-weight: 800; }
.btn-play-again {
  display: block;
  width: 100%;
  background: var(--green-hover);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 11px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s;
}
.btn-play-again:hover { background: var(--green-dark); }
.btn-play-again.outline {
  background: none;
  border: 1.5px solid var(--gray-300);
  color: #555;
}
.btn-play-again.outline:hover { background: var(--gray-50); }

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

/* =============================================
   BELOW-GAME SEO CONTENT
   ============================================= */
#seo-content {
  background: #fff;
  padding: 0;
}
.seo-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px;
}
.seo-inner h1 {
  font-size: 26px;
  font-weight: 800;
  color: #111;
  margin-bottom: 12px;
  line-height: 1.25;
}
.seo-inner h2 {
  font-size: 20px;
  font-weight: 700;
  color: #111;
  margin: 28px 0 10px;
}
.seo-inner h3 {
  font-size: 16px;
  font-weight: 700;
  color: #222;
  margin: 18px 0 6px;
}
.seo-inner p { line-height: 1.65; color: #444; margin-bottom: 10px; }
.lead { font-size: 16px; color: #555; text-align: center; max-width: 680px; margin: 0 auto 24px; line-height: 1.6; }

.rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.stars { color: #f5a623; font-size: 20px; }
.rating-text { color: #666; font-size: 14px; }

.testimonials {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: var(--gray-50);
  padding: 24px;
  border-radius: 8px;
  margin: 20px 0;
}
.testimonial .stars { font-size: 18px; margin-bottom: 6px; }
.testimonial p { font-size: 14px; color: #444; font-weight: 500; font-style: italic; margin: 0 0 6px; }
.testimonial cite { font-size: 13px; color: var(--gray-500); font-style: normal; }

/* Review submission form */
.review-form-wrap {
  background: var(--gray-50);
  border-radius: 10px;
  padding: 24px;
  margin: 20px 0;
}
.review-form-title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
  margin: 0 0 12px;
}
.star-picker {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  font-size: 30px;
  cursor: pointer;
  color: #ddd;
  user-select: none;
}
.star-picker span.active { color: #f5a623; }
.star-picker span:hover { color: #f5a623; }
.rev-input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #333;
  background: #fff;
  box-sizing: border-box;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s;
}
.rev-input:focus { border-color: #5cb85c; }
.rev-textarea { resize: vertical; }
.rev-submit-btn {
  background: #5cb85c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.rev-submit-btn:hover { background: #4cae4c; }
.rev-msg { font-size: 13px; color: #5cb85c; margin: 8px 0 0; min-height: 18px; }

.rev-more-btn {
  background: none;
  border: 1.5px solid var(--gray-300);
  border-radius: 20px;
  padding: 9px 28px;
  font-size: 13px;
  font-weight: 700;
  color: #555;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-family: inherit;
}
.rev-more-btn:hover {
  border-color: var(--green-dark);
  color: var(--green-dark);
  background: #f0f7f0;
}

.rules-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 18px;
}
.rules-list li {
  padding: 5px 0 5px 22px;
  position: relative;
  color: #444;
  line-height: 1.55;
  border-bottom: 1px solid var(--gray-100);
}
.rules-list li::before {
  content: '✅';
  position: absolute;
  left: 0;
  top: 5px;
  font-size: 12px;
}

.faq h3 { margin-top: 20px; }

.game-collection-section { margin-top: 36px; }
.game-links-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.game-link-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 8px 16px;
  text-decoration: none;
  color: #333;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.game-link-card:hover { background: var(--gray-100); color: var(--green-dark); }

/* =============================================
   EMBED SECTION
   ============================================= */
.embed-section { margin: 36px 0; padding: 32px; background: var(--gray-50); border-radius: 8px; text-align: center; }
.embed-section h2 { margin-bottom: 12px; }
.embed-section p { color: #555; margin-bottom: 12px; }
.embed-logos { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; margin: 20px 0; color: #666; font-weight: 600; font-size: 14px; }
.embed-btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 13px 32px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  max-width: 480px;
  transition: background 0.15s;
}
.embed-btn:hover { background: #2563eb; }

/* New embed widget section */
.embed-widget-section {
  margin: 44px 0 0;
  padding: 36px 32px;
  background: #f6f8ff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  text-align: center;
}
.embed-title {
  font-size: 22px;
  font-weight: 800;
  color: #1a202c;
  margin: 0 0 14px;
}
.embed-desc {
  font-size: 15px;
  color: #555;
  line-height: 1.65;
  max-width: 680px;
  margin: 0 auto 10px;
}
.embed-desc-sm { font-size: 13px; color: #5b7c99; margin-top: 12px; }
.embed-options {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0 18px;
}
.embed-row { display: flex; align-items: center; gap: 8px; }
.embed-label { font-size: 13px; font-weight: 600; color: #444; white-space: nowrap; }
.embed-select {
  border: 1.5px solid #cbd5e0;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  color: #333;
  background: #fff;
  cursor: pointer;
  outline: none;
}
.embed-select:focus { border-color: #6366f1; }
.embed-generate-btn {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px 0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  max-width: 420px;
  transition: background 0.15s;
  letter-spacing: 0.01em;
}
.embed-generate-btn:hover { background: #4f46e5; }
.embed-result { margin-top: 24px; text-align: left; }
.embed-copy-label { font-size: 13px; font-weight: 600; color: #444; margin-bottom: 6px; }
.embed-code-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1.5px solid #cbd5e0;
  border-radius: 8px;
  overflow: hidden;
  background: #1e1e2e;
  margin-bottom: 20px;
}
.embed-code {
  flex: 1;
  display: block;
  padding: 12px 14px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #a5f3fc;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}
.embed-copy-btn {
  background: #6366f1;
  color: #fff;
  border: none;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.embed-copy-btn:hover { background: #4f46e5; }
.embed-copy-btn.copied { background: #16a34a; }
.embed-preview-wrap { margin-top: 4px; }
.embed-preview-wrap iframe {
  border-radius: 8px;
  border: 1.5px solid #cbd5e0;
  display: block;
  max-width: 100%;
}

/* Rating count */
.rating-count { font-size: 18px; color: #222; margin-right: 6px; }

/* =============================================
   SITE FOOTER
   ============================================= */
#site-footer {
  background: var(--gray-50);
  border-top: 1px solid #e5e7eb;
  padding: 32px 40px;
}
.sf-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
}
.sf-games { flex: 1; min-width: 0; }
.sf-collection-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.sf-collection-title a { color: var(--green-dark); text-decoration: none; }
.sf-game-icons { display: flex; flex-wrap: wrap; gap: 16px; }
.sf-game-icon-link { display: flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none; color: #444; font-size: 12px; width: 64px; text-align: center; }
.sf-game-icon-link:hover { color: var(--green-dark); }
.sf-game-icon {
  width: 48px; height: 48px;
  background: var(--green-dark);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #fff;
}
.sf-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}
.sf-copy { font-size: 12px; color: #999; }
.sf-links { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: flex-end; }
.sf-links a { color: #666; font-size: 13px; text-decoration: none; }
.sf-links a:hover { color: #111; }
.sf-social { display: flex; align-items: center; gap: 8px; }
.sf-social-label { font-size: 11px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: .04em; margin-right: 2px; }
.sf-social-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.sf-social-btn:hover { opacity: 0.82; transform: translateY(-2px); }
.sf-fb     { background: #1877F2; }
.sf-x      { background: #000; }
.sf-wa     { background: #25D366; }
.sf-reddit { background: #FF4500; }

/* Footer: simple link list (used on game pages without icon grid) */
.sf-game-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 8px;
}
.sf-game-links a {
  color: #555;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.sf-game-links a:hover { color: var(--green-dark); text-decoration: underline; }


/* =============================================
   ACCOUNT MODAL
   ============================================= */

/* Wider box for account modal */
.acct-box { width: 720px; max-width: 96vw; }

.acct-modal-body { padding: 0; }
.acct-tab-pad    { padding: 20px 24px; }

/* Avatar circle */
.acct-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, #2d7a2d, #4cae4c);
  color: #fff; font-size: 30px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 24px;
  box-shadow: 0 2px 12px rgba(45,110,45,0.3);
}

/* Account form fields */
.acct-field-group { margin-bottom: 18px; }
.acct-label { display: block; font-size: 13px; font-weight: 700; color: #555; margin-bottom: 6px; }
.acct-input-row   { display: flex; gap: 8px; }
.acct-input {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 14px; font-family: inherit; color: #333;
  transition: border-color 0.15s;
}
.acct-input:focus { outline: none; border-color: #2d7a2d; }
.acct-save-btn {
  padding: 10px 18px; background: #2d7a2d; color: #fff;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 700;
  transition: background 0.15s;
}
.acct-save-btn:hover { background: #245624; }
.acct-note { font-size: 12px; color: #aaa; margin-top: 20px; text-align: center; }

/* Stats tab */
.stats-filter-bar { margin-bottom: 16px; }
.stats-filter-sel {
  padding: 8px 12px; border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 14px; font-family: inherit; cursor: pointer; width: 100%;
  background: #fff; color: #333;
}
.stats-panels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 560px) { .stats-panels { grid-template-columns: 1fr; } }

.stats-panel { background: #f8f8f8; border-radius: 10px; padding: 14px 16px; }
.stats-panel-title { font-size: 14px; font-weight: 700; margin: 0 0 12px; color: #333; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.stats-table td { padding: 6px 2px; border-bottom: 1px solid #eee; color: #555; }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table td:last-child { text-align: right; font-weight: 700; color: #222; }

.stats-chart-label { font-size: 12px; color: #aaa; text-align: center; margin: 10px 0 6px; }

/* Donut chart */
.donut-wrap   { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.donut-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center; }
.donut-leg-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: #555;
}
.donut-leg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.stats-no-data { text-align: center; color: #bbb; font-size: 13px; padding: 24px 0; }

/* Google sign-in section */
.acct-avatar-img {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; display: block; margin: 4px auto 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.acct-google-wrap { margin-bottom: 16px; }
#google-signin-btn { display: flex; justify-content: center; margin-bottom: 12px; }
.acct-or-divider {
  display: flex; align-items: center; gap: 10px;
  color: #bbb; font-size: 12px; margin: 4px 0 16px;
}
.acct-or-divider::before, .acct-or-divider::after {
  content: ''; flex: 1; height: 1px; background: #e5e5e5;
}
.acct-google-signed-in {
  display: flex; align-items: center; justify-content: space-between;
  background: #f8f8f8; border: 1px solid #e5e5e5;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
}
.acct-google-info { display: flex; align-items: center; gap: 10px; }
.acct-google-logo { flex-shrink: 0; }
.acct-google-name  { font-weight: 700; font-size: 14px; color: #222; }
.acct-google-email { font-size: 12px; color: #888; margin-top: 1px; }
.acct-signout-btn {
  padding: 7px 14px; border: 1.5px solid #ddd; border-radius: 8px;
  background: #fff; color: #555; font-size: 13px; font-family: inherit;
  cursor: pointer; font-weight: 600; transition: border-color 0.15s, color 0.15s;
}
.acct-signout-btn:hover { border-color: #e53935; color: #e53935; }

/* Achievements tab */
.ach-list { display: flex; flex-direction: column; gap: 10px; }
.ach-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: #f5f5f5;
  border-radius: 12px; border: 1px solid #eee;
  opacity: 0.55; transition: opacity 0.2s;
}
.ach-row.ach-unlocked {
  opacity: 1; background: #fff;
  border-color: #e0e0e0;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}
.ach-badge {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #ddd; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ach-badge.ach-badge-on { border-color: #f5a623; background: #fff8ed; }
.ach-badge-icon { font-size: 20px; line-height: 1; }
.ach-name  { font-weight: 700; font-size: 14px; color: #222; }
.ach-desc  { font-size: 12px; color: #888; margin-top: 2px; }
.ach-date  { font-size: 11px; color: #4cae4c; margin-top: 3px; font-weight: 600; }

/* =============================================
   UTILITIES
   ============================================= */
.hidden { display: none !important; }

/* =============================================
   RESPONSIVE — MOBILE-FIRST
   ============================================= */

/* ── iOS 100vh fix: use dynamic viewport height where supported ── */
@supports (min-height: 100dvh) {
  #game-wrapper { min-height: 100dvh; }
}

/* ── Touch device: prevent scroll fighting during card drag ── */
@media (hover: none) and (pointer: coarse) {
  .card       { touch-action: none; }
  #game-board { touch-action: pan-y; }
  /* Bigger tap targets for fat fingers */
  .foot-btn   { min-height: 44px; }
  .mode-btn   { min-height: 40px; }
  .dd-item    { min-height: 44px; padding-top: 11px; padding-bottom: 11px; }
  .card:hover,
  .card.card-face-up:hover {
    transform: none;
    filter: none;
    box-shadow: var(--card-shadow);
  }
}

/* ── Sidebar hidden at ≤1400px ── */
@media (max-width: 1400px) {
  #sidebar { display: none; }
  :root    { --sidebar-w: 0px; }
}

/* ── Tablet (≤ 768px) ── */
@media (max-width: 768px) {
  #main-area {
    padding: 8px 8px 0;
    min-width: 0;
  }
  #game-board {
    gap: 8px;
    overflow-x: clip;
  }
  #top-row,
  #tableau {
    gap: 5px;
  }
  #game-header {
    padding: 0 8px;
  }
  .header-left,
  .header-right {
    min-width: 0;
  }
  .header-right {
    gap: 8px;
    font-size: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .mode-btn {
    padding: 4px 10px;
  }
  .pause-btn {
    min-width: 34px;
  }
  .logo-text      { font-size: 15px; }
  .seo-inner      { padding: 32px 20px; }
  .seo-inner h1   { font-size: 22px; }
  /* Footer */
  .sf-inner       { flex-direction: column; }
  .sf-right       { align-items: flex-start; }
}

/* ── Mobile landscape / small tablet (≤ 640px) ── */
@media (max-width: 640px) {
  :root {
    --card-w:     64px;
    --card-h:     90px;
    --peek-down:  14px;
    --peek-up:    19px;
  }

  /* Game area padding */
  #main-area { padding: 6px 6px 0 6px; }
  #top-row   { gap: 4px; }
  #tableau   { gap: 4px; }
  .pile      { border-width: 1px; }

  /* Waste pile fan — narrower so it doesn't eat 2 column widths */
  .waste-pile { width: calc(var(--card-w) + 26px); }

  /* Cards text */
  .card-center   { font-size: 20px; }
  .card-rank     { font-size: 12px; }
  .card-suit-sm  { font-size: 9px; }
  .card-face-art { font-size: 24px; }
  .found-hint    { font-size: 22px; }

  /* Header */
  .header-right { font-size: 11px; gap: 7px; }
  .logo-text    { font-size: 14px; }
  .mode-btn     { padding: 4px 9px; font-size: 12px; }

  /* Footer — auto height, wraps, safe-area-aware */
  #game-footer {
    height: auto;
    min-height: var(--footer-h);
    padding: 7px 10px;
    padding-bottom: max(7px, env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: 5px;
  }
  .footer-left, .footer-right { gap: 5px; flex-wrap: wrap; }
  .foot-btn { padding: 7px 11px; font-size: 12px; }

  /* Slim down icon buttons — hide all text labels */
  .foot-btn.icon-btn span       { display: none; }
  .foot-btn.bookmark-btn span:not(.btn-icon) { display: none; }
  .foot-btn.download-btn span:not(.btn-icon) { display: none; }

  /* Dropdown: cap height so it doesn't go off screen */
  .dropdown-menu { max-height: 70vh; overflow-y: auto; }

  /* SEO content */
  .testimonials   { grid-template-columns: 1fr; }
  .seo-inner      { padding: 28px 16px; }
  .seo-inner h1   { font-size: 20px; }
  .lead           { font-size: 15px; }
  .embed-options  { flex-direction: column; align-items: stretch; }
  .embed-row      { justify-content: space-between; }
  .embed-select   { flex: 1; }

  /* Account modal full-width on mobile */
  .acct-box { width: 100%; }
}

/* ── Small phone (≤ 480px) ── */
@media (max-width: 480px) {
  :root {
    --card-w:     54px;
    --card-h:     76px;
    --peek-down:  11px;
    --peek-up:    16px;
  }

  /* Header: hide Klondike mode buttons — accessible in Settings */
  #btn-turn1, #btn-turn3 { display: none; }

  /* Compress logo text */
  .logo-text { font-size: 13px; }

  /* Stats text — tighter */
  .header-right { gap: 5px; font-size: 10px; }
  .pause-btn    { padding: 2px 4px; font-size: 14px; }
  #game-header  { height: auto; min-height: var(--header-h); padding-top: 4px; padding-bottom: 4px; }

  /* Footer: remove non-essential buttons */
  .foot-btn.bookmark-btn,
  .foot-btn.download-btn { display: none; }

  /* Waste pile — minimal fan */
  .waste-pile { width: calc(var(--card-w) + 18px); }

  /* Foundation hint icon fits in narrow card */
  .found-hint { font-size: 18px; }

  /* Smaller card text */
  .card-rank { font-size: 11px; }
  .card-suit-sm { font-size: 8px; }
  .card-center { font-size: 18px; }
  .card-face-art { font-size: 20px; }

  /* Settings modal row — stack toggle groups */
  .srow { flex-wrap: wrap; }
  .tgroup { flex-wrap: wrap; }

  /* SEO / below-game */
  .seo-inner   { padding: 20px 14px; }
  .seo-inner h1 { font-size: 18px; }

  /* Footer site */
  #site-footer { padding: 24px 16px; }
  .sf-inner { flex-direction: column; gap: 20px; }
  .sf-right { align-items: flex-start; }
}

/* ── Phone portrait-first layout ── */
@media (max-width: 480px) and (orientation: portrait) {
  #main-area {
    padding: 4px 4px 0;
  }

  #game-board {
    gap: 6px;
  }

  #top-row,
  #tableau {
    gap: 3px;
  }

  #game-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    row-gap: 4px;
  }

  .header-left {
    gap: 4px;
    flex-wrap: wrap;
  }

  .header-right {
    gap: 4px;
    font-size: 9px;
    line-height: 1.15;
    justify-content: flex-end;
  }

  .mode-btn {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 16px;
  }

  .pause-btn,
  .header-account-btn,
  .header-dashboard-btn {
    min-height: 30px;
  }

  #game-footer {
    padding: 6px 8px;
    gap: 4px;
  }

  .footer-left,
  .footer-right {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }

  .foot-btn {
    padding: 7px 8px;
    font-size: 11px;
  }

  .foot-btn.primary-btn,
  .foot-btn.undo-btn,
  .foot-btn.hint-btn {
    flex: 1 1 0;
    justify-content: center;
  }

  .waste-pile {
    width: calc(var(--card-w) + 14px);
  }

  .found-hint {
    font-size: 16px;
  }
}

/* ── Very small phone (≤ 360px) ── */
@media (max-width: 360px) {
  :root {
    --card-w:     46px;
    --card-h:     64px;
    --peek-down:  9px;
    --peek-up:    13px;
  }

  #top-row { gap: 3px; }
  #tableau { gap: 3px; }

  /* Hide logo text completely — show only card icon */
  .logo-text { display: none; }

  .header-right { font-size: 9px; gap: 4px; }
  .foot-btn     { padding: 6px 8px; font-size: 11px; }
  .card-rank    { font-size: 10px; }
  .card-suit-sm { font-size: 7px; }
  .found-hint   { font-size: 15px; }
  .card-center  { font-size: 16px; }

  /* Waste: minimal */
  .waste-pile { width: calc(var(--card-w) + 14px); }
}

/* ── DEAL ANIMATION ── */
@keyframes deckShuffle {
  0%   { transform: translateX(0)   rotate(0deg); }
  20%  { transform: translateX(-10px) rotate(-4deg); }
  40%  { transform: translateX(10px)  rotate(4deg); }
  60%  { transform: translateX(-6px)  rotate(-2deg); }
  80%  { transform: translateX(6px)   rotate(2deg); }
  100% { transform: translateX(0)   rotate(0deg); }
}
.deck-shuffle { animation: deckShuffle 0.45s ease-in-out; }

/* ── CARD FLIP (face-down → face-up reveal) ── */
@keyframes cardFlip {
  0%   { transform: perspective(500px) rotateY(-90deg) scale(0.9); opacity: 0.3; }
  60%  { transform: perspective(500px) rotateY(8deg)   scale(1.04); opacity: 1; }
  100% { transform: perspective(500px) rotateY(0deg)   scale(1);    opacity: 1; }
}
.card-flip { animation: cardFlip 0.32s ease-out; }

/* ── FOUNDATION POP (card lands on foundation) ── */
@keyframes foundPop {
  0%   { transform: scale(0.65); opacity: 0.6; }
  65%  { transform: scale(1.14); }
  85%  { transform: scale(0.96); }
  100% { transform: scale(1);    opacity: 1; }
}
.found-pop { animation: foundPop 0.3s cubic-bezier(0.34,1.56,0.64,1); }

/* ── INVALID MOVE SHAKE ── */
@keyframes cardShake {
  0%,100% { transform: translateX(0); }
  18%     { transform: translateX(-9px) rotate(-2deg); }
  36%     { transform: translateX(9px)  rotate(2deg); }
  54%     { transform: translateX(-6px); }
  72%     { transform: translateX(6px); }
  88%     { transform: translateX(-3px); }
}
.card-shake { animation: cardShake 0.38s ease; }

/* ── FACE-UP CARD HOVER LIFT ── */
.card.card-face-up { cursor: pointer; }
.card.card-face-up:hover {
  transform: translateY(-4px);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: var(--card-shadow-hover);
  z-index: 200 !important;
}

/* ── HINT PULSE ── */
@keyframes hintPulse {
  0%,100% { box-shadow: 0 0 0 3px #00e676, 0 0 16px rgba(0,230,118,0.6); transform: translateY(0); }
  50%     { box-shadow: 0 0 0 5px #00e676, 0 0 28px rgba(0,230,118,0.9); transform: translateY(-4px); }
}
@keyframes hintPulseDest {
  0%,100% { box-shadow: 0 0 0 3px #2979ff, 0 0 14px rgba(41,121,255,0.5); }
  50%     { box-shadow: 0 0 0 5px #2979ff, 0 0 24px rgba(41,121,255,0.8); }
}
.card.hint-highlight {
  animation: hintPulse 0.65s ease-in-out infinite;
  z-index: 500 !important;
  position: relative;
}
.card.hint-dest,
.pile.hint-dest {
  animation: hintPulseDest 0.65s ease-in-out infinite;
}
.pyr-card.hint-hl {
  animation: hintPulse 0.65s ease-in-out infinite;
  z-index: 500 !important;
  position: relative;
}

/* ── SCORE POPUP ── */
@keyframes scorePop {
  0%   { opacity: 1; transform: translateY(0)   scale(1); }
  80%  { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-55px) scale(0.9); }
}
.score-popup {
  position: fixed;
  font-size: 18px;
  font-weight: 700;
  color: #ffe600;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 9999;
  animation: scorePop 0.9s ease-out forwards;
}

/* ═══════════════════════════════════════════════
   DAILY CHALLENGE MODAL
   ═══════════════════════════════════════════════ */
.dchal-box {
  width: 700px;
  max-width: 97vw;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
}
.dchal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: #555; line-height: 1;
}
.dchal-close:hover { color: #111; }
.dchal-header {
  text-align: center;
  padding: 28px 20px 16px;
  position: relative;
}
.dchal-header h2 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.dchal-header p  { color: #666; font-size: 14px; }

.dchal-cal-wrap {
  background: #f7f7f7;
  border-radius: 8px;
  margin: 0 20px 16px;
  padding: 16px;
}
.dchal-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dchal-month-nav span { font-size: 16px; font-weight: 700; }
.dchal-nav-btn {
  background: none; border: 1px solid #ccc;
  border-radius: 4px; cursor: pointer;
  padding: 2px 8px; font-size: 14px; color: #444;
}
.dchal-nav-btn:hover { background: #eee; }
.dchal-nav-btn:disabled { opacity: 0.3; cursor: default; }

/* Progress bar */
.dchal-progress-wrap {
  position: relative;
  margin: 0 20px 20px;
  padding: 0 0 28px;
}
.dchal-prog-label {
  font-size: 13px; font-weight: 700;
  color: #e67e00;
  margin-bottom: 6px;
}
.dchal-prog-track {
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  position: relative;
}
.dchal-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #f0a500, #e67e00);
  border-radius: 3px;
  transition: width 0.4s;
}
.dchal-trophies {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
}
.dchal-trophy {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  top: -24px;
}
.dchal-trophy-icon { font-size: 22px; line-height: 1; }
.dchal-trophy-num  {
  font-size: 11px; font-weight: 700;
  position: absolute;
  top: 24px;
}

/* Calendar inside dchal */
.dchal-cal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
}
.dchal-cal-table th {
  text-align: center;
  font-size: 12px;
  color: #999;
  font-weight: 600;
  padding: 4px 0;
}
.dchal-cal-table td {
  text-align: center;
  padding: 7px 0;
  font-size: 14px;
  font-weight: 600;
  color: #bbb;
  border-radius: 50%;
  cursor: default;
}
.dchal-cal-past   { color: #555; }
.dchal-cal-today  { background: #f5a623 !important; color: #fff !important; border-radius: 50%; }
.dchal-cal-won    { background: #4CAF50 !important; color: #fff !important; border-radius: 50%; cursor: default; }

.dchal-play-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px 24px;
  padding: 14px;
  background: #5cb85c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.dchal-play-btn:hover { background: #4cae4c; }

/* ═══════════════════════════════════════════════
   LEADERBOARD MODAL
   ═══════════════════════════════════════════════ */
.lbm-box {
  width: 760px;
  max-width: 97vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  padding: 0;
}
.lbm-head {
  padding: 20px 24px 14px;
  border-bottom: 1px solid #eee;
  position: relative;
  flex-shrink: 0;
}
.lbm-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}
.lbm-title span { text-decoration: underline; cursor: pointer; }
.lbm-user-msg {
  font-size: 13px;
  color: #666;
  margin-top: 8px;
  padding: 8px 12px;
  background: #f8f8f8;
  border-radius: 6px;
  text-align: center;
}
.lbm-user-msg.found { background: #e8f5e9; color: #2e7d32; }
.lbm-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none;
  font-size: 22px; cursor: pointer; color: #555;
}
.lbm-close:hover { color: #111; }
.lbm-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 24px 20px;
}
.lbm-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}
.lbm-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #eee;
  color: #555;
  font-weight: 700;
  font-size: 13px;
}
.lbm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.lbm-table tr:hover td { background: #fafafa; }
.lbm-table tr.lbm-me td { background: #fffde7; font-weight: 700; }
.lbm-rank-cell { width: 50px; text-align: center; font-weight: 700; }
.lbm-medal { font-size: 20px; }
.lbm-username-cell { font-weight: 600; }
.lbm-loading { text-align: center; padding: 30px; color: #888; }
