/* ============ Zendarq's Blackjack — main.css ============ */

:root {
  --felt: #1a472a;
  --felt-dark: #0d2818;
  --accent: #d4af37;
  --chalk: #f5f5f5;
  --gold: #d4af37;
  --gold-glow: rgba(212, 175, 55, 0.5);
  --red: #d32f2f;
  --green: #2e7d32;
  --text: #f5f5f5;
  --text-dim: rgba(245, 245, 245, 0.6);
  --card-w: 60px;
  --card-h: 84px;
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--felt-dark);
  color: var(--text);
  touch-action: manipulation;
}

body {
  background: radial-gradient(ellipse at center top, var(--felt) 0%, var(--felt-dark) 70%);
}

button { font-family: inherit; cursor: pointer; }

/* ============ Screens ============ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.screen.active { display: flex; }

/* ============ Title screen ============ */
#screen-title {
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.title-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.card-pair {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  perspective: 800px;
  animation: float 4s ease-in-out infinite;
}

.title-card {
  width: 80px;
  height: 112px;
  border-radius: 10px;
  position: relative;
  transform-style: preserve-3d;
}
.title-card.ace  { --tilt: -8deg; animation: cardSpin 10s ease-in-out infinite; }
.title-card.king { --tilt: 8deg;  animation: cardSpin 10s ease-in-out infinite; animation-delay: -5s; }

.title-card .face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.title-card .face.front {
  background: #fff;
  border: 2px solid #333;
  color: #1a1a1a;
}
.title-card .face.front.red { color: var(--red); }
.title-card .face.front .suit { font-size: 3rem; }
.title-card .face.front .label {
  position: absolute; top: 6px; left: 8px;
  font-size: 1rem; font-weight: 700;
}
.title-card .face.front .label.bottom {
  top: auto; bottom: 6px; left: auto; right: 8px;
  transform: rotate(180deg);
}
.title-card .face.back {
  background: linear-gradient(135deg, #1a237e, #283593);
  border: 3px solid var(--gold);
  transform: rotateY(180deg);
}
.title-card .face.back::after {
  content: '♠';
  color: rgba(212,175,55,0.3);
  font-size: 2rem;
}

.title-name {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 700;
  font-size: clamp(2.5rem, 9vw, 4.5rem);
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.title-game {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: clamp(1.5rem, 6vw, 2.8rem);
  color: var(--chalk);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  margin: 0.3rem 0 2.5rem;
  text-indent: 0.35em; /* balance letter-spacing */
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: min(280px, 80vw);
}

.title-footer {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 1rem);
  left: 0; right: 0;
  text-align: center;
  letter-spacing: 1.5rem;
  color: rgba(245,245,245,0.2);
  font-size: 1.2rem;
  z-index: 1;
}

.music-prompt {
  position: absolute;
  top: calc(var(--safe-top) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(212,175,55,0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  z-index: 5;
  animation: pulse 2s ease-in-out infinite;
}

/* ============ Buttons ============ */
.btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.1s, background 0.2s, box-shadow 0.2s;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,0.15); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #b8860b);
  border: none;
  color: #1a1a1a;
  box-shadow: 0 4px 16px var(--gold-glow);
}
.btn-big, .btn.big { padding: 1.1rem 2rem; font-size: 1.15rem; }
.btn.small { padding: 0.5rem 1rem; font-size: 0.85rem; }

/* ============ App header ============ */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  padding-top: calc(0.7rem + var(--safe-top));
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.2);
  z-index: 10;
}
.brand {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold);
}
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn {
  background: rgba(212,175,55,0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(212,175,55,0.25); }
.chip-balance {
  background: rgba(212,175,55,0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ============ Overlay ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay-box {
  background: linear-gradient(135deg, #1a2a1a, #0d180d);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.overlay-box h2 { font-family: 'Cinzel', serif; color: var(--gold); margin-bottom: 1rem; }
.overlay-box .btn { margin: 0.5rem; }

/* ============ Mobile ============ */
@media (max-width: 480px) {
  .title-card { width: 60px; height: 84px; }
  .title-card .face.front .suit { font-size: 2rem; }
  .card-pair { gap: 1rem; }
  .title-game { letter-spacing: 0.25em; text-indent: 0.25em; }
}
