/* ==========================================================================
   Spider Solitaire — Windows 7 style
   ========================================================================== */

:root {
  --card-w: 90px;
  --card-h: 126px;
  --gap: 8px;
  --stack-down: 14px;
  --stack-up: 28px;
  --felt-1: #4f9d63;
  --felt-2: #2f7a45;
  --felt-3: #1c5230;
  --glass-1: rgba(255, 255, 255, 0.28);
  --glass-2: rgba(255, 255, 255, 0.10);
  --ink: #eaf6ee;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", "Segoe UI Variable", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* subtle felt vignette + weave */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 4px),
    radial-gradient(140% 120% at 50% 30%, transparent 55%, rgba(0,0,0,0.35) 100%);
  z-index: 0;
}

/* ----------------------------- top bar -------------------------------- */

#topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: linear-gradient(180deg, var(--glass-1), var(--glass-2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.brand-spade {
  font-size: 26px;
  color: #0d2b18;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
#topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #08240f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.stats {
  display: flex;
  gap: 10px;
  margin-left: 8px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.stat label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.75;
}
.stat span {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
}

.controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

select {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #7c8a80;
  background: linear-gradient(#ffffff, #e6efe8);
  color: #223;
  cursor: pointer;
}

/* ----------------------------- board ---------------------------------- */

#board {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 4px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

#board-content {
  flex: 1 1 auto;
  min-height: 0;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

#top-row {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 18px;
  height: calc(var(--card-h) + 8px);
  margin-bottom: 6px;
}

#foundations {
  display: flex;
  gap: var(--gap);
}
.found-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  position: relative;
}
.found-slot .card { position: absolute; inset: 0; }

#stock {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  cursor: pointer;
  border-radius: 7px;
}
#stock .card { position: absolute; left: 0; top: 0; }
#stock-empty {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px dashed rgba(255, 255, 255, 0.25);
}

#tableau {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--gap);
  min-height: 0;
  overflow: hidden;
}

.column {
  position: relative;
  flex: 0 0 var(--card-w);
  border-radius: 7px;
}
.column.empty::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.16);
  border: 1px dashed rgba(255, 255, 255, 0.25);
}
.column.drop-ok::before,
.column.drop-ok.empty::before {
  border: 2px solid rgba(120, 255, 150, 0.9);
  background: rgba(80, 220, 110, 0.18);
  box-shadow: 0 0 14px rgba(120, 255, 150, 0.5);
}

/* ----------------------------- cards ---------------------------------- */

.card {
  position: absolute;
  left: 0;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.card.face {
  background: linear-gradient(160deg, #ffffff 0%, #f4f2ea 100%);
  border: 1px solid #b9b4a3;
  touch-action: none;
  cursor: grab;
  overflow: hidden;
}
.card.face:active { cursor: grabbing; }
.card.face.red { color: #d21f2c; }
.card.face.black { color: #23262b; }

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.9;
  width: 22%;
}
.corner .rank {
  font-size: calc(var(--card-w) * 0.2);
  font-weight: 700;
}
.corner .suit {
  font-size: calc(var(--card-w) * 0.17);
  margin-top: 1px;
}
.corner.tl { top: 4px; left: 5px; }
.corner.br {
  bottom: 4px;
  right: 5px;
  transform: rotate(180deg);
}

.pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.5);
  opacity: 0.92;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

/* card back — Windows 7 blue */
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.16) 0 3px, transparent 3px 9px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.16) 0 3px, transparent 3px 9px),
    linear-gradient(150deg, #4f86d6 0%, #2b56a8 60%, #1f3f85 100%);
  border: 3px solid #eef2fb;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.4);
}
.card.back .back-inner {
  position: absolute;
  inset: 4px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

/* states */
.card.ghost { opacity: 0.28; }
.card.hint {
  box-shadow: 0 0 0 3px rgba(255, 224, 66, 0.95), 0 0 16px 4px rgba(255, 210, 40, 0.7);
  z-index: 20 !important;
}
.card.flip {
  animation: flip 0.32s ease;
}
@keyframes flip {
  0%   { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

/* ----------------------------- toolbar -------------------------------- */

#toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 12px;
  background: linear-gradient(0deg, var(--glass-2), rgba(255,255,255,0.16));
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.win-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #243028;
  padding: 6px 16px;
  border-radius: 5px;
  border: 1px solid #6f7d73;
  background: linear-gradient(#fdfdfb, #dfe7e0 48%, #cdd8cf 52%, #e7efe8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: filter 0.1s;
}
.win-btn:hover { background: linear-gradient(#ffffff, #e6f2fb 48%, #d5e6f5 52%, #eef6fd); }
.win-btn:active { background: linear-gradient(#d3e2ee, #c2d3e2); }
.win-btn:disabled { opacity: 0.5; cursor: default; }

.icon-btn {
  font-size: 18px;
  width: 36px;
  height: 34px;
  border-radius: 5px;
  border: 1px solid #6f7d73;
  background: linear-gradient(#fdfdfb, #dfe7e0);
  cursor: pointer;
}
.icon-btn.off { filter: grayscale(1) opacity(0.7); }

.spacer { flex: 1; }
.help-text {
  font-size: 12px;
  opacity: 0.7;
}

/* ----------------------------- toast ---------------------------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%) translateY(12px);
  z-index: 40;
  padding: 9px 18px;
  border-radius: 6px;
  background: rgba(15, 30, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ----------------------------- win overlay ---------------------------- */

#win {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 20, 12, 0.6);
  backdrop-filter: blur(3px);
}
#win.show { display: flex; }
.win-box {
  text-align: center;
  padding: 34px 48px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(40, 90, 55, 0.96), rgba(20, 55, 33, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.win-spades {
  font-size: 44px;
  color: #ffe36e;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
  margin-bottom: 6px;
}
.win-box h2 {
  margin: 0 0 20px;
  font-size: 26px;
  font-weight: 600;
}
.win-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ----------------------------- drag layer ----------------------------- */

#drag-layer {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  display: none;
  pointer-events: none;
  will-change: left, top;
}

/* ----------------------------- responsive ----------------------------- */

@media (max-width: 760px) {
  .help-text { display: none; }
  .stat { min-width: 46px; padding: 2px 6px; }
  .stat span { font-size: 14px; }
  #topbar h1 { font-size: 15px; }
  .brand-spade { font-size: 20px; }
  .stats { gap: 6px; }
  .win-btn { padding: 6px 10px; font-size: 13px; }
}
