/* UX fixes layered on top of the baseline stylesheet. */

/* The old clear-selection button is intentionally removed from the UI.
   A selected card can be clicked again to deselect it. */
#clear-btn { display: none !important; }

/* Desktop table is a viewport-bound game surface. Dynamic content must never
   be allowed to grow the app shell beyond the browser window. */
@media (min-width: 1181px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden;
  }

  .game-layout,
  .helper-panel,
  .table-wrap,
  .wood-frame,
  .felt-table {
    min-height: 0;
    max-height: 100%;
  }

  .game-layout,
  .helper-panel,
  .table-wrap,
  .wood-frame {
    height: 100%;
    overflow: hidden;
  }

  .felt-table {
    height: 100%;
    overflow: hidden;
  }
}

/* Keep player controls clearly ABOVE the cards instead of overlapping them. */
.human-area { height: 330px; }
.human-hand { bottom: 78px; height: 166px; max-width: 100%; min-width: 0; }
.action-bar {
  bottom: 260px;
  width: max-content;
  max-width: calc(100% - 40px);
  justify-content: center;
  flex-wrap: wrap;
  padding: 6px 8px;
  border: 1px solid rgba(215,180,94,.18);
  border-radius: 13px;
  background: rgba(7,18,12,.72);
  box-shadow: 0 12px 28px rgba(0,0,0,.22);
  backdrop-filter: blur(7px);
}

/* Normal-size hands stay as a fan. When the fan would become too tight, JS
   switches to a horizontally scrollable rack. In rack mode cards do not
   overlap at all, so every full card remains a reliable click target. */
.human-hand {
  overflow: visible;
  contain: layout;
}
.hand-card { min-width: 0; }
.human-hand.hand-scroll-mode {
  height: 190px;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  contain: layout paint;
  padding: 28px 18px 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(215,180,94,.42) rgba(0,0,0,.16);
}
.human-hand.hand-scroll-mode::-webkit-scrollbar { height: 7px; }
.human-hand.hand-scroll-mode::-webkit-scrollbar-track { background: rgba(0,0,0,.16); border-radius: 99px; }
.human-hand.hand-scroll-mode::-webkit-scrollbar-thumb { background: rgba(215,180,94,.42); border-radius: 99px; }
.human-hand.hand-scroll-mode .hand-card {
  flex: 0 0 var(--cardw, 106px);
  scroll-snap-align: nearest;
}

/* Jack/Ace decisions should not hide the player's own hand. The choice panel
   floats above the hand with only a very light veil over the table. */
#choice-modal.choice-peek-overlay {
  place-items: end center;
  padding: 0 18px 340px;
  background: rgba(2,7,4,.14);
  backdrop-filter: none;
  pointer-events: none;
}
#choice-modal.choice-peek-overlay .choice-card {
  width: min(690px, calc(100vw - 48px));
  padding: 16px 18px;
  pointer-events: auto;
  background: rgba(14, 27, 21, .96);
  box-shadow: 0 18px 48px rgba(0,0,0,.38);
}
#choice-modal.choice-peek-overlay .choice-card h2 { margin: 3px 0 4px; font-size: 24px; }
#choice-modal.choice-peek-overlay .choice-card > p { margin: 5px 0 0; }
#choice-modal.choice-peek-overlay .choice-options {
  grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
  gap: 7px;
  margin-top: 11px;
}
#choice-modal.choice-peek-overlay .choice-button {
  min-height: 52px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
#choice-modal.choice-peek-overlay .rank-choice,
#choice-modal.choice-peek-overlay .no-demand-choice { flex-direction: column; gap: 2px; }
#choice-modal.choice-peek-overlay .choice-button small {
  display: block;
  color: #9db8a7;
  font: 700 9px Inter, system-ui, sans-serif;
  letter-spacing: .02em;
  white-space: nowrap;
}
#choice-modal.choice-peek-overlay .suit-choice span { display: grid; gap: 2px; text-align: left; }
#choice-modal.choice-peek-overlay .no-demand-choice {
  border-color: rgba(215,180,94,.45);
  color: var(--gold2, #e7cd78);
}

/* The helper panel is the actual scroll container for the Journal tab. Give it
   the same quiet gold-on-dark scrollbar language as the card rack. */
.helper-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(215,180,94,.48) rgba(0,0,0,.18);
  scrollbar-gutter: stable;
}
.helper-content::-webkit-scrollbar { width: 8px; }
.helper-content::-webkit-scrollbar-track {
  background: rgba(0,0,0,.18);
  border-radius: 99px;
}
.helper-content::-webkit-scrollbar-thumb {
  background: linear-gradient(rgba(231,205,120,.62), rgba(189,145,55,.54));
  border: 2px solid rgba(8,17,13,.76);
  border-radius: 99px;
}
.helper-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(rgba(241,215,130,.78), rgba(215,180,94,.68));
}
.log-list { padding-right: 5px; }
.log-list p { line-height: 1.45; }

/* Transient flight cards used for play/draw feedback. */
.ux-flight-card {
  position: fixed !important;
  z-index: 120 !important;
  margin: 0 !important;
  pointer-events: none !important;
  transform-origin: center center;
  will-change: transform, opacity;
  box-shadow: 0 20px 36px rgba(0,0,0,.38) !important;
}
.ux-flight-card.is-flying {
  transition: transform .38s cubic-bezier(.2,.72,.22,1), opacity .18s ease .24s;
}
.ux-arriving-card { opacity: .12; }

@media (max-width: 820px) {
  .human-area { height: 272px; }
  .human-hand { bottom: 65px; height: 125px; contain: none; }
  .human-hand.hand-scroll-mode { height: 146px; padding-top: 24px; gap: 5px; }
  .action-bar {
    bottom: 205px;
    width: max-content;
    max-width: 96%;
  }
  #choice-modal.choice-peek-overlay { padding-bottom: 270px; }
  #choice-modal.choice-peek-overlay .choice-card { width: min(620px, calc(100vw - 28px)); }
}

@media (max-width: 560px) {
  .human-area { height: 286px; }
  .human-hand { bottom: 76px; }
  .action-bar {
    bottom: 218px;
    width: max-content;
    max-width: 94%;
  }
  #choice-modal.choice-peek-overlay { padding: 0 10px 290px; }
  #choice-modal.choice-peek-overlay .choice-options { grid-template-columns: repeat(2, 1fr); }
}
