/* EwrekaGames — Klondike solitaire table (assets/js/solo/klondike.js). Shell styles: assets/css/solo.css.
 * The table is sized once from the viewport by the script (width/height inline, --cw / --ch card size) and never
 * changes size while a deal is played; everything that appears later (menu, statistics, "no more moves") is an overlay. */
/* card art (faces, back, colours, dark tones): the shared deck, assets/css/cards.css */
:root {
  --kl-felt-1: #2f8a6e; --kl-felt-2: #1d6852; --kl-felt-3: #144c3c; --kl-mark: rgba(255, 255, 255, .26);
}
:root[data-theme="dark"] {
  --kl-felt-1: #1c5646; --kl-felt-2: #113a30; --kl-felt-3: #0a241d; --kl-mark: rgba(255, 255, 255, .2);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --kl-felt-1: #1c5646; --kl-felt-2: #113a30; --kl-felt-3: #0a241d; --kl-mark: rgba(255, 255, 255, .2);
  }
}

/* the shell's board column is 560 px wide for the grid puzzles; the card table uses the whole stage */
#soloBoard.kl-host { max-width: none; }
/* wave16 fix: the same from the first paint (kl-host is only added when the table mounts: the 560 px column then
   widened and moved left, a layout shift of 0.06 on desktop) */
#soloMain[data-game="klondike"] .solo-board { max-width: none; }
/* CLS: the loading placeholder takes about the table's room, so the content below does not jump when it is drawn */
body.solo-page #soloBoard > .loading-box { min-height: min(560px, calc(100svh - 230px)); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; }
/* wave16 fix (CLS 0.06-0.07 on desktop): with the side rail the board starts 181 px down and klondike.js sizes table +
   button bar to the rest of the window minus 12 px, so the placeholder takes exactly that (the language-suggestion strip
   above the game adds 32 px to the top) */
@media (min-width: 1024px) and (min-height: 600px) and (max-height: 1100px) {
  body.solo-page #soloBoard > .loading-box { min-height: calc(100vh - 193px); min-height: calc(100svh - 193px); }
  body.solo-page:has(.langhint) #soloBoard > .loading-box { min-height: calc(100vh - 225px); min-height: calc(100svh - 225px); }
}

.kl-wrap { position: relative; margin: 0 auto; max-width: 100%; }
.kl-table {
  position: relative; z-index: 0; isolation: isolate; border-radius: 16px; overflow: visible;
  background: radial-gradient(120% 90% at 50% 18%, var(--kl-felt-1), var(--kl-felt-2));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 4px 0 var(--kl-felt-3);
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.kl-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kl-slots, .kl-cards { position: absolute; inset: 0; }
.kl-cards { pointer-events: none; }
.kl-cards .kl-card { pointer-events: auto; }
.kl-topl { position: absolute; inset: 0; pointer-events: none; z-index: 1500; }

/* empty piles */
.kl-slot { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); border-radius: var(--r); outline: none; }
.kl-stock, .kl-waste, .kl-found { box-shadow: inset 0 0 0 2px var(--kl-mark); }
.kl-tab::before { content: ""; position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); border-radius: var(--r); box-shadow: inset 0 0 0 2px var(--kl-mark); }
.kl-found svg { position: absolute; left: 22%; top: 25%; width: 56%; height: 50%; color: var(--kl-mark); }
.kl-stock { cursor: pointer; }
.kl-redeal { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .75); opacity: 0; transition: opacity .2s; }
.kl-redeal .ico, .kl-redeal svg { width: 46%; height: 46%; }
.kl-stock.can-redeal .kl-redeal { opacity: 1; }
.kl-slot:focus-visible { box-shadow: inset 0 0 0 2px var(--kl-mark), 0 0 0 3px #ffd54a; }
.kl-tab:focus-visible { box-shadow: 0 0 0 3px rgba(255, 213, 74, .85); }
.kl-badge { position: absolute; left: 0; top: 0; min-width: 22px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--surface); font: 700 11px/18px var(--sans, inherit); text-align: center; font-variant-numeric: tabular-nums; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.kl-badge.hidden { display: none; }

/* cards */
.kl-card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  cursor: pointer; touch-action: none;
  transition: transform .19s cubic-bezier(.2, .75, .25, 1);
  will-change: transform;
}
.kl-table.nt .kl-card, .kl-card.drag { transition: none; }
.kl-card.drag { cursor: grabbing; }
.kl-card.drag .kl-in, .kl-card.fly .kl-in { box-shadow: 0 6px 14px rgba(0, 0, 0, .35); }
.kl-in { position: relative; width: 100%; height: 100%; border-radius: var(--r); box-shadow: 0 1px 1.5px rgba(0, 0, 0, .28); }
.kl-face, .kl-back { position: absolute; inset: 0; }
.kl-face svg, .kl-back svg { display: block; width: 100%; height: 100%; }
.kl-card:not(.up) .kl-face, .kl-card.up .kl-back { visibility: hidden; }
.kl-card:not(.up) { cursor: default; }

/* turning a card over */
.kl-card.flip .kl-in { animation: kl-flip .26s ease; }
.kl-card.flip.up .kl-back { animation: kl-half-a .26s; }
.kl-card.flip.up .kl-face { animation: kl-half-b .26s; }
@keyframes kl-flip { 0% { transform: scaleX(1); } 50% { transform: scaleX(.02); } 100% { transform: scaleX(1); } }
@keyframes kl-half-a { 0%, 49% { visibility: visible; } 50%, 100% { visibility: hidden; } }
@keyframes kl-half-b { 0%, 49% { visibility: hidden; } 50%, 100% { visibility: visible; } }
/* keyboard cursor, picked-up cards, hints, refusals, the win */
.kl-card.kcur .kl-in { box-shadow: 0 0 0 3px #ffd54a, 0 1px 2px rgba(0, 0, 0, .3); }
.kl-card.ksel .kl-in { box-shadow: 0 0 0 3px var(--blue), 0 4px 10px rgba(0, 0, 0, .3); }
.kl-card.khint .kl-in, .kl-slot.khint { animation: kl-hint .8s ease 3; }
@keyframes kl-hint { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 213, 74, 0); } 50% { box-shadow: 0 0 0 4px #ffd54a, 0 0 16px 4px rgba(255, 213, 74, .6); } }
.kl-card.nope .kl-in { animation: kl-nope .32s ease; }
@keyframes kl-nope { 20% { transform: translateX(-4px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } 100% { transform: none; } }
.kl-card.pop .kl-in { animation: kl-pop .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes kl-pop { 0% { transform: none; } 40% { transform: translateY(-14%) scale(1.12) rotate(-4deg); box-shadow: 0 10px 18px rgba(0, 0, 0, .35); } 100% { transform: none; } }
.kl-wrap.finishing .kl-table { cursor: progress; }

/* tool bar under the table (fixed height) */
.kl-bar { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 8px; height: 48px; margin-top: 8px; }
.kl-btn { height: 44px; min-width: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 700 14px/1 var(--sans, inherit); display: inline-flex; align-items: center; justify-content: center; gap: 7px; box-shadow: var(--press, 0 3px 0 var(--line-2)); cursor: pointer; touch-action: manipulation; transition: transform .08s, box-shadow .08s, opacity .15s; }
.kl-btn .ico, .kl-btn .ico svg { width: 18px; height: 18px; }
.kl-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.kl-btn:disabled { opacity: .4; cursor: default; }
.kl-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kl-wrap.kl-narrow .kl-bl { display: none; }
.kl-wrap.kl-narrow .kl-btn { padding: 0; width: 46px; }
.kl-info { min-width: 0; text-align: center; line-height: 1.2; color: var(--ink-2); }
.kl-i1 { display: flex; justify-content: center; align-items: baseline; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kl-i1 b { color: var(--ink); font-size: 15px; font-weight: 800; }
.kl-dot { color: var(--ink-3); }
.kl-deal { display: block; font-size: 11px; font-weight: 600; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* overlays (never move anything underneath) */
.kl-over { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 10px; border-radius: 16px; background: rgba(10, 16, 26, .38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.kl-over.hidden { display: none; }
.kl-box { position: relative; width: min(100%, 380px); max-height: 100%; overflow: auto; display: grid; gap: 12px; padding: 18px 18px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, .3)); color: var(--ink); animation: kl-in .22s ease; }
@keyframes kl-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.kl-box h3 { margin: 0 40px 0 0; font-size: 18px; font-weight: 800; }
.kl-box p { margin: 0; color: var(--ink-2); font-size: 14px; }
.kl-box .kl-note { font-size: 12px; color: var(--ink-3); margin-top: -6px; }
.kl-x { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.kl-x .ico, .kl-x svg { width: 20px; height: 20px; }
.kl-x:hover { background: var(--surface-2); }
.kl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kl-lbl { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.kl-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.kl-seg button { height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font: 600 14px/1 var(--sans, inherit); cursor: pointer; }
.kl-seg button.on { background: var(--surface); color: var(--brand); box-shadow: 0 1px 0 var(--line-2), 0 0 0 1px var(--line); }
.kl-sw { min-height: 40px; }
.kl-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kl-acts .btn { min-height: 44px; }
.kl-acts .btn:only-child, .kl-acts .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.kl-ask .kl-q { margin: 8px 28px 4px 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.kl-stuck { text-align: center; justify-items: center; }
.kl-stuck .kl-acts { width: 100%; }
.kl-stuck h3 { margin: 0; }
.kl-stuck-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--brand); }
.kl-stuck-ic .ico, .kl-stuck-ic svg { width: 28px; height: 28px; }
.kl-stats { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.kl-stats th, .kl-stats td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.kl-stats thead th { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.kl-stats tbody th { text-align: left; font-weight: 600; color: var(--ink-2); }
.kl-stats td { font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  .kl-card, .kl-redeal, .kl-btn { transition: none; }
  .kl-card.flip .kl-in, .kl-card.flip.up .kl-back, .kl-card.flip.up .kl-face, .kl-card.khint .kl-in, .kl-slot.khint,
  .kl-card.nope .kl-in, .kl-card.pop .kl-in, .kl-box { animation: none; }
  .kl-card.khint .kl-in, .kl-slot.khint { box-shadow: 0 0 0 4px #ffd54a; }
}
