/* Main Styles for Mexican Train Dominoes */
:root {
  --brand-primary-color: #228B22;    /* Forest Green */
  --brand-secondary-color: #00CCFF;  /* Bright Cyan */
  --brand-tertiary-color: #FFA500;   /* Orange */
  --brand-background: #004d00;       /* Darker Green */
  --brand-text-color: #FFFFFF;       /* White */
  --brand-accent-color: #FFD700;     /* Gold */
  --brand-error-color: #FF6347;      /* Tomato Red */
}

body {
  font-family: 'Roboto', sans-serif;
  background: linear-gradient(135deg, var(--brand-background) 0%, var(--brand-primary-color) 100%);
  color: var(--brand-text-color);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: 'Press Start 2P', cursive;
  letter-spacing: 1px;
  margin-bottom: 1rem;
}

/* Game container styles */
.game-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Game Stats */
.game-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  background: rgba(0,0,0,0.2);
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Button styles */
button {
  font-family: 'Press Start 2P', cursive;
  background-color: var(--brand-primary-color);
  color: var(--brand-text-color);
  border: 2px solid #fff;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  margin: 0.25rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

button:hover {
  background-color: var(--brand-secondary-color);
  transform: translateY(-2px);
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  background-color: #888;
  cursor: not-allowed;
  transform: none;
}

/* Animated message styles */
#animated-message-container {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 80%;
  text-align: center;
  visibility: hidden;
}

#animated-message-container.info {
  background-color: var(--brand-primary-color);
}

#animated-message-container.success {
  background-color: #28a745;
}

#animated-message-container.error {
  background-color: var(--brand-error-color);
}

/* Game layout structure */
.game-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  gap: 1rem;
}

/* Game areas */
.station-area {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.station-area h2 {
  margin-top: 0;
  color: var(--brand-accent-color);
}

/* Train areas */
.trains-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.train {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: relative;
}

.train h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
}

/* Enhanced domino display */
.domino {
  background: white;
  color: black;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 4px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  width: 60px;
  height: 120px;
  overflow: visible;
  border: 1px solid #ccc;
}

.domino:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--brand-secondary-color);
}

/* Fix orientation - properly display dominoes */
.domino-value {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 24px;
  flex: 1;
  position: relative;
}

/* Horizontal domino layout for trains */
.domino.played-horizontal {
  flex-direction: row;
  width: 90px; /* Fixed width for horizontal dominos */
  height: 45px; /* Fixed height for horizontal dominos */
  margin: 8px 4px;
}

/* Handle double dominoes */
.domino.double.played-horizontal {
  transform: rotate(90deg); /* Doubles played horizontally rotate */
  transform-origin: center;
  margin: 25px 10px; /* Add margin to account for rotation */
}

/* Divider line between domino halves */
.domino::after {
  content: '';
  position: absolute;
  background-color: #000;
  opacity: 0.3;
}

.domino:not(.played-horizontal)::after {
  height: 2px;
  width: 100%;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.domino.played-horizontal::after {
  height: 100%;
  width: 2px;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* Train display as flexbox for proper alignment */
.train-dominoes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 60px;
  align-items: center;
  overflow-x: auto;
  padding: 10px 0;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

/* Player hand styles */
.player-hand {
  display: flex;
  flex-wrap: wrap;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  position: relative;
  min-height: 140px; /* Ensure enough height for dominoes */
}

.player-hand h3 {
  width: 100%;
  margin-bottom: 10px;
  font-size: 1.1rem;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

.player-hand .domino {
  margin: 5px;
}

.player-marker {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
}

/* Controls and status area */
.controls-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Boneyard area */
.boneyard-area {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin: 1rem 0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.boneyard-area h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

/* Game area layout */
#game-area {
  display: flex;
  flex-direction: column;
}

/* Animation class for moving dominoes */
.animating {
  position: absolute;
  z-index: 100;
  transition: none;
  pointer-events: none;
}

/* Responsive design adjustments */
@media (max-width: 768px) {
  .domino {
    width: 40px;
    height: 80px;
  }
  
  .domino.played-horizontal {
    width: 70px;
    height: 35px;
  }
  
  .domino-value {
    font-size: 18px;
  }
  
  h2, h3 {
    font-size: 0.9rem;
  }
  
  #game-status {
    font-size: 0.9rem;
  }

  .controls-container {
    flex-wrap: wrap;
  }
}

/* Visual indicator for current player */
.current-player {
  border: 3px solid var(--brand-secondary-color);
  box-shadow: 0 0 15px var(--brand-secondary-color);
}

/* Clear train display for legibility */
#mexican-train, .train {
  overflow-x: auto;
  white-space: nowrap;
  min-height: 100px;
  margin-bottom: 1rem;
}

/* Selected domino highlight */
.selected-domino {
  border: 3px solid var(--brand-secondary-color);
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 120, 255, 0.5);
}

/* Station domino specific styling */
#station-domino {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.station-domino-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 140px;
}

/* For double dominoes in station - make them horizontal */
.domino.double.station-double {
  flex-direction: row;
  width: 120px;
  height: 60px;
}

/* Horizontal domino layout for trains */
.domino.played-horizontal {
  flex-direction: row;
  width: 120px;
  height: 60px;
}

/* Handle double dominoes in trains */
.domino.double.played-horizontal {
  transform: rotate(90deg);
  transform-origin: center;
  margin: 30px 0;
}

/* Divider line between domino halves */
.domino::after {
  content: '';
  position: absolute;
  background-color: #000;
  opacity: 0.3;
}

.domino:not(.played-horizontal):not(.station-double)::after {
  height: 2px;
  width: 100%;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.domino.played-horizontal::after, .domino.station-double::after {
  height: 100%;
  width: 2px;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* Train container styles */
.train {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  min-height: 100px;
  overflow-x: auto;
}

.train h2 {
  margin-bottom: 1rem;
}

.train-dominoes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 80px;
}

/* Player hand styles */
.player-hand {
  display: flex;
  flex-wrap: wrap;
  padding: 1rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.player-hand h3 {
  width: 100%;
  margin-bottom: 10px;
}

.hand-dominoes-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Current player highlight */
.current-player {
  border: 3px solid var(--brand-secondary-color);
  box-shadow: 0 0 15px var(--brand-secondary-color);
}

/* Selected domino highlight */
.selected-domino {
  border: 3px solid var(--brand-secondary-color);
  transform: translateY(-10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

/* Public train marker */
.player-marker {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: 8px;
}

/* Boneyard area */
#boneyard-area {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
}

/* Animation class */
.animating {
  position: absolute;
  z-index: 100;
  transition: none;
  pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .domino {
    width: 50px;
    height: 100px;
  }
  
  .domino.played-horizontal, .domino.double.station-double {
    width: 100px;
    height: 50px;
  }
  
  .domino-value {
    font-size: 18px;
  }
}

/* Rules Section Styling */
.rules-section { /* Add this class to the section in HTML if not already present, or target existing class/ID */
  background-color: rgba(0, 0, 0, 0.3); /* Darker, slightly transparent background for the section */
  padding: 2rem;
  border-radius: 12px;
  margin-top: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.rules-section h2 {
  color: var(--brand-accent-color); /* Gold for the main title */
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.8rem; /* Larger main title */
}

.rules-section h3 {
  color: var(--brand-secondary-color); /* Bright Cyan for subheadings */
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.3rem; /* Slightly larger subheadings */
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 0.5rem;
}

.rules-section p, .rules-section ul {
  color: #f0f0f0; /* Lighter text color for better contrast on the darker background */
  line-height: 1.6;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.rules-section ul {
  list-style-type: disc;
  padding-left: 25px; /* Indent lists */
}

.rules-section li {
  margin-bottom: 0.5rem;
}

.rules-section strong {
  color: var(--brand-tertiary-color); /* Orange for emphasized text */
}

.rules-section a {
  color: var(--brand-secondary-color);
  text-decoration: underline;
}

.rules-section a:hover {
  color: var(--brand-accent-color);
}
