/* Use JS-driven viewport height — iOS Chrome's bottom toolbar overlaps
   both 100vh and 100dvh, so we measure window.innerHeight in JS and
   expose it as --app-vh. Falls back to 100dvh / 100vh for non-JS. */
html, body {
  height: 100vh;
  height: 100dvh;
  height: var(--app-vh, 100dvh);
}
#game {
  height: var(--app-vh, 100dvh);
  padding-bottom: max(0.375rem, env(safe-area-inset-bottom));
  padding-top: max(0.375rem, env(safe-area-inset-top));
}
@media (min-width: 640px) {
  #game {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
}

/* Card sizes — responsive */
.card {
  width: 56px;
  height: 80px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #aaa;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  color: #111;
  font-family: "Georgia", serif;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .card { width: 68px; height: 96px; border-radius: 8px; }
}

.card .corner {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}
@media (min-width: 640px) {
  .card .corner { font-size: 13px; }
}
.card .corner.top    { top: 3px;  left: 4px; }
.card .corner.bottom { bottom: 3px; right: 4px; transform: rotate(180deg); }
.card .center-suit {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
}
@media (min-width: 640px) {
  .card .center-suit { font-size: 32px; }
}
.card.red   { color: #d32f2f; }
.card.black { color: #111; }

/* Card backs */
.card-back, .card.back {
  width: 56px;
  height: 80px;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, #b71c1c, #b71c1c 6px, #7f0000 6px, #7f0000 12px);
  box-shadow: inset 0 0 0 3px #fff, 0 2px 4px rgba(0,0,0,0.35);
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .card-back, .card.back { width: 68px; height: 96px; border-radius: 8px; }
}

/* Bot hand: smaller backs that overlap */
.hand-bot-h { display: flex; }
.hand-bot-h .card-mini {
  width: 28px;
  height: 40px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #b71c1c, #b71c1c 4px, #7f0000 4px, #7f0000 8px);
  box-shadow: inset 0 0 0 2px #fff, 0 1px 2px rgba(0,0,0,0.3);
  margin-left: -10px;
}
.hand-bot-h .card-mini:first-child { margin-left: 0; }
@media (min-width: 640px) {
  .hand-bot-h .card-mini { width: 38px; height: 54px; margin-left: -14px; }
}

.hand-bot-v { display: flex; flex-direction: column; }
.hand-bot-v .card-mini {
  width: 40px;
  height: 28px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #b71c1c, #b71c1c 4px, #7f0000 4px, #7f0000 8px);
  box-shadow: inset 0 0 0 2px #fff, 0 1px 2px rgba(0,0,0,0.3);
  margin-top: -10px;
}
.hand-bot-v .card-mini:first-child { margin-top: 0; }
@media (min-width: 640px) {
  .hand-bot-v .card-mini { width: 54px; height: 38px; margin-top: -14px; }
}


/* Human hand cards */
.human-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.human-card.playable {
  cursor: pointer;
}
.human-card.playable:hover {
  transform: translateY(-10px);
  box-shadow: 0 12px 22px rgba(0,0,0,0.45);
}
.human-card.playable:active { transform: translateY(-4px); }

/* Active turn — make the human's whole hand glow + cards bob gently */
.human-card.my-turn {
  cursor: pointer;
  animation: cardBob 1.8s ease-in-out infinite;
  box-shadow: 0 0 0 2px rgba(255,215,64,0.7), 0 6px 14px rgba(0,0,0,0.4);
}
.human-card.my-turn:nth-child(2) { animation-delay: 0.15s; }
.human-card.my-turn:nth-child(3) { animation-delay: 0.3s; }
.human-card.my-turn:nth-child(4) { animation-delay: 0.45s; }
.human-card.my-turn:hover {
  animation-play-state: paused;
  transform: translateY(-14px);
  box-shadow: 0 0 0 3px #ffd740, 0 14px 26px rgba(0,0,0,0.5);
}

/* Not your turn: cursor default, slight dim, NO not-allowed cursor */
.human-card.idle {
  cursor: default;
  opacity: 0.85;
}

@keyframes cardBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* Pulsing player-info when active */
.player-info.active {
  outline: 2px solid #ffd740;
  outline-offset: 2px;
  animation: glowPulse 1.6s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,215,64,0.6); }
  50%      { box-shadow: 0 0 0 8px rgba(255,215,64,0); }
}

/* Table pile cards */
#table-pile .card {
  position: absolute;
  top: 0;
  transition: transform 0.3s ease;
}

/* Floating last-action message */
#last-msg.show {
  opacity: 1;
}

/* PİŞTİ! big banner */
#pisti-banner.show { display: flex; }
#pisti-banner-inner {
  background: linear-gradient(135deg, #ffd740 0%, #ff6f00 100%);
  color: #1a1a1a;
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 6px rgba(255,255,255,0.2);
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@media (min-width: 640px) {
  #pisti-banner-inner { font-size: 56px; letter-spacing: 6px; }
}
#pisti-banner-inner .sub {
  display: block;
  font-size: 14px;
  letter-spacing: 2px;
  margin-top: 4px;
  opacity: 0.85;
}
@media (min-width: 640px) {
  #pisti-banner-inner .sub { font-size: 18px; }
}

/* Sparkle particles around banner */
#pisti-banner .sparkle {
  position: absolute;
  font-size: 28px;
  animation: floatUp 1.2s ease-out forwards;
  pointer-events: none;
}
@keyframes floatUp {
  0%   { transform: translate(-50%, -50%) translateY(0)    scale(0.5); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(-120px) scale(1.4); opacity: 0; }
}

@keyframes popIn {
  0%   { transform: translate(-50%, -50%) scale(0.3) rotate(-15deg); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.15) rotate(4deg);  opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1)    rotate(0deg);  opacity: 1; }
}

/* Modal table styling (Tailwind doesn't auto-style tables) */
#modal-body table { width: 100%; border-collapse: collapse; margin: 8px 0; }
#modal-body th, #modal-body td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  text-align: left;
  font-size: 12px;
}
@media (min-width: 640px) {
  #modal-body th, #modal-body td { font-size: 13px; padding: 6px 8px; }
}
#modal-body th { color: #ffd740; }
#modal-body tr.winner { color: #ffd740; font-weight: 700; }

/* Active turn class helper for Tailwind class toggling */
.player-info.active { background: rgba(255, 215, 64, 0.25); }

/* Game type selection buttons */
.gametype-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 10px 6px;
  cursor: pointer;
  color: #fff;
  transition: all 0.18s ease;
}
.gametype-btn:hover:not(.selected) {
  background: rgba(255,255,255,0.18);
}
.gametype-btn.selected {
  background: linear-gradient(135deg, #ffd740, #ffb300);
  color: #1a1a1a;
  border-color: #ffd740;
  box-shadow: 0 4px 12px rgba(255,215,64,0.3);
}
.gametype-btn:active { transform: scale(0.97); }

/* Team styling for partnered mode */
.player-info.team-us {
  outline: 1.5px solid rgba(255, 215, 64, 0.7);
  outline-offset: 1px;
}
.player-info.team-them {
  outline: 1.5px solid rgba(244, 67, 54, 0.5);
  outline-offset: 1px;
}
.partner-badge {
  background: rgba(255, 215, 64, 0.85);
  color: #1a1a1a;
  padding: 0px 5px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Hand-size badge — cards currently held */
.hand-count {
  background: rgba(76, 175, 80, 0.35);
  border: 1px solid rgba(76, 175, 80, 0.55);
  color: #fff;
  padding: 0px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.4;
}
.hand-count::before {
  content: "🂠";
  font-size: 11px;
}
.hand-count.empty {
  background: rgba(120, 120, 120, 0.25);
  border-color: rgba(120, 120, 120, 0.4);
  opacity: 0.6;
}
.hand-count.bump-hand {
  animation: handBump 0.35s ease;
}
@keyframes handBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); background: rgba(76, 175, 80, 0.7); }
  100% { transform: scale(1); }
}

/* Pişti count badge — next to captured count */
.pisti-count {
  background: linear-gradient(135deg, #ffd740, #ff6f00);
  color: #1a1a1a;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.3);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.pisti-count::before {
  content: "✨";
  font-size: 10px;
}
.pisti-count.hidden { display: none; }
.pisti-count.bump-pisti {
  animation: pistiPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pistiPop {
  0%   { transform: scale(0.4) rotate(-15deg); }
  60%  { transform: scale(1.5) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Captured count bump when cards arrive */
.captured-count.bump {
  animation: capturedBump 0.55s ease;
}
@keyframes capturedBump {
  0%   { transform: scale(1);   background: rgba(255,255,255,0.15); }
  40%  { transform: scale(1.6); background: #ffd740; color: #111; }
  100% { transform: scale(1);   background: rgba(255,255,255,0.15); }
}

/* Flying capture cards */
.fly-container {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  will-change: transform, opacity;
  transition: transform 0.42s cubic-bezier(0.42, 0, 0.4, 1.1), opacity 0.42s ease-in;
}
.fly-container .card {
  position: absolute;
  box-shadow: 0 12px 24px rgba(0,0,0,0.45);
}

/* Trail/streak from table to capturer */
.capture-trail {
  position: fixed;
  pointer-events: none;
  z-index: 55;
  height: 4px;
  background: linear-gradient(90deg, rgba(255,215,64,0) 0%, rgba(255,215,64,0.8) 50%, rgba(255,215,64,0) 100%);
  border-radius: 2px;
  transform-origin: left center;
  opacity: 0;
  animation: trailFlash 0.42s ease-out;
}
@keyframes trailFlash {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}
