/* ===== SPIDER LAYOUT =====
 * Perustuu v119:n spider.php:n inline-CSS:ään (rivit 259-434).
 * Näissä säännöissä !important:t override:avat game-base.css:n 7-sarake klondike-layoutin,
 * koska Spider tarvitsee 10 saraketta.
 */

#game {
  align-items: flex-start !important;
  justify-content: center;
}

#game-inner {
  max-width: none !important;
  width: 100% !important;
}

.tab-zone {
  position: relative;
  height: auto;
  min-height: var(--ch);
  width: auto !important;
}

/* Spider-board on 10-sarake grid-konteksti. Molemmat rivit jakavat saman gridin,
   joten top-row:n ja tableau-row:n sarakkeet linjautuvat pikselilleen pystysuunnassa. */
#spider-board {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: calc(10 * var(--cw) + 9 * var(--gap));
  max-width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
  /* Varmista että board EI vuoda ulos — näin se pysyy viewportin sisällä */
  overflow: visible;
}

/* #game-inner pitää keskittää spider-board kunnolla */
#game-inner {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

#top-row,
#tableau-row {
  display: grid !important;
  grid-template-columns: repeat(10, var(--cw)) !important;
  gap: var(--gap) !important;
  align-items: flex-start;
  justify-content: start !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

#top-row > #stock-zone { grid-column: 1; }
#top-row > #top-spacer { grid-column: 2; width: var(--cw); flex-shrink: 0; }
#top-row > #completed-sets {
  grid-column: 3 / span 8;
  display: grid;
  grid-template-columns: repeat(8, var(--cw));
  gap: var(--gap);
}

#stock-zone { height: var(--ch) !important; width: var(--cw); }

.completed-slot {
  width: var(--cw);
  height: var(--ch);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: var(--cr);
  background: rgba(255,255,255,.04);
  flex-shrink: 0;
}
.completed-slot.filled {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 2vw, 24px);
  color: #fff;
  background: rgba(20,80,40,.65);
  border: 2px solid rgba(120,220,120,.45);
  animation: setAppear .4s ease;
}
@keyframes setAppear {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Kortit jotka kuuluvat yhtenäiseen sarjaan */
.card-face.in-sequence {
  box-shadow: 0 0 0 1.5px rgba(100,220,100,.4), 0 2px 6px rgba(0,0,0,.3);
}
/* Valittu kortti */
.card-face.selected {
  box-shadow: 0 0 0 2.5px #f0c040, 0 4px 14px rgba(0,0,0,.4);
  transform: translateY(-3px);
}

/* ===== VAIKEUSASTE-DIALOGI — Spider-teema ===== */
#diff-overlay {
  align-items: center;
  justify-content: center;
}

#diff-dialog {
  background: linear-gradient(160deg, #164a37 0%, #0a2d1f 100%);
  border: 2px solid #f0c040;
  border-radius: 18px;
  padding: 32px 28px 28px;
  max-width: 540px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  color: #fff;
  box-shadow:
    0 20px 60px rgba(0,0,0,.7),
    0 0 40px rgba(240,192,64,0.15),
    inset 0 1px 0 rgba(255,255,255,0.06);
  font-family: 'Inter', sans-serif;
}

#diff-dialog h2 {
  font-family: 'Righteous', cursive;
  font-size: clamp(22px, 4vw, 30px);
  color: #f0c040;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#diff-dialog h2::before {
  content: '';
  width: 28px;
  height: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='3' fill='%23f0c040'/><line x1='12' y1='9' x2='12' y2='2' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='12' y1='15' x2='12' y2='22' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='9' y1='12' x2='2' y2='12' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='15' y1='12' x2='22' y2='12' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='9.5' y1='9.5' x2='3' y2='3' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='14.5' y1='9.5' x2='21' y2='3' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='9.5' y1='14.5' x2='3' y2='21' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/><line x1='14.5' y1='14.5' x2='21' y2='21' stroke='%23f0c040' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

#diff-dialog p {
  color: rgba(255,255,255,.6);
  margin-bottom: 22px;
  font-size: 13px;
  letter-spacing: 0.2px;
}

.diff-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 520px) {
  .diff-buttons {
    grid-template-columns: 1fr;
  }
}

.diff-btn {
  background: rgba(0,0,0,.35);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 18px 12px 16px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: all .2s ease;
  font-family: inherit;
  min-height: 130px;
  position: relative;
}

@media (max-width: 520px) {
  .diff-btn {
    flex-direction: row;
    min-height: 70px;
    padding: 14px 18px;
    gap: 14px;
    text-align: left;
  }
}

.diff-btn:hover {
  transform: translateY(-2px);
  background: rgba(240,192,64,0.08);
  border-color: rgba(240,192,64,0.5);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.diff-btn .diff-suits {
  font-size: 28px;
  line-height: 1;
  letter-spacing: 2px;
}
@media (max-width: 520px) {
  .diff-btn .diff-suits {
    font-size: 22px;
    min-width: 60px;
    text-align: center;
  }
}

.diff-btn strong {
  display: block;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  margin-top: 2px;
}

.diff-btn small {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,.55);
  line-height: 1.3;
  margin-top: 2px;
}

.diff-easy   { border-color: rgba(120,220,140,.25); }
.diff-easy:hover   { border-color: rgba(120,220,140,.7); background: rgba(120,220,140,0.08); }
.diff-medium { border-color: rgba(220,200,100,.25); }
.diff-medium:hover { border-color: rgba(220,200,100,.7); background: rgba(220,200,100,0.08); }
.diff-hard   { border-color: rgba(220,110,110,.25); }
.diff-hard:hover   { border-color: rgba(220,110,110,.7); background: rgba(220,110,110,0.08); }

.diff-cancel {
  margin-top: 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.5);
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.diff-cancel:hover {
  color: #fff;
  border-color: rgba(255,255,255,.3);
}

/* ===== WIN DIALOGI ===== */
#win-dialog {
  background: linear-gradient(135deg, #1a3a2a, #0f2218);
  border: 1px solid rgba(240,192,64,.3);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  color: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.win-emoji { font-size: 48px; margin-bottom: 10px; }
#win-dialog h2 { font-size: 28px; color: #f0c040; margin-bottom: 16px; }
#win-stats {
  background: rgba(0,0,0,.3);
  border-radius: 10px;
  padding: 14px;
  font-size: 15px;
  line-height: 2;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  color: rgba(255,255,255,.75);
}
.stat-row strong { color: #fff; }

/* ===== HINTING — vilkkuu ===== */
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 2px #f0c040; }
  50%      { box-shadow: 0 0 0 4px #f0c040, 0 0 12px rgba(240,192,64,.5); }
}
.card-face.hint-from { animation: hintPulse .8s ease 3; }
.card-face.hint-to   { animation: hintPulse .8s ease 3 .2s; }

/* ===== MOBIILI ===== */
@media (max-width: 480px) {
  .ctrl-btn { padding: 5px 8px; font-size: 12px; }
}

/* Spider mobiili — JS laskee --cw/--gap, grid hoitaa linjauksen. */
@media (max-width: 600px) {
  :root {
    --off-down: 10px;
    --off-up: 14px;
  }
  #spider-board { max-width: 100vw; }
  #game { padding: 0 2px 4px; }
  .completed-slot { border-width: 1px; }
}
