:root {
  --bg-color: #f0f2f5;
  --text-color: #333;
  --primary-color: #4CAF50;
  --secondary-color: #f44336;
  --card-bg: rgba(255, 255, 255, 0.9);
  --shadow-color: rgba(0, 0, 0, 0.2);
  --accent-glow: rgba(76, 175, 80, 0.4);
}

.dark-mode {
  --bg-color: #1a1a1a;
  --text-color: #f0f2f5;
  --primary-color: #81c784;
  --secondary-color: #e57373;
  --card-bg: rgba(45, 45, 45, 0.85);
  --shadow-color: rgba(0, 0, 0, 0.6);
  --accent-glow: rgba(129, 199, 132, 0.4);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  color: var(--text-color);
  text-align: center;
  transition: background-color 0.5s ease, color 0.5s ease;
  background-color: var(--bg-color);
}

#background-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  z-index: 0;
  transition: opacity 1s ease-in-out;
  pointer-events: none;
}

#background-overlay::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("https://www.transparenttextures.com/patterns/carbon-fibre.png");
  opacity: 0.1;
  z-index: 1;
}

.main-container, .theme-toggle-container, #painting-info {
  position: relative;
  z-index: 10;
}

.main-container {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 24px;
  box-shadow: 0 20px 50px var(--shadow-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 85%;
  width: 450px;
  animation: fadeIn 1s ease-out;
  margin: 20px;
}

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

h1 {
  color: var(--primary-color);
  margin-bottom: 25px;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 2px var(--shadow-color);
}

#lotto-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 20px 0;
  min-height: 60px;
}

.lotto-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
  margin: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), #45a049);
  color: white;
  font-size: 1.2em;
  font-weight: bold;
  box-shadow: 0 5px 12px var(--accent-glow);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lotto-number:hover {
  transform: scale(1.15) rotate(5deg);
  filter: brightness(1.2);
}

#generate-button {
  padding: 14px 28px;
  font-size: 1.1em;
  font-weight: bold;
  color: white;
  background: linear-gradient(135deg, var(--secondary-color), #d32f2f);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 15px rgba(244, 67, 54, 0.3);
}

#generate-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(244, 67, 54, 0.4);
}

.theme-toggle-container {
  position: fixed;
  top: 15px;
  right: 15px;
}

.toggle-btn {
  background: var(--card-bg);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid var(--primary-color);
  color: var(--text-color);
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 600;
  box-shadow: 0 4px 10px var(--shadow-color);
}

#painting-info {
  position: fixed;
  bottom: 15px;
  left: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75em;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0.8;
  max-width: fit-content;
  pointer-events: none;
}

/* Comment Section Styles */
.comment-section {
  margin-top: 40px;
  text-align: left;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 20px;
}

.dark-mode .comment-section {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.comment-section h3 {
  font-size: 1.1rem;
  margin-bottom: 15px;
  color: var(--primary-color);
}

#comment-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 5px;
}

#comment-list::-webkit-scrollbar {
  width: 4px;
}
#comment-list::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

.comment-item {
  background: rgba(255, 255, 255, 0.5);
  padding: 10px 15px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  box-shadow: 0 2px 5px var(--shadow-color);
  animation: slideIn 0.3s ease-out;
}

.dark-mode .comment-item {
  background: rgba(0, 0, 0, 0.3);
}

.comment-item .name {
  font-weight: bold;
  color: var(--primary-color);
  margin-right: 8px;
}

.comment-input-group {
  display: flex;
  flex-direction: column; /* Stacked by default for mobile */
  gap: 10px;
}

.comment-input-row {
  display: flex;
  gap: 8px;
}

.comment-input-group input {
  background: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 12px;
  border-radius: 10px;
  color: var(--text-color);
  font-size: 1rem;
  width: 100%;
}

.dark-mode .comment-input-group input {
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#comment-name {
  width: 100px;
}

#comment-text {
  flex-grow: 1;
}

#submit-comment {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
  width: 100%; /* Full width for mobile */
}

#submit-comment:hover {
  filter: brightness(1.1);
}

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

/* Mobile Optimizations */
@media (max-width: 480px) {
  h1 { font-size: 1.2rem; }
  .lotto-number { width: 40px; height: 40px; font-size: 1em; }
  .main-container { padding: 20px; width: 90%; }
}

@media (min-width: 481px) {
  .comment-input-group {
    flex-direction: row;
    align-items: center;
  }
  #submit-comment {
    width: auto;
    padding: 10px 20px;
  }
}
