/* ============================================================
   STEAL THE RESERVE — 8-bit Higher/Lower mini-game
   Page layout (mounts at /steal-the-reserve/) + launcher card
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ── Launcher card (lives on Al's profile) ── */
.steal-reserve-launcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 1.5rem auto 2rem;
  padding: 1.25rem 1.5rem;
  max-width: 520px;
  background: linear-gradient(180deg, #1a4d1a 0%, #0f2e0f 100%);
  border: 4px solid #ffd700;
  box-shadow:
    0 0 0 2px #0d0d0d,
    0 0 0 4px #c19a00,
    0 8px 0 0 #6b3e1c,
    0 12px 24px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  text-decoration: none;
  color: #fff;
  transition: transform 0.1s ease;
  user-select: none;
  image-rendering: pixelated;
}

.steal-reserve-launcher:hover {
  transform: translateY(-2px);
  color: #fff;
}

.steal-reserve-launcher:active {
  transform: translateY(2px);
  box-shadow:
    0 0 0 2px #0d0d0d,
    0 0 0 4px #c19a00,
    0 4px 0 0 #6b3e1c;
}

.steal-reserve-launcher-text {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
}

.steal-reserve-launcher-eyebrow {
  font-size: 0.5rem;
  color: #ffd700;
  letter-spacing: 0.1em;
}

.steal-reserve-launcher-title {
  font-size: 0.85rem;
  line-height: 1.4;
  color: #fff;
  text-shadow: 2px 2px 0 #0d0d0d;
}

.steal-reserve-launcher-cta {
  font-size: 0.55rem;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.steal-reserve-launcher-coins {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.steal-reserve-launcher-coin {
  width: 48px;
  height: 48px;
  background: #ffd700;
  border: 4px solid #0d0d0d;
  border-radius: 50%;
  position: relative;
  box-shadow: inset -4px -4px 0 0 #c19a00;
  animation: coinSpin 2.5s ease-in-out infinite;
}

.steal-reserve-launcher-coin::before {
  content: '$';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 1.4rem;
  color: #6b3e1c;
  text-shadow: 1px 1px 0 #c19a00;
}

@keyframes coinSpin {
  0%, 100% { transform: scale(1) rotateY(0); }
  50%      { transform: scale(0.85) rotateY(180deg); }
}

@media (max-width: 540px) {
  .steal-reserve-launcher {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  .steal-reserve-launcher-text {
    align-items: center;
    text-align: center;
  }
}

/* ============================================================
   Page-level layout
   ============================================================ */

.srv-page-body {
  background: #050505;
}

.srv-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1rem 3rem;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  image-rendering: pixelated;
}

.srv-page-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

/* ── Exit button (top-right) ── */
.srv-exit {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 1.2rem;
  line-height: 1;
  color: #fff;
  background: #d63838;
  border: 4px solid #0d0d0d;
  box-shadow: 4px 4px 0 #6b1818;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.05s ease;
  user-select: none;
}

.srv-exit:hover {
  background: #e85555;
  color: #fff;
}

.srv-exit:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #6b1818;
}

@media (max-width: 520px) {
  .srv-exit {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    top: 0.7rem;
    right: 0.7rem;
  }
}

.srv-page-title {
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: #ffd700;
  text-shadow: 4px 4px 0 #0d0d0d, 8px 8px 0 #6b3e1c;
  margin: 0 0 0.8rem;
  line-height: 1.2;
}

.srv-page-subtitle {
  font-size: 0.6rem;
  color: #c19a00;
  letter-spacing: 0.1em;
  margin: 0;
}

.srv-mount {
  position: relative;
}

/* ── Game container ── */
.srv-game {
  background: #1a1a1a;
  border: 4px solid #ffd700;
  box-shadow:
    0 0 0 2px #0d0d0d,
    0 0 0 6px #c19a00,
    0 0 80px rgba(255, 215, 0, 0.18);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.7rem;
}

/* ── Status banner ── */
.srv-banner {
  background: #0d0d0d;
  border: 3px solid #6b3e1c;
  text-align: center;
  padding: 0.7rem;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: #c19a00;
  text-shadow: 2px 2px 0 #000;
  min-height: 1.4em;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.srv-banner--win {
  border-color: #66bb6a;
  color: #aef0b0;
}

.srv-banner--bust {
  border-color: #d63838;
  color: #ff8a8a;
}

.srv-banner--heist {
  border-color: #ffd700;
  color: #ffd700;
  animation: heistPulse 0.6s ease-in-out infinite alternate;
}

@keyframes heistPulse {
  from { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
  to   { box-shadow: 0 0 24px rgba(255, 215, 0, 0.6); }
}

/* ── Arena: Al side | center | player side ── */
.srv-arena {
  display: grid;
  grid-template-columns: 1fr 1.8fr 1fr;
  gap: 1rem;
  align-items: stretch;
  background: linear-gradient(180deg, #0a2a0a 0%, #051405 100%);
  border: 3px solid #2a4d2a;
  padding: 1.2rem 0.8rem;
  position: relative;
}

.srv-arena::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 2px,
      transparent 2px,
      transparent 6px
    );
  pointer-events: none;
}

/* Side columns (Al / player) */
.srv-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
}

.srv-side-name {
  font-size: 0.55rem;
  color: #ffd700;
  letter-spacing: 0.12em;
  text-shadow: 2px 2px 0 #000;
}

/* Avatars */
.srv-avatar {
  width: 100%;
  max-width: 130px;
  aspect-ratio: 1 / 1;
  background: #2a4d2a;
  border: 4px solid #ffd700;
  box-shadow: 4px 4px 0 #0d0d0d;
  position: relative;
  overflow: hidden;
  image-rendering: pixelated;
}

.srv-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
  filter: contrast(1.1) saturate(1.1);
}

.srv-avatar--player svg {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* Speech bubble (Al) */
.srv-speech {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #0d0d0d;
  padding: 0.55rem 0.7rem;
  font-size: 0.5rem;
  white-space: nowrap;
  border: 3px solid #0d0d0d;
  box-shadow: 3px 3px 0 #6b3e1c;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 3;
}

.srv-speech::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-top-color: #0d0d0d;
}

.srv-speech.visible {
  opacity: 1;
}

/* ── Reserve (under Al) ── */
.srv-reserve {
  width: 100%;
  background: linear-gradient(180deg, #6b3e1c 0%, #3d2410 100%);
  border: 3px solid #ffd700;
  box-shadow: 3px 3px 0 #0d0d0d;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.srv-reserve--empty {
  filter: grayscale(0.6);
  opacity: 0.5;
}

.srv-reserve-label {
  font-size: 0.5rem;
  color: #ffd700;
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #0d0d0d;
}

.srv-reserve-coins,
.srv-bag-coins {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  width: 100%;
  min-height: 18px;
  align-content: end;
}

.srv-coin {
  aspect-ratio: 1 / 1;
  background: #ffd700;
  border-radius: 50%;
  border: 1px solid #c19a00;
  box-shadow: inset -1px -1px 0 #c19a00;
  animation: coinTwinkle 1.6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.05s);
}

@keyframes coinTwinkle {
  0%, 100% { box-shadow: inset -1px -1px 0 #c19a00; }
  50%      { box-shadow: inset -1px -1px 0 #c19a00, 0 0 4px #ffd700; }
}

.srv-reserve-value,
.srv-bag-value {
  font-size: 0.7rem;
  color: #ffd700;
  letter-spacing: 0.05em;
  text-shadow: 2px 2px 0 #0d0d0d;
}

/* ── Bag (under player) ── */
.srv-bag {
  width: 100%;
  background: linear-gradient(180deg, #1c4d2a 0%, #0a2a14 100%);
  border: 3px solid #66bb6a;
  box-shadow: 3px 3px 0 #0d0d0d;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.srv-bag-label {
  font-size: 0.5rem;
  color: #aef0b0;
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #0d0d0d;
}

/* ── Center: cards ── */
.srv-center {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.srv-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  width: 100%;
}

.srv-card-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.srv-card-label {
  font-size: 0.5rem;
  color: #c19a00;
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #0d0d0d;
}

.srv-card {
  width: 100%;
  max-width: 110px;
  aspect-ratio: 5 / 7;
  background: #fff;
  border: 4px solid #0d0d0d;
  box-shadow: 4px 4px 0 #6b3e1c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  font-family: 'Press Start 2P', monospace;
  user-select: none;
  transform-style: preserve-3d;
}

.srv-card--up.suit-red .srv-card-rank,
.srv-card--up.suit-red .srv-card-suit,
.srv-card--up.suit-red .srv-card-corner {
  color: #d63838;
}

.srv-card--up.suit-black .srv-card-rank,
.srv-card--up.suit-black .srv-card-suit,
.srv-card--up.suit-black .srv-card-corner {
  color: #0d0d0d;
}

.srv-card--up .srv-card-rank {
  font-size: 1.6rem;
  line-height: 1;
}

.srv-card--up .srv-card-suit {
  font-size: 1.4rem;
  line-height: 1;
  margin-top: 0.4rem;
}

.srv-card--up .srv-card-corner {
  position: absolute;
  top: 5px;
  left: 6px;
  font-size: 0.5rem;
  line-height: 1.1;
  text-align: left;
}

.srv-card--up .srv-card-corner.bottom-right {
  top: auto;
  left: auto;
  bottom: 5px;
  right: 6px;
  transform: rotate(180deg);
}

/* Face-down card */
.srv-card--down {
  background:
    repeating-linear-gradient(
      45deg,
      #2a1a5f 0,
      #2a1a5f 8px,
      #1a0f3f 8px,
      #1a0f3f 16px
    );
  border-color: #ffd700;
}

.srv-card-back {
  font-size: 2rem;
  color: #ffd700;
  text-shadow: 3px 3px 0 #0d0d0d;
}

.srv-card.flipping {
  animation: cardFlip 0.45s ease-in-out;
}

@keyframes cardFlip {
  0%   { transform: rotateY(0); }
  50%  { transform: rotateY(90deg); }
  100% { transform: rotateY(0); }
}

.srv-card.bust {
  animation: cardShake 0.5s ease-in-out;
  border-color: #d63838;
  box-shadow: 4px 4px 0 #6b1818, 0 0 30px rgba(214, 56, 56, 0.6);
}

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ── Streak / multiplier meter ── */
.srv-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.srv-meter-cell {
  background: #0d0d0d;
  border: 3px solid #2a4d2a;
  padding: 0.55rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.srv-meter-label {
  font-size: 0.45rem;
  color: #66bb6a;
  letter-spacing: 0.1em;
}

.srv-meter-value {
  font-size: 0.8rem;
  color: #aef0b0;
  text-shadow: 2px 2px 0 #0d0d0d;
}

/* ── Controls ── */
.srv-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.srv-secondary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

.srv-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #fff;
  background: #2a4d2a;
  border: 4px solid #0d0d0d;
  box-shadow: 4px 4px 0 #6b3e1c;
  padding: 1rem 0.6rem;
  cursor: pointer;
  transition: transform 0.05s ease;
  text-transform: uppercase;
}

.srv-btn:hover:not(:disabled) {
  background: #356635;
}

.srv-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #6b3e1c;
}

.srv-btn:disabled {
  background: #2a2a2a;
  color: #555;
  cursor: not-allowed;
  box-shadow: 4px 4px 0 #1a1a1a;
}

.srv-btn--higher {
  background: #1c4d8b;
  box-shadow: 4px 4px 0 #0a2a4d;
}

.srv-btn--higher:hover:not(:disabled) {
  background: #2563b3;
}

.srv-btn--lower {
  background: #8b2a4d;
  box-shadow: 4px 4px 0 #4d162a;
}

.srv-btn--lower:hover:not(:disabled) {
  background: #b3375f;
}

.srv-btn--cashout {
  background: #ffd700;
  color: #0d0d0d;
  box-shadow: 4px 4px 0 #6b3e1c;
}

.srv-btn--cashout:hover:not(:disabled) {
  background: #fff070;
}

.srv-btn--restart {
  background: #6b3e1c;
}

/* ── Persistent stats footer ── */
.srv-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  border-top: 3px solid #6b3e1c;
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.srv-stat {
  background: #0d0d0d;
  border: 3px solid #6b3e1c;
  padding: 0.55rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.srv-stat-label {
  font-size: 0.45rem;
  color: #c19a00;
  letter-spacing: 0.1em;
}

.srv-stat-value {
  font-size: 0.85rem;
  color: #ffd700;
  text-shadow: 2px 2px 0 #6b3e1c;
}

/* ── Floating coin animation ── */
.srv-floating-coin {
  position: absolute;
  width: 24px;
  height: 24px;
  background: #ffd700;
  border-radius: 50%;
  border: 2px solid #0d0d0d;
  box-shadow: inset -2px -2px 0 #c19a00;
  pointer-events: none;
  z-index: 5;
}

.srv-floating-coin::before {
  content: '$';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: #6b3e1c;
}

/* ── Rules section ── */
.srv-rules {
  margin-top: 2rem;
  padding: 1rem 1.2rem;
  background: #0d0d0d;
  border: 3px solid #2a4d2a;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  line-height: 1.8;
  color: #aef0b0;
}

.srv-rules h2 {
  font-size: 0.75rem;
  color: #ffd700;
  margin: 0 0 0.8rem;
  letter-spacing: 0.1em;
}

.srv-rules ol {
  margin: 0;
  padding-left: 1.4rem;
}

.srv-rules li {
  margin-bottom: 0.6rem;
}

.srv-rules-note {
  font-size: 0.5rem;
  color: #c19a00;
  margin: 0 0 0.8rem;
  letter-spacing: 0.06em;
  line-height: 1.6;
}

.srv-rules-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  margin-top: 0.4rem;
  border: 3px solid #2a4d2a;
}

.srv-rules-table thead {
  background: #2a4d2a;
}

.srv-rules-table th {
  text-align: left;
  padding: 0.6rem 0.7rem;
  color: #ffd700;
  letter-spacing: 0.1em;
  border-bottom: 3px solid #1a4d1a;
  font-weight: normal;
}

.srv-rules-table td {
  padding: 0.55rem 0.7rem;
  color: #aef0b0;
  border-bottom: 1px solid #1a3d1a;
}

.srv-rules-table tbody tr:last-child td {
  border-bottom: none;
}

.srv-rules-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.srv-rules-table td:nth-child(2) {
  color: #ffd700;
}

.srv-rules-table td:nth-child(3) {
  color: #fff;
  text-align: right;
}

.srv-rules-table th:nth-child(3) {
  text-align: right;
}

/* ── Responsive ── */
@media (max-width: 820px) {
  .srv-page-title {
    font-size: 1.1rem;
    text-shadow: 3px 3px 0 #0d0d0d, 5px 5px 0 #6b3e1c;
  }
  .srv-arena {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  .srv-side {
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
  }
  .srv-avatar {
    max-width: 80px;
    flex-shrink: 0;
  }
  .srv-side-name {
    display: none;
  }
  .srv-reserve,
  .srv-bag {
    flex: 1;
  }
  .srv-reserve-coins,
  .srv-bag-coins {
    grid-template-columns: repeat(12, 1fr);
  }
  .srv-center {
    order: -1;
  }
  .srv-table {
    gap: 1rem;
  }
  .srv-card {
    max-width: 100px;
  }
  .srv-speech {
    font-size: 0.45rem;
  }
}

@media (max-width: 520px) {
  .srv-game {
    padding: 0.9rem 0.7rem;
    font-size: 0.6rem;
  }
  .srv-card--up .srv-card-rank {
    font-size: 1.3rem;
  }
  .srv-card--up .srv-card-suit {
    font-size: 1.1rem;
  }
  .srv-card-back {
    font-size: 1.6rem;
  }
  .srv-meter-value,
  .srv-stat-value {
    font-size: 0.7rem;
  }
  .srv-btn {
    padding: 0.85rem 0.5rem;
    font-size: 0.6rem;
  }
}
