/* Klondike Solitaire: game styles. Colors and fonts come from ../shared/eg-theme.css */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.45;
}
[hidden] { display: none !important; }

.noscript { margin: 16px; padding: 16px; border: 2px solid var(--ink); border-radius: 12px; background: #FBF6EA; color: #1F3246; }

:focus-visible { outline: 4px solid var(--mid); outline-offset: 2px; }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ---------- extra colors used only by this game ---------- */
:root {
  --suit-red: #B3261E;
  --cardface: #FFFFFF;
  --back1: #1F3246;
  --back2: #E0792B;
  --slot: #8A7A5A;
}
:root[data-contrast="high"] {
  --suit-red: #B00020;
  --cardface: #FFFFFF;
  --back1: #000000;
  --back2: #FFFFFF;
  --slot: #000000;
}

/* ---------- header and settings ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px 4px;
}
.name-block { min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 12px; }
.name { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.kind { margin: 0; white-space: nowrap; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.kind::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--dot); border: 2px solid var(--ink); flex: none; }

.textlink {
  color: var(--ink); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 4px;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; white-space: nowrap;
}
.linkbtn { background: none; border: 0; cursor: pointer; }

.settings {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 4px 16px 10px; border-bottom: 2px solid var(--rule);
}
.settings-label { font-size: 18px; margin-right: 2px; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px; padding: 8px 16px;
  font: inherit; font-weight: 700; font-size: 20px; line-height: 1.2;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: 12px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn.small { min-height: 46px; font-size: 18px; padding: 6px 14px; }
.btn.primary { background: var(--ink); color: var(--card); }
.btn[aria-disabled="true"] { opacity: 0.5; border-style: dashed; cursor: default; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.btn.attn { outline: 5px solid var(--dot); outline-offset: 2px; }

/* ---------- layout ---------- */
main { padding: 12px 6px 40px; max-width: 1180px; margin: 0 auto; }
.h2 { margin: 8px 0 12px; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.panel { background: var(--card); border: 2px solid var(--rule); border-radius: 20px; padding: 4px 18px; margin: 0 0 12px; max-width: 760px; }
.howto { margin: 14px 0; font-size: 20px; }
.note { margin: 10px 0 0; font-size: 18px; }
.legend { margin-top: 8px; }

.msg {
  margin: 0 0 8px; padding: 8px 12px;
  font-size: 19px; line-height: 1.35;
  background: var(--card); border: 2px solid var(--rule); border-radius: 12px;
}
.msg:empty { display: none; }

.titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.titlerow .h2 { font-size: 26px; margin: 4px 0; }
.count { margin: 0 0 8px; font-size: 18px; }

details.howto-panel { padding: 0 18px; }
details.howto-panel summary {
  min-height: 52px; display: flex; align-items: center; cursor: pointer;
  font-family: var(--font-head); font-weight: 800; font-size: 24px;
}
details.howto-panel[open] summary { border-bottom: 2px solid var(--rule); margin-bottom: 4px; }

/* ---------- the table ---------- */
.board-wrap {
  background: var(--iconbg); border: 2px solid var(--ink); border-radius: 16px;
  padding: 3px; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom;
}
.board { position: relative; margin: 0 auto; }

.lbl {
  position: absolute; margin: 0; font-size: 16px; line-height: 1.1; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: clip;
}

/* A card or an empty place. Size and position come from the numbers app.js sets on each one. */
.card, .slot {
  position: absolute; margin: 0; padding: 0;
  border-radius: calc(var(--cw) * 0.12);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  font: inherit; color: var(--ink);
}
.slot {
  background: transparent; border: 3px dashed var(--slot); cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 700; font-size: calc(var(--cw) * 0.26); line-height: 1.1;
}
.slot .ghost { display: block; width: 52%; opacity: 0.35; }
.slot .ghost svg { display: block; width: 100%; height: auto; }
.slot.again { font-size: calc(var(--cw) * 0.27); }

.card {
  background: var(--cardface); border: 2px solid var(--ink);
  box-shadow: 1px 2px 0 var(--ink); cursor: pointer; overflow: hidden;
}
.card.down {
  background-color: var(--back1);
  background-image:
    repeating-linear-gradient(45deg, transparent 0 5px, var(--back2) 5px 6px);
  border-color: var(--ink); cursor: default; box-shadow: 1px 2px 0 var(--ink);
}
.card.stockback { cursor: pointer; }
.card .count-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  min-width: 56%; padding: 2px 4px; text-align: center;
  background: var(--cardface); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px;
  font-family: var(--font-head); font-weight: 800; font-size: calc(var(--cw) * 0.36); line-height: 1.1;
}

.card .corner {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: calc(var(--cw) * 0.01);
  padding: calc(var(--cw) * 0.05) calc(var(--cw) * 0.05) 0; line-height: 1;
}
.card .rk { font-family: var(--font-head); font-weight: 800; font-size: calc(var(--cw) * 0.40); letter-spacing: -0.04em; }
.card .corner .suit { width: calc(var(--cw) * 0.33); height: calc(var(--cw) * 0.33); flex: none; }
.card .big { position: absolute; left: 0; right: 0; bottom: 6%; display: flex; justify-content: center; }
.card .big .suit { width: 52%; height: auto; }
.card .red { color: var(--suit-red); }
.card .black { color: var(--ink); }
.suit.k-red { fill: var(--suit-red); }
.suit.k-black { fill: var(--ink); }
.slot .suit.k-red { fill: var(--suit-red); }

/* The card you are holding: lifted, with a thick dark outline. */
.card.held { outline: 5px solid var(--ink); outline-offset: 1px; box-shadow: 4px 6px 0 var(--ink); }
/* A solid orange outline means "this is the card to pick up". A dashed outline means "it can go here". */
.card.hint, .slot.hint { outline: 6px solid var(--dot); outline-offset: 1px; }
.card.dest, .slot.dest { outline: 5px dashed var(--accent-text); outline-offset: 1px; }
.card.nudge, .slot.nudge { animation: nudge 0.35s ease-in-out; }
@keyframes nudge { 0%, 100% { translate: 0 0; } 25% { translate: -5px 0; } 75% { translate: 5px 0; } }

.dock {
  position: sticky; bottom: 0; z-index: 5000;
  margin-top: 10px; padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  background: var(--bg); border-top: 2px solid var(--rule);
}
.dock.static { position: static; }
.dock .msg { margin-bottom: 8px; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.controls.two { grid-template-columns: 1fr 1fr; }
.controls.three { grid-template-columns: 1fr; }
.controls.four { grid-template-columns: repeat(4, 1fr); margin-top: 0; }
.dock.narrow .controls.four { grid-template-columns: 1fr 1fr; }
.controls .btn { min-height: 56px; font-size: 19px; }
.dock .controls .btn { padding: 6px 4px; }
.confirm { margin-top: 0; }
.confirm-text { margin: 0 0 4px; font-size: 19px; }
.confirm .controls { margin-top: 8px; }
@media (max-height: 480px) { .dock { position: static; } }

/* ---------- all cards up ---------- */
.clear { margin-top: 16px; padding: 18px; }
.clear-title { margin: 0 0 6px; font-family: var(--font-head); font-weight: 800; font-size: 36px; line-height: 1.1; }
.clear p { margin: 0 0 14px; }
.clear-buttons { display: grid; gap: 8px; }
.clear-buttons .btn { min-height: 56px; }
.won #board-wrap, .won .legend, .won #dock, .won #count { display: none; }
.won .clear { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .card.nudge, .slot.nudge { animation: none; }
}

.slot .kmark { font-family: var(--font-head); font-weight: 800; font-size: calc(var(--cw) * 0.5); opacity: 0.35; }
.card { scroll-margin: 12px 12px 230px 12px; }
