/* Family Solitaire — accessible, large-target, landscape-first styling. */

:root {
  --felt: #0b6b3a;
  --felt-dark: #075029;
  --cw: 110px;        /* card width, set by JS */
  --ch: 154px;        /* card height, set by JS */
  --red: #c0202a;
  --black: #1c1c1c;
  --slot: rgba(255, 255, 255, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--felt-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: radial-gradient(circle at 50% 35%, var(--felt) 0%, var(--felt-dark) 100%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---- Top bar ---- */
#topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
}
#title { font-size: 20px; font-weight: 700; color: rgba(255,255,255,0.85); letter-spacing: 0.5px; }
#controls { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.ctrl {
  min-height: 56px; min-width: 96px;
  padding: 0 20px;
  font-size: 20px; font-weight: 700;
  color: #fff; background: rgba(255,255,255,0.16);
  border: 2px solid rgba(255,255,255,0.28); border-radius: 14px;
  cursor: pointer;
}
.ctrl:active { transform: scale(0.96); background: rgba(255,255,255,0.28); }
.ctrl.primary { background: #1f8a4c; border-color: #2aa85e; }
.ctrl.hidden { display: none; }

.iconbtn {
  min-height: 52px; min-width: 52px;
  font-size: 26px; color: #fff;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.22);
  border-radius: 14px; cursor: pointer;
}
.iconbtn:active { transform: scale(0.94); }

/* ---- Board ---- */
#board { position: relative; flex: 1 1 auto; margin: 4px 14px 10px; }

.slot {
  position: absolute;
  width: var(--cw); height: var(--ch);
  border: 2px dashed var(--slot); border-radius: calc(var(--cw) * 0.09);
  background: rgba(0,0,0,0.10);
}
.slot.stock-empty { display: flex; align-items: center; justify-content: center; }
.slot.stock-empty::after { content: "\21BB"; color: rgba(255,255,255,0.5); font-size: calc(var(--cw)*0.5); }

/* ---- Cards ---- */
.card {
  position: absolute;
  width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * 0.09);
  transition: transform 0.18s ease, box-shadow 0.12s ease;
  will-change: transform;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.card .face, .card .back {
  position: absolute; inset: 0;
  border-radius: inherit; overflow: hidden;
}
.card .face { background: #fff; }

/* placeholder / real photo fills the card; thin suit-colored frame */
.photo {
  position: absolute; inset: 0;
  border-radius: inherit;
  background-size: cover; background-position: center top;
}
.photo.placeholder { display: flex; align-items: center; justify-content: center; }
.photo.placeholder .ph-emoji { font-size: calc(var(--cw) * 0.5); opacity: 0.7; filter: saturate(0.7); }
.face { border: calc(var(--cw) * 0.03) solid #fff; }
.face.red { border-color: var(--red); }
.face.black { border-color: var(--black); }

/* corner index bands: solid color so legibility never depends on the photo */
.band {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: calc(var(--cw) * 0.30);
  padding: calc(var(--cw) * 0.03) calc(var(--cw) * 0.04);
  border-radius: calc(var(--cw) * 0.06);
  line-height: 1;
}
.band.tl { top: calc(var(--cw) * 0.05); left: calc(var(--cw) * 0.05); }
.band.br { bottom: calc(var(--cw) * 0.05); right: calc(var(--cw) * 0.05); transform: rotate(180deg); }
.band.red { background: var(--red); }
.band.black { background: var(--black); }
.band .rank { font-size: calc(var(--cw) * 0.26); font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.band .pip { font-size: calc(var(--cw) * 0.20); color: #fff; margin-top: calc(var(--cw) * 0.01); }

/* face-down back */
.back {
  background:
    repeating-linear-gradient(45deg, #1d3f7a 0, #1d3f7a 8px, #244a8c 8px, #244a8c 16px);
  border: calc(var(--cw) * 0.03) solid #fff;
}
.back.has-photo { background-size: cover; background-position: center; }

.card.selectable { cursor: pointer; }
.card.hint { box-shadow: 0 0 0 4px #ffd84d, 0 2px 8px rgba(0,0,0,0.4); }
.slot.hint { box-shadow: 0 0 0 4px #ffd84d inset; }
.card.nudge { animation: nudge 0.32s ease; }
@keyframes nudge { 0%,100%{transform:translate(var(--tx),var(--ty));} 25%{transform:translate(calc(var(--tx) + 6px),var(--ty));} 75%{transform:translate(calc(var(--tx) - 6px),var(--ty));} }

/* ---- Overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.overlay-card {
  background: #fff; color: #222; border-radius: 22px;
  padding: 30px 34px; max-width: 90vw; text-align: center;
  box-shadow: 0 16px 50px rgba(0,0,0,0.45);
}
.win-emoji { font-size: 64px; }
.win-title { font-size: 34px; font-weight: 800; margin: 8px 0 22px; }
.big-btn {
  min-height: 64px; padding: 0 34px;
  font-size: 24px; font-weight: 800; color: #fff;
  background: #1f8a4c; border: none; border-radius: 16px; cursor: pointer;
}
.big-btn:active { transform: scale(0.97); }
.big-btn.ghost { background: #e8e8e8; color: #333; }

.settings-title, .confirm-text { font-size: 26px; font-weight: 800; margin-bottom: 18px; }
.settings-row { margin: 14px 0; }
.settings-label { font-size: 19px; font-weight: 600; margin-bottom: 10px; }
.seg { display: flex; gap: 10px; justify-content: center; }
.seg-btn {
  min-height: 60px; padding: 0 22px; font-size: 19px; font-weight: 700;
  background: #eee; color: #333; border: 3px solid #ddd; border-radius: 14px; cursor: pointer;
}
.seg-btn.on { background: #1f8a4c; color: #fff; border-color: #2aa85e; }
.settings-hint { font-size: 15px; color: #666; max-width: 360px; margin: 10px auto 20px; line-height: 1.4; }
.confirm-buttons { display: flex; gap: 14px; justify-content: center; }

/* confetti for the win */
.confetti { position: absolute; width: 14px; height: 20px; border-radius: 3px; top: -30px; z-index: 49; }
