/* HiLo Game Styling - Consistent with Plinko & Mines */
:root {
  --card-bg: rgba(255, 255, 255, 0.05);
  --accent: #c6ff00;
  --muted: #9aa0a6;
  --danger: #ff6b6b;
}

html {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #14151f;
  color: #fff;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.container {
  width: 100%;
  max-width: 650px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1em;
}

.header h1 {
  font-size: 1.8em;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-link {
  color: #fff;
  text-decoration: none;
  font-size: 1em;
  line-height: 1;
  transition: all 0.2s;
  opacity: 0.7;
  display: flex;
  align-items: center;
}

.back-link:hover {
  opacity: 1;
  color: var(--accent);
  transform: translateX(-2px);
}

.balance-display {
  font-size: 1.2em;
  font-weight: 600;
  color: #00ff00;
}

button {
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.8;
}

button:hover {
  opacity: 1;
}

button:active {
  opacity: 0.8;
}

.controls {
  background: var(--card-bg);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.controls-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  white-space: nowrap;
}

.controls input[type="number"],
.controls input[type="range"] {
  width: 100px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.controls input[type="range"] {
  width: 80px;
}

.controls input:focus {
  outline: none;
  border-color: var(--accent);
}

.controls button {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  white-space: nowrap;
}

#start-game {
  background: var(--accent);
  color: #000;
}

#start-game:hover {
  background: #00ff00;
  transform: translateY(-1px);
}

#cash-out {
  background: #ffa726;
  color: #000;
}

#cash-out:hover:not(:disabled) {
  background: #ff9800;
  transform: translateY(-1px);
}

#cash-out:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  opacity: 0.5;
}

#reset {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

#reset:hover {
  background: rgba(255, 255, 255, 0.15);
}

.message {
  color: #ffd166;
  font-size: 14px;
  text-align: right;
  min-height: 20px;
  flex: 1;
}

/* Game Section */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.game-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

/* Rank Indicator (Vertical A > 2) */
.rank-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 16px;
  border-radius: 12px;
}

.rank-item {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.rank-divider {
  font-size: 16px;
  color: var(--accent);
}

/* Game Area */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
  gap: 18px;
}

.game-row {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
  width: 100%;
}

/* Deck Stack (3 blue cards stacked) */
.deck-stack {
  width: 160px;
  height: 240px;
  position: relative;
}

.deck-card {
  position: absolute;
  width: 160px;
  height: 240px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}

.deck-card-1 {
  background: linear-gradient(135deg,#1e3a8a,#3b82f6);
  border: 3px solid #60a5fa;
  top: 0;
  left: 0;
  z-index: 3;
}

.deck-card-2 {
  background: linear-gradient(135deg,#164189,#1f5adf);
  border: 3px solid #4f93f3;
  top: -6px;
  left: -6px;
  z-index: 2;
  opacity: 0.85;
}

.deck-card-3 {
  background: linear-gradient(135deg,#0f2f6a,#163f9a);
  border: 3px solid #3e7be6;
  top: -12px;
  left: -12px;
  z-index: 1;
  opacity: 0.7;
}

/* Deal from deck */
.deal-temp {
  pointer-events: none;
  border-radius: 12px;
  overflow: hidden;
}

.deal-temp .card-inner {
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.deal-temp .card-back, .deal-temp .card-front {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  backface-visibility: hidden;
}

/* Card Stage */
.card-stage {
  width: 300px;
  height: 260px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prev-holder {
  position: absolute;
  left: -220px;
  width: 160px;
  height: 240px;
  pointer-events: none;
}

.prev-card {
  width: 160px;
  height: 240px;
  border-radius: 12px;
  background: linear-gradient(135deg,#222,#444);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 1;
  transition: opacity .6s ease;
}

/* Previous card fade + slide */
.prev-card.fade-slide {
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.prev-card.fade-slide.fade-out {
  opacity: 0;
  transform: translateX(-80px) rotate(-10deg) scale(0.8);
}

/* Game Card */
.card {
  width: 160px;
  height: 240px;
  position: relative;
  perspective: 1000px;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .56s;
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front {
  background: linear-gradient(135deg,#1e3a8a,#3b82f6);
  border: 3px solid #60a5fa;
  font-size: 48px;
  font-weight: 700;
}

.card-back {
  transform: rotateY(180deg);
  background: #fff;
  color: #000;
  flex-direction: column;
  padding: 14px;
  border: 3px solid #e0e0e0;
}

.card.flipped .card-inner { transform: rotateY(180deg); }

.card-back .rank { font-size: 56px; font-weight: 800; line-height: 1; }
.card-back .suit { font-size: 44px; margin-top: 6px; }
.card-back .suit.red { color: #dc2626; }
.card-back .suit.black { color: #000; }

/* Guess Buttons */
.guess-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
  max-width: 640px;
}

.guess-btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guess-btn .label { font-size: 13px; color: var(--muted); text-transform: uppercase; }
.guess-btn .step { font-weight: 800; color: var(--accent); font-size: 18px; }
.guess-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.guess-btn.win { box-shadow: 0 8px 28px rgba(0,255,122,0.12); background: rgba(0,255,122,0.06); border-color: #00ff7a; }
.guess-btn.lose { animation: shake .4s; box-shadow: 0 8px 28px rgba(255,40,40,0.12); background: rgba(255,40,40,0.06); border-color: #ff2828; }

@keyframes pop {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

.footer {
  margin-top: 2em;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85em;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.3em;
  }

  .controls {
    gap: 8px;
  }

  .controls-row {
    flex-direction: column;
    gap: 8px;
  }

  .controls label {
    justify-content: flex-start;
    width: 100%;
  }

  .controls-row-left {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .controls button {
    width: 100%;
  }

  .message {
    text-align: center;
    justify-self: center;
    align-self: center;
  }

  .game-row {
    margin-top: 18px;
  }

  .deck-stack {
    width: 140px;
    height: 200px;
  }

  .deck-card {
    width: 140px;
    height: 200px;
  }

  .card-stage {
    width: 140px;
    height: 200px;
  }

  .card {
    width: 140px;
    height: 200px;
  }

  .card-inner {
    width: 140px;
    height: 200px;
  }

  .prev-holder {
    display: none;  /* Hide previous card holder on mobile */
  }

  .card-back .rank {
    font-size: 48px;
  }

  .card-back .suit {
    font-size: 36px;
  }

  .card-front {
    font-size: 40px;
  }
}
