:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  
  --red: #ef4444;
  --blue: #3b82f6;
  --green: #10b981;
  --yellow: #f59e0b;
  --black: #1f2937;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-gradient);
  color: white;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 500px;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: env(safe-area-inset-top, 40px) 15px env(safe-area-inset-bottom, 30px);
}

.top-bar {
  position: absolute;
  top: env(safe-area-inset-top, 20px);
  right: 15px;
  z-index: 10;
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.icon-btn:active { transform: scale(0.95); }

.round-btn {
  width: 45px;
  height: 45px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
}

.cpu-area, .player-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  width: 100%;
}

.center-area {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 15px;
}

.player-label {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  margin-bottom: 25px;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 2;
}

.hand-container {
  width: 100%;
  height: 160px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.hand {
  position: relative;
  width: 100%;
  height: 115px;
}

.hand .card {
  position: absolute;
  bottom: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), left 0.4s ease, bottom 0.4s ease;
  transform-origin: bottom center;
}

/* Player specific card states */
#player-hand .card.playable {
  bottom: 15px !important;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

#player-hand .card:active {
  bottom: 25px !important;
  z-index: 200 !important;
}

.card {
  width: 75px;
  height: 115px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  background-color: white;
  border: 4px solid white;
  cursor: pointer;
  overflow: hidden;
}

.card .inner {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
}
.corner-val {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
}
.center-val {
  text-align: center;
}
.card .inner.symbol-card {
  font-size: 1.2rem;
}

/* Match Stack My Pile premium cards */
.card.red .inner { color: var(--red); border: 3px solid var(--red); }
.card.blue .inner { color: var(--blue); border: 3px solid var(--blue); }
.card.green .inner { color: var(--green); border: 3px solid var(--green); }
.card.yellow .inner { color: var(--yellow); border: 3px solid var(--yellow); }
.card.black .inner { color: var(--black); border: 3px solid var(--black); }

.card.card-back .inner {
  background: #1f2937;
  color: #fbbf24;
  border: 3px solid #374151;
  font-size: 1.8rem;
  font-weight: 800;
  text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.deck-area {
  display: flex;
  gap: 20px;
  align-items: flex-end;
}

.pile-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pile-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
}

#draw-pile {
  cursor: pointer;
  transition: transform 0.1s;
}
#draw-pile:active {
  transform: scale(0.95);
}

.btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

#status-text {
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #fbbf24;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  transition: color 0.3s;
}

.modal {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 30px;
  border-radius: 24px;
  text-align: center;
  box-shadow: var(--glass-shadow);
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 90%;
}
.modal.hidden .modal-content {
  transform: scale(0.8);
}

.modal-content h3, .modal-content h2 {
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.color-options {
  display: flex;
  gap: 15px;
  justify-content: center;
}
.color-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid white;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.color-btn:active { transform: scale(0.9); }
.color-btn.red { background: var(--red); }
.color-btn.blue { background: var(--blue); }
.color-btn.green { background: var(--green); }
.color-btn.yellow { background: var(--yellow); }

.rules-content {
  text-align: left;
}
.rules-text {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 25px;
  color: #e2e8f0;
}
.rules-text p { margin-bottom: 10px; }
.rules-text ul { padding-left: 20px; margin-bottom: 15px; }
.rules-content ul li {
  margin-bottom: 8px;
}

.settings-options {
  margin: 20px 0;
  text-align: left;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 1.1rem;
}
.setting-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: #fbbf24;
}
.rules-content .btn { width: 100%; }

/* Game Over Modal Styling */
.game-over-content {
  text-align: center;
  padding: 40px 30px;
  border-radius: 20px;
  width: 85%;
  max-width: 340px;
}
#winner-text {
  font-size: 3.5rem;
  font-weight: 800;
  color: #f97316; /* orange-500 */
  margin-bottom: 5px;
  text-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.game-over-content .subtitle {
  font-size: 1.1rem;
  margin-bottom: 30px;
  color: rgba(255,255,255,0.9);
}
.game-over-content .btn {
  width: 100%;
  margin-bottom: 15px;
  padding: 15px;
  font-size: 1.2rem;
  border-radius: 30px;
}
.primary-btn {
  background: #f97316;
  border: none;
  color: white;
  box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}
.secondary-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  box-shadow: none;
}
#confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

@keyframes dealCard {
  from { opacity: 0; top: -50px; }
  to { opacity: 1; top: 0; }
}
.animate-deal {
  animation: dealCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
