/* ============================================================
   F2pGames – Shared Stylesheet
   Aesthetic: Rich casino felt · ivory cards · mahogany & gold
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,700&family=Lato:wght@400;700;900&display=swap');

/* ── TOKENS ── */
:root {
  --felt:        #2d6a4f;
  --felt-dark:   #1b4332;
  --felt-deeper: #122d23;
  --felt-light:  #40916c;
  --mahogany:    #3d1a08;
  --mahogany-lt: #5c2b10;
  --gold:        #d4a017;
  --gold-light:  #f0c040;
  --gold-dim:    rgba(212,160,23,.35);
  --ivory:       #fdf6e3;
  --ivory-dark:  #f0e6c8;
  --card-border: #c9a96e;
  --red:         #c0392b;
  --black:       #1a1a2e;
  --text-light:  #e8f5e9;
  --text-dim:    #a8d5b5;
  --ad-bg:       #111e14;
  --ad-border:   #2e4a2e;
  --radius:      8px;
  --card-w:      82px;
  --card-h:      115px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Lato', sans-serif;
  background: var(--felt-dark);
  color: var(--text-light);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── HEADER ── */
.site-header {
  background: var(--mahogany);
  border-bottom: 3px solid var(--gold);
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 2px 16px rgba(0,0,0,.55);
}
.header-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 24px;
  height: 50px; display: flex; align-items: center; gap: 20px;
}
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; flex-shrink: 0; }
.logo-icon { font-size: 1.6rem; color: var(--gold); }
.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem; font-weight: 900;
  color: var(--gold); letter-spacing: 1px;
}
.main-nav { display: flex; gap: 2px; flex: 1; }
.nav-link {
  color: var(--text-dim); text-decoration: none;
  padding: 6px 13px; border-radius: 4px;
  font-weight: 700; font-size: .88rem; letter-spacing: .5px;
  transition: all .2s;
}
.nav-link:hover, .nav-link.active { background: rgba(212,160,23,.15); color: var(--gold); }
.btn-header {
  background: var(--gold); color: var(--mahogany);
  border: none; padding: 8px 18px; border-radius: 5px;
  font-weight: 900; font-size: .88rem; cursor: pointer;
  letter-spacing: .5px; transition: background .2s, transform .1s; flex-shrink: 0;
}
.btn-header:hover { background: var(--gold-light); transform: translateY(-1px); }

/* ── HAMBURGER ── */
.nav-toggle {
  display: none;
  background: none; border: 1.5px solid var(--gold-dim);
  color: var(--gold); padding: 5px 9px; border-radius: 5px;
  cursor: pointer; font-size: 1.1rem; line-height: 1;
  flex-shrink: 0;
}
.nav-toggle:hover { border-color: var(--gold); background: rgba(212,160,23,.1); }

/* ── AD SLOTS ── */
.ad-slot {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 6px;
}
.ad-label { font-size: .6rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; opacity: .55; }
.ad-placeholder {
  background: var(--ad-bg); border: 1.5px dashed var(--ad-border);
  border-radius: 4px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: #3a6a3a; font-size: .72rem; font-weight: 700;
}
.ad-leaderboard .ad-placeholder { width: min(728px,100%); height: 90px; }
.ad-sidebar   .ad-placeholder   { width: 160px; height: 600px; }
.ad-rect      .ad-placeholder   { width: 300px; height: 250px; }
.ad-banner    .ad-placeholder   { width: min(468px,100%); height: 60px; }

/* ── SECTION TITLES ── */
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.85rem; font-weight: 900;
  color: var(--gold); letter-spacing: .5px;
}
.section-sub { color: var(--text-dim); font-size: .95rem; margin-top: 6px; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--gold); color: var(--mahogany);
  border: none; padding: 12px 32px; border-radius: 8px;
  font-weight: 900; font-size: 1rem; cursor: pointer;
  letter-spacing: .5px; transition: all .2s; display: inline-block;
  text-decoration: none; text-align: center; font-family: 'Lato', sans-serif;
}
.btn-primary:hover { background: var(--gold-light); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(212,160,23,.4); }
.btn-secondary {
  background: transparent; border: 1.5px solid var(--gold-dim);
  color: var(--text-dim); padding: 8px 20px; border-radius: 5px;
  cursor: pointer; font-size: .85rem; transition: all .2s; font-family: 'Lato', sans-serif;
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-icon {
  background: rgba(212,160,23,.1); border: 1px solid var(--gold-dim);
  color: var(--gold); padding: 3px 8px; border-radius: 4px;
  cursor: pointer; font-size: .7rem; font-weight: 700; transition: all .2s; white-space: nowrap;
}
.btn-icon:hover { background: rgba(212,160,23,.25); }
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }

/* ── SCORE BAR ── */
.score-bar {
  width: 100%; max-width: 700px;
  background: rgba(0,0,0,.3); border: 1px solid var(--gold-dim);
  border-radius: 6px; padding: 4px 12px;
  display: flex; align-items: center; gap: 14px; flex-wrap: nowrap;
}
.score-item { display: flex; flex-direction: row; align-items: center; gap: 5px; }
.score-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); white-space: nowrap; }
.score-value { font-family: 'Playfair Display', serif; font-size: .9rem; font-weight: 700; color: var(--gold); }
.score-actions { flex: 1; display: flex; flex-direction: row; justify-content: flex-end; gap: 5px; flex-wrap: nowrap; }

/* ── CARDS ── */
.card {
  width: var(--card-w); height: var(--card-h);
  background: var(--ivory); border: 2px solid var(--card-border);
  border-radius: var(--radius); position: absolute;
  cursor: pointer; user-select: none;
  box-shadow: 2px 3px 8px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  justify-content: space-between; padding: 5px 6px;
  transition: box-shadow .15s, transform .15s;
  font-family: 'Lato', sans-serif; font-weight: 700;
}
.card:hover  { box-shadow: 3px 5px 16px rgba(0,0,0,.5); }
.card.face-down {
  background: repeating-linear-gradient(135deg, #1b5e3a 0px,#1b5e3a 4px,#164d30 4px,#164d30 8px);
  cursor: default; border-color: #0d3320;
}
.card.face-down::after {
  content: ''; position: absolute; inset: 5px;
  border: 2px solid rgba(212,160,23,.3); border-radius: 4px;
}
.card.red   { color: var(--red); }
.card.black { color: var(--black); }
.card.selected { box-shadow: 0 0 0 3px var(--gold), 2px 3px 8px rgba(0,0,0,.35) !important; }
.card-rank-top { font-size: 1.05rem; line-height: 1; }
.card-suit-top { font-size: .85rem;  line-height: 1; }
.card-center   { font-size: 2rem; text-align: center; opacity: .85; margin: auto; }
.card-rank-bot { font-size: 1.05rem; line-height: 1; transform: rotate(180deg); align-self: flex-end; }
.card.dragging { opacity: .7; box-shadow: 6px 10px 24px rgba(0,0,0,.6); z-index: 1000; transform: rotate(2deg); }
.card.hint-glow { animation: hintGlow .75s ease-in-out 3; }
.card.in-col { position: absolute; }

@keyframes hintGlow {
  0%,100% { box-shadow: 2px 3px 8px rgba(0,0,0,.35); }
  50%      { box-shadow: 0 0 22px 5px var(--gold), 2px 3px 8px rgba(0,0,0,.35); }
}

/* ── PILES ── */
.pile {
  width: var(--card-w); height: var(--card-h);
  border: 2px dashed var(--gold-dim); border-radius: var(--radius);
  position: relative; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: border-color .2s;
  flex-shrink: 0; overflow: hidden;
}
.pile.drag-over { border-color: var(--gold); background: rgba(212,160,23,.1); }
.foundation-pile::after { content: attr(data-suit); font-size: 2rem; opacity: .2; pointer-events: none; }
.stock-pile::after      { content: '🂠'; font-size: 2.5rem; opacity: .25; pointer-events: none; }
.freecell-pile::after {
  content: attr(data-label); font-size: .62rem; opacity: .45;
  text-align: center; color: var(--gold); pointer-events: none;
  font-weight: 700; letter-spacing: .5px; white-space: pre-line;
}
/* Hide background label once a card occupies the pile */
.pile.occupied::after { display: none; }

/* ── WIN OVERLAY ── */
.win-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; border-radius: 12px; backdrop-filter: blur(4px);
}
.win-overlay.hidden { display: none; }
.win-card {
  background: var(--mahogany); border: 3px solid var(--gold);
  border-radius: 16px; padding: 40px 50px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  animation: winPop .5s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes winPop { from{transform:scale(.5);opacity:0} to{transform:scale(1);opacity:1} }
.win-suits { font-size: 2.5rem; letter-spacing: 8px; margin-bottom: 8px; }
.win-card h2 { font-family: 'Playfair Display', serif; font-size: 3rem; color: var(--gold); margin-bottom: 10px; }
.win-stats  { color: var(--text-dim); margin-bottom: 24px; font-size: 1rem; }

/* ── STATS SECTION ── */
.stats-section { background: var(--mahogany); border-top: 3px solid var(--gold); border-bottom: 3px solid var(--gold); padding: 44px 20px; }
.stats-inner { max-width: 920px; margin: 0 auto; text-align: center; }
.stats-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 14px; margin: 24px 0; }
.stat-card { background: rgba(0,0,0,.3); border: 1px solid var(--gold-dim); border-radius: 10px; padding: 18px 8px; }
.stat-num  { font-family: 'Playfair Display', serif; font-size: 2rem; font-weight: 700; color: var(--gold); }
.stat-label { font-size: .72rem; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── INFO SECTION ── */
.info-section { background: var(--felt-dark); padding: 52px 20px; }
.info-inner { max-width: 920px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
.info-block h2 { font-family: 'Playfair Display', serif; font-size: 1.5rem; color: var(--gold); margin-bottom: 14px; }
.info-block h3 { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--gold-light); margin-bottom: 10px; }
.info-block p  { color: var(--text-dim); line-height: 1.8; margin-bottom: 12px; font-size: .94rem; }
.how-to-list { list-style: none; counter-reset: steps; }
.how-to-list li {
  counter-increment: steps; padding: 10px 0 10px 44px;
  position: relative; color: var(--text-dim); line-height: 1.7;
  font-size: .92rem; border-bottom: 1px solid rgba(255,255,255,.05);
}
.how-to-list li::before {
  content: counter(steps); position: absolute; left: 0; top: 10px;
  width: 28px; height: 28px; background: var(--gold); color: var(--mahogany);
  border-radius: 50%; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
}
.how-to-list li strong { color: var(--text-light); }
.tips-block { grid-column: 1/-1; }
.tips-block ul { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; list-style: none; }
.tips-block ul li {
  background: rgba(0,0,0,.25); border-left: 3px solid var(--gold);
  padding: 10px 14px; color: var(--text-dim); font-size: .89rem; border-radius: 0 6px 6px 0;
}

/* ── FOOTER ── */
.site-footer { background: var(--mahogany); border-top: 3px solid var(--gold); padding: 20px; }
.footer-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; text-align: center;
}
.footer-logo { font-family: 'Playfair Display', serif; color: var(--gold); font-size: 1.1rem; order: 3; }
.footer-copy { color: var(--text-dim); font-size: .8rem; order: 1; }
.footer-nav { display: flex; gap: 20px; order: 2; }
.footer-nav a { color: var(--text-dim); text-decoration: none; font-size: .8rem; transition: color .2s; }
.footer-nav a:hover { color: var(--gold); }

/* ── GAME PAGE LAYOUT ── */
.main-layout {
  max-width: 1400px; margin: 0 auto;
  display: grid; grid-template-columns: 184px 1fr 184px;
  padding: 6px 0; min-height: 700px;
}
.sidebar { display: flex; align-items: flex-start; justify-content: center; padding-top: 6px; }
.game-section { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 7px; position: relative; }
.game-board   { width: 100%; max-width: 700px; display: flex; flex-direction: column; gap: 10px; }

/* ── TABLEAU / FREECELL COLUMN ROWS ── */
.top-row { display: flex; align-items: flex-start; gap: 10px; }
.card-area  { display: flex; gap: 10px; }
.spacer     { flex: 1; }
.foundation-area { display: flex; gap: 10px; margin-left: auto; }
.tableau-row, .fc-top-row, .fc-tableau-row { display: flex; gap: 10px; align-items: flex-start; }
.tableau-col, .fc-tableau-col {
  width: var(--card-w); min-height: var(--card-h);
  border: 2px dashed rgba(212,160,23,.2); border-radius: var(--radius);
  position: relative; flex-shrink: 0;
}
.tableau-col.drag-over, .fc-tableau-col.drag-over { border-color: var(--gold); background: rgba(212,160,23,.08); }

/* ── FLASH MESSAGE ── */
.flash-msg {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--mahogany); border: 2px solid var(--gold); color: var(--gold-light);
  padding: 10px 20px; border-radius: 8px; font-weight: 700; z-index: 9999;
  font-family: 'Lato', sans-serif; box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: flashFade 2.5s forwards; pointer-events: none;
  max-width: min(92vw, 480px); width: max-content;
  white-space: normal; word-wrap: break-word; text-align: center;
  font-size: .92rem; line-height: 1.35; box-sizing: border-box;
}
@keyframes flashFade { 0%,65%{opacity:1} 100%{opacity:0} }
@media (max-width: 480px) {
  .flash-msg { top: 60px; font-size: .82rem; padding: 8px 14px; max-width: 94vw; }
}

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  .sidebar { display: none; }
  .main-layout { grid-template-columns: 1fr; }
}
@media (max-width: 740px) {
  :root { --card-w: 62px; --card-h: 87px; }
  .stats-grid { grid-template-columns: repeat(3,1fr); }
  .info-inner { grid-template-columns: 1fr; }
  .tips-block { grid-column: 1; }
  .tips-block ul { grid-template-columns: 1fr; }
  .game-board { max-width: 100%; }
  .tableau-row, .fc-tableau-row { gap: 6px; }
  .top-row, .fc-top-row { gap: 6px; }
  .foundation-area { gap: 6px; }
}
@media (max-width: 500px) {
  :root { --card-w: 50px; --card-h: 70px; }
  .score-bar { flex-wrap: wrap; row-gap: 4px; }
  .score-actions { flex: 1 1 100%; justify-content: center; flex-wrap: nowrap; }
  .btn-icon { font-size: .65rem; padding: 3px 6px; }
  .card-center { font-size: 1.4rem; }
  .win-card { padding: 28px 24px; }
  .win-card h2 { font-size: 2.2rem; }
}

/* ── CONFETTI ── */
.confetti-container {
  position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden;
}
.confetti-piece {
  position: absolute; top: -10px;
  width: 10px; height: 14px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg) scaleX(1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg) scaleX(-1); opacity: 0; }
}

/* ── MOBILE NAV (hamburger) ── */
@media (max-width: 950px) {
  .header-inner {
    position: relative; height: 48px; padding: 0 10px;
    display: flex; align-items: center; justify-content: space-between; gap: 0;
  }
  .nav-toggle { display: flex; order: 1; flex-shrink: 0; z-index: 2; }
  .logo { position: absolute; left: 50%; transform: translateX(-50%); order: 2; }
  .main-nav {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--mahogany); border-bottom: 2px solid var(--gold);
    flex-direction: column; padding: 6px 12px; gap: 1px;
    z-index: 300; box-shadow: 0 4px 20px rgba(0,0,0,.5); order: 4;
    /* Bound the dropdown to the visible viewport height (minus the header
       itself) and make it independently scrollable — on short landscape-
       phone screens the page's own scroll can't be relied on to reach
       every item, since this dropdown sits absolutely over the content. */
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .main-nav.open { display: flex; }
  .nav-link { padding: 7px 12px; font-size: .84rem; border-radius: 4px; flex-shrink: 0; }

  /* Extra-compact rows specifically for short (landscape-phone) viewports,
     so as many nav items as possible fit without needing to scroll at all. */
  @media (max-height: 420px) {
    .main-nav { padding: 3px 10px; gap: 0; max-height: calc(100vh - 40px); }
    .nav-link { padding: 5px 10px; font-size: .76rem; }
  }
  .btn-header { order: 3; flex-shrink: 0; font-size: .78rem; padding: 6px 10px; margin-left: auto; z-index: 2; }
}

/* ── AD SWAP: vertical sidebars hidden, optional horizontal pair on phones ── */
@media (max-width: 950px) {
  .sidebar { display: none !important; }
  .main-layout { grid-template-columns: 1fr; }
}
.ad-horizontal-pair {
  display: none; flex-direction: row; gap: 8px; justify-content: center;
  flex-wrap: wrap; padding: 6px 0;
}
@media (max-width: 950px) {
  .ad-horizontal-pair { display: flex; }
  .ad-horizontal-pair .ad-placeholder { width: min(320px, 45vw); height: 50px; }
}

/* ── UNIVERSAL MOBILE WIDTH GUARD ──
   Every game wraps its play area in .game-board or a game-specific
   "-wrap" container. This ensures none of them can ever exceed the
   viewport width regardless of internal fixed-px children. ── */
.game-board, [class$="-wrap"], [class*="-board"] {
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 480px) {
  .score-bar { padding: 3px 8px; gap: 8px; }
  .score-label { font-size: .56rem; }
  .score-value { font-size: .78rem; }
}
