body {
  font-family: Arial, sans-serif;
  text-align: center;
  margin: 0;
  background: #f5f5f5;
}

h1 {
  margin-top: 20px;
}

.calendar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

#calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  width: 90%;
  max-width: 700px; /* keeps it a nice calendar width */
  margin: 20px auto;
  padding: 10px;
}

/* Each day is a responsive square cell */
.day {
  position: relative;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  aspect-ratio: 1 / 1; /* maintains squares */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px;
  overflow: hidden;
  transition: background 0.2s ease, transform 0.1s ease;
}

.day:hover {
  background: #eef5ff;
  transform: scale(1.03);
}

.empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.today {
  background: #eef5ff;
  border: 2px solid #0056b3;
}

.day-number {
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.event-list {
  font-size: 0.7rem;
  line-height: 1.2;
  text-align: left;
  overflow-y: auto;
  width: 100%;
  flex-grow: 1;
}

.event-title {
  background: #f0f8ff;
  border-left: 3px solid #007bff;
  padding: 1px 3px;
  margin: 1px 0;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Weekday headers */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 90%;
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
  font-weight: bold;
  background: #007bff;
  color: white;
  border-radius: 6px;
  padding: 4px 0;
}

.weekdays div {
  padding: 6px;
}

/* Responsive adjustments */
@media (max-width: 700px) {
  #calendar, .weekdays {
    width: 100%;
    max-width: 100%;
  }
  .day {
    padding: 4px;
  }
  .day-number {
    font-size: 0.75rem;
  }
  .event-list {
    font-size: 0.6rem;
  }
}

.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* prevent body scroll */
  background-color: rgba(0, 0, 0, 0.5);
}

/* The modal content box */
.modal-content {
  background-color: #fefefe;
  margin: 5vh auto;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh; /* Prevent overflow beyond viewport */
  overflow-y: auto; /* Enable internal scrolling */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* The close button */
.close {
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close:hover {
  color: #000;
}

/* Smooth scroll inside modal */
.modal-content::-webkit-scrollbar {
  width: 8px;
}
.modal-content::-webkit-scrollbar-thumb {
  background-color: #bbb;
  border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
  background-color: #999;
}

.close {
  float: right;
  font-size: 28px;
  cursor: pointer;
}
