/* ============================================================
   GiverGames Higher or Lower -- hl.css
   Builds on dnd.css (marquee, gate, result, code box, sparks).
   ============================================================ */

.hl-page .marquee-title .mt-deal,
.hl-page .marquee-title .mt-nodeal { font-size: clamp(2rem, 7.5vw, 3.2rem); }
.hl-page .dnd-stage.playing .mt-deal,
.hl-page .dnd-stage.playing .mt-nodeal { font-size: clamp(1.4rem, 5.6vw, 1.9rem); }


/* ============================================================
   BOARD LAYOUT
   ============================================================ */
.hl-board {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  max-width: 640px;
  margin: 0 auto;
}
.hl-board > * { min-width: 0; }

.hl-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}


/* ============================================================
   STREAK LADDER (bottom to top on desktop, a row on phones)
   ============================================================ */
.streak {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
}
.streak li {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.05);
  transition: background 0.35s ease, color 0.35s ease, transform 0.35s ease;
}
.streak li .bonus {
  font-size: 0.66rem;
  color: var(--yellow);
  opacity: 0.7;
}
.streak li.milestone { box-shadow: inset 0 0 0 1.5px rgba(253,205,44,0.45); }
.streak li.done {
  background: linear-gradient(90deg, rgba(19,199,182,0.55), rgba(19,199,182,0.3));
  color: var(--white);
}
.streak li.done.milestone {
  background: linear-gradient(90deg, #FFE27A, var(--yellow));
  color: var(--charcoal);
  box-shadow: 0 0 16px rgba(253,205,44,0.5);
}
.streak li.done.milestone .bonus { color: var(--charcoal); opacity: 1; }
.streak li.next { color: var(--white); box-shadow: inset 0 0 0 1.5px var(--teal); }
.streak li.just { animation: climb 0.6s ease; }
@keyframes climb {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}


/* ============================================================
   CARDS
   ============================================================ */
.hl-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  perspective: 1000px;
}

.hl-card {
  position: relative;
  width: 172px;
  height: 236px;
  flex-shrink: 0;
}
.hl-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(.3,1.35,.5,1);
}
.hl-card.down .hl-card-inner { transform: rotateY(180deg); }
.hl-card.instant .hl-card-inner { transition: none; }

.hl-face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Face: gold card with the number */
.hl-front {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.4) 0%, transparent 35%),
    linear-gradient(180deg, #FFE27A 0%, var(--yellow) 45%, #D9A300 100%);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35), inset 0 -6px 0 rgba(0,0,0,0.14), 0 18px 40px rgba(0,0,0,0.45);
}
.hl-front::before,
.hl-front::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(24,34,40,0.18);
}
.hl-front::before { top: 14px; left: 14px; }
.hl-front::after  { bottom: 14px; right: 14px; }
.hl-num {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--charcoal);
  text-shadow: 0 2px 0 rgba(255,255,255,0.4);
}
.hl-num.long { font-size: 3.2rem; }

/* Back: teal with the G$G mark */
.hl-back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.07) 0 8px, transparent 8px 16px),
    linear-gradient(180deg, #17B5A6, #0B6E66);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,0.25), 0 18px 40px rgba(0,0,0,0.45);
}
.hl-back span {
  font-size: 1.8rem;
  font-weight: 900;
  color: rgba(255,255,255,0.85);
  padding: 10px 14px;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 14px;
}

/* Outcomes */
.hl-card.right .hl-front { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35), 0 0 0 4px var(--teal), 0 0 40px rgba(19,199,182,0.6); }
.hl-card.wrong .hl-front { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35), 0 0 0 4px #E2574C, 0 0 40px rgba(226,87,76,0.55); }
.hl-card.wrong { animation: shake 0.5s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-2deg); }
  40% { transform: translateX(9px)  rotate(2deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* Previous card, smaller, off to the side */
.hl-prev {
  width: 92px;
  height: 126px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border: 1.5px dashed rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.75);
}
.hl-prev:empty { visibility: hidden; }
.hl-prev b { font-size: 1.7rem; font-weight: 900; color: var(--white); }
.hl-prev small { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.5); }
.hl-prev.slide { animation: slideIn 0.4s ease; }
@keyframes slideIn {
  from { transform: translateX(60px) scale(1.4); opacity: 0; }
  to   { transform: none; opacity: 1; }
}


/* ============================================================
   STATS + BUTTONS
   ============================================================ */
.hl-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 400px;
}
.hl-stats > div {
  padding: 10px 6px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}
.hl-stats dt {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.hl-stats dd {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--white);
  line-height: 1.2;
}
.hl-stats dd small { font-size: 0.55em; color: rgba(255,255,255,0.45); }
#statPoints { color: var(--yellow); }
#statSafe { color: var(--teal); }
.hl-stats dd.bump { animation: thump 0.45s ease; }

.hl-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.btn-hl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 16px;
  border: none;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-higher {
  background: linear-gradient(180deg, #3FE0D0, var(--teal) 50%, #0E9A8E);
  color: var(--ink);
  box-shadow: 0 6px 0 #08695F, 0 10px 24px rgba(19,199,182,0.3);
}
.btn-lower {
  background: linear-gradient(180deg, #FFE27A, var(--yellow) 50%, #D9A300);
  color: var(--charcoal);
  box-shadow: 0 6px 0 #9C7400, 0 10px 24px rgba(253,205,44,0.3);
}
.btn-hl:hover { filter: brightness(1.07); transform: translateY(-2px); }
.btn-hl:active { transform: translateY(4px); box-shadow: none; }
.btn-hl:disabled, .hl-actions .btn-deal:disabled, .hl-actions .btn-nodeal:disabled { opacity: 0.55; cursor: wait; transform: none; }
.hl-actions .btn-deal, .hl-actions .btn-nodeal { font-size: 1.05rem; }


/* History of cards in this run */
.hl-history {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 420px;
}
.hl-history li {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.7);
}
.hl-history li.right { background: rgba(19,199,182,0.2); color: #BFF5EF; }
.hl-history li.wrong { background: rgba(226,87,76,0.22); color: #FFC4BF; }
.hl-history li.tie   { background: rgba(255,255,255,0.12); color: var(--white); }
.hl-history-full { margin: 14px auto 0; }


/* Toast for dead heats, milestones and the wrong call */
.hl-toast {
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 150;
  transform: translate(-50%, -50%);
  padding: 18px 28px;
  border-radius: 20px;
  background: rgba(24,34,40,0.94);
  box-shadow: 0 0 0 2px rgba(253,205,44,0.6), 0 20px 50px rgba(0,0,0,0.5);
  text-align: center;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--yellow);
  white-space: nowrap;
  pointer-events: none;
  animation: toastIn 0.45s cubic-bezier(.2,1.6,.4,1) both;
}
.hl-toast small { display: block; font-size: 0.85rem; font-weight: 600; color: rgba(255,255,255,0.8); margin-top: 4px; white-space: normal; }
.hl-toast.teal { color: var(--teal); box-shadow: 0 0 0 2px rgba(19,199,182,0.6), 0 20px 50px rgba(0,0,0,0.5); }
.hl-toast.red  { color: #FF8A80; box-shadow: 0 0 0 2px rgba(226,87,76,0.6), 0 20px 50px rgba(0,0,0,0.5); }
@keyframes toastIn {
  from { transform: translate(-50%, -50%) scale(1.8) rotate(-6deg); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1) rotate(-2deg); opacity: 1; }
}


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 760px) {
  .hl-board { grid-template-columns: minmax(0, 1fr); gap: 18px; }

  /* Ladder becomes a single row of 15 steps */
  .streak {
    flex-direction: row;
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    gap: 3px;
  }
  .streak li {
    flex-direction: column;
    justify-content: center;
    padding: 5px 0 4px;
    font-size: 0.66rem;
    border-radius: 6px;
    min-height: 34px;
  }
  .streak li .bonus { font-size: 0.55rem; }

  .hl-cards { gap: 12px; }
  .hl-card { width: 138px; height: 190px; }
  .hl-num { font-size: 3.2rem; }
  .hl-num.long { font-size: 2.6rem; }
  .hl-back span { font-size: 1.4rem; }
  .hl-prev { width: 74px; height: 102px; }
  .hl-prev b { font-size: 1.35rem; }

  .hl-stats dd { font-size: 1.3rem; }
  .hl-toast { font-size: 1.35rem; }
}

@media (max-width: 360px) {
  .hl-card { width: 120px; height: 166px; }
  .hl-num { font-size: 2.8rem; }
  .hl-num.long { font-size: 2.3rem; }
  .hl-prev { width: 64px; height: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  .hl-card-inner { transition-duration: 0.01ms !important; }
  .hl-card.wrong, .hl-prev.slide, .streak li.just, .hl-toast { animation: none !important; }
}
