/* ============================================================
   ONYX CARD CHALLENGE — a Magic-Towers-style mini game.
   Original visual design built entirely from the site's own design
   tokens (colors, type, easing) — no borrowed casino/solitaire assets.
   ============================================================ */

.ocg-overlay{
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 32px);
  background: rgba(6,5,5,.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s var(--ease-soft);
}
.ocg-overlay.is-open{
  opacity: 1;
  pointer-events: auto;
}

.ocg-modal{
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--onyx-ink) 0%, var(--onyx-black) 100%);
  border: 1px solid var(--onyx-line-strong);
  border-radius: 18px;
  box-shadow: 0 40px 100px rgba(0,0,0,.6);
  padding: clamp(24px, 4vw, 44px);
  transform: translateY(18px) scale(.98);
  opacity: 0;
  transition: transform .4s var(--ease-out), opacity .4s var(--ease-out);
}
.ocg-overlay.is-open .ocg-modal{
  transform: translateY(0) scale(1);
  opacity: 1;
}

.ocg-close{
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--onyx-charcoal);
  border: 1px solid var(--onyx-line);
  color: var(--onyx-smoke);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color .25s var(--ease-soft), border-color .25s var(--ease-soft);
  z-index: 5;
}
.ocg-close:hover{ color: var(--onyx-ivory); border-color: var(--onyx-line-strong); }

/* ---------------- shared bits ---------------- */

.ocg-eyebrow{
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 14px;
}
.ocg-h1{
  font-family: var(--font-serif);
  font-weight: 340;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.05;
  color: var(--onyx-white);
  letter-spacing: -0.01em;
}
.ocg-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--onyx-white);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 15px 30px;
  cursor: pointer;
  transition: background-color .25s var(--ease-soft), transform .2s;
}
.ocg-btn:hover{ background: var(--accent-dim); transform: translateY(-1px); }
.ocg-btn:active{ transform: translateY(0); }
.ocg-btn.ocg-btn-ghost{
  background: transparent;
  border: 1px solid var(--onyx-line-strong);
  color: var(--onyx-smoke);
}
.ocg-btn.ocg-btn-ghost:hover{ color: var(--onyx-ivory); border-color: var(--onyx-line-strong); background: var(--onyx-charcoal); }

/* ---------------- intro screen ---------------- */

.ocg-intro{ text-align: left; padding-top: 8px; }
.ocg-intro-copy{
  margin-top: 18px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--onyx-smoke);
  max-width: 46ch;
}
.ocg-intro-rules{
  margin-top: 28px;
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border: 1px solid var(--onyx-line);
  border-radius: 10px;
  background: rgba(255,255,255,.02);
}
.ocg-intro-rules li{
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--onyx-smoke);
  list-style: none;
  padding-left: 20px;
  position: relative;
}
.ocg-intro-rules li::before{
  content: '';
  position: absolute;
  left: 0; top: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.ocg-intro-actions{ margin-top: 30px; }

/* ---------------- game HUD ---------------- */

.ocg-hud{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(16px, 3vw, 26px);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--onyx-line);
}
.ocg-hud-group{ display: flex; gap: clamp(16px, 4vw, 32px); }
.ocg-hud-item{ text-align: left; }
.ocg-hud-label{
  display: block;
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--onyx-smoke-dim);
  margin-bottom: 4px;
}
.ocg-hud-value{
  font-family: var(--font-serif);
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 500;
  color: var(--onyx-ivory);
  line-height: 1;
  transition: transform .18s var(--ease-out);
}
.ocg-hud-value.is-pulsing{ transform: scale(1.18); color: var(--accent); }
.ocg-hud-item.ocg-hud-streak .ocg-hud-value{ color: var(--accent); }
.ocg-hud-deck{ text-align: right; }
.ocg-hud-deck .ocg-hud-value{ color: var(--onyx-smoke); font-size: clamp(16px,3vw,20px); }

/* the countdown — plain and quiet at rest, so it doesn't compete with
   score/streak, but shifts to a warm warning tone with a slow, gentle
   pulse (not a hard blink) once time is running short */
.ocg-hud-timer .ocg-hud-value{ font-variant-numeric: tabular-nums; }
.ocg-hud-timer .ocg-hud-value.is-low{
  color: #c0574f;
  animation: ocgTimerLow 1s ease-in-out infinite;
}
@keyframes ocgTimerLow{
  0%, 100%{ opacity: 1; }
  50%{ opacity: .55; }
}

/* ---------------- table: deck + active card ---------------- */

.ocg-table{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 6vw, 48px);
  margin-bottom: clamp(20px, 4vw, 32px);
  position: relative;
}

.ocg-deck-wrap{ text-align: center; }
.ocg-deck{
  position: relative;
  width: clamp(64px, 15vw, 82px);
  height: clamp(90px, 21vw, 114px);
  cursor: pointer;
}
.ocg-deck .ocg-card{
  position: absolute;
  inset: 0;
  transition: transform .15s var(--ease-out);
}
.ocg-deck:active .ocg-card{ transform: scale(.96); }
.ocg-deck.is-empty{ cursor: default; }
.ocg-deck.is-empty .ocg-card{ opacity: .25; }
.ocg-deck.is-drawing-anim .ocg-card:first-child{
  animation: ocgDeckDraw .14s var(--ease-out);
}
@keyframes ocgDeckDraw{
  0%{ transform: translateY(0) rotate(0); }
  100%{ transform: translateY(-14px) rotate(-6deg); opacity: .4; }
}
.ocg-deck-label{
  margin-top: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--onyx-smoke-dim);
}

.ocg-active-wrap{ text-align: center; }
.ocg-active-slot{
  position: relative;
  width: clamp(78px, 18vw, 100px);
  height: clamp(110px, 25vw, 140px);
}
.ocg-active-label{
  margin-top: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--onyx-smoke-dim);
}
.ocg-active-slot .ocg-card{
  position: absolute;
  inset: 0;
  box-shadow: 0 16px 34px rgba(0,0,0,.5), 0 0 0 2px rgba(179,96,58,.35);
}
.ocg-active-slot .ocg-card.is-entering{
  animation: ocgActiveIn .32s var(--ease-out);
}
@keyframes ocgActiveIn{
  from{ opacity: 0; transform: scale(.7) rotate(-6deg); }
  to{ opacity: 1; transform: scale(1) rotate(0); }
}

/* ---------------- towers ---------------- */

.ocg-towers{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 2.4vw, 20px);
}

.ocg-tower{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ocg-tower-label{
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--onyx-smoke-dim);
}
.ocg-tower-stack{
  position: relative;
  width: clamp(56px, 15vw, 88px);
  height: clamp(120px, 30vw, 168px);
}
.ocg-tower-stack .ocg-card{
  position: absolute;
  left: 0; right: 0;
  top: 0;
  transition: transform .3s var(--ease-out), opacity .3s var(--ease-out), box-shadow .25s var(--ease-soft);
}
.ocg-tower.is-cleared .ocg-tower-stack{
  border: 1px dashed var(--onyx-line);
  border-radius: 10px;
}
.ocg-tower.is-cleared .ocg-tower-label{ color: var(--accent); }

/* ---------------- the card itself ---------------- */

.ocg-card{
  width: 100%;
  aspect-ratio: 5/7;
  border-radius: 8px;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ocg-card-face{
  position: absolute; inset: 0;
  border-radius: 8px;
  background: linear-gradient(160deg, var(--onyx-ivory) 0%, #e9e1d1 100%);
  border: 1px solid rgba(17,17,16,.08);
  box-shadow: 0 6px 14px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(6px, 1.6vw, 10px);
}
.ocg-card-rank{
  font-family: var(--font-serif);
  font-weight: 560;
  font-size: clamp(16px, 4.2vw, 24px);
  line-height: 1;
  color: var(--onyx-ink);
}
.ocg-card-rank.is-bottom{ align-self: flex-end; transform: rotate(180deg); }
.ocg-card-suit{
  align-self: center;
  width: clamp(16px, 4vw, 22px);
  height: clamp(16px, 4vw, 22px);
  color: var(--accent-dim);
}
.ocg-card-suit svg{ width: 100%; height: 100%; display: block; }

.ocg-card-back{
  position: absolute; inset: 0;
  border-radius: 8px;
  background:
    repeating-linear-gradient(135deg, rgba(242,236,225,.045) 0 2px, transparent 2px 10px),
    linear-gradient(150deg, var(--onyx-charcoal-2) 0%, var(--onyx-ink) 100%);
  border: 1px solid var(--onyx-line);
  box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
}
.ocg-card-back::after{
  content: '';
  width: 34%;
  height: 34%;
  border-radius: 50%;
  border: 1px solid var(--onyx-line-strong);
}

/* face-down cards behind the exposed one — a tight cascade so depth reads
   clearly without eating vertical space */
.ocg-tower-stack .ocg-card.ocg-depth-0{ z-index: 5; }
.ocg-tower-stack .ocg-card.ocg-depth-1{ z-index: 4; transform: translateY(10%) scale(.97); opacity: .9; }
.ocg-tower-stack .ocg-card.ocg-depth-2{ z-index: 3; transform: translateY(18%) scale(.94); opacity: .75; }
.ocg-tower-stack .ocg-card.ocg-depth-3{ z-index: 2; transform: translateY(24%) scale(.91); opacity: .6; }
.ocg-tower-stack .ocg-card.ocg-depth-4{ z-index: 1; transform: translateY(29%) scale(.88); opacity: .45; }

/* every exposed (top) tower card looks and behaves identically, whether or
   not it happens to be a valid move — no glow, outline, dimming or any
   other cue gives away which one is "correct". The player has to read the
   active card and decide for themselves. Only a neutral, equal affordance
   that "this card can be tapped" is shown. */
.ocg-card.is-exposed{ cursor: pointer; }
.ocg-card.is-exposed .ocg-card-face{ transition: box-shadow .2s var(--ease-soft), transform .15s var(--ease-out); }
.ocg-card.is-exposed:hover .ocg-card-face{ box-shadow: 0 10px 22px rgba(0,0,0,.4); }
.ocg-card.is-exposed:active .ocg-card-face{ transform: scale(.96); }

/* a wrong guess — reactive feedback only, shown after the player has
   already committed to a card, never before. Distinct from the warm
   accent used for correct plays so the two are never ambiguous. */
.ocg-card.is-wrong .ocg-card-face{
  animation: ocgWrongShake .4s var(--ease-soft);
  box-shadow: 0 0 0 2px rgba(179,70,63,.65), 0 8px 20px rgba(0,0,0,.4);
}
@keyframes ocgWrongShake{
  0%, 100%{ transform: translateX(0); }
  20%{ transform: translateX(-7px); }
  40%{ transform: translateX(6px); }
  60%{ transform: translateX(-5px); }
  80%{ transform: translateX(3px); }
}

.ocg-card.is-selected .ocg-card-face{ transform: scale(1.08) translateY(-6px); }
.ocg-card.is-leaving{
  transition: transform .28s var(--ease-soft), opacity .28s var(--ease-soft);
  transform: scale(.7) translateY(-40px);
  opacity: 0;
}
.ocg-card.is-flipping{ animation: ocgFlip .34s var(--ease-out); }
@keyframes ocgFlip{
  0%{ transform: rotateY(90deg); opacity: .3; }
  100%{ transform: rotateY(0); opacity: 1; }
}
.ocg-tower.is-clearing .ocg-tower-stack{
  animation: ocgTowerClear .5s var(--ease-out);
}
@keyframes ocgTowerClear{
  0%{ box-shadow: 0 0 0 0 rgba(179,96,58,0); }
  40%{ box-shadow: 0 0 40px 8px rgba(179,96,58,.5); }
  100%{ box-shadow: 0 0 0 0 rgba(179,96,58,0); }
}

/* ---------------- floating score / streak feedback ---------------- */

.ocg-floaters{
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 10;
}
.ocg-floater{
  position: absolute;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 18px;
  color: var(--accent);
  white-space: nowrap;
  animation: ocgFloatUp .9s var(--ease-out) forwards;
}
.ocg-floater.is-negative{ color: #b3463a; }
@keyframes ocgFloatUp{
  0%{ opacity: 0; transform: translate(-50%, 0) scale(.8); }
  15%{ opacity: 1; transform: translate(-50%, -8px) scale(1.05); }
  100%{ opacity: 0; transform: translate(-50%, -56px) scale(1); }
}

.ocg-streak-callout{
  position: fixed;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%) scale(.7);
  z-index: 2100;
  font-family: var(--font-serif);
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 500;
  color: var(--onyx-white);
  text-shadow: 0 0 30px rgba(179,96,58,.7);
  opacity: 0;
  pointer-events: none;
}
.ocg-streak-callout.is-active{
  animation: ocgStreakCallout 1.1s var(--ease-out);
}
@keyframes ocgStreakCallout{
  0%{ opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  22%{ opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  35%{ transform: translate(-50%, -50%) scale(1); }
  80%{ opacity: 1; }
  100%{ opacity: 0; transform: translate(-50%, -50%) scale(1.02); }
}

/* ---------------- end screen ---------------- */

.ocg-end{ text-align: left; }
.ocg-end-score-row{
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 22px 0 6px;
}
.ocg-end-score{
  font-family: var(--font-serif);
  font-size: clamp(44px, 10vw, 64px);
  color: var(--onyx-white);
  line-height: 1;
}
.ocg-end-score-label{
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--onyx-smoke-dim);
}
.ocg-end-message{
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--onyx-smoke);
  max-width: 46ch;
}

.ocg-reward{
  margin-top: 26px;
  padding: 24px clamp(18px, 4vw, 28px);
  border-radius: 12px;
  border: 1px solid var(--accent-dim);
  background: linear-gradient(160deg, rgba(179,96,58,.14) 0%, rgba(179,96,58,.03) 100%);
}
.ocg-reward-title{
  font-family: var(--font-serif);
  font-size: clamp(20px, 4vw, 26px);
  color: var(--accent);
  margin-bottom: 14px;
}
.ocg-reward-line{
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--onyx-smoke);
  margin-bottom: 4px;
}
.ocg-reward-line b{ color: var(--onyx-ivory); font-weight: 600; }
.ocg-code-row{
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ocg-code{
  font-family: var(--font-serif);
  font-size: clamp(20px, 4.4vw, 26px);
  letter-spacing: .04em;
  color: var(--onyx-white);
  padding: 10px 16px;
  border: 1px dashed var(--onyx-line-strong);
  border-radius: 8px;
}
.ocg-fineprint{
  margin-top: 18px;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.7;
  color: var(--onyx-smoke-dim);
}
.ocg-end-actions{ margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce){
  .ocg-overlay, .ocg-modal, .ocg-card, .ocg-card-face, .ocg-hud-value, .ocg-floater, .ocg-streak-callout, .ocg-tower-stack{
    transition: none !important;
    animation: none !important;
  }
}

/* ---------------- mobile: 2x2 tower grid, bigger tap targets ----------------
   Everything here is sized to fit *inside* the modal on small phones with no
   horizontal scroll and no unnecessary vertical scroll. The previous version
   of this block set .ocg-tower-stack's width and height independently (100%/
   max-width 132px vs 30vw/max-height 150px) — those two numbers don't track
   the same ratio, so at real mobile widths the actual card inside (which is
   always width × 7/5 tall, via aspect-ratio on .ocg-card) ended up taller
   than the box meant to hold it and visibly poked out of/overlapped the
   tower grid. Using aspect-ratio on the stack itself instead of an
   independent height guarantees the box always matches what's actually
   rendered inside it, at any width. */
@media (max-width: 640px){
  .ocg-modal{ padding: 10px 14px; border-radius: 14px; max-height: 94vh; }
  .ocg-close{ top: 6px; right: 6px; width: 32px; height: 32px; font-size: 16px; }

  .ocg-hud{ gap: 6px; margin-bottom: 8px; padding-bottom: 8px; }
  .ocg-hud-group{ gap: 14px; }
  .ocg-hud-label{ font-size: 9px; margin-bottom: 2px; }
  .ocg-hud-value{ font-size: 19px; }
  .ocg-hud-deck .ocg-hud-value{ font-size: 15px; }

  .ocg-table{ gap: 8vw; margin-bottom: 12px; }
  .ocg-deck{ width: clamp(50px, 14vw, 60px); height: auto; aspect-ratio: 5 / 7; }
  .ocg-active-slot{ width: clamp(60px, 17vw, 74px); height: auto; aspect-ratio: 5 / 7; }
  .ocg-deck-label, .ocg-active-label{ margin-top: 6px; font-size: 10px; }

  .ocg-towers{
    grid-template-columns: repeat(2, 1fr);
    gap: 22px 10px; /* extra row-gap gives the fanned-back-card cascade
                       room to peek below its stack without visually
                       colliding with the tower row underneath */
    /* the bottom row's own cascade peeks the same way below *its* stacks,
       past the last row entirely — without this the modal's natural
       content height doesn't account for that peek and it silently added
       a few unnecessary pixels of scroll below the fold */
    margin-bottom: 20px;
  }
  .ocg-tower{ gap: 6px; }
  .ocg-tower-label{ font-size: 9px; }
  .ocg-tower-stack{
    width: 100%;
    max-width: 92px;
    height: auto;
    max-height: none;
    aspect-ratio: 5 / 7;
  }

  .ocg-intro-rules{ padding: 14px 16px; margin-top: 20px; gap: 8px; }
  .ocg-intro-copy{ margin-top: 14px; font-size: 14px; }
  .ocg-intro-actions{ margin-top: 22px; }
  .ocg-btn{ padding: 13px 24px; }

  .ocg-end-score-row{ margin: 16px 0 4px; }
  .ocg-reward{ margin-top: 20px; padding: 18px 16px; }
  .ocg-end-actions{ margin-top: 22px; }
}
