/* NateBox — physical card-deck play mode (#/decks/play/:name).
   A felt table: deck pile right, discard left, the drawn card front-and-center
   with 3D flip. Landscape-first; portrait shows a rotate hint. */

.dpv {
  height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(1000px 600px at 50% 20%, rgba(142, 91, 255, 0.18), transparent 60%),
    radial-gradient(circle, rgba(0, 0, 0, 0.22) 1.2px, transparent 1.4px) 0 0 / 18px 18px,
    linear-gradient(160deg, #143a2b, #0d2a1f 70%);
  overflow: hidden;
}
.dpv-missing { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }

.dpv-top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.dpv-back { padding: 8px 14px; font-size: 13px; }
.dpv-title { font-family: var(--display); font-size: 20px; display: flex; align-items: center; gap: 8px; }
.dpv-sub { color: rgba(244, 238, 255, 0.55); font-weight: 700; font-size: 12px; }

.dpv-table {
  flex: 1; min-height: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 18px calc(14px + env(safe-area-inset-bottom));
}
.dpv-center {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  position: relative;
}
.dpv-cardzone {
  flex: 1; min-height: 0; width: 100%;
  display: flex; align-items: center; justify-content: center;
  perspective: 1400px;
}
.dpv-idle-hint {
  position: absolute; bottom: 46%;
  color: rgba(244, 238, 255, 0.5); font-weight: 900;
  animation: fadePulse 1.6s infinite;
  pointer-events: none;
}
.dpv-center:has(.dpc) .dpv-idle-hint { display: none; }

/* ---------- the card ---------- */
.dpc {
  width: min(96%, 152dvh);
  height: min(100%, 62vw);
  max-height: 100%;
  transition: transform 0.45s cubic-bezier(0.34, 1.3, 0.5, 1), opacity 0.4s ease;
}
.dpc.is-dealing { transform: translateX(58vw) translateY(-8vh) rotate(14deg) scale(0.55); opacity: 0; }
.dpc.is-discarding { transform: translateX(-75vw) rotate(-20deg) scale(0.7); opacity: 0; transition-timing-function: cubic-bezier(0.5, 0, 0.8, 0.4); }
.dpc-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.1, 0.25, 1);
}
.dpc.is-flipped .dpc-inner { transform: rotateY(180deg); }
.dpc-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(165deg, #fdf7e8, #f2e7cd);
  color: #221536;
  border-radius: 18px;
  border: 3px solid rgba(34, 21, 54, 0.85);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column;
  padding: 12px 18px;
  overflow: hidden;
}
.dpc-back { transform: rotateY(180deg); background: linear-gradient(165deg, #efe6ff, #ded0f6); }
.dpc-head {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 2.5px solid rgba(34, 21, 54, 0.8);
  padding-bottom: 6px; margin-bottom: 6px;
  flex: 0 0 auto;
}
.dpc-deckname { font-family: var(--display); font-size: 15px; }
.dpc-facetag {
  background: #221536; color: #ffd51e;
  font-weight: 900; letter-spacing: 0.18em; font-size: 11px;
  border-radius: 999px; padding: 3px 12px;
}
.dpc-no { margin-left: auto; font-weight: 700; font-size: 11px; color: rgba(34, 21, 54, 0.55); }
.dpc-rows {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; justify-content: space-evenly; gap: 2px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;  /* safety net: never clip a row */
}
.dpc-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 2px 0; min-height: 0;
}
.dpc-row-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--catc); border: 2px solid rgba(34, 21, 54, 0.8);
  flex: 0 0 auto; align-self: center;
}
.dpc-row-cat {
  font-weight: 900; font-size: clamp(9px, 1.5dvh, 13px);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(34, 21, 54, 0.6);
  width: 14ch; flex: 0 0 auto;
}
.dpc-row-text { font-weight: 700; font-size: clamp(12px, 2.5dvh, 19px); line-height: 1.25; }
.dpc-row-text.is-answer { font-weight: 900; color: #6b21a8; }
.dpc-row-choices { font-weight: 600; font-size: 0.82em; color: rgba(34, 21, 54, 0.65); }

/* ---------- piles ---------- */
.dpv-pile {
  position: relative;
  width: clamp(90px, 15vw, 150px); height: clamp(120px, 21vw, 205px);
  cursor: pointer; flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.dpv-pile:hover { transform: translateY(-4px); }
.dpv-pile:active { transform: translateY(2px) scale(0.98); }
.dpv-pile-card {
  position: absolute; inset: 0;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.15), transparent 50%),
    repeating-linear-gradient(45deg, #4c2a8c 0 10px, #3b1f70 10px 20px);
  border: 2.5px solid rgba(244, 238, 255, 0.85);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.dpv-pile-card.is-c2 { transform: translate(4px, 4px) rotate(2deg); }
.dpv-pile-card.is-c3 { transform: translate(8px, 8px) rotate(-2deg); }
.dpv-pile.is-empty .dpv-pile-card { filter: grayscale(0.5) brightness(0.75); }
.dpv-pile-logo { font-size: 34px; }
.dpv-pile-hint { font-weight: 900; font-size: 10px; letter-spacing: 0.14em; color: rgba(244, 238, 255, 0.85); }
.dpv-pile-count {
  position: absolute; top: -12px; right: -10px;
  background: var(--yellow); color: #3c2c00;
  font-weight: 900; font-size: 14px;
  border-radius: 999px; padding: 3px 11px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.dpv-discard {
  width: clamp(70px, 11vw, 110px); height: clamp(95px, 15.5vw, 152px);
  border: 3px dashed rgba(244, 238, 255, 0.35);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: rgba(244, 238, 255, 0.5);
  flex: 0 0 auto;
  transition: all 0.3s ease;
}
.dpv-discard:not(.is-empty) {
  border-style: solid;
  background: repeating-linear-gradient(45deg, rgba(76, 42, 140, 0.6) 0 10px, rgba(59, 31, 112, 0.6) 10px 20px);
  color: rgba(244, 238, 255, 0.85);
}
.dpv-discard-label { font-weight: 900; font-size: 10px; letter-spacing: 0.16em; }
.dpv-discard-count { font-family: var(--display); font-size: 22px; }

.dpv-actions { display: flex; gap: 12px; flex: 0 0 auto; }
.dpv-actions.is-hidden { visibility: hidden; }
.dpv-btn { font-size: 15px; }

/* portrait: still works, but nudge toward landscape */
.dpv-rotate { display: none; }
@media (orientation: portrait) {
  .dpv-rotate {
    display: block;
    text-align: center;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    color: var(--yellow); font-weight: 900; font-size: 12px;
    animation: fadePulse 1.6s infinite;
  }
  /* portrait uses the whole card zone; the rotate hint sits below it */
  .dpc { width: 100%; height: 100%; }
  .dpc-row-cat { width: auto; max-width: 8ch; }
}

/* ---------- phone fit: shrink everything so all 6 rows fit, both orientations
   (Trivial-Pursuit cards are dense — on a small screen we trade the big desktop
   type for a compact, complete card rather than a clipped one). ---------- */
@media (max-width: 900px), (max-height: 640px) {
  .dpv-top { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); gap: 10px; }
  .dpv-title { font-size: 16px; }
  .dpv-sub { display: none; }              /* the "pass it around" hint eats a row of space */
  .dpv-table { gap: 8px; padding: 4px 10px calc(8px + env(safe-area-inset-bottom)); }

  .dpc { width: 100%; height: 100%; max-height: 100%; }
  .dpc-face { padding: 8px 11px; border-radius: 14px; border-width: 2.5px; }
  .dpc-head { gap: 8px; padding-bottom: 4px; margin-bottom: 4px; }
  .dpc-deckname { font-size: 12px; }
  .dpc-facetag { font-size: 9px; padding: 2px 8px; letter-spacing: 0.12em; }
  .dpc-no { font-size: 9px; }
  .dpc-rows { justify-content: space-between; gap: 1px; }
  .dpc-row { gap: 7px; padding: 1px 0; }
  .dpc-row-dot { width: 11px; height: 11px; border-width: 1.5px; }
  .dpc-row-cat { font-size: 9px; width: auto; max-width: 7ch; letter-spacing: 0.02em; }
  .dpc-row-text { font-size: clamp(11px, 2.05dvh, 15px); line-height: 1.18; }
  .dpc-row-choices { font-size: 0.78em; }

  /* piles get out of the card's way on tight screens */
  .dpv-pile { width: clamp(66px, 13vw, 104px); height: clamp(90px, 18vw, 146px); }
  .dpv-discard { width: clamp(52px, 9vw, 84px); height: clamp(72px, 12.5vw, 116px); }
  .dpv-btn { font-size: 13px; padding: 10px 16px; }
  .dpv-actions { gap: 8px; }
}

/* very short landscape phones (e.g. 375-tall): go even tighter */
@media (max-height: 430px) and (orientation: landscape) {
  .dpv-top { padding: 3px 10px; padding-top: calc(3px + env(safe-area-inset-top)); }
  .dpv-title-emoji { display: none; }
  .dpc-face { padding: 5px 9px; }
  .dpc-head { padding-bottom: 3px; margin-bottom: 3px; }
  .dpc-deckname { font-size: 11px; }
  .dpc-rows { gap: 0; }
  .dpc-row { padding: 0; }
  .dpc-row-text { font-size: clamp(9px, 2.9dvh, 13px); line-height: 1.1; }
  .dpc-row-cat { max-width: 6ch; font-size: 8px; }
  .dpc-row-choices { font-size: 0.72em; }
}
