:root {
  --green: #0b6b3a;
  --green-dark: #084f2b;
  --felt: #0f7a44;
  --card: #ffffff;
  --card-face: #f8f9fa;
  --border: rgba(255, 255, 255, 0.6);
  --shadow: rgba(0, 0, 0, 0.2);
  --red: #d63939;
  --back-primary: #203a79;
  --back-dark: #142856;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: #fff;
  background-color: var(--green);
  background-image: url('assets/backgrounds/green-baize-background_1536x2816.webp');
  background-position: center top;
  background-size: 100% auto; /* fill horizontally */
  background-repeat: repeat-y; /* tile vertically if needed */
}

.app-header, .app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(0deg, var(--green-dark), rgba(0,0,0,0));
}

.title {
  margin: 0;
  font-weight: 700;
  font-size: 22px;
}
.title a {
  color: #fff;
  text-decoration: none;
}

.controls .btn,
.form-card .btn {
  background: #fff;
  color: #222;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px var(--shadow);
}
.btn[aria-pressed="true"] {
  background: #111;
  color: #fff;
}


.controls .btn:active,
.form-card .btn:active {
  transform: translateY(1px);
}

.board {
  width: min(1600px, 98vw);
  margin: 0 auto;
  padding: 12px 8px 24px 8px;
}

.top-row, .tableau-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.left-group {
  grid-column: 1 / span 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.foundations {
  grid-column: 4 / span 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.pile {
  position: relative;
  min-height: 224px;
  border-radius: 8px;
  /*outline: 2px dashed var(--border);*/
  outline-offset: -6px;
  box-shadow: inset 0 2px 8px var(--shadow);
}
.pile.tableau {
  box-shadow: none;
}

.stock, .waste, .foundation {
  height: 320px;
}

.tableau {
  height: 840px;
}

.card {
  position: absolute;
  width: 200px;
  height: 280px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: var(--card);
  color: #222;
  box-shadow: 0 6px 14px var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 6px;
  -webkit-user-select: none;
  user-select: none;
}

.card.face-down {
  background: var(--back-primary);
  overflow: hidden;
}
.custom-back .card.face-down {
  background-image: var(--deck-back-url);
  background-size: cover;
  background-position: center;
}
/* When using a custom back image, hide the patterned pseudo-elements */
.custom-back .card.face-down::before,
.custom-back .card.face-down::after {
  display: none;
}
/* Hide X-Ray corners by default on face-down cards */
.card.face-down .xray-corners { display: none; }
.xray .card.face-down .xray-corners { position: absolute; inset: 6px; display: grid; grid-template-rows: auto 1fr auto; z-index: 3; color: #79f5ff; filter: drop-shadow(0 0 6px rgba(0,255,255,0.8)) drop-shadow(0 0 16px rgba(0,255,255,0.5)); font-weight: 700; transform: scaleX(-1); transform-origin: center; }
.xray .card.face-down .xray-corners .rank, .xray .card.face-down .xray-corners .small-suit { color: #79f5ff; }
.xray .card.face-down::after,
.xray .card.face-down::before { opacity: 0.2; }
.xray .card.face-down { filter: brightness(1.1) saturate(1.2); }
.xray .card.face-down .xray-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #79f5ff;
  text-shadow: 0 0 6px rgba(0,255,255,0.8), 0 0 16px rgba(0,255,255,0.5);
  font-weight: 700;
  font-size: 42px;
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 3;
}
.card.face-down::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.08) 25%, transparent 25% 75%, rgba(255,255,255,0.08) 75%) 0 0/20px 20px,
    linear-gradient(-45deg, rgba(255,255,255,0.08) 25%, transparent 25% 75%, rgba(255,255,255,0.08) 75%) 0 0/20px 20px,
    var(--back-dark);
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,0.2), inset 0 2px 8px rgba(0,0,0,0.35);
  z-index: 1;
}
.card.face-down::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 54px; height: 54px;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 6px;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35), inset 0 0 0 4px rgba(255,255,255,0.25);
  z-index: 2;
}

.card .rank, .card .suit { font-weight: 700; font-size: 28px; line-height: 1.1;}
.card .suit { justify-self: end; }
.card .corner { display: inline-grid; align-content: start; justify-items: center; gap: 4px; justify-self: start; }
.card .corner { position: relative; z-index: 1; }
.card .small-suit { font-weight: 700; font-size: 40px; line-height: .4; }
.card .big-suit { font-weight: 700; font-size: 40px; line-height: .4; }
.card .corner.bottom { justify-self: end; align-self: end; transform: rotate(180deg); }

/* Improve contrast of rank/suit over photos */
.card .rank, .card .suit, .card .small-suit, .card .big-suit {
  -webkit-text-stroke: .3px #ffffff;
  text-shadow:
  .3px 0 0 #ffffff,
  -.3px 0 0 #ffffff,
  0 .3px 0 #ffffff,
  0 -.3px 0 #ffffff,
  .3px .3px 0 #ffffff,
  -.3px -.3px 0 #ffffff,
  .3px -.3px 0 #ffffff,
  -.3px .3px 0 #ffffff;
}

/* Center photo slot for face-up cards */
.card .center-slot {
  position: absolute;
  inset: 6px;
  border-radius: 6px;
  overflow: hidden;
  z-index: 0;
}
.card .center-slot.photo {
  background-size: cover;
  background-position: center;
}
.card .center-slot.photo {
  inset: 0;
  border-radius: 8px;
}

/* Tiny caption bottom-left for photo credits */
.card .photo-caption {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 10px;
  line-height: 1.2;
  color: #fff;
  padding: 2px 4px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.6));
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  pointer-events: auto;
  z-index: 2;
}
.card .photo-caption a {
  color: #aeeaff;
  text-decoration: underline;
}

/* Lightbox */
.lightbox { position: fixed; inset: 0; display: none; z-index: 9999; }
.lightbox[aria-hidden="false"] { display: block; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.82); }
.lightbox-dialog { position: absolute; inset: 4%; display: grid; place-items: center; }
.lightbox-media { position: relative; max-width: min(92vw, 1100px); max-height: 92vh; }
.lightbox-media img { display: block; width: auto; height: auto; max-width: 100%; max-height: 92vh; border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,0.65); }
.lightbox-caption { left: 20px; bottom: 20px; font-size: 12px; cursor: pointer; border-radius: 6px; padding: 6px 8px; background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.6)); text-shadow: 0 1px 2px rgba(0,0,0,0.7); }
.lightbox-media .lightbox-caption { position: absolute; }
.lightbox-close { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.65); color: #fff; border-radius: 999px; width: 32px; height: 32px; line-height: 28px; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
a.license-link {
  color: white;
  text-decoration: none;
}
a.license-link:hover {
  text-decoration: underline;
}
.card .center-slot.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.15);
}

.red {
  color: var(--red);
}

.card.face-up { cursor: pointer; }
.card.selected {
  outline: 6px solid rgba(255, 215, 0, 0.9);
  outline-offset: -3px;
}

.placeholder {
  position: absolute;
  inset: 8px;
  border-radius: 6px;
  /*border: 2px dashed rgba(255,255,255,0.35);*/
}

@media (max-width: 768px) {
  .card { width: 84px; height: 120px; }
  .stock, .waste, .foundation { height: 140px; }
  .tableau { height: 380px; }
}


/* Deck selection modal */
.deck-modal { position: fixed; inset: 0; display: none; z-index: 10000; }
.deck-modal[aria-hidden="false"] { display: block; }
.deck-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.8); }
.deck-modal-dialog { position: absolute; inset: 4% 2%; margin: 0 auto; width: min(96vw, 1600px); height: 92vh; overflow: auto; background: rgba(0,0,0,0.25); border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,0.6); }
.deck-modal .ed-header { padding: 12px 16px; }
.deck-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:16px;padding:12px 16px}
.deck-card{display:block;text-decoration:none;color:#e6f6ee;background:rgba(0,0,0,.25);border-radius:12px;overflow:hidden}
.deck-thumb{width:100%;aspect-ratio:5/7;background:#0a5c34;display:grid;place-items:center}
.deck-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.deck-meta{padding:10px}
.deck-title{margin:0 0 4px 0;font-size:16px}

/* Global link styles */
a { color: #fff; }
a:visited { color: #fff; }
a:hover { text-decoration: underline; }

/* Forms */
.form-card { max-width: min(800px, 96vw); margin: 16px auto; background: rgba(0,0,0,0.25); padding: 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.contact-form { display: grid; grid-template-columns: 1fr; gap: 12px; }
.contact-form .field { display: grid; gap: 6px; }
.contact-form label { font-weight: 600; }
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea { padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.85); color: #111; font-size: 16px; }
.contact-form textarea { resize: vertical; }
.contact-form .actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.form-status { max-width: min(800px, 96vw); margin: 12px auto; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.form-status.success { background: rgba(16, 110, 63, 0.85); }
.form-status.error { background: rgba(160, 20, 20, 0.85); }
