:root {
  --cell-size: 12px;
  --cell-gap: 1px;
}

#game {
  display: grid;
  /* grid-template-columns will be set dynamically by JavaScript */
  grid-gap: var(--cell-gap);
  margin-bottom: 10px;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  overflow: auto;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: #5b0202;
  border: 1px solid #2c0202;
  box-sizing: border-box; /* Ensures border is included in size */
}

.cell.alive {
  background: #efe9e9;
}

body {
  min-height: 100vh;
  margin: 0;
  background-color: black;
  color: white;
  font-family: Arial, sans-serif;
}

/* Mobile Controls */
.mobile-controls {
  display: none;
  flex-direction: column;
  gap: 15px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 20px;
}

.mobile-game-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.mobile-game-controls button {
  padding: 10px 20px;
  font-weight: bold;
  border-radius: 4px;
  background: transparent;
  color: #ffd700;
  border: 2px solid #ffd700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.mobile-game-controls button:hover {
  background: #ffd700;
  color: black;
}

.mobile-pattern-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.mobile-pattern-selector label {
  font-weight: bold;
  color: #ffd700;
}

.mobile-pattern-selector select {
  padding: 8px 12px;
  border-radius: 4px;
  border: 2px solid #ffd700;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.9rem;
  min-width: 200px;
}

.mobile-pattern-selector button {
  padding: 8px 16px;
  font-weight: bold;
  border-radius: 4px;
  background: transparent;
  color: #ffd700;
  border: 2px solid #ffd700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.mobile-pattern-selector button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mobile-pattern-selector button:not(:disabled):hover {
  background: #ffd700;
  color: black;
}

.mobile-rules-toggle button {
  padding: 10px 20px;
  font-weight: bold;
  border-radius: 4px;
  background: transparent;
  color: #ffd700;
  border: 2px solid #ffd700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  width: 100%;
  max-width: 250px;
}

.mobile-rules-toggle button:hover {
  background: #ffd700;
  color: black;
}

/* Pattern Preview Modal */
.pattern-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8);
}

.pattern-modal-content {
  background-color: #1a1a1a;
  margin: 10% auto;
  padding: 20px;
  border: 2px solid #ffd700;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  position: relative;
  color: white;
}

.pattern-modal-close {
  color: #ffd700;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.pattern-modal-close:hover {
  color: white;
}

#pattern-modal-title {
  color: #ffd700;
  margin: 0 0 15px 0;
  text-align: center;
}

#pattern-modal-preview {
  display: flex;
  justify-content: center;
  margin: 15px 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

#pattern-modal-description {
  text-align: center;
  color: #ccc;
  margin: 15px 0;
  font-size: 0.9rem;
}

.pattern-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.pattern-modal-actions button {
  padding: 10px 20px;
  font-weight: bold;
  border-radius: 4px;
  border: 2px solid #ffd700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

#place-pattern {
  background: #ffd700;
  color: black;
}

#place-pattern:disabled {
  background: transparent;
  color: #666;
  border-color: #666;
  cursor: not-allowed;
}

#place-pattern:not(:disabled):hover {
  background: #ffed4e;
  transform: translateY(-1px);
}

#cancel-pattern {
  background: transparent;
  color: #ffd700;
}

#cancel-pattern:hover {
  background: #ffd700;
  color: black;
}

.main-layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  gap: 40px;
}
.game-rules,
.game-history {
  flex: 1 1 300px;
  color: white;
  background: transparent;
  margin-top: 20px;
  text-align: left;
  max-width: 350px;
}
.game-rules h2,
.game-history h2 {
  margin-bottom: 8px;
}
.game-rules ul {
  padding-left: 20px;
}
.game-center {
  flex: 2 1 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0; /* Allow shrinking */
}
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

.rules-customization {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.rules-customization h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #ffd700;
}

.rule-input {
  margin-bottom: 15px;
}

.rule-input label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.rule-input input {
  width: 100%;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #555;
  border-radius: 4px;
  color: white;
  font-size: 14px;
}

.rule-input input:focus {
  outline: none;
  border-color: #ffd700;
}

.rule-input small {
  display: block;
  margin-top: 3px;
  color: #ccc;
  font-size: 12px;
}

#apply-rules {
  background: #ffd700;
  color: black;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s;
}

#apply-rules:hover {
  background: #ffed4e;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal[open] {
  display: flex;
}

.modal-box {
  background: #1a1a1a;
  border: 2px solid #ffd700;
  border-radius: 12px;
  padding: 20px;
  min-width: 320px;
  max-width: 500px;
  position: relative;
  color: white;
}

.modal-box h3 {
  margin: 0 0 15px 0;
  color: #ffd700;
  font-size: 1.25rem;
  font-weight: bold;
}

.modal-box p {
  margin: 0;
  line-height: 1.5;
}

.btn {
  background: #ffd700;
  color: black;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s;
}

.btn:hover {
  background: #ffed4e;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.875rem;
}

.btn-circle {
  border-radius: 50%;
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost {
  background: transparent;
  color: #ffd700;
  border: 1px solid #ffd700;
}

.btn-ghost:hover {
  background: #ffd700;
  color: black;
}

.absolute {
  position: absolute;
}

.right-2 {
  right: 8px;
}

.top-2 {
  top: 8px;
}

.text-lg {
  font-size: 1.125rem;
}

.font-bold {
  font-weight: bold;
}

.py-4 {
  padding-top: 16px;
  padding-bottom: 16px;
}

.title {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  font-size: 2.5em;
  text-align: center;
}

/* Spaceship Gallery Styles */

.spaceship-patterns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 25px;
  justify-content: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* For very large screens, create a more organized layout */
@media (min-width: 1200px) {
  .spaceship-patterns {
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
  }
}

@media (min-width: 1600px) {
  .spaceship-patterns {
    grid-template-columns: repeat(5, 1fr);
    gap: 35px;
  }
}

.spaceship-gallery {
  margin-top: 20px;
}

.click-instruction {
  color: #ffd700;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 20px;
  text-align: center;
}

.ship-display {
  margin-bottom: 0; /* Remove bottom margin since grid handles spacing */
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%; /* Use full grid cell width */
  flex-shrink: 0;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 200px; /* Ensure consistent card heights */
}

.ship-display.clickable {
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.ship-display.clickable:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: #ffd700;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
}

.ship-display.clickable:active {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.ship-display h4 {
  margin: 0 0 15px 0;
  color: #ffd700;
  font-size: 1.2rem;
  text-align: center;
  font-weight: bold;
}

/* Enhanced pattern container */
.ship-pattern {
  display: grid;
  grid-gap: 1px;
  margin: 15px 0;
  justify-content: center;
  background: #2c0202;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #555;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ship-pattern .cell {
  width: 14px;
  height: 14px;
  background: #5b0202;
  border: 1px solid #2c0202;
  transition: background 0.2s ease;
}

.ship-pattern .cell.alive {
  background: #efe9e9;
  box-shadow: 0 0 3px rgba(239, 233, 233, 0.5);
}

/* Category Headers */
.pattern-category-header {
  grid-column: 1 / -1; /* Span all columns */
  text-align: center;
  margin: 30px 0 20px 0;
  padding: 20px;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.1),
    rgba(255, 215, 0, 0.05)
  );
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.pattern-category-header h3 {
  margin: 0 0 10px 0;
  color: #ffd700;
  font-size: 1.5rem;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.pattern-category-header p {
  margin: 0;
  color: #ddd;
  font-size: 1rem;
  opacity: 0.9;
}

/* Special styling for different categories */
.spaceships-header {
  border-color: rgba(0, 255, 127, 0.3);
  background: linear-gradient(
    135deg,
    rgba(0, 255, 127, 0.1),
    rgba(0, 255, 127, 0.05)
  );
}

.spaceships-header h3 {
  color: #00ff7f;
}

.oscillators-header {
  border-color: rgba(255, 165, 0, 0.3);
  background: linear-gradient(
    135deg,
    rgba(255, 165, 0, 0.1),
    rgba(255, 165, 0, 0.05)
  );
}

.oscillators-header h3 {
  color: #ffa500;
}

.generators-header {
  border-color: rgba(255, 20, 147, 0.3);
  background: linear-gradient(
    135deg,
    rgba(255, 20, 147, 0.1),
    rgba(255, 20, 147, 0.05)
  );
}

.generators-header h3 {
  color: #ff1493;
}

.methuselahs-header {
  border-color: rgba(138, 43, 226, 0.3);
  background: linear-gradient(
    135deg,
    rgba(138, 43, 226, 0.1),
    rgba(138, 43, 226, 0.05)
  );
}

.methuselahs-header h3 {
  color: #8a2be2;
}

.stilllifes-header {
  border-color: rgba(255, 255, 255, 0.3);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
}

.stilllifes-header h3 {
  color: #ffffff;
}

.ship-display p {
  margin: 15px 0 0 0;
  font-size: 0.95rem;
  color: #ddd;
  line-height: 1.5;
  text-align: center;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Styles for patterns that are too large for current grid */
.ship-display.pattern-too-large {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
  position: relative;
}

.ship-display.pattern-too-large::before {
  content: "TOO LARGE";
  position: absolute;
  top: 5px;
  right: 5px;
  background: #ff6b6b;
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 3px;
  z-index: 1;
}

.ship-display.pattern-too-large h4 {
  color: #ff6b6b;
}

.ship-display.pattern-too-large .ship-pattern {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.size-info {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid #ff6b6b;
  border-radius: 4px;
  padding: 5px 8px;
  margin-top: 8px !important;
}

@media (max-width: 900px) {
  :root {
    --cell-size: 16px;
    --cell-gap: 1px;
  }
  .main-layout {
    gap: 18px;
  }
  .game-rules,
  .game-history {
    max-width: 320px;
  }
}

@media (max-width: 768px) {
  /* Show mobile controls on tablets and phones */
  .mobile-controls {
    display: flex;
  }

  /* Hide desktop pattern gallery and category headers */
  .spaceship-patterns {
    display: none;
  }

  .pattern-category-header {
    display: none;
  }

  .click-instruction {
    display: none;
  }

  /* Collapse rules section by default on mobile */
  .game-rules {
    display: none;
  }

  .game-rules.mobile-expanded {
    display: block;
    order: 3;
  }

  .game-history {
    display: none;
  }

  /* Adjust main layout for mobile */
  .main-layout {
    flex-direction: column;
    align-items: center;
  }

  .game-center {
    order: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Hide desktop controls */
  .game-center > .container > div {
    display: none;
  }
}

@media (max-width: 640px) {
  /* Phone layout — stack columns and shrink content */
  :root {
    --cell-size: 12px;
    --cell-gap: 1px;
  }

  .main-layout {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 16px;
  }

  .game-center,
  .game-rules,
  .game-history {
    width: 100%;
    max-width: none;
  }

  /* Make the grid container responsive */
  #game {
    justify-content: center;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px;
    max-width: 100vw;
  }

  /* Smaller mobile controls */
  .mobile-game-controls button {
    padding: 8px 16px;
    font-size: 0.8rem;
  }

  .mobile-pattern-selector select {
    min-width: 180px;
  }
}

/* Make controls easier to tap */
button,
.btn {
  padding: 10px 14px;
  font-size: 16px;
  border-radius: 8px;
}

/* Titles and modal sizing */
.title {
  font-size: 1.6em;
  height: 64px;
}
.modal-box {
  width: 92%;
  max-width: none;
  padding: 16px;
}
.click-instruction {
  font-size: 0.9rem;
}

/* Very narrow phones: make sure things remain usable */
@media (max-width: 480px) {
  :root {
    --cell-size: 8px;
    --cell-gap: 1px;
  }
  .title {
    font-size: 1.4rem;
    height: 56px;
  }
  button,
  .btn {
    font-size: 15px;
    padding: 9px 12px;
  }

  /* Even smaller spaceship cards for small phones */
  .ship-display {
    width: 140px;
    padding: 10px;
  }
}

/* Extra narrow phones */
@media (max-width: 380px) {
  :root {
    --cell-size: 6px;
    --cell-gap: 1px;
  }
  .title {
    font-size: 1.25rem;
    height: 56px;
  }
  button,
  .btn {
    font-size: 14px;
    padding: 8px 10px;
  }

  /* Smallest spaceship cards for tiny screens */
  .ship-display {
    width: 120px;
    padding: 8px;
  }
}

.btn-ghost-lg {
  padding: 10px 20px; /* match #apply-rules */
  font-weight: bold;
  border-radius: 4px;
  background: transparent;
  color: #ffd700;
  border: 2px solid #ffd700; /* slightly thicker so it reads at larger size */
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.08s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
}

.btn-ghost-lg:hover {
  background: #ffd700;
  color: black;
  transform: translateY(-1px);
}

/* Ensure small-variant still works if needed */
.btn-ghost-lg.btn-sm {
  padding: 8px 14px;
  font-size: 0.95rem;
}

/* Optional: target common IDs if your HTML uses them (keeps markup changes optional) */
#start,
#stop,
#reset {
  /* only apply if these are plain buttons without classes */
  padding: 10px 20px;
  font-weight: bold;
  border-radius: 4px;
  background: transparent;
  color: #ffd700;
  border: 2px solid #ffd700;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.08s;
}

#start:hover,
#stop:hover,
#reset:hover {
  background: #ffd700;
  color: black;
  transform: translateY(-1px);
}

/* Fullscreen mode styles */
#fullscreen-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: black;
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

#fullscreen-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  flex-wrap: wrap;
  justify-content: center;
}

#fullscreen-controls button {
  padding: 10px 20px;
  font-weight: bold;
  border-radius: 4px;
  background: transparent;
  color: #ffd700;
  border: 2px solid #ffd700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

#fullscreen-controls button:hover {
  background: #ffd700;
  color: black;
  transform: translateY(-1px);
}

#exit-fullscreen {
  background: #ff6b6b !important;
  border-color: #ff6b6b !important;
  color: white !important;
}

#exit-fullscreen:hover {
  background: #ff5252 !important;
  border-color: #ff5252 !important;
  color: white !important;
}

#fullscreen-tick-counter {
  color: #ffd700;
  font-weight: bold;
  font-size: 1.1rem;
  margin-left: 20px;
}

#fullscreen-game {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: auto;
}

/* Fullscreen pattern selector */
#fullscreen-patterns {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 215, 0, 0.2);
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  align-items: center;
  max-height: 120px;
  overflow-y: auto;
}

.fullscreen-pattern-category {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pattern-category-title {
  color: #ffd700;
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
}

.fullscreen-pattern-btn {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 3px;
  background: transparent;
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.fullscreen-pattern-btn:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: #ffd700;
  color: #ffd700;
  transform: translateY(-1px);
}

.fullscreen-pattern-btn:active {
  transform: translateY(0);
}

/* Override cell size in fullscreen mode */
#fullscreen-container #game {
  margin-bottom: 0;
}

#fullscreen-container .cell {
  width: 8px;
  height: 8px;
} /* Mobile fullscreen adjustments */
@media (max-width: 768px) {
  #fullscreen-controls {
    flex-wrap: wrap;
    padding: 10px;
    gap: 10px;
  }

  #fullscreen-controls button {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  #fullscreen-tick-counter {
    margin-left: 0;
    margin-top: 10px;
    width: 100%;
    text-align: center;
  }

  #fullscreen-container .cell {
    width: 6px;
    height: 6px;
  }

  /* Mobile pattern selector adjustments */
  #fullscreen-patterns {
    padding: 8px 15px;
    gap: 10px;
    max-height: 100px;
  }

  .fullscreen-pattern-category {
    gap: 6px;
  }

  .pattern-category-title {
    font-size: 0.8rem;
  }

  .fullscreen-pattern-btn {
    padding: 3px 6px;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  #fullscreen-controls button {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  #fullscreen-container .cell {
    width: 4px;
    height: 4px;
  }

  /* Very small mobile pattern selector */
  #fullscreen-patterns {
    padding: 6px 10px;
    gap: 8px;
    max-height: 80px;
    flex-direction: column;
  }

  .fullscreen-pattern-category {
    gap: 4px;
    justify-content: center;
  }

  .pattern-category-title {
    font-size: 0.75rem;
    margin-right: 5px;
  }

  .fullscreen-pattern-btn {
    padding: 2px 5px;
    font-size: 0.65rem;
  }
}

/* Authentication System Styles */
#auth-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  background: rgba(26, 26, 26, 0.95);
  border: 2px solid #ffd700;
  border-radius: 12px;
  padding: 20px;
  min-width: 300px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.auth-panel {
  color: white;
}

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

.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 10px;
}

#username-display {
  color: #ffd700;
  font-weight: bold;
  text-align: center;
  flex: 1;
}

.minimize-btn {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
  border: 1px solid #ffd700;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  margin-left: 10px;
}

.minimize-btn:hover {
  background: #ffd700;
  color: black;
}

.user-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

/* Minimized state */
#auth-container.minimized {
  min-width: 200px;
}

#auth-container.minimized .user-actions {
  display: none !important;
}

.auth-forms {
  display: flex;
  flex-direction: column;
}

.auth-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 10px 15px;
  background: transparent;
  color: #ccc;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
}

.auth-tab.active {
  background: #ffd700;
  color: black;
}

.auth-tab:hover:not(.active) {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-form h3 {
  margin: 0 0 10px 0;
  color: #ffd700;
  text-align: center;
}

.auth-form input {
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: white;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: #ffd700;
  background: rgba(255, 255, 255, 0.15);
}

.auth-form input::placeholder {
  color: #aaa;
}

.auth-btn {
  padding: 12px 20px;
  background: #ffd700;
  color: black;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.3s ease;
}

.auth-btn:hover {
  background: #ffed4e;
  transform: translateY(-1px);
}

.auth-btn:active {
  transform: translateY(0);
}

/* Profile Modal Styles */
.profile-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.profile-info p {
  margin: 8px 0;
  color: #ddd;
}

.profile-info strong {
  color: #ffd700;
}

.game-stats {
  background: rgba(255, 215, 0, 0.1);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.game-stats h4 {
  margin: 0 0 10px 0;
  color: #ffd700;
}

.game-stats p {
  margin: 5px 0;
  color: #ddd;
}

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* Form styles in modals */
#change-password-form,
#update-email-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 15px;
}

#change-password-form input,
#update-email-form input {
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: white;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

#change-password-form input:focus,
#update-email-form input:focus {
  outline: none;
  border-color: #ffd700;
  background: rgba(255, 255, 255, 0.15);
}

#change-password-form input::placeholder,
#update-email-form input::placeholder {
  color: #aaa;
}

/* Message Container */
.message-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.message {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: bold;
  text-align: center;
  min-width: 250px;
  animation: slideIn 0.3s ease, slideOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

.message-success {
  background: rgba(76, 175, 80, 0.9);
  color: white;
  border: 2px solid #4caf50;
}

.message-error {
  background: rgba(244, 67, 54, 0.9);
  color: white;
  border: 2px solid #f44336;
}

.message-info {
  background: rgba(33, 150, 243, 0.9);
  color: white;
  border: 2px solid #2196f3;
}

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

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

/* Mobile Authentication Styles */
@media (max-width: 768px) {
  #auth-container {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    margin: 10px;
    min-width: auto;
    max-width: calc(100% - 20px);
  }

  .auth-toggle {
    margin-bottom: 15px;
  }

  .auth-tab {
    padding: 8px 12px;
    font-size: 14px;
  }

  .auth-form input {
    padding: 10px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .auth-btn {
    padding: 10px 16px;
    font-size: 16px;
  }

  .profile-actions {
    flex-direction: column;
  }

  .profile-actions .btn {
    min-width: auto;
  }

  .message {
    min-width: 200px;
    font-size: 14px;
    padding: 10px 16px;
  }
}

@media (max-width: 480px) {
  #auth-container {
    margin: 5px;
    padding: 15px;
    max-width: calc(100% - 10px);
  }

  .auth-form {
    gap: 12px;
  }

  .auth-form input,
  .auth-btn {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  #change-password-form,
  #update-email-form {
    gap: 12px;
  }

  .message {
    min-width: 180px;
    margin: 0 10px;
  }
}
