/* ═══════════════════════════════════════════════════════════
   SOLITAIRE — THEME 1: TERMINAL DARK
   Matches site_style.css design tokens.
   Accent: teal (#00e5b4) · Font: DM Mono + Syne
═══════════════════════════════════════════════════════════ */

/* ── Design tokens (mirrors site_style.css) ─────────────── */
:root {
  --bg:          #080d0d;
  --surface:     #0f1a1a;
  --sidebar:     #0b1212;
  --border:      #142020;
  --border2:     #1e3030;
  --teal:        #00e5b4;
  --teal-dim:    rgba(0, 229, 180, 0.08);
  --teal-mid:    rgba(0, 229, 180, 0.18);
  --teal-glow:   rgba(0, 229, 180, 0.04);
  --text:        #d4ede8;
  --muted:       #3a6060;
  --dim:         #1a2a2a;
  --danger:      #ff4d6a;
  --amber:       #ffa940;

  --card-w:      127px;
  --card-h:      178px;
  --pile-gap:    22px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Body & scanline overlay ─────────────────────────────── */

body {
  background: var(--bg);
  min-height: 100vh;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--text);
  min-width: 320px;
  padding: 12px 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px)
           calc(env(safe-area-inset-right, 0px) + 16px)
           calc(env(safe-area-inset-bottom, 0px) + 12px)
           calc(env(safe-area-inset-left, 0px) + 16px);
}

/* ── Top bar ─────────────────────────────────────────────── */

main {
  max-width: 1100px;
  margin: 0 auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  color: var(--text);
}

.top-bar h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--teal);
}

/* Inline comment decoration after title */
.top-bar h1::after {
  content: ' //';
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0;
}

.stats {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* Code-comment style stat prefix */
.stats::before {
  content: '// ';
  color: var(--border2);
}

.controls {
  display: flex;
  gap: 8px;
}

/* Buttons — match site .btn-primary */
button {
  padding: 6px 14px;
  border: 1px solid rgba(0, 229, 180, 0.25);
  border-radius: 4px;
  background: rgba(0, 229, 180, 0.10);
  color: var(--teal);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s;
}

button:hover {
  background: rgba(0, 229, 180, 0.20);
  border-color: rgba(0, 229, 180, 0.45);
}


/* ── Layout rows ─────────────────────────────────────────── */

.control-row {
  display: flex;
  gap: var(--pile-gap);
  align-items: flex-start;
  margin-bottom: 20px;
}

.gap { flex: 1; }

.tableau-row {
  display: flex;
  gap: var(--pile-gap);
  align-items: flex-start;
}

/* ── Pile containers ─────────────────────────────────────── */

.pile-container {
  width: var(--card-w);
  position: relative;
  flex-shrink: 0;
}

.pile-container--stock,
.pile-container--waste,
.pile-container--foundation,
.pile-container--freecell {
  height: var(--card-h);
}

.pile-container--tableau {
  min-height: var(--card-h);
}

/* Empty pile — dashed teal border */
.pile-empty {
  width: 100%;
  height: var(--card-h);
  border-radius: 6px;
  border: 1px dashed rgba(0, 229, 180, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: rgba(0, 229, 180, 0.20);
  background: var(--teal-glow);
}

.pile-empty--clickable { cursor: pointer; }

/* ── Cards ───────────────────────────────────────────────── */

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

/* Face-up: dark surface panel, matching --surface token */
.card.face-up {
  background: var(--surface);
  border: 1px solid var(--border2);
  cursor: pointer;
}

.card.face-up.red  { color: #2e8f7a; }
.card.face-up.black { color: var(--text); }

/* Face-down: diagonal teal scanline pattern */
.card.face-down {
  background-color: var(--sidebar);
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(0, 229, 180, 0.04) 0px,
      rgba(0, 229, 180, 0.04) 2px,
      transparent 2px,
      transparent 10px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(0, 229, 180, 0.04) 0px,
      rgba(0, 229, 180, 0.04) 2px,
      transparent 2px,
      transparent 10px
    );
  border: 1px solid rgba(0, 229, 180, 0.10);
  cursor: pointer;
}

/* Inset frame on face-down cards */
.card.face-down::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(0, 229, 180, 0.08);
  border-radius: 3px;
  pointer-events: none;
}

.card-label {
  position: absolute;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  line-height: 1;
  white-space: nowrap;
}

.card-label--top    { top: 5px;    left: 6px; }
.card-label--bottom { bottom: 5px; right: 6px; transform: rotate(180deg); }

.card-corner-suit {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  line-height: 1;
  pointer-events: none;
}

.card-suit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

/* ── Stock count badge ───────────────────────────────────── */

.pile-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--teal);
  border: 1px solid rgba(0, 229, 180, 0.20);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  font-weight: 700;
  pointer-events: none;
  z-index: 10;
  line-height: 1.4;
  letter-spacing: 0.05em;
}

/* ── Selection & drag-and-drop ───────────────────────────── */

.card.selected {
  outline: 1px solid var(--teal);
  outline-offset: -1px;
  /* Soft teal glow */
  box-shadow: 0 0 0 3px rgba(0, 229, 180, 0.15);
}

.drop-valid {
  outline: 1px dashed var(--teal);
  outline-offset: -2px;
  border-radius: 6px;
  background: var(--teal-dim);
}

/* ── Rules overlay ───────────────────────────────────────── */

.rules-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.80);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.rules-box {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(0, 229, 180, 0.30);
  border-radius: 8px;
  padding: 32px 40px;
  width: min(480px, 90%);
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(0, 229, 180, 0.08);
}

.rules-box ul {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rules-box li {
  position: relative;
  padding-left: 1.3em;
  font-size: 0.85rem;
  line-height: 1.5;
}

.rules-box li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--teal);
}

.rules-box button {
  display: block;
  margin: 0 auto;
}

/* ── Win overlay ─────────────────────────────────────────── */

.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.hidden { display: none; }

.win-box {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(0, 229, 180, 0.30);
  border-radius: 8px;
  padding: 48px 64px;
  text-align: center;
  box-shadow: 0 0 60px rgba(0, 229, 180, 0.08);
  position: relative;
  z-index: 101;
}

.win-box h2 {
  font-family: 'Syne', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: var(--teal);
}

/* Subheading in win box */
.win-box h2::after {
  content: '\A// game complete';
  white-space: pre;
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-top: 6px;
}

.win-box button {
  background: rgba(0, 229, 180, 0.12);
  color: var(--teal);
  border: 1px solid rgba(0, 229, 180, 0.30);
  padding: 10px 28px;
  font-size: 0.8rem;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
  margin-top: 24px;
}

.win-box button:hover {
  background: rgba(0, 229, 180, 0.22);
}

/* ── Confetti ────────────────────────────────────────────── */

.confetti-piece {
  position: fixed;
  font-size: 2.8rem;
  top: -3rem;
  opacity: 0;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg);        opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg);  opacity: 0; }
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 800px) {
  :root {
    --card-w:   95px;
    --card-h:   132px;
    --pile-gap: 14px;
  }
  body { padding: 8px 10px; }
  .card-label { font-size: 1.1rem; }
  .card-corner-suit { font-size: 0.95rem; }
  .card-suit { font-size: 1.85rem; }
}

@media (max-width: 500px) {
  :root {
    --card-w:   44px;
    --card-h:   62px;
    --pile-gap: 6px;
  }
  body { padding: 6px 8px; }
  main, .top-bar { max-width: 100%; }
  .top-bar h1 { font-size: 1rem; letter-spacing: 1px; }
  .top-bar h1::after { display: none; }
  .stats::before { display: none; }
  .card-label { font-size: 0.7rem; }
  .card-corner-suit { font-size: 0.72rem; }
  .card-suit { font-size: 0.95rem; }
  .card.face-down::after { inset: 2px; }
  .win-box { padding: 28px 24px; }
  .win-box h2 { font-size: 1.5rem; }
  .rules-box { padding: 20px 16px; }
}
