* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.table {
  background: #16213e;
  border-radius: 24px;
  padding: 40px;
  width: 600px;
  text-align: center;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

h1 {
  color: #e94560;
  margin-bottom: 16px;
  font-size: 2rem;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f3460;
  padding: 10px 20px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-weight: 600;
}

.info-buttons {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 2px solid #aaa;
  color: #aaa;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}

.btn-icon:hover {
  border-color: #e94560;
  color: #e94560;
}

.rules-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.rules-content {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
  position: relative;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.rules-content h2 {
  color: #e94560;
  font-size: 1.4rem;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.rules-content h3 {
  color: #eee;
  font-size: 1rem;
  margin: 16px 0 8px;
  border-bottom: 1px solid #0f3460;
  padding-bottom: 4px;
}

.rules-content p,
.rules-content li {
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.6;
}

.rules-content ul,
.rules-content ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.rules-content li {
  margin-bottom: 4px;
}

.rules-content ul ul {
  margin-top: 4px;
}

.rules-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.rules-close:hover { color: #e94560; }

.hand { margin-bottom: 24px; }

.hand h2 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.hand h2 span { color: #e94560; }

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

.card {
  width: 80px;
  height: 112px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: #fff;
  color: #222;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.3);
  opacity: 0;
  animation: dealCard 0.35s ease-out forwards;
}

.card.flip {
  animation: flipCard 0.4s ease-in-out forwards;
}

@keyframes flipCard {
  0%   { transform: scaleX(1); }
  50%  { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

.card.red { color: #d32f2f; }

.card .suit { font-size: 1.8rem; line-height: 1; }
.card .rank { font-size: 1.2rem; line-height: 1; }

.card.facedown {
  background: linear-gradient(135deg, #e94560, #0f3460);
  color: transparent;
}
.card.facedown .suit,
.card.facedown .rank { visibility: hidden; }

@keyframes dealCard {
  0%   { opacity: 0; transform: translateY(-40px) rotate(-8deg) scale(0.7); }
  60%  { opacity: 1; transform: translateY(4px) rotate(1deg) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
}

.message {
  font-size: 1.4rem;
  font-weight: 700;
  min-height: 2rem;
  margin-bottom: 16px;
  color: #e94560;
}

.controls-area {
  height: 44px;
  position: relative;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.controls button, .btn-deal {
  background: #0f3460;
  color: #eee;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.controls button:hover, .btn-deal:hover { background: #e94560; }

#current-bet {
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 60px;
}

.btn-deal {
  margin-left: 16px;
}

.hidden { display: none !important; }

/* Win/Lose animations */
.table.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-12px) rotate(-1deg); }
  30%  { transform: translateX(10px) rotate(1deg); }
  45%  { transform: translateX(-8px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
}

.message.win {
  animation: winPulse 0.6s ease-in-out;
  color: #4caf50;
}

.message.blackjack {
  animation: winPulse 0.6s ease-in-out;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.message.lose {
  animation: loseFade 0.5s ease-in-out;
  color: #e94560;
}

.message.push {
  animation: pushPulse 0.5s ease-in-out;
  color: #aaa;
}

@keyframes winPulse {
  0%   { transform: scale(0.5); opacity: 0; }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes loseFade {
  0%   { transform: scale(1.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pushPulse {
  0%   { opacity: 0; }
  50%  { opacity: 0.5; }
  100% { opacity: 1; }
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.3); }
}

.player-hand .card.win-glow {
  box-shadow: 0 0 16px 4px rgba(76, 175, 80, 0.6);
  transition: box-shadow 0.4s;
}

.player-hand .card.blackjack-glow {
  box-shadow: 0 0 20px 6px rgba(255, 215, 0, 0.7);
  transition: box-shadow 0.4s;
}

.player-hand .card.lose-dim {
  opacity: 0.5;
  filter: grayscale(0.5);
  transition: opacity 0.4s, filter 0.4s;
}

/* History panel */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  background: #16213e;
  border-left: 2px solid #0f3460;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
  box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 12px;
  border-bottom: 1px solid #0f3460;
}

.history-header h2 {
  color: #e94560;
  font-size: 1.2rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.history-header .rules-close {
  position: static;
}

.history-stats {
  display: flex;
  justify-content: space-around;
  padding: 12px 16px;
  border-bottom: 1px solid #0f3460;
  font-size: 0.8rem;
  color: #aaa;
}

.history-stats .stat {
  text-align: center;
}

.history-stats .stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #eee;
}

.history-stats .stat-value.positive { color: #4caf50; }
.history-stats .stat-value.negative { color: #e94560; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }

.history-entry {
  background: #0f3460;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  animation: fadeIn 0.2s ease-out;
}

.history-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: #aaa;
}

.history-entry-result {
  font-weight: 700;
  font-size: 0.85rem;
}

.history-entry-result.win { color: #4caf50; }
.history-entry-result.blackjack { color: #ffd700; }
.history-entry-result.lose { color: #e94560; }
.history-entry-result.push { color: #aaa; }

.history-entry-hands {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.history-hand {
  flex: 1;
}

.history-hand-label {
  font-size: 0.7rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.history-cards {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.history-card {
  font-size: 0.75rem;
  font-weight: 600;
  background: #1a1a2e;
  padding: 2px 5px;
  border-radius: 3px;
  color: #eee;
}

.history-card.red { color: #d32f2f; }

.history-empty {
  text-align: center;
  color: #555;
  padding: 40px 20px;
  font-size: 0.9rem;
}
