/* Bird Card Blackjack - Styles */

:root {
  /* Primary palette */
  --color-green: #025b2a;
  --color-green-dark: #024421;
  --color-green-light: #036b32;
  --color-red: #c8102e;
  --color-gold: #ffcd00;
  --color-black: #231f20;
  --color-white: #f8f9fd;

  /* Secondary */
  --color-brown: #996c2e;
  --color-blue: #004c97;

  /* Derived */
  --color-green-felt: #025b2a;
  --color-shadow: rgba(0, 0, 0, 0.3);

  /* Typography */
  --font-primary: 'Copperplate', 'Copperplate Gothic Bold', 'Copperplate Gothic', serif;

  /* Card dimensions - bigger cards */
  --card-width: 120px;
  --card-height: 168px;
  --card-gap: -45px;
  --card-border-radius: 8px;

  /* Animation timing */
  --deal-duration: 0.4s;
  --flip-duration: 0.5s;
  --slide-duration: 0.3s;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html, body {
  height: 100%;
  font-family: var(--font-primary);
  background: var(--color-green-dark);
  color: var(--color-white);
  overflow: hidden;
}

/* Felt Table - Full Bleed */
.felt-table {
  position: fixed;
  inset: 0;
  background: var(--color-green);
  background-image:
    radial-gradient(ellipse at center 40%, var(--color-green-light) 0%, var(--color-green) 40%, var(--color-green-dark) 100%);
}

/* Felt texture overlay */
.felt-table::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.08;
  pointer-events: none;
}

/* Vignette / depth shadow */
.felt-table::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 150px 60px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Felt branding - flat print on felt */
.felt-branding {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 30px;
  width: auto;
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

/* Felt title - screen printed below logo */
.felt-title {
  position: absolute;
  top: calc(46% + 18px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-gold);
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

/* Bankroll - screen-printed on felt */
.felt-bankroll {
  position: absolute;
  top: 28px;
  right: 24px;
  text-align: right;
  pointer-events: none;
  z-index: 0;
}

.felt-bankroll-label {
  font-family: var(--font-primary);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-gold);
  opacity: 0.7;
  margin-bottom: 2px;
}

.felt-bankroll-amount {
  font-family: var(--font-primary);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--color-gold);
  opacity: 0.9;
}

/* Felt branding responsive */
@media (min-width: 768px) {
  .felt-branding {
    height: 45px;
    top: 48%;
  }

  .felt-title {
    top: calc(48% + 28px);
    font-size: 1rem;
  }

  .felt-bankroll {
    top: 36px;
    right: 30px;
  }

  .felt-bankroll-label {
    font-size: 0.7rem;
  }

  .felt-bankroll-amount {
    font-size: 1.3rem;
  }
}

/* VERSION B: Rail - add class "with-rail" to body to enable */
body.with-rail {
  background: #1a1a18;
}

body.with-rail .felt-table {
  inset: 16px;
  border-radius: 24px;
  box-shadow:
    0 0 0 6px var(--color-brown),
    0 0 0 10px #4a3a1a,
    0 0 0 12px #2a2210,
    0 10px 40px rgba(0, 0, 0, 0.6);
}

body.with-rail .felt-table::before {
  border-radius: 24px;
}

body.with-rail .felt-table::after {
  border-radius: 24px;
  box-shadow: inset 0 0 120px 50px rgba(0, 0, 0, 0.35);
}

/* Game Container */
.game-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Game Table */
.game-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 15px;
  position: relative;
  min-height: 0;
}

/* Hand Areas */
.dealer-area,
.player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dealer-area {
  padding-top: 12px;
}

.player-area {
  flex-direction: column;
  padding-bottom: 10px;
}

.hand-label {
  font-size: 0.875rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.8;
}

.hand-value {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-gold);
  min-height: 1.5rem;
}

/* Card Hands */
.hand {
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
  min-height: var(--card-height);
  position: relative;
}

.hand .card {
  margin-left: var(--card-gap);
  transition: none;
}

.hand .card:first-child {
  margin-left: 0;
}

/* Cards */
.card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-border-radius);
  box-shadow: 0 4px 8px var(--color-shadow);
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) ease-in-out;
}

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

.card-face,
.card-back {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  border-radius: var(--card-border-radius);
  overflow: hidden;
}

.card-face {
  background: var(--color-white);
}

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

.card-face img,
.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Card flipped state */
.card.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Card dealing animation */
.card.dealing {
  animation: dealCard var(--deal-duration) ease-out forwards;
}

@keyframes dealCard {
  0% {
    transform: translateX(300px) translateY(-100px) rotate(15deg);
    opacity: 0;
  }
  100% {
    transform: translateX(0) translateY(0) rotate(0deg);
    opacity: 1;
  }
}

/* Card hit animation */
.card.hitting {
  animation: hitCard var(--slide-duration) ease-out forwards;
}

@keyframes hitCard {
  0% {
    transform: translateX(200px) rotate(10deg);
    opacity: 0;
  }
  70% {
    transform: translateX(-5px) rotate(-2deg);
  }
  100% {
    transform: translateX(0) rotate(0deg);
    opacity: 1;
  }
}

/* Result Message */
.result-message {
  position: fixed;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-shadow: 2px 2px 4px var(--color-shadow);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  background: var(--color-green);
  min-width: 220px;
  max-width: 90vw;
  padding: 30px 50px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.result-message.show {
  animation: showResult 0.4s ease-out forwards;
}

.result-message.win {
  color: var(--color-gold);
}

.result-message.lose {
  color: #ff6b6b;
  background: #1a1210;
}

.result-message.bust {
  color: #ff6b6b;
  background: #1a1210;
}

.result-message.push {
  color: var(--color-white);
}

.result-message.blackjack {
  color: var(--color-gold);
  font-size: 1.8rem;
  text-shadow:
    0 0 20px var(--color-gold),
    3px 3px 6px var(--color-shadow);
}

@keyframes showResult {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Win/Lose hand animations */
.hand.winner .card {
  animation: winPulse 0.6s ease-in-out;
}

@keyframes winPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 8px var(--color-shadow);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--color-gold);
  }
}

.hand.loser .card {
  animation: loseShake 0.4s ease-in-out;
}

@keyframes loseShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* Game Controls */
.game-controls {
  padding: 12px 20px;
  background: var(--color-green-dark);
  border-top: 3px solid var(--color-brown);
  box-shadow: inset 0 2px 0 0 #4a3a1a;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Button Area - swaps between deal/action/restart */
.button-area {
  position: relative;
  min-height: 48px;
}

.button-area > * {
  display: none;
}

.button-area > .active {
  display: flex;
}

/* Action Buttons */
.action-buttons {
  justify-content: center;
  gap: 12px;
}

.action-buttons.active {
  display: flex;
}

.btn-deal.active,
.btn-restart.active {
  display: block;
}

/* Buttons */
.btn {
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-hit {
  background: var(--color-white);
  color: var(--color-black);
}

.btn-hit:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(248, 249, 253, 0.3);
}

.btn-stand {
  background: var(--color-red);
  color: var(--color-white);
}

.btn-stand:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
}

.btn-double {
  background: var(--color-gold);
  color: var(--color-black);
}

.btn-double:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(255, 205, 0, 0.4);
}

.btn-deal {
  background: var(--color-gold);
  color: var(--color-black);
  width: 100%;
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-deal:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(255, 205, 0, 0.4);
}

.btn-restart {
  background: var(--color-blue);
  color: var(--color-white);
  width: 100%;
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-restart:hover {
  box-shadow: 0 4px 16px rgba(0, 76, 151, 0.4);
}

/* Desktop Adjustments */
@media (min-width: 768px) {
  :root {
    --card-width: 160px;
    --card-height: 224px;
    --card-gap: -65px;
  }

  .hand-value {
    font-size: 1.1rem;
  }

  .result-message {
    font-size: 2rem;
    padding: 40px 70px;
  }

  .result-message.blackjack {
    font-size: 2.5rem;
  }
}

/* Tall phone screens - give more space to game table */
@media (min-height: 700px) {
  .game-table {
    padding: 20px 15px;
  }
}
