:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --background-color: #f8f9fa;
  --card-base-width: 80px;
  --border-radius: 8px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
  background: linear-gradient(135deg, #004d00 0%, #222222 100%);
  min-height: 100vh;
  color: var(--primary-color);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Desktop: Better container width */
@media (min-width: 769px) {
  .container {
    max-width: 1400px;
    padding: 30px;
  }
}

h1 {
  text-align: center;
  color: white;
  margin-bottom: 30px;
  font-size: 2.5em;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Connection Setup Styles */
.connection-setup {
  background: white;
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  margin-bottom: 20px;
}

.connection-setup h1 {
  color: #222;              /* dark gray: softer than black */
  font-size: 3rem;          /* large and readable */
  font-weight: 600;         /* slightly bold, not too heavy */
  text-align: center;       /* centered looks friendly for welcomes */
  font-family: 'Segoe UI', Roboto, sans-serif; /* clean modern font */
  text-shadow: 0;
}

.logo-image {
  width: 30vw;
  max-width: 300px;
  height: auto; 
  display: block;
  margin: 0 auto; 
}

.connection-instructions {
  background: #f8f9fa;
  padding: 20px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  border-left: 4px solid var(--secondary-color);
}

.rules-dropdown {
  margin-top: 20px;
  margin-bottom: 20px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.rules-dropdown summary {
  font-weight: bold;
  font-size: 1.1em;
  color: var(--primary-color);
  outline: none;
}

.rules-dropdown summary:hover {
  color: var(--secondary-color);
}

.rules-dropdown[open] summary {
  color: var(--secondary-color);
}

.rules-content {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  color: #555;
  line-height: 1.6;
}

.rules-content h3 {
  color: var(--primary-color);
  margin-top: 15px;
  margin-bottom: 8px;
  font-size: 1em;
}

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

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

.connection-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.connection-input, .code-display {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.code-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.3s;
  flex-grow: 1;
}

textarea:focus {
  outline: none;
  border-color: var(--secondary-color);
}

button {
  background: var(--secondary-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

button:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

button:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button-success {
  background: var(--success-color);
}

.button-success:hover {
  background: #229954;
}

.button-danger {
  background: var(--accent-color);
}

.button-danger:hover {
  background: #c0392b;
}

/* Button styles */
.button-warning {
  background-color: #ff9800;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.button-warning:hover {
  background-color: #f57c00;
}

.button-warning:active {
  background-color: #ef6c00;
}

/* Game Area Styles */
.game-container {
  display: none;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.game-container.active {
  display: block;
}

/* Desktop: Use flex layout when active */
@media (min-width: 769px) {
  .game-container.active {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 60px);
  }
}

.game-header {
  background: var(--primary-color);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  flex-shrink: 0;
}

/* Desktop: Better header layout */
@media (min-width: 769px) {
  .game-header {
    padding: 15px 30px;
  }
}

.connection-status {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 500;
}

.connection-status.connected {
  background: var(--success-color);
  color: white;
}

.connection-status.disconnected {
  background: var(--accent-color);
  color: white;
}

.game-content {
  display: flex;
  height: calc(100vh - 200px);
  min-height: 600px;
}

/* Desktop: Better use of space */
@media (min-width: 769px) {
  .game-content {
    height: calc(100vh - 150px);
    min-height: 700px;
  }
  
  .game-area {
    flex: 1;
    max-width: none;
    /* padding: 20px; */
    justify-content: space-between;
  }
}

.chat-area {
  display: flex;
  flex-direction: column;
  width: 300px;
  min-width: 250px;
  background: white;
  border-left: 1px solid #ddd;
  height: 100%;
  overflow: hidden;
}

/* Desktop: Wider chat area */
@media (min-width: 769px) {
  .chat-area {
    width: 350px;
  }
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.player-area {
  width: 100%;
  text-align: center;
}

/* Desktop: Better spacing for player areas */
@media (min-width: 769px) {
  .player-area {
    max-width: 600px;
  }
  
  .opponent-area {
    margin-bottom: 10px;
  }
}

.hand-label {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 5px;
  color: #333;
}

.hand {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin: 0 auto;
}

/* Desktop: Larger card spacing */
@media (min-width: 769px) {
  .hand {
    gap: 10px;
  }
  
  :root {
    --card-base-width: 70px;
  }
}

.card {
  width: var(--card-base-width);
  aspect-ratio: 2.5/3.5;
  border: 2px solid #333;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  font-weight: bold;
  background: white;
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.card.red {
  color: var(--accent-color);
}

.card.black {
  color: var(--primary-color);
}

.card.face-down {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 16px;
}

.card.selectable {
  border-color: var(--success-color);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 4px 8px rgba(39, 174, 96, 0.4); }
  100% { box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
}

/* Piles layout */
.piles {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}

/* Desktop: Better pile spacing */
@media (min-width: 769px) {
  .piles {
    gap: 15px;
    margin: 15px 0;
  }
}

.pile {
  width: 80px;
  height: 120px;
  border: 2px solid #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9em;
  text-align: center;
}

.pile.clickable {
  border-color: #4CAF50;
  background: #E8F5E8;
  cursor: pointer;
}

.pile.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.drawn-card-display {
  border-color: #2196F3;
  background: #E3F2FD;
}

.drawn-card-display:hover {
  transform: none; /* No hover effect for display area */
  box-shadow: none;
}

/* Status area */
.status-area {
  text-align: center;
  margin: 10px 0;
}

/* Desktop: Better status area spacing */
@media (min-width: 769px) {
  .status-area {
    margin: 15px 0;
  }
}

.turn-indicator {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 5px;
}

.game-status {
  font-size: 1.1em;
  color: #666;
  margin-bottom: 5px;
}

.score {
  text-align: center;
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 5px;
  padding: 8px;
  background: rgba(255,255,255,0.8);
  border-radius: var(--border-radius);
}

/* Controls */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 10px 0;
}

/* Desktop: Better controls spacing */
@media (min-width: 769px) {
  .controls {
    gap: 15px;
    margin: 15px 0;
  }
}

/* Chat Styles */
.chat-header {
  padding: 15px;
  background: var(--primary-color);
  color: white;
  font-weight: bold;
  text-align: center;
}

.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  word-wrap: break-word;
  min-height: 0; /* Allow flex to shrink */
}

.chat-message {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 80%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-message.own {
  background: var(--secondary-color);
  color: white;
  margin-left: auto;
  margin-right: 0;
}

.chat-message.other {
  background: #e9ecef;
  color: var(--primary-color);
  margin-right: auto;
  margin-left: 0;
  border: 1px solid #dee2e6;
}

.chat-message.system {
  background: #fff3cd;
  color: #856404;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  font-style: italic;
  font-size: 0.9em;
  border: 1px solid #ffeaa7;
}

.chat-input-area {
  padding: 15px;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 10px;
  flex-shrink: 0; /* Prevent input area from being compressed */
  background: white;
}

.chat-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
}

.chat-send {
  padding: 10px 20px;
  border-radius: 20px;
  min-width: 60px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .game-content {
    flex-direction: column;
    height: auto;
  }

  .game-area {
    overflow-y: visible;
    padding: 15px;
  }

  .chat-area {
    width: 100%;
    max-height: 300px;
    border-left: none;
    border-top: 1px solid #ddd;
  }

  .hand {
    max-width: 240px;
  }

  :root {
    --card-base-width: 60px;
  }

  .piles {
    gap: 20px;
  }

  .game-header {
    flex-direction: column;
    gap: 10px;
  }
  
  .connection-controls {
    flex-direction: column;
    gap: 10px;
  }
  
  .controls {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px;
  }
  
  h1 {
    font-size: 2em;
  }
  
  .connection-setup {
    padding: 20px;
  }
  
  .game-header {
    padding: 15px;
  }

  /* .game-area { */
    /* padding: 15px; */
    /* gap: 15px; */
  /* } */ 

}

/* Animations */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

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

/* Hand grid layout for 6 Card Golf */
.hand-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 5px;
  width: 100%;
  max-width: calc(var(--card-base-width) * 3 + 10px); /* 3 cards + 2 gaps */
  margin: 0 auto;
}

.hand-grid .card {
  aspect-ratio: 2.5/3.5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hand-grid .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.hand-grid .card.selectable {
  border: 2px solid #4CAF50;
  background-color: #E8F5E8;
}

.hand-grid .card.face-down {
  background: linear-gradient(45deg, #1a1a1a, #2a2a2a);
  color: white;
  border: 2px solid #333;
}

.hand-grid .card.red {
  color: #d32f2f;
}

.hand-grid .card.black {
  color: #212121;
}
