/* Solitaire. Mobile-first. */
:root {
  --navy: #0a0f1e; --cyan: #00d4ff; --white: #f0f4ff; --silver: #c8d6e8; --muted: #8aa0c4;
  --felt: #0f5a3c; --felt-d: #0a3f2a; --gold: #f4c150; --ink: #111827; --red: #c81e3a; --line: rgba(255,255,255,.12);
  --cw: 48px; --ch: 67px; --gap: 6px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--navy); color: var(--white); font-family: 'DM Sans', system-ui, sans-serif;
  overflow-x: hidden; touch-action: manipulation; }
button, select { font-family: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 4px; max-width: 1000px; margin: 0 auto; }
.top h1 { font-family: 'Bebas Neue', sans-serif; font-weight: 400; font-size: 1.7rem; letter-spacing: 1px; margin: 0; line-height: 1; }
.top h1 span { color: var(--gold); }
.back { color: var(--cyan); text-decoration: none; font-size: .86rem; font-weight: 500; white-space: nowrap; padding: 8px 0; }
.back:hover { text-decoration: underline; }
.tools { display: flex; gap: 5px; }
.ibtn { background: rgba(255,255,255,.08); color: var(--white); border: 1px solid rgba(255,255,255,.15); border-radius: 9px; min-height: 40px; min-width: 40px; font-size: .82rem; cursor: pointer; padding: 0 9px; }
.ibtn:hover { background: rgba(0,212,255,.18); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 4px 8px 24px; }
.ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 6px; }
.fld { display: flex; flex-direction: column; gap: 2px; font-size: .68rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); flex: 1 1 130px; min-width: 0; }
.fld select { font-size: .92rem; color: var(--white); background: #16213a; border: 1px solid var(--line); border-radius: 9px; padding: 8px; min-height: 42px; text-transform: none; letter-spacing: 0; min-width: 0; width: 100%; }
.chk { display: flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--silver); min-height: 42px; }
.chk input { width: 18px; height: 18px; accent-color: var(--gold); }
.chk[hidden] { display: none; }

.hud { display: flex; gap: 6px; margin-bottom: 6px; }
.stat { flex: 1; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px; text-align: center; min-width: 0; }
.stat.wide { flex: 2.2; }
.stat .k { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat .v { display: block; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v.small { font-size: .74rem; font-weight: 500; line-height: 1.25; padding-top: 3px; white-space: normal; }
.v.ok { color: #7ee0a1; }

.board-wrap { border-radius: 16px; padding: 8px; border: 3px solid #3b2a14; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #167a52 0%, var(--felt) 55%, var(--felt-d) 100%);
  box-shadow: inset 0 0 40px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.4); }
.board { position: relative; width: 100%; user-select: none; -webkit-user-select: none; }

/* cards */
.card-el, .slot { position: absolute; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .11); }
.slot { border: 2px dashed rgba(255,255,255,.22); background: rgba(0,0,0,.14); display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.3); font-size: calc(var(--cw) * .5); }
.slot.hot { border-color: var(--gold); }
.slot.stockslot { cursor: pointer; }
.card-el { background: linear-gradient(160deg, #ffffff 0%, #f3efe2 100%); border: 1px solid #b9b19a; color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.45); cursor: pointer; overflow: hidden; }
.card-el.red { color: var(--red); }
.card-el .idx { position: absolute; left: 3px; top: 1px; font-weight: 700; font-size: calc(var(--cw) * .3); line-height: 1.05; white-space: nowrap; letter-spacing: -.5px; }
.card-el .big { position: absolute; left: 0; right: 0; bottom: calc(var(--cw) * .06); text-align: center; font-size: calc(var(--cw) * .5); line-height: 1; }
.card-el.back { background: repeating-linear-gradient(45deg, #12305c 0 5px, #1a4a8a 5px 10px); border: 2px solid #e9edf7; cursor: default; }
.card-el.back::after { content: ""; position: absolute; inset: 15%; border: 1px solid rgba(244,193,80,.75); border-radius: 4px; }
.card-el.stockback { cursor: pointer; }
.card-el.hint { box-shadow: 0 0 0 3px var(--gold), 0 0 16px 3px rgba(244,193,80,.8); z-index: 500 !important; }
.card-el.dragging { z-index: 1000 !important; box-shadow: 0 8px 18px rgba(0,0,0,.55); cursor: grabbing; transition: none; }
.card-el.pop { animation: pop .22s ease-out; }
@keyframes pop { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }
.card-el.shake { animation: shake .25s linear; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.cnt { position: absolute; font-size: calc(var(--cw) * .28); color: rgba(255,255,255,.7); font-weight: 700; pointer-events: none; text-align: center; }

.status { min-height: 1.4em; margin: 6px 2px 0; font-size: .86rem; color: var(--silver); text-align: center; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.btn { font-size: .88rem; font-weight: 500; color: var(--white); background: #223357; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 44px; cursor: pointer; }
.btn:hover:not(:disabled) { background: #2b4170; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--gold); color: #3b2a14; border-color: transparent; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #ffd47a; }
.btn:focus-visible, select:focus-visible, .ibtn:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.modal { position: fixed; inset: 0; background: rgba(5,8,18,.78); display: flex; align-items: center; justify-content: center; padding: 12px; z-index: 2000; }
.modal[hidden] { display: none; }
.modal .card { background: #121b30; border: 1px solid var(--line); border-radius: 16px; padding: 16px; max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto; }
.modal .card.small { max-width: 380px; text-align: center; }
.modal h2 { margin: 0 0 8px; font-size: 1.2rem; }
.modal h3 { margin: 12px 0 4px; font-size: .95rem; color: var(--gold); }
.modal ul { margin: 0; padding-left: 18px; font-size: .88rem; line-height: 1.5; color: var(--silver); }
.modal-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.fine { font-size: .74rem; color: var(--muted); }
.tblwrap { overflow-x: auto; }
.stbl { border-collapse: collapse; width: 100%; font-size: .78rem; }
.stbl th, .stbl td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stbl th:first-child, .stbl td:first-child { text-align: left; }
.stbl th { color: var(--muted); font-weight: 500; }

.fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1500; }
.fly { position: absolute; width: 44px; height: 62px; border-radius: 6px; background: linear-gradient(160deg, #fff, #f3efe2); border: 1px solid #b9b19a;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; animation: fly 2.6s cubic-bezier(.3,.6,.4,1) forwards; }
.fly.red { color: var(--red); }
@keyframes fly { 0% { transform: translate(0,0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

@media (min-width: 700px) {
  .top h1 { font-size: 2.2rem; }
  .btn { padding: 8px 18px; }
}
@media (prefers-reduced-motion: reduce) { .fly, .card-el.pop, .card-el.shake { animation: none; } }
