:root {
  --page: #f3f0ea;
  --top: #3b3b3b;
  --top-2: #2f2f2f;
  --felt: #31a64c;
  --felt-dark: #247a3a;
  --rail: #247c3a;
  --slot: rgba(255,255,255,.18);
  --slot-border: rgba(255,255,255,.25);
  --card: #fffdfa;
  --ink: #1f2937;
  --muted: #e6e6e6;
  --red: #d72638;
  --black: #162033;
  --blue: #36a2ff;
  --shadow: 0 28px 80px rgba(0,0,0,.35);
  --card-w: 72px;
  --card-h: 100px;
  --overlap: 28px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(72,152,255,.16), transparent 26%),
    radial-gradient(circle at 80% 100%, rgba(49,166,76,.16), transparent 30%),
    var(--page);
  color: var(--ink);
  overflow: hidden;
}
button, select, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .42; cursor: not-allowed; }
.page-wrap {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  place-items: stretch;
  padding: 0;
}
.solitaire-app {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  background: var(--felt);
  display: grid;
  grid-template-rows: clamp(56px, 7vh, 74px) 1fr clamp(58px, 7.5vh, 76px);
}
.game-topbar {
  background: linear-gradient(180deg, #444, var(--top));
  color: #fff;
  display: grid;
  grid-template-columns: 74px 1fr 130px 130px 150px;
  align-items: center;
  padding: 0 clamp(14px, 2.2vw, 34px);
  gap: 14px;
}
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #36445e, #141923);
  color: #a4c9ff;
  font-size: 1.85rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.stat { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; color: #fff; font-weight: 800; }
.stat:first-of-type { justify-content: center; font-size: 1.05rem; }
.stat small { color: #cfcfcf; font-weight: 600; font-size: .9rem; }
.stat strong { font-size: 1rem; min-width: 28px; text-align: left; }
.top-actions { display: flex; justify-content: end; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px;
  color: #fff;
  background: transparent;
  border-radius: 50%;
  font-size: 1.25rem;
  display: grid; place-items: center;
  transition: background .15s ease, transform .15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.13); transform: scale(1.03); }
.game-table {
  position: relative;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,.08), transparent 34%),
    linear-gradient(90deg, var(--rail) 0 clamp(62px, 7vw, 96px), var(--felt) clamp(62px, 7vw, 96px) calc(100% - clamp(62px, 7vw, 96px)), var(--rail) calc(100% - clamp(62px, 7vw, 96px)));
  display: grid;
  grid-template-columns: clamp(62px, 7vw, 96px) 1fr clamp(62px, 7vw, 96px);
  overflow: hidden;
}
.left-rail, .right-rail {
  padding: clamp(14px, 2vh, 26px) 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 2;
}
.play-space { position: relative; min-width: 0; padding: clamp(16px, 2.2vh, 30px) clamp(14px, 2vw, 36px) 86px; }
.tableau {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: clamp(10px, 1.8vw, 34px);
  align-items: start;
}
.column {
  position: relative;
  min-height: calc(100vh - 190px);
  border-radius: 12px;
}
.column.empty::before {
  content: "";
  position: absolute;
  width: var(--card-w); height: var(--card-h);
  border-radius: 10px;
  border: 2px dashed rgba(255,255,255,.22);
  background: rgba(255,255,255,.06);
  left: 50%; transform: translateX(-50%);
}
.slot {
  width: clamp(52px, 5.1vw, 74px); height: clamp(70px, 7vw, 102px);
  border-radius: 7px;
  border: 2px solid var(--slot-border);
  background: var(--slot);
  position: relative;
  display: grid; place-items: center;
  color: rgba(255,255,255,.35);
  font-size: 2rem;
  font-weight: 900;
}
.foundation-heart::before { content: "♥"; }
.foundation-diamond::before { content: "♦"; }
.foundation-club::before { content: "♣"; }
.foundation-spade::before { content: "♠"; }
.stock-slot::before { content: ""; }
.waste-slot { margin-top: 8px; }
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 9px;
  background: var(--card);
  color: var(--black);
  border: 1px solid rgba(0,0,0,.22);
  box-shadow: 0 5px 12px rgba(0,0,0,.24);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  user-select: none;
  touch-action: none;
  cursor: grab;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 7px;
  font-weight: 900;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  animation: cardIn .16s ease-out both;
  z-index: 5;
}
.slot .card { width: clamp(52px, 5.1vw, 74px); height: clamp(70px, 7vw, 102px); border-radius: 7px; padding: 5px; position: absolute; top: -2px; left: 50%; }
.card.red { color: var(--red); }
.card.back {
  color: transparent;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.8), rgba(255,255,255,.22) 16%, transparent 18%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 5px, transparent 5px 10px),
    linear-gradient(145deg, #56b4ff, #2587f1);
  border: 2px solid rgba(255,255,255,.82);
}
.card.back::after {
  content: "G";
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  text-shadow: 0 1px 2px rgba(0,0,0,.16);
}
.card.dragging { cursor: grabbing; filter: brightness(1.04); box-shadow: 0 14px 28px rgba(0,0,0,.32); transition: none; z-index: 1000 !important; }
.card.selected { outline: 3px solid rgba(255,255,255,.92); box-shadow: 0 0 0 6px rgba(54,162,255,.55), 0 12px 24px rgba(0,0,0,.28); }
.card.hint { animation: hintPulse .7s ease-in-out 0s 3; }
.card .corner { line-height: .96; font-size: .95rem; letter-spacing: -.04em; }
.card .suit-big { align-self: center; font-size: 2rem; line-height: 1; margin-top: -4px; }
.card .corner.bottom { align-self: flex-end; transform: rotate(180deg); }
.slot .card .corner { font-size: .72rem; }
.slot .card .suit-big { font-size: 1.35rem; }
.message {
  position: absolute;
  left: 50%; bottom: 20px; transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 220px);
  color: rgba(255,255,255,.92);
  background: rgba(0,0,0,.16);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 9px 16px;
  text-align: center;
  font-weight: 750;
  z-index: 3;
}
.bottom-controls {
  background: var(--felt);
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(30px, 9vw, 160px);
  padding: 0 28px;
}
.bottom-btn {
  color: #fff;
  background: transparent;
  text-transform: uppercase;
  letter-spacing: .02em;
  font-weight: 850;
  border-radius: 16px;
  padding: 12px 18px;
  transition: background .15s ease, transform .15s ease;
}
.bottom-btn:hover:not(:disabled) { background: rgba(255,255,255,.12); transform: translateY(-1px); }
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 18px);
  opacity: 0;
  color: #fff;
  background: rgba(32,32,32,.92);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 12px 35px rgba(0,0,0,.24);
  padding: 11px 16px;
  border-radius: 999px;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.settings-dialog {
  border: 0;
  padding: 0;
  border-radius: 20px;
  width: min(92vw, 460px);
  background: transparent;
}
.settings-dialog::backdrop { background: rgba(0,0,0,.46); }
.dialog-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.x-btn { width: 34px; height: 34px; border-radius: 50%; background: #f1f5f9; font-size: 1.4rem; }
.dialog-card label { display: block; font-weight: 800; color: #475569; margin: 16px 0 0; }
.dialog-card select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #d9e0ea;
  border-radius: 13px;
  padding: 10px 12px;
  background: #fff;
}
.check-line { display: flex !important; align-items: center; gap: 10px; }
.check-line input { width: auto; transform: scale(1.1); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.primary-btn, .secondary-btn {
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 900;
}
.primary-btn { color: #fff; background: #218a3c; }
.secondary-btn { color: #334155; background: #e2e8f0; }
.rules-box { margin-top: 15px; color: #475569; line-height: 1.45; }
.win-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.28);
  display: grid; place-items: center;
  z-index: 50;
}
.win-overlay.hidden { display: none; }
.win-card {
  width: min(90%, 380px);
  border-radius: 24px;
  padding: 28px;
  background: #fff;
  text-align: center;
  box-shadow: var(--shadow);
}
.win-icon { color: #f9b923; font-size: 3rem; }
.win-card h1 { margin: 4px 0; font-size: 2rem; }
.win-card p { color: #64748b; }
@keyframes cardIn { from { opacity: 0; transform: translate(-50%, -8px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes hintPulse { 0%,100% { box-shadow: 0 5px 12px rgba(0,0,0,.24); } 50% { box-shadow: 0 0 0 7px rgba(255,255,255,.7), 0 16px 28px rgba(0,0,0,.32); } }
@media (max-width: 900px) {
  :root { --card-w: 62px; --card-h: 86px; --overlap: 24px; }
  .page-wrap { padding: 0; place-items: stretch; }
  .solitaire-app { height: 100vh; min-height: 100vh; }
  .game-topbar { grid-template-columns: 48px 1fr 88px 88px 112px; gap: 6px; padding: 0 10px; }
  .brand-mark { width: 34px; height: 34px; font-size: 1.45rem; }
  .stat { gap: 6px; }
  .stat small { font-size: .75rem; }
  .game-table { grid-template-columns: 58px 1fr 58px; background: linear-gradient(90deg, var(--rail) 0 58px, var(--felt) 58px calc(100% - 58px), var(--rail) calc(100% - 58px)); }
  .slot { width: 44px; height: 60px; font-size: 1.5rem; }
  .slot .card { width: 44px; height: 60px; }
  .play-space { padding: 16px 9px 70px; }
  .tableau { gap: 7px; grid-template-columns: repeat(7, minmax(42px, 1fr)); }
  .bottom-controls { gap: 4px; justify-content: space-around; padding: 0 8px; }
  .bottom-btn { padding: 10px 8px; font-size: .83rem; }
  .message { max-width: calc(100% - 135px); font-size: .8rem; padding: 7px 10px; }
}
@media (max-width: 560px) {
  :root { --card-w: 48px; --card-h: 68px; --overlap: 20px; }
  .solitaire-app { grid-template-rows: 58px 1fr 60px; min-height: 100vh; }
  .game-topbar { grid-template-columns: 34px 1fr 58px 58px 96px; font-size: .82rem; }
  .top-actions { gap: 2px; }
  .icon-btn { width: 30px; height: 30px; font-size: 1rem; }
  .game-table { grid-template-columns: 48px 1fr 48px; background: linear-gradient(90deg, var(--rail) 0 48px, var(--felt) 48px calc(100% - 48px), var(--rail) calc(100% - 48px)); }
  .left-rail, .right-rail { padding: 12px 4px; gap: 9px; }
  .slot { width: 38px; height: 52px; }
  .slot .card { width: 38px; height: 52px; }
  .card .corner { font-size: .66rem; }
  .card .suit-big { font-size: 1.25rem; }
  .slot .card .corner { font-size: .54rem; }
  .slot .card .suit-big { font-size: .95rem; }
  .column { min-height: 300px; }
  .message { display: none; }
}
