/* ==========================================================================
   Bhabhi Thulla — Master Stylesheet & Mobile App Landscape Optimization
   Realistic CSS Playing Cards, Felt Table & Responsive Micro-Animations
   ========================================================================== */

:root {
  --table-green: #0d4227;
  --table-dark: #072315;
  --felt-border: #1a6b41;
  --card-red: #dc2626;
  --card-black: #0f172a;
  --gold-accent: #ffd43b;
}

/* Base Mobile & Touch Reset */
body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Card Table Felt Surface */
.card-table-felt {
  background: radial-gradient(ellipse at center, #115332 0%, #0a331f 70%, #051c11 100%);
  border: 4px solid var(--felt-border);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6), 0 15px 35px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  user-select: none;
  transition: all 0.3s ease;
}

/* Subtle table texture pattern */
.card-table-felt::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0);
  background-size: 16px 16px;
  pointer-events: none;
}

/* ==========================================================================
   Realistic CSS Playing Cards
   ========================================================================== */
.playing-card {
  width: clamp(54px, 12vw, 78px);
  height: clamp(78px, 17vw, 112px);
  background: #ffffff;
  border-radius: 9px;
  border: 1px solid #d1d5db;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28), 0 1px 3px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 5px;
  position: relative;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .playing-card {
    width: 86px;
    height: 124px;
    border-radius: 11px;
    padding: 6px 8px;
  }
}

.playing-card.mini {
  width: 48px;
  height: 70px;
  padding: 3px 4px;
}

@media (min-width: 640px) {
  .playing-card.mini {
    width: 58px;
    height: 84px;
    padding: 4px 5px;
  }
}

/* Red & Black Suits */
.playing-card.red {
  color: var(--card-red);
}

.playing-card.black {
  color: var(--card-black);
}

/* Card Corners (Rank & Mini Suit) */
.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.top-left {
  align-self: flex-start;
}

.card-corner.bottom-right {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-rank {
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 900;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (min-width: 640px) {
  .card-rank {
    font-size: 16px;
  }
}

.card-suit {
  font-size: clamp(9px, 2vw, 12px);
}

@media (min-width: 640px) {
  .card-suit {
    font-size: 13px;
  }
}

/* Large Center Pip */
.card-center-pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 5vw, 32px);
  pointer-events: none;
  opacity: 0.92;
}

@media (min-width: 640px) {
  .card-center-pip {
    font-size: 40px;
  }
}

.playing-card.mini .card-center-pip {
  font-size: 18px;
}

/* Playable Card Glow & Interaction */
.playing-card.playable {
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35), 0 0 14px rgba(250, 204, 21, 0.55);
  border-color: #facc15;
}

.playing-card.playable:hover,
.playing-card.playable:active {
  transform: translateY(-16px) scale(1.06);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45), 0 0 24px rgba(250, 204, 21, 0.85);
  z-index: 35 !important;
}

.playing-card.not-playable {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(30%);
}

/* ==========================================================================
   Human Hand Container (Fanned & Responsive Mobile Overlap)
   ========================================================================== */
.human-hand-fanned {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 10px 4px;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  -webkit-overflow-scrolling: touch;
}

.human-hand-fanned::-webkit-scrollbar {
  display: none;
}

.human-hand-fanned > .playing-card {
  margin-left: clamp(-36px, -6vw, -22px);
}

@media (min-width: 640px) {
  .human-hand-fanned > .playing-card {
    margin-left: -42px;
  }
}

.human-hand-fanned > .playing-card:first-child {
  margin-left: 0;
}

/* ==========================================================================
   Computer Hand Mini Card Backs
   ========================================================================== */
.card-back-mini {
  width: clamp(14px, 2.5vw, 20px);
  height: clamp(22px, 3.8vw, 30px);
  background: #1e3a8a;
  background-image: repeating-linear-gradient(45deg, #2563eb 0, #2563eb 2px, #1e3a8a 0, #1e3a8a 8px);
  border: 1px solid #93c5fd;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  margin-left: clamp(-10px, -1.8vw, -8px);
  flex-shrink: 0;
}

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

/* ==========================================================================
   Player Boxes & Glow Turn Indicators
   ========================================================================== */
.player-box {
  background: rgba(15, 23, 42, 0.88);
  border: 2px solid rgba(51, 65, 85, 0.65);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 6px 10px;
  color: #ffffff;
  transition: all 0.25s ease;
}

@media (min-width: 640px) {
  .player-box {
    padding: 8px 14px;
  }
}

.player-box.active-turn {
  border-color: #ffd43b;
  box-shadow: 0 0 22px rgba(255, 212, 59, 0.55);
  background: rgba(30, 41, 59, 0.95);
}

.player-box.player-safe {
  border-color: #10b981;
  background: rgba(6, 78, 59, 0.88);
}

.badge-turn {
  background: #ffd43b;
  color: #183153;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 900;
}

.badge-thinking {
  background: #38bdf8;
  color: #082f49;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
}

.badge-waiting {
  background: #334155;
  color: #94a3b8;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 700;
}

.badge-safe {
  background: #10b981;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 900;
}

/* ==========================================================================
   Center Trick Area Animations
   ========================================================================== */
.card-played-anim {
  animation: cardPlayIn 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes cardPlayIn {
  0% { opacity: 0; transform: scale(0.6) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.winning-card-glow {
  animation: winningPulse 0.6s infinite alternate;
  border: 2px solid #ffd43b !important;
  z-index: 25;
}

@keyframes winningPulse {
  0% { box-shadow: 0 0 10px rgba(255, 212, 59, 0.5); transform: scale(1.02); }
  100% { box-shadow: 0 0 25px rgba(255, 212, 59, 0.95); transform: scale(1.07); }
}

.trick-clearing .playing-card {
  transition: transform 0.4s ease-in, opacity 0.4s ease-in;
  transform: scale(0.2) translate(150px, -150px) rotate(45deg);
  opacity: 0;
}

.lead-suit-pill {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.lead-suit-pill.red { color: var(--card-red); }
.lead-suit-pill.black { color: var(--card-black); }

/* ==========================================================================
   LANDSCAPE MOBILE APP MODE & IMMERSIVE STYLES
   ========================================================================== */
@media (orientation: landscape) and (max-height: 600px) {
  /* Prevent awkward vertical page scrolls in landscape app view */
  body {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }

  header#globalHeader,
  footer#globalFooter {
    display: none !important;
  }

  main {
    margin-bottom: 4px !important;
    padding-top: 0 !important;
    max-width: 100% !important;
  }

  /* Compact banner in landscape */
  .bg-slate-900\/80 {
    padding: 6px 12px !important;
    margin-bottom: 6px !important;
    border-radius: 12px !important;
  }

  /* Full viewport Felt Table Arena */
  .card-table-felt {
    min-h-[440px] !important;
    padding: 8px 12px !important;
    margin-bottom: 4px !important;
    border-radius: 18px !important;
  }

  /* Scale Center Trick circle */
  #centerTrickArea {
    width: 140px !important;
    height: 140px !important;
  }

  /* Adjust Center Trick Cards */
  #centerTrickArea .playing-card {
    width: 48px !important;
    height: 68px !important;
    padding: 3px 4px !important;
  }

  #centerTrickArea .card-rank { font-size: 11px !important; }
  #centerTrickArea .card-center-pip { font-size: 18px !important; }

  /* Compact Human Player Area */
  #playerBox_0 {
    margin-bottom: 2px !important;
    padding: 4px 10px !important;
  }

  .human-hand-fanned {
    padding-top: 4px !important;
    padding-bottom: 2px !important;
  }

  .human-hand-fanned > .playing-card {
    width: 52px !important;
    height: 76px !important;
    margin-left: -26px !important;
    padding: 3px 4px !important;
  }

  .human-hand-fanned > .playing-card:first-child {
    margin-left: 0 !important;
  }

  .human-hand-fanned .card-rank { font-size: 11px !important; }
  .human-hand-fanned .card-center-pip { font-size: 19px !important; }

  /* Player Side Boxes */
  #playerBox_1, #playerBox_2, #playerBox_3 {
    padding: 4px 8px !important;
  }

  /* Modals in landscape: scrollable & centered */
  #rulesModal > div,
  #statsModal > div,
  #gameOverModal > div {
    max-height: 94vh !important;
    padding: 14px !important;
    border-radius: 18px !important;
  }
}

/* Fullscreen Native Class */
.app-fullscreen-active {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: #0c1626 !important;
  margin: 0 !important;
  padding: 4px !important;
  overflow: hidden !important;
}
