:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --success: #10b981;
  --danger: #ef4444;
  --muted: #64748b;
  --text: #1e293b;
}

* {
  box-sizing: border-box;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

body {
  margin: 0;
  background: linear-gradient(135deg, var(--bg) 0%, #e2e8f0 100%);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}
@media (max-width: 768px) {
  .container {
    padding: 12px;
    max-width: 100%;
  }
  h1 {
    font-size: 24px;
    margin-bottom: 16px;
  }
  #setup, #playerSetup, #deckEditor {
    padding: 12px;
  }
  #setup {
    grid-template-columns: 1fr;
  }
  #setup > div {
    flex-direction: column;
    align-items: flex-start;
  }
  #setup > button, #showDeckEditorBtn {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
  }
  select, input[type="number"], input[type="text"] {
    max-width: 100%;
    width: 100%;
  }
}
h1 {
  text-align: center;
  margin: 0 0 20px 0;
  color: var(--accent);
  font-size: 2.5rem;
  text-shadow: none;
  animation: fadeIn 1s ease-out;
}

#setup, #playerSetup, #deckEditor {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

#setup {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
}

#setup > div {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

#setup > div:last-of-type {
  margin-bottom: 0;
}

#setup > button {
  grid-column: 1;
}

#showDeckEditorBtn {
  grid-column: 2;
  grid-row: 1 / 4;
  align-self: start;
  margin-left: 20px;
}

#setup label {
  color: var(--text);
  font-weight: 600;
  min-width: 100px;
}

select, input[type="number"], input[type="text"] {
  padding: 8px 12px;
  border: 2px solid #cbd5e1;
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  max-width: 280px;
}

select {
  max-width: 280px;
}

select:focus, input[type="number"]:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.game-enter {
  animation: fadeIn 0.6s ease-out;
}

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

.hidden {
  display: none !important;
}

.cardBox {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  min-height: 120px;
}

#meta {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 768px) {
  #meta {
    gap: 10px;
    margin-bottom: 16px;
  }
}

#roundInfo {
  background: var(--accent);
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

@media (max-width: 768px) {
  #roundInfo {
    padding: 10px 16px;
    font-size: 13px;
  }
}

#scenarioArea {
  margin: 16px 0;
  padding: 24px;
  background: linear-gradient(135deg, #fef3c7 0%, #fccf1c 100%);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
}

@media (max-width: 768px) {
  #scenarioArea {
    margin: 12px 0;
    padding: 16px;
  }
}

#scenarioText {
  font-size: 1.3rem;
  margin: 0;
  font-weight: 600;
  color: #78350f;
  line-height: 1.6;
}

@media (max-width: 768px) {
  #scenarioText {
    font-size: 1.1rem;
  }
}

#hand {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  perspective: 1000px;
}

@media (max-width: 768px) {
  #hand {
    gap: 10px;
    justify-content: center;
  }
}

.card {
  background: linear-gradient(135deg, #ffffff 0%, #f5f7fa 100%);
  border: 2px solid #e2e8f0;
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 160px;
  text-align: center;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  color: var(--text);
  line-height: 1.5;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transform-style: preserve-3d;
  animation: dealCard 0.5s ease-out forwards;
  opacity: 0;
}

@media (max-width: 768px) {
  .card {
    min-width: 120px;
    padding: 10px;
    font-size: 13px;
  }
}

@keyframes dealCard {
  from { opacity: 0; transform: translateY(20px) rotateX(-20deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

#hand .card:nth-child(1) { animation-delay: 0.1s; }
#hand .card:nth-child(2) { animation-delay: 0.2s; }
#hand .card:nth-child(3) { animation-delay: 0.3s; }
#hand .card:nth-child(4) { animation-delay: 0.4s; }
#hand .card:nth-child(5) { animation-delay: 0.5s; }
#hand .card:nth-child(6) { animation-delay: 0.6s; }
#hand .card:nth-child(7) { animation-delay: 0.7s; }
#hand .card:nth-child(8) { animation-delay: 0.8s; }
#hand .card:nth-child(9) { animation-delay: 0.9s; }
#hand .card:nth-child(10) { animation-delay: 1s; }


.card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
  transform: translateY(-5px) scale(1.02);
}

.card.selected {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  border-color: var(--accent-light);
  color: #000;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.6);
  transform: translateY(-5px) scale(1.05);
}

#playedArea .card {
  animation: flipIn 0.6s ease-out forwards;
}

@keyframes flipIn {
  from {
    opacity: 0;
    transform: rotateY(-90deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotateY(0) scale(1);
  }
}

#playedCards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#playedCards .card {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: var(--success);
  color: #065f46;
  cursor: pointer;
  transition: all 0.3s;
}

#playedCards .card:hover {
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
  transform: scale(1.03);
}

#playedCards .card.winner {
  animation: winner-pop 1.2s ease-out forwards !important;
  background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%) !important;
  border: 3px solid #dc2626 !important;
  color: #7c2d12 !important;
  font-weight: 700;
  opacity: 1 !important;
  visibility: visible !important;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.6) !important;
  display: block !important;
}

@keyframes winner-pop {
  0% { 
    transform: scale(1); 
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.6);
    opacity: 1;
  }
  50% { 
    transform: scale(1.15); 
    box-shadow: 0 0 30px rgba(220, 38, 38, 0.8);
    opacity: 1;
  }
  100% { 
    transform: scale(1.1); 
    box-shadow: 0 0 25px rgba(220, 38, 38, 0.7);
    opacity: 1;
  }
}


button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
  border: 0;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
  min-height: 44px;
}

@media (max-width: 768px) {
  button {
    padding: 10px 16px;
    min-height: 40px;
    font-size: 13px;
    width: 100%;
  }
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

button:active {
  transform: translateY(-1px);
}

button.secondary {
  background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

button.secondary:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
}

#playerInputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.playerInput {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
}

.playerAvatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 18px;
  transition: transform 0.3s;
}

.playerInput input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
}

#controls {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  #controls {
    margin-top: 16px;
    gap: 8px;
  }
  #controls button {
    flex: 1;
    min-width: 100px;
    width: auto;
  }
}

#scoreboard {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.score {
  background: linear-gradient(135deg, #d1fae5 0%, #dbeafe 100%);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--success);
  font-weight: 700;
  color: var(--success);
  min-width: 100px;
  text-align: center;
  transition: all 0.3s;
}
.score:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}
.score.judge {
  border-color: var(--accent);
  color: var(--accent);
}

#turnLabel {
  margin: 0 0 16px 0;
  color: var(--text);
  font-size: 1.1rem;
}

footer {
  text-align: center;
  margin-top: 30px;
  color: var(--muted);
  font-size: 12px;
}

/* Deck Editor Styles */
#deckEditor {
  max-width: 600px;
  padding: 20px;
}

#deckEditor .deck-editor-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

#deckEditor textarea {
  width: 100%;
  padding: 10px;
  border: 2px solid #cbd5e1;
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  resize: vertical;
  min-height: 200px;
}
#deckEditor h3 {
  margin: 0 0 8px 0;
  color: var(--text);
  font-size: 0.95rem;
}

h2 {
  color: var(--text);
  margin: 0 0 16px 0;
  font-size: 1.5rem;
}

h3 {
  color: var(--text);
  margin: 0 0 12px 0;
}

/* Trump Card Styles */
.card.trump-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
  border: 3px solid #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.card.trump-card:hover {
  border-color: #dc2626;
  box-shadow: 0 0 25px rgba(220, 38, 38, 0.7);
  transform: translateY(-8px) scale(1.05);
}

.card.trump-card.selected {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  border-color: #7c2d12;
  color: #fef3c7;
  box-shadow: 0 0 30px rgba(220, 38, 38, 0.9);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
}

.modal {
  background: var(--card);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  animation: slideDown 0.3s ease-out;
}

.modal h2 {
  margin-top: 0;
  color: #f59e0b;
  text-align: center;
}

.modal p {
  color: var(--text);
  line-height: 1.6;
  margin: 12px 0;
}

.modal-overlay.hidden {
  display: none !important;
}

#shuffleBtn {
  background: linear-gradient(135deg, #f59e0b 0%, #dc2626 100%);
  display: block;
  margin: 16px auto 0;
  padding: 6px 16px;
  font-size: 12px;
  min-height: 32px;
  width: auto;
  opacity: 0.8;
}

#shuffleBtn:hover {
  opacity: 1;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.judge-instruction {
  background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
  color: #78350f;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.6); }
}

@media (max-width: 768px) {
  .modal {
    padding: 20px;
  }
}
