/* TriPeaks: a park-poster scene with three mountains; the cards sit on the slopes. */
.tp-col {
  --bw: min(100vw - 12px, 700px, (100vh - 300px) * 1.7);
  --cw: calc(var(--bw) / 10);
  --k: 1.45; /* card height / width */
  --dw: clamp(48px, calc(var(--cw) * 2.1), 92px);
}
.tp-poster {
  position: relative;
  width: var(--bw);
  padding: calc(var(--cw) * 1.1) 0 16px;
  border-radius: 16px;
  overflow: hidden;
  direction: ltr;
  background: linear-gradient(180deg, #0B162B 0, #1D3358 22%, #3F7CC4 58%, #1E5A3A 58.2%, #17472E 100%);
  box-shadow: 0 0 0 2px rgba(255, 196, 61, 0.35), 0 16px 40px rgba(0, 0, 0, 0.4);
}
.tp-mtn { position: absolute; top: 0; left: 0; width: 100%; height: calc(var(--cw) * (1.7 + 2.5 * var(--k))); display: block; }
.tp-sun { position: absolute; left: calc(var(--cw) * 5.9); top: calc(var(--cw) * 0.7); width: calc(var(--cw) * 1.3); height: calc(var(--cw) * 1.3); border-radius: 50%; background: #FFC43D; box-shadow: 0 0 24px rgba(255, 196, 61, 0.45); }
.tp-poster::before { /* everything under the mountains is meadow */
  content: ''; position: absolute; left: 0; right: 0; top: calc(var(--cw) * (1.68 + 2.5 * var(--k))); bottom: 0;
  background: linear-gradient(180deg, #1E5A3A, #143F29);
}
.tp-flag { opacity: 0; transform: translateY(2px); transition: opacity 0.3s, transform 0.4s var(--ease-out); }
.tp-flag.is-up { opacity: 1; transform: none; }

.tp-board { position: relative; width: 100%; height: calc(var(--cw) * var(--k) * 2.5); }
.tp-card {
  position: absolute;
  width: var(--cw);
  height: calc(var(--cw) * var(--k));
  padding: 0;
  border: 0;
  background: none;
  color: #13233F;
  font-family: var(--font-text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  perspective: 300px;
}
.tp-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; z-index: 3; }
.tp-in {
  position: absolute; top: 0; right: 1px; bottom: 0; left: 1px;
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.tp-face, .tp-back {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  border-radius: calc(var(--cw) * 0.13);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.tp-face {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #FFFBF0, #FFF1D6);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(19, 35, 63, 0.3);
  line-height: 1;
}
.tp-face.is-red { color: #D42B2F; }
.tp-r { font-size: calc(var(--cw) * 0.5); font-weight: 800; letter-spacing: -0.04em; }
.tp-s { font-size: calc(var(--cw) * 0.5); margin-top: calc(var(--cw) * 0.04); }
.tp-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, #FFF1D6 0 14%, transparent 15%),
    repeating-linear-gradient(45deg, rgba(255, 241, 214, 0.2) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 241, 214, 0.2) 0 2px, transparent 2px 7px),
    #C92A2E;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), inset 0 0 0 2px #FFF1D6, inset 0 0 0 3px rgba(19, 35, 63, 0.35);
}
.tp-card.is-down { cursor: default; }
.tp-card.is-down .tp-in { transform: rotateY(180deg); }
.tp-card.is-gone { visibility: hidden; pointer-events: none; }
.tp-card.is-dealt { animation: tp-deal 0.3s var(--ease-out) backwards; }
.tp-card.is-no { animation: kit-shake 0.3s; }
.tp-card:not(.is-down):active .tp-in { transform: translateY(-3px); }

/* ---------- stock, waste and the run counter ---------- */
.tp-deck {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: calc(var(--dw) * 0.3);
  margin-top: calc(var(--cw) * 0.95);
}
.tp-slot { --cw: var(--dw); --k: 1.45; position: relative; width: var(--dw); height: calc(var(--dw) * 1.45); flex: none; }
.tp-slot .tp-card { left: 0; top: 0; }
.tp-stock .tp-back { transform: none; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), inset 0 0 0 2px #FFF1D6, 3px 3px 0 -1px #8E1D20, 6px 6px 0 -2px #6E1518; }
.tp-stock.is-empty { cursor: default; border-radius: calc(var(--cw) * 0.13); box-shadow: inset 0 0 0 2px rgba(255, 241, 214, 0.25); }
.tp-stock:active .tp-back { transform: translate(2px, 2px); }
.tp-count {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%);
  min-width: 1.9em; padding: 3px 6px; border-radius: 999px;
  background: #13233F; color: #FFC43D; font-size: 0.82rem; font-weight: 800; line-height: 1;
}
.tp-waste { cursor: default; transform-origin: 0 0; transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1); z-index: 4; }
.tp-waste .tp-face { box-shadow: 0 0 0 2px #FFC43D, 0 4px 10px rgba(0, 0, 0, 0.45); }

.tp-run {
  --grow: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: var(--dw); height: calc(var(--dw) * 1.45); flex: none;
  color: rgba(255, 241, 214, 0.55);
}
.tp-run__label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.tp-run__n {
  font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1;
  transform: scale(var(--grow)); transform-origin: 50% 30%;
  transition: transform 0.2s var(--ease-out), color 0.2s;
}
.tp-run.is-on { color: #FFF1D6; }
.tp-run.is-on .tp-run__n { color: #FFC43D; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.tp-run.is-hot .tp-run__n { color: #FF7A4D; text-shadow: 0 0 14px rgba(255, 122, 77, 0.6), 0 2px 0 rgba(0, 0, 0, 0.35); }
.tp-run.is-pop { animation: tp-pop 0.22s var(--ease-out); }
.tp-run.is-shake { animation: tp-shake 0.36s; }
.tp-plus {
  position: absolute; left: 50%; top: -6px; margin-left: calc(var(--dw) * -0.2);
  color: #FFC43D; font-family: var(--font-display); font-size: 1.25rem; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  pointer-events: none; z-index: 6; animation: tp-plus 0.7s var(--ease-out) forwards;
}

@keyframes tp-deal { from { opacity: 0; transform: translateY(-14px) scale(0.8); } }
@keyframes tp-pop { 50% { transform: scale(1.14); } }
@keyframes tp-shake {
  0%, 100% { transform: none; } 15% { transform: translateX(-5px) rotate(-5deg); } 35% { transform: translateX(5px) rotate(5deg); }
  55% { transform: translateX(-4px) rotate(-3deg); } 75% { transform: translateX(3px) rotate(2deg); }
}
@keyframes tp-plus { from { opacity: 0; transform: translateY(8px) scale(0.7); } 25% { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-34px); } }

/* Tall phones: longer cards are easier to hit and fill the screen. */
@media (max-aspect-ratio: 3/4) and (max-width: 520px) {
  .tp-col { --k: 1.8; --bw: min(100vw - 12px, (100vh - 330px) * 1.25); }
}
/* Short landscape screens: the deck moves beside the peaks. */
@media (orientation: landscape) and (max-height: 480px) {
  .tp-col { --bw: min(100vw - 190px, (100vh - 150px) * 2.1); --dw: clamp(44px, calc(var(--cw) * 1.4), 60px); }
  .tp-poster { width: calc(var(--bw) + 176px); padding: calc(var(--cw) * 1.1) 0 calc(var(--cw) * 0.6); }
  .tp-mtn, .tp-board { width: var(--bw); }
  .tp-poster::before { top: 0; left: var(--bw); background: linear-gradient(180deg, #1D3358, #17472E 70%); }
  .tp-deck { position: absolute; top: 0; bottom: 0; right: 0; width: 176px; margin: 0; flex-wrap: wrap; align-content: center; gap: 6px 12px; }
  .tp-run { height: auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .tp-in, .tp-waste, .tp-run__n { transition: none; }
  .tp-card.is-dealt, .tp-card.is-no, .tp-run.is-pop, .tp-run.is-shake { animation: none; }
}
@media (max-width: 350px) { .fa-scores .fa-chip:nth-child(2) { display: none; } }
