:root {
  --primary: #2c3e3e;
  --secondary: #e4c59e;
  --accent: #c04b3c;
  --background: #f8f5f0;
  --text: #2b2b2b;
  --surface: #ffffff;
  --outline: rgba(44, 62, 62, 0.18);
  --ok: #c04b3c;
  --shadow-soft: 0 14px 32px rgba(44, 62, 62, 0.14);
  --card-width: 126px;
  --card-height: 162px;
  --card-radius: 14px;
  --card-padding: 10px;
  --card-offset: 50px;
  --stack-gap: 18px;
  --page-gutter: 16px;
}

* {
  box-sizing: border-box;
}

body,
body * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Playfair Display", system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(228, 197, 158, 0.35), transparent 60%),
    radial-gradient(circle at top left, rgba(44, 62, 62, 0.15), transparent 45%),
    var(--background);
  background-attachment: fixed; /* ensures gradient covers entire viewport */
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--text);
}

body[data-card-style="classic"] {
  background: url("/assets/ruudy/bg.png") center / cover no-repeat fixed;
}


header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: var(--primary);
  color: var(--secondary);
  box-shadow: 0 4px 18px rgba(44, 62, 62, 0.32);
}

header .brand {
  color: var(--secondary);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-decoration: none;
}

header .brand:hover,
header .brand:focus-visible {
  color: #ffffff;
  outline: none;
}

.status-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(248, 245, 240, 0.85);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(44, 62, 62, 0.12);
  backdrop-filter: blur(8px);
}

.status-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-group.current-stats {
  justify-self: center;
}

.status-group.total-stats {
  justify-self: end;
}

.status-bar span {
  white-space: nowrap;
}

.status-divider {
  font-size: 0.9em;
  color: rgba(44, 62, 62, 0.45);
}

@media (max-width: 640px) {
  .status-bar {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .status-group.total-stats {
    justify-self: center;
  }
}

.game-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 600;
  color: #f9f6f1;
}

.controls {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.controls button {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(192, 75, 60, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.options-wrapper {
  position: relative;
}

.options-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-width: 180px;
  padding: 16px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid rgba(44, 62, 62, 0.12);
  box-shadow: 0 16px 36px rgba(44, 62, 62, 0.2);
  z-index: 10;
}

.options-panel[hidden] {
  display: none !important;
}

.options-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
}

.options-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.options-choice input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.controls button:hover,
.controls button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(192, 75, 60, 0.28);
  outline: none;
}

main {
  max-width: 820px;
  margin: 32px auto 40px;
  padding: 0 var(--page-gutter);
}

.win-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(44, 62, 62, 0.45);
  backdrop-filter: blur(6px);
  z-index: 200;
}

.win-modal[hidden] {
  display: none !important;
}

.win-modal__content {
  min-width: min(320px, 100%);
  padding: 28px 32px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  text-align: center;
  display: grid;
  gap: 16px;
}

.win-modal__content h2 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--primary);
}

.win-modal__score {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}

.win-modal__btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(192, 75, 60, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.win-modal__btn:hover,
.win-modal__btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(192, 75, 60, 0.28);
  outline: none;
}

.tableau {
  display: flex;
  justify-content: center;
  gap: var(--stack-gap);
  align-items: flex-start;
}

.stack {
  position: relative;
  min-height: calc(var(--card-height) + (var(--card-offset) * 12));
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--card-width);
  flex: 0 0 var(--card-width);
}

.card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  transform: translateY(calc(var(--card-offset) * var(--card-index, 0)));
  border-radius: var(--card-radius);
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-soft);
  padding: var(--card-padding);
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card.card-classic {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
}

.card.card-classic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
  display: block;
  pointer-events: none;
}

.card.top {
  box-shadow: 0 18px 38px rgba(44, 62, 62, 0.24);
}

.card.card-classic.top img {
  box-shadow: 0 18px 38px rgba(44, 62, 62, 0.24);
}

.card.dragging {
  cursor: grabbing;
  box-shadow: 0 24px 44px rgba(44, 62, 62, 0.35);
  transform: translateY(calc(var(--card-offset) * var(--card-index, 0))) scale(1.02);
}

.card.card-classic.dragging img {
  box-shadow: 0 24px 44px rgba(44, 62, 62, 0.35);
}

.card.selected {
  outline: 3px solid var(--secondary);
}

.rank {
  font-size: clamp(16px, calc(var(--card-width) * 0.18), 24px);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.suit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* centers within the card */
  font-size: clamp(28px, calc(var(--card-width) * 0.37), 52px);   /* keep or tweak */
  line-height: 1;
  pointer-events: none; /* so dragging/clicks aren’t intercepted */
}

.corner {
  position: absolute;
  top: 8px;
  right: 10px;
  font-weight: 700;
  font-size: clamp(16px, calc(var(--card-width) * 0.18), 24px);
  color: var(--text);
}

.drop-target {
  outline: 2px dashed rgba(44, 62, 62, 0.25);
  border-radius: calc(var(--card-radius) + 2px);
}

.slot {
  width: var(--card-width);
  height: var(--card-height);
  border: 2px dotted rgba(44, 62, 62, 0.28);
  border-radius: calc(var(--card-radius) + 2px);
  background: rgba(228, 197, 158, 0.25);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1024px) {
  :root {
    --card-width: 128px;
    --card-height: calc(var(--card-width) * 1.2857);
    --card-padding: 9px;
    --card-offset: 38px;
    --stack-gap: 16px;
    --card-radius: 12px;
  }
}

@media (max-width: 720px) {
  :root {
    --page-gutter: 12px;
    --stack-gap: clamp(8px, 2.4vw, 12px);
    --card-width: clamp(68px, calc((100vw - (var(--page-gutter) * 2) - (var(--stack-gap) * 3)) / 4), 92px);
    --card-height: calc(var(--card-width) * 1.2857);
    --card-padding: clamp(6px, calc(var(--card-width) * 0.085), 9px);
    --card-offset: calc(var(--card-height) * 0.24);
    --card-radius: 10px;
  }
  header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
    text-align: center;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .controls button {
    width: calc(50% - 8px);
    min-width: 140px;
  }

  main {
    margin-top: 24px;
  }
}

.stack {
  overflow: visible; /* ensure the card isn't clipped when translated outside */
}

.card {
  will-change: transform;   /* smoother + avoids odd repaints */
  touch-action: none;       /* prevents touch scrolling from swallowing the drag */
  -webkit-user-select: none;
  user-select: none;
}

.card * {
  -webkit-user-select: none;
  user-select: none;
}

.card.dragging {
  z-index: 9999;            /* float above header/other stacks while dragging */
  /* optional: don't restyle transform here—let JS fully control it */
  /* legacy: transform: translateY(var(--y, 0)) scale(1.02); */
}

.draw-controls {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
}

.draw-btn {
  position: relative;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  padding: 16px 128px;
  border: none;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(192, 75, 60, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;  /* centers Draw */
}

/* Center "Draw" text block */
.draw-label {
  position: relative;
  z-index: 2; /* keep it above key-hint */
}

/* Float [Space] independently — doesn't affect centering */
.key-hint {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(192, 75, 60, 0.15);
  color: #f8d3cd;
  border: 1px solid rgba(192, 75, 60, 0.25);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

.draw-btn:hover,
.draw-btn:focus-visible {
  transform: scale(1.05);
  box-shadow: 0 16px 36px rgba(192, 75, 60, 0.45);
  outline: none;
}

.draw-btn:hover .key-hint {
  background: rgba(192, 75, 60, 0.25);
  border-color: rgba(192, 75, 60, 0.35);
}

.undo-btn {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(228, 197, 158, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.undo-btn:hover,
.undo-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(228, 197, 158, 0.45);
  outline: none;
}

.undo-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 4px 10px rgba(228, 197, 158, 0.25);
}

@media (max-width: 720px) {
  .draw-btn {
    font-size: 1.1rem;
    padding: 14px 96px;
  }
  .draw-controls {
    bottom: 20px;
    gap: 10px;
    flex-direction: column;
    transform: translateX(-50%);
  }
  .undo-btn {
    width: 100%;
    padding: 10px 18px;
  }
}
