.contest-calendar-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
}

.calendar-wrapper,
.calendar-contest-details {
  background: #fff;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.calendar-month-year {
  font-size: 2rem;
  font-weight: 700;
  color: #2846c3;
}

.calendar-nav-btn {
  background: #f5f5f5;
  border: none;
  border-radius: 50%;
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.calendar-nav-btn:hover {
  background: #2846c3;
  color: #fff;
}

.calendar-nav-btn i {
  font-size: 2rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border: 1px solid #e0e0e0;
  border-radius: 0.5rem;
  overflow: visible;
  position: relative;
}

.calendar-day-header {
  text-align: center;
  padding: 1rem;
  font-weight: 700;
  color: #666;
  font-size: 1.4rem;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  background: #f5f5f5;
}

.calendar-day-header:last-child {
  border-right: none;
}

.calendar-day-header.sunday {
  color: #e74c3c;
}

.calendar-day-header.saturday {
  color: #3498db;
}

.calendar-day {
  aspect-ratio: 1;
  padding: 0.8rem;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #fafafa;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  overflow: visible;
}

.calendar-day:nth-child(7n) {
  border-right: none;
}

.calendar-day.other-month {
  opacity: 0.3;
}

.calendar-day.today {
  background: #fff3e0;
  border: 2px solid #ff9800 !important;
  border-radius: 0;
}

/* 대회 바 스타일 - 여러 날짜에 걸친 대회를 연속된 바로 표시 */
.calendar-day.contest-bar-start {
  border-top-left-radius: 0.4rem;
  border-bottom-left-radius: 0.4rem;
}

.calendar-day.contest-bar-middle {
  border-radius: 0;
}

.calendar-day.contest-bar-end {
  border-top-right-radius: 0.4rem;
  border-bottom-right-radius: 0.4rem;
}

/* 주간 경계에서도 바가 연속되도록 처리 */
.calendar-day.contest-bar-continues-right {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

.calendar-day.contest-bar-continues-left {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}

/* 대회 바가 있는 날짜의 숫자 색상 - 원래 색상 유지 */

.calendar-day.selected {
  border: 2px solid #2846c3 !important;
  border-radius: 0;
}

.calendar-day.has-contest.selected:not(.contest-bar-start):not(
    .contest-bar-middle
  ):not(.contest-bar-end) {
  background: #bbdefb;
  border: 2px solid #2846c3 !important;
  border-radius: 0;
}

.calendar-day.contest-bar-start.selected,
.calendar-day.contest-bar-middle.selected,
.calendar-day.contest-bar-end.selected {
  border: 2px solid #2846c3 !important;
}

.calendar-day.today.selected {
  border: 2px solid #2846c3 !important;
  border-radius: 0;
}

.calendar-day.today.has-contest.selected {
  background: #bbdefb;
  border: 2px solid #2846c3 !important;
  border-radius: 0;
}

.calendar-day.today.contest-bar-start,
.calendar-day.today.contest-bar-middle,
.calendar-day.today.contest-bar-end {
  border: 2px solid #ff9800 !important;
}

.calendar-day.today.contest-bar-start.selected,
.calendar-day.today.contest-bar-middle.selected,
.calendar-day.today.contest-bar-end.selected {
  border: 2px solid #ff9800 !important;
}

.calendar-day-number {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.calendar-day.sunday .calendar-day-number {
  color: #e74c3c;
}

.calendar-day.saturday .calendar-day-number {
  color: #3498db;
}

/* badge 컨테이너 - 여러 행으로 배치 */
.calendar-contest-badges-container {
  position: absolute;
  top: 2.5rem;
  left: 0;
  width: auto;
  min-width: 100%;
  z-index: 10;
  overflow: visible;
  pointer-events: none;
}

.calendar-contest-badge {
  font-size: 1.3rem;
  background: #2846c3;
  color: #fff;
  padding: 0.4rem 0.6rem;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  position: absolute;
  text-align: left;
  height: auto;
  line-height: 1.2;
  min-width: 100%;
  flex-shrink: 0;
  left: 0;
  top: 0;
  z-index: 10;
  pointer-events: auto;
  display: block;
  visibility: visible;
}

/* 대한유도회 주최 대회 뱃지 스타일 */
.calendar-contest-badge.badge-korea-judo {
  background: #c62828;
}

/* 시작 날짜의 badge 컨테이너 - 뱃지 자체에 border-radius가 적용되므로 컨테이너 스타일 불필요 */

/* 시작 날짜의 첫 번째 badge는 왼쪽 둥근 모서리 */
.calendar-day.contest-bar-start
  .calendar-contest-badges-container
  .calendar-contest-badge:first-child {
  border-top-left-radius: 0.3rem;
}

/* 시작 날짜의 마지막 badge는 왼쪽 둥근 모서리 */
.calendar-day.contest-bar-start
  .calendar-contest-badges-container
  .calendar-contest-badge:last-child {
  border-bottom-left-radius: 0.3rem;
}

/* 단일 날짜인 경우 첫 번째 badge는 양쪽 위 둥근 모서리, 마지막 badge는 양쪽 아래 둥근 모서리 */
.calendar-contest-badge.badge-single-day:first-child {
  border-top-right-radius: 0.3rem;
}

.calendar-contest-badge.badge-single-day:last-child {
  border-bottom-right-radius: 0.3rem;
}

/* 여러 날짜에 걸친 경우 첫 번째 badge는 오른쪽 위 둥근 모서리, 마지막 badge는 오른쪽 아래 둥근 모서리 */
.calendar-contest-badge.badge-multi-day-end:first-child {
  border-top-right-radius: 0.3rem;
}

.calendar-contest-badge.badge-multi-day-end:last-child {
  border-bottom-right-radius: 0.3rem;
}

/* 주간 경계에서 분할된 뱃지 스타일 */
/* 대회의 시작이면서 주의 시작인 경우 - 왼쪽 둥근 모서리 */
.calendar-contest-badge.badge-week-start {
  border-top-left-radius: 0.3rem;
  border-bottom-left-radius: 0.3rem;
}

/* 대회의 끝이면서 주의 끝인 경우 - 오른쪽 둥근 모서리 */
.calendar-contest-badge.badge-week-end {
  border-top-right-radius: 0.3rem;
  border-bottom-right-radius: 0.3rem;
}

/* 주간 경계에서 분할된 중간 부분 - 양쪽 모두 직각 */
.calendar-contest-badge.badge-week-middle {
  border-radius: 0;
}

.calendar-contest-details {
  max-height: 80vh;
  overflow-y: auto;
}

.calendar-contest-details h3 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #2846c3;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e0e0e0;
}

.contest-details-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.no-contest-selected {
  text-align: center;
  color: #999;
  padding: 3rem 1rem;
  font-size: 1.4rem;
}

.calendar-contest-item {
  background: #f9f9f9;
  border-radius: 0.8rem;
  padding: 1.5rem;
  border-left: 4px solid #2846c3;
  cursor: pointer;
  transition: all 0.3s ease;
}

.calendar-contest-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.calendar-contest-header {
  cursor: pointer;
}

.calendar-contest-item h4 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 1rem;
}

.calendar-contest-item p {
  font-size: 1.3rem;
  color: #666;
  margin: 0.5rem 0;
}

.calendar-contest-item .contest-status {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 0.4rem;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.calendar-contest-expand {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0;
}

.calendar-contest-item.expanded .calendar-contest-expand {
  max-height: 500px;
  padding-top: 1.5rem;
}

.calendar-contest-item .textButton {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-contest-item .textButton button {
  width: 100%;
  background-color: var(--navy, #2846c3);
  border-radius: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
  padding: 1.4rem 0;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.calendar-contest-item .textButton button:hover {
  background-color: #1e35a0;
}

.calendar-contest-item .textButton button img {
  width: 1.2rem;
  height: 1.2rem;
  margin-right: 0.5rem;
}

.contest-status.ongoing {
  background: #4caf50;
  color: #fff;
}

.contest-status.ended {
  background: #9e9e9e;
  color: #fff;
}

.contest-status.upcoming {
  background: #ff9800;
  color: #fff;
}

@media (max-width: 1024px) {
  .contest-calendar-container {
    grid-template-columns: 1fr;
  }

  .calendar-contest-details {
    max-height: 50vh;
  }
}

@media (max-width: 768px) {
  .contest-calendar-container {
    overflow-x: visible;
    overflow-y: visible;
    width: 100%;
  }

  .calendar-wrapper {
    min-width: 0;
    padding: 1rem;
    overflow-x: visible;
    overflow-y: visible;
  }

  .calendar-contest-details {
    max-height: none;
    overflow-y: visible;
  }

  .calendar-header {
    margin-bottom: 1rem;
  }

  .calendar-month-year {
    font-size: 1.6rem;
  }

  .calendar-nav-btn {
    width: 3.5rem;
    height: 3.5rem;
  }

  .calendar-grid {
    gap: 0;
    min-width: 0;
    width: 100%;
    overflow: visible;
  }

  .calendar-day {
    padding: 0.5rem;
    min-width: 0;
    aspect-ratio: auto;
    min-height: 10rem;
  }

  .calendar-day-number {
    font-size: 1.2rem;
  }

  .calendar-day-header {
    padding: 0.5rem;
    font-size: 1.2rem;
  }

  .calendar-contest-badge {
    font-size: 1rem;
  }

  .calendar-contest-badges-container {
    top: 2.2rem;
  }

  .calendar-contest-details {
    padding: 1rem;
  }

  .calendar-contest-item {
    padding: 1rem;
  }

  .calendar-contest-item h4 {
    font-size: 1.4rem;
  }

  .calendar-contest-item p {
    font-size: 1.2rem;
  }

  .calendar-contest-item .textButton button {
    font-size: 1.2rem;
    padding: 1.2rem 0;
  }

  .calendar-contest-item .textButton button img {
    width: 1rem;
    height: 1rem;
  }
}
