/* ==========================================================================
   SHARED CARD GAMES CHROME
   Common page/header/modal/card styling reused by Klondike, Spider,
   Pyramid and TriPeaks. Board-specific layout lives in each game's own
   stylesheet. FreeCell predates this file and is not wired to it.
   ========================================================================= */

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #0a4d2c;
  background-image: radial-gradient(#11633b 20%, #0a4d2c 80%);
  overflow-x: hidden;
  text-align: center;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 8px;
  box-sizing: border-box;
}

/* ==========================================================================
   HEADER
   ========================================================================= */
header {
  background: white;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.back-link,
.help-btn {
  display: inline-block;
  height: 34px;
  line-height: 34px;
  width: 85px;
  text-decoration: none;
  border-radius: 8px;
  background: #333;
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition:
    transform 0.2s,
    background-color 0.2s;
  text-align: center;
}

.help-btn {
  background: #555;
}

.back-link:hover,
.help-btn:hover {
  transform: scale(1.03);
  background-color: #444;
}

.title-area h1 {
  margin: 0;
  font-size: 24px;
  color: #333;
  text-align: center;
}

.logo {
  width: 55px;
  height: auto;
}

/* ==========================================================================
   SHARED SLOT / CARD PRIMITIVES
   ========================================================================= */
.zone {
  display: flex;
  gap: 4px;
}

.slot {
  flex: 1;
  max-width: 100px;
  aspect-ratio: 100 / 145;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  position: relative;
  background: rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
}

.suit-watermark {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: rgba(255, 255, 255, 0.15);
  user-select: none;
}

.card-container {
  position: absolute;
  width: 100%;
  aspect-ratio: 100 / 145;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 6px;
  background-color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  user-select: none;
  box-sizing: border-box;
  border: 1px solid #c8cbcf;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
}

/* Face-down card back: patterned background + centered Lormark logo,
   reusing the existing brand asset instead of a new image file. */
.card-back {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  border: 1px solid #c8cbcf;
  background-color: #1a3f8f;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0, rgba(255, 255, 255, 0.08) 2px, transparent 2px, transparent 10px),
    linear-gradient(135deg, #1a3f8f, #0d2456);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

.card-back img {
  width: 62%;
  height: auto;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.card-img.selected-card {
  border: 2px solid #ffeb3b !important;
  box-shadow: 0 0 12px #ffeb3b !important;
  transform: translateY(-4px);
}

@keyframes invalid-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.card-img.invalid-shake {
  animation: invalid-shake 0.3s;
  border-color: #e53935 !important;
}

/* Dismissible "Clear the deck?" auto-complete banner (FreeCell/Klondike/Spider) */
.autocomplete-banner {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 1500;
  background: white;
  color: #222;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  align-items: center;
  gap: 12px;
}

.autocomplete-banner.visible {
  display: flex;
}

.autocomplete-banner button {
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-weight: bold;
  cursor: pointer;
}

.autocomplete-banner .autocomplete-confirm {
  background: #2e7d32;
  color: white;
}

.autocomplete-banner .autocomplete-dismiss {
  background: #ccc;
  color: #222;
}

.slot.drag-over,
.column.drag-over {
  border-color: #90ee90 !important;
  background-color: rgba(144, 238, 144, 0.2) !important;
}

/* ==========================================================================
   MODAL RULES BOX
   ========================================================================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal-box {
  background: white;
  color: #333;
  padding: 25px;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  text-align: left;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  max-height: 80vh;
  overflow-y: auto;
}

.close-modal-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #333;
  color: white;
  font-weight: bold;
  cursor: pointer;
}

.close-modal-btn:hover {
  background: #444;
}

/* ==========================================================================
   MOBILE HEADER LAYOUT (shared 2-row grid, same breakpoint as FreeCell)
   ========================================================================= */
@media (max-width: 700px) {
  body {
    padding: 4px;
  }

  header {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 10px;
    margin-bottom: 12px;
    gap: 10px;
    align-items: center;
  }

  .title-area {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
    width: auto;
    margin-bottom: 0;
  }

  .title-area h1 {
    font-size: 20px;
  }

  .logo {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    grid-column: 2;
    grid-row: 1;
    width: 40px;
    height: auto;
  }

  .header-buttons {
    grid-column: 1 / span 2;
    grid-row: 2;
    display: flex;
    width: 100%;
    gap: 8px;
    justify-content: center;
  }

  .back-link,
  .help-btn {
    flex: 1;
    max-width: 150px;
    height: 34px;
    line-height: 34px;
    font-size: 12px;
  }
}
