: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: #00ff7a;
}

button {
  transition: all 0.2s ease;
}

button:hover:not(:disabled) {
  opacity: 0.9;
}

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"] {
  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:focus {
  outline: none;
  border-color: var(--accent);
}

.controls input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

#deal-btn {
  background: var(--accent);
  color: #000;
}

#deal-btn:hover:not(:disabled) {
  background: #00ff00;
  transform: translateY(-1px);
}

#deal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#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 {
  margin-bottom: 16px;
}

.hand-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.card-stage {
  width: 100%;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

.hand-label {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hand-total {
  font-weight: 700;
  font-size: 16px;
}

.hand-cards {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
  min-height: 120px;
}

.dealer-rule {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  font-style: italic;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Card Styles - Match Baccarat */
.card {
  width: 80px;
  height: 120px;
  position: relative;
  perspective: 1000px;
  opacity: 0;
  transform: translateY(-20px);
  transition: transform 0.45s ease-out, opacity 0.45s ease-out;
}

.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;
}

/* Blue Card Back (shows when NOT flipped) */
.card-front {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  border: 3px solid #60a5fa;
  font-size: 48px;
  font-weight: 700;
  color: #fff;
}

/* White Card Face (shows when flipped) */
.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.appear {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.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;
}

#split-area {
  display: none;
}

/* Action Buttons - Match Baccarat Guess Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  width: 100%;
}

.action-btn {
  flex: 1;
  padding: 16px 20px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: var(--card-bg);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.action-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.05);
}

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

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

  .controls {
    gap: 8px;
  }

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

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

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

  .controls button {
    width: 100%;
  }

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

  .action-buttons {
    flex-direction: row;
    gap: 8px;
  }

  .action-btn {
    width: 100%;
  }

  .hand-cards {
    min-height: 75px;
  }

  .card {
    width: 50px;
    height: 75px;
  }

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

  .card-back .suit {
    font-size: 28px;
    margin-top: 3px;
  }
}
