/* Game Layout - Dark Theme */

.game-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* recordOS dark table with crosshatch pattern */
.game-table {
  width: 100%;
  height: 100%;
  background-color: #0a0a0a;
  background-image:
    /* Crosshatch pattern - diagonal lines */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 9px,
      rgba(0, 255, 65, 0.04) 9px,
      rgba(0, 255, 65, 0.04) 10px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 9px,
      rgba(0, 255, 65, 0.04) 9px,
      rgba(0, 255, 65, 0.04) 10px
    ),
    /* Subtle center vignette */
    radial-gradient(ellipse at center, #0d1a0d 0%, #0a0a0a 70%);
  padding: clamp(10px, 2vmin, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3vmin, 26px);
  position: relative;
}

/* Weyland-Yutani watermark */
.game-table::after {
  content: 'WEYLAND-YUTANI CORP // BUILDING BETTER WORLDS';
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-family: 'VT323', monospace;
  font-size: 10px;
  color: rgba(0, 255, 65, 0.12);
  letter-spacing: 1px;
  pointer-events: none;
  white-space: nowrap;
}

/* Top row: Stock, Waste, and Foundations */
.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.stock-waste {
  display: flex;
  gap: var(--pile-gap);
}

.foundations {
  display: flex;
  gap: var(--pile-gap);
}

/* Pile base styling */
.pile {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  flex-shrink: 0;
}

/* Stock pile */
.pile.stock {
  cursor: pointer;
}

/* Waste pile - show up to 3 cards fanned */
.pile.waste {
  width: calc(var(--card-width) + var(--pile-gap) * 2);
}

.pile.waste .card {
  position: absolute;
  top: 0;
}

.pile.waste .card:nth-last-child(3) {
  left: 0;
}

.pile.waste .card:nth-last-child(2) {
  left: var(--pile-gap);
}

.pile.waste .card:nth-last-child(1) {
  left: calc(var(--pile-gap) * 2);
}

/* Tableau area */
.tableau {
  display: flex;
  justify-content: space-between;
  flex: 1;
  min-height: 0;
}

/* Tableau pile */
.pile.tableau-pile {
  height: auto;
  min-height: var(--card-height);
}

/* Cards in tableau stack vertically */
.pile.tableau-pile .card {
  position: absolute;
  left: 0;
}

/* Win animation canvas - only covers game area */
#win-canvas {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  cursor: pointer;
}

#win-canvas.active {
  display: block;
  pointer-events: auto;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .menu-bar {
    font-size: 10px;
  }

  .status-bar {
    font-size: 10px;
  }

  .status-field {
    min-width: 60px;
    padding: 1px 4px;
  }

  .title-bar-text {
    font-size: 11px;
  }
}

/* Mobile: Flip tableau to horizontal orientation */
@media (max-width: 500px) {
  .game-table {
    padding: 6px;
    gap: 6px;
    overflow-y: auto;
    /* Grid layout: foundations on right, stock/waste + tableau on left */
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "stock-waste foundations"
      "tableau foundations";
  }

  .top-row {
    display: contents;
  }

  .stock-waste {
    grid-area: stock-waste;
    gap: 4px;
    display: flex;
  }

  /* Foundations stack vertically on the right */
  .foundations {
    grid-area: foundations;
    flex-direction: column;
    gap: 4px;
    align-self: start;
  }

  .foundations .pile {
    width: var(--card-width);
  }

  /* Tableau fills the left side below stock/waste */
  .tableau {
    grid-area: tableau;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    overflow-y: auto;
    padding-bottom: 20px;
    padding-right: 6px;
  }

  /* Each tableau pile becomes a horizontal row */
  .pile.tableau-pile {
    width: 100%;
    height: var(--card-height);
    min-height: var(--card-height);
    display: flex;
    flex-direction: row;
    position: relative;
  }

  /* Cards in tableau fan horizontally on mobile */
  .pile.tableau-pile .card {
    position: absolute;
    top: 0 !important;
  }
}

@media (max-width: 400px) {
  .status-field.moves {
    display: none;
  }
}

/* Landscape phone - reduce top row height impact */
@media (max-height: 500px) and (orientation: landscape) {
  .game-table {
    padding: 6px;
    gap: 8px;
  }

  :root {
    --stack-offset: clamp(10px, 2vmin, 18px);
    --stack-offset-facedown: clamp(3px, 0.6vmin, 6px);
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  .card {
    /* Ensure adequate touch target */
    min-width: 40px;
    min-height: 56px;
  }

  .menu-option {
    padding: 10px 20px;
    min-height: 44px;
  }

  .menu-label {
    padding: 6px 12px;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .win95-btn {
    padding: 8px 20px;
    min-height: 44px;
  }

  /* Prevent double-tap zoom on game area */
  .game-table {
    touch-action: manipulation;
  }
}

/* Iframe mode detection - minimal chrome */
.iframe-mode .title-bar {
  display: none;
}

.iframe-mode .menu-bar {
  padding: 1px 0;
}

.iframe-mode .menu-label {
  padding: 2px 8px;
  font-size: 11px;
}

.iframe-mode .status-bar {
  padding: 2px 4px;
}

.iframe-mode .status-field {
  min-width: 50px;
  padding: 1px 4px;
  font-size: 11px;
}

/* Hide watermark in iframe - recordOS already has its own branding */
.iframe-mode .game-table::after {
  display: none;
}

/* High contrast/accessibility */
@media (prefers-contrast: high) {
  .card {
    border-width: 2px;
  }

  .pile-placeholder {
    border-width: 3px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }
}

/* Print styles */
@media print {
  .title-bar,
  .menu-bar,
  .status-bar,
  .modal-overlay {
    display: none !important;
  }

  .game-table {
    background: white !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid black !important;
  }
}
