* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #0b6b3a;
  color: #f0f0f0;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.page {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

/* Header */

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #08492a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.header-bar .score,
.header-bar .timer {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 120px;
}

.header-bar .timer {
  text-align: right;
}

.new-game-btn {
  padding: 8px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #08492a;
  background: #f0d060;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.new-game-btn:hover {
  background: #f7de7e;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary-btn {
  background: transparent;
  color: #f0d060;
  border: 2px solid #f0d060;
}

.secondary-btn:hover {
  background: rgba(240, 208, 96, 0.15);
}

.game-options {
  position: relative;
}

.options-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  padding: 10px;
  background: #08492a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.options-menu.hidden {
  display: none;
}

.options-menu-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px 2px;
}

.option-btn {
  padding: 8px 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f0f0f0;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.option-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.option-btn.active {
  background: #f0d060;
  color: #08492a;
}

/* Content layout */

.content {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 16px 20px;
  height: 100%;
  min-height: 0;
}

.board {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.board-top {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.status-message {
  font-size: 0.95rem;
  color: #ffe08a;
  min-height: 1.2em;
}

/* Stock pile */

.stock-pile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.stock-pile.disabled {
  cursor: default;
  opacity: 0.4;
}

.stock-card-back {
  width: 60px;
  height: 84px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    45deg,
    #1a3a8f,
    #1a3a8f 4px,
    #2a4fb0 4px,
    #2a4fb0 8px
  );
  border: 2px solid #0d2361;
}

.stock-count {
  font-size: 0.9rem;
}

/* Tableau */

.tableau {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: 1fr;
  gap: 8px;
}

.column {
  height: 100%;
  min-height: 0;
  padding: 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.column.drop-target {
  outline: 3px solid #ffd54a;
  outline-offset: -2px;
}

/* Cards */

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.card.face-up {
  background: #fdfdf6;
  color: #111;
}

.card.face-up.suit-red {
  color: #b5122a;
}

.card.face-up.suit-black {
  color: #111;
}

.card.face-down {
  background: repeating-linear-gradient(
    45deg,
    #1a3a8f,
    #1a3a8f 4px,
    #2a4fb0 4px,
    #2a4fb0 8px
  );
}

.card .corner {
  position: absolute;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}

.card .corner.top-left {
  top: 4px;
  left: 4px;
}

.card .corner.bottom-right {
  bottom: 4px;
  right: 4px;
  transform: rotate(180deg);
}

.card.face-up.selected {
  outline: 3px solid #ffd54a;
  outline-offset: -1px;
  z-index: 5;
}

.card.face-up.selectable {
  touch-action: none;
}

.card.face-up.selectable:hover {
  cursor: grab;
  filter: brightness(0.95);
}

.card.dragging-source {
  opacity: 0.35;
}

.card.dealing {
  animation: dealCard 240ms ease-out both;
}

@keyframes dealCard {
  from {
    transform: translate(var(--deal-dx, 0), var(--deal-dy, 0)) scale(0.92);
    opacity: 0.5;
  }
  to {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0.95;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45));
}

.card.shake {
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Ad slot */

.ad-slot {
  width: clamp(120px, 20vw, 300px);
  height: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-placeholder {
  width: 100%;
  height: 100%;
  max-width: 300px;
  max-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

/* Win overlay */

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

.win-overlay.hidden {
  display: none;
}

.win-message {
  background: #08492a;
  padding: 32px 40px;
  border-radius: 10px;
  text-align: center;
}

.win-message p {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 16px;
}

