.calendar__page {
  background-color: #074033;
  margin-left: 0;
  margin-right: 0;
  padding-bottom: 220px;
  margin-bottom: -250px;
}

.calendar__header {
  color: #fff;
  text-align: center;
  background-image: url('/local/templates/kitfort_new25(1)/img/calendar-header-n.png');
  background-position: center;
  height: 306px;
}

.calendar__header h1 {
  font-weight: 800;
  font-size: 30px;
  margin: 0 0 25px 0;
  line-height: 1.2;
}

.calendar__header p {
  margin: 30px 0 15px;
  font-size: 19px;
  padding: 0 10px;
  line-height: 1;
}

.calendar__label {
  display: inline-block;
  font-weight: 700;
  font-size: 30px;
  padding: 13px 20px;
  background-color: #F45252;
  border-radius: 60px;
  /*animation: float 1s ease-in-out infinite;*/
}

.calendar__counter {
  display: inline-block;
  color: #fff;
  font-size: 17px;
  padding: 4px 20px;
  background-color: #2D517C;
  border-radius: 55px;
}

/* --- GRID SYSTEM --- */
.calendar__container {
  max-width: 1320px;
  margin: 30px auto;
  padding: 0 20px;
}

.grid {
  display: grid;
  /* Mobile Default: 2 Columns (matches iPhone reference) */
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* Desktop override */
@media (max-width: 768px) {
.calendar__header {
  background-image: url('/local/templates/kitfort_new25(1)/img/calendar-header-n2.png');
  background-position: center;
}
}


@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 15px;
  }

  .calendar__header {
    padding: 30px 20px 42px;
  }

  .calendar__header h1 {
    font-size: 72px;
  }

}

/* --- FLIP CARD --- */
.day-item {
  height: 170px; /* Slightly shorter for mobile to fit more on screen */
  perspective: 1000px;
  cursor: pointer;
  position: relative;
  /* Remove default tap highlight */
  user-select: none;
}

.day-item.past {
  pointer-events: none;
}


.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

.day-item.flipped .card-inner {
  transform: rotateY(180deg);
}

.day-item:not(.future) .card-front {
  padding-top: 12px;
}

.day-item.future .date-text {
  margin-bottom: 10px;
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s;
}

.card-front:hover {
  transform: scale(1.03);
}

/* TYPOGRAPHY INSIDE CARDS */
.date-num {
  font-size: 96px;
  font-weight: 700;
  line-height: 0.8;
  color: #fff;
  margin-top: 15px;
}

.date-text {
  font-size: 19px;
  font-weight: 700;
  text-transform: uppercase;
  color: #2D517C;
}

/* STATE: ACTIVE (Today) */
.day-item.active .card-front {
  background: #F45252;
  box-shadow: 0 0 15px rgba(244, 82, 82, 0.2);
  animation: pulse-animation 2s infinite;
}

.day-item.active .date-num, .day-item.active .date-text {
  color: #fff;
}

.day-item.active .card-back {
  border: 3px solid #F45252;
  animation: pulse-animation 2s infinite;
}

/* STATE: PAST */
.day-item.past .card-front {
  background-color: #fff;
}

.active-day-text {
  color: #fff;
  font-size: 17px;
}

.day-item:not(.future) .card-icon {
  display: none;
}

.day-item.past .card-back {
  border: 2px solid #ddd;
}

.day-item.future .card-front {
  background-image: url('/local/templates/kitfort_new25(1)/img/icons/snowflakes.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

.day-item.future .card-back {
  border: 2px solid #CDDC69;
}

/* BACK FACE CONTENT */
.card-back {
  transform: rotateY(180deg);
  background-color: #fff;
}

.prize-icon {
  width: 50px;
  height: 50px;
  margin-bottom: 8px;
  object-fit: contain;
}

.day-item.past .prize-icon {
  opacity: 0.6;
}

.prize-name {
  font-size: 12px;
  font-weight: 700;
  padding: 0 5px;
  line-height: 1.2;
  color: #2C504C;
  height: 35px;
  overflow: hidden;
}

.day-item.past .prize-name {
  color: #777;
}

.card-bar {
  font-size: 12px;
  padding: 0 18px;
  border-radius: 22px;
  margin-bottom: 15px;
}

.card-bar.discount {
  color: #827717;
  background-color: #F0F4C3;
}

.card-bar.prize {
  color: #0277BD;
  background-color: #E1F5FE;
}

.card-bar.promo {
  color: #E65100;
  background-color: #FFE0B2;
}

.day-item.past .card-bar {
  color: #777;
  background-color: #F3F2F4;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pulse-animation {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 82, 82, 0.6);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(244, 82, 82, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(244, 82, 82, 0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* --- MODAL MOBILE OPTIMIZED --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 60, 64, 0.85); /* Darker background for focus */
  z-index: 2000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 500px; /* Fits nicely on iPhone 11 width (414px) */
  border-radius: 16px;
  padding: 30px 32px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Handle landscape or small screens */
  max-height: 85vh;
  overflow-y: auto;
}

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

.close-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 32px;
  color: #ccc;
  cursor: pointer;
  line-height: 0.8;
  padding: 5px; /* Larger touch area */
}

.close-modal_swipe {
  width: 50px;
  height: 5px;
  margin: 0px auto 16px auto;
  background-color: #D9D9D9;
  border-radius: 26px;
  display: none;
}

.modal-product-link {
  display: inline-block;
  text-decoration: none;
}

.modal-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin: 0 auto 2px;
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  color: #781ECD;
  margin: 0 0 7px;
  line-height: 1.2;
}

.modal-desc {
  font-size: 13px;
  color: #666;
  margin-bottom: 15px;
  line-height: 1.4;
}

/* Task Box */

.discount-box {
  background-color: #F9FBEF;
  border: 2px dashed #AAB656;
  border-radius: 15px;
  padding: 16px;
  margin-bottom: 10px;
}

.modal-content[data-type="prize"] .discount-box {
  background-color: #E1F5FE;
  border: 2px dashed #0277BD;
}

.modal-content[data-type="promo"] .discount-box {
  background-color: #FFE0B2;
  border: 2px dashed #E65100;
}

.modal-content.expired .discount-box {
  background-color: #F3F2F4;
  border-color: #999;
}

.highlight-text {
  font-size: 19px;
  font-weight: 700;
  color: #AAB656;
  line-height: 1;
  margin-bottom: 4px;
}

.modal-content[data-type="prize"] .highlight-text {
  color: #0277BD;
}

.modal-content[data-type="promo"] .highlight-text {
  color: #E65100;
}

.task-text {
  font-size: 14px;
  color: #2C504C;
  line-height: 1.2;
}

.modal-footer-text {
  font-size: 14px;
  color: #777;
  line-height: 1.3;
  margin-bottom: 6px;
}

.modal-content.expired .highlight-text,
.modal-content.expired .task-text,
.modal-content.expired .modal-footer-text {
  color: #999;
}

.modal-content.expired .highlight-text {
  text-decoration: line-through;
}

/* Mobile Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 16px; /* Taller for touch */
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: none;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.modal-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 400;
  transition: 0.5s;
  background-color: #781ECD;
  color: #fff;
  border: 1px solid #781ECD;
}

.modal-btn:hover {
  background-color: #f3e5f5;
}

.modal-btn.btn-outline {
  background-color: #fff;
  color: #781ECD;
}

.modal-btn.btn-outline:hover {
  background-color: #f3e5f5;
}

@media (max-width: 1060px) {
  main.calendar__page {
    padding-top: 78px !important;
  }
}

@media (max-width: 767px) {
  .grid {
    gap: 15px;
  }
  .calendar__header {
    height: 255px;
    padding-top: 50px;
  }
  .calendar__header h1 {
    letter-spacing: unset;
    margin-bottom: 30px;
    line-height: 1;
  }

  .calendar__label {
    font-size: 17px;
    padding: 8px 20px;
  }

  .calendar__header p {
    font-size: 14px;
    margin: 30px 0 11px;
  }

  .calendar__counter {
    font-size: 14px;
  }

  .calendar__container {
    margin-top: 30px;
    padding: 0 16px;
  }

  .day-item {
    height: 156px;
  }
}

@media (max-width: 660px) {
  main.calendar__page {
    margin-top: 16px;
  }
}

@media (max-width: 450px) {
  .calendar__header {
    background-image: url('/local/templates/kitfort_new25(1)/img/calendar-header-n3.png');
    background-position: center;
  }
}

@keyframes swipeOut {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100vh);
  }
}

@media (max-width: 500px) {
  .modal-content {
    padding: 16px;
  }

  .modal-content .close-modal {
    display: none;
  }

  .modal-content .close-modal_swipe {
    display: block;
  }

  .modal-overlay {
    height: calc(100% - 70px);
    transition: opacity 0.3s ease-out;
  }

  .modal-overlay .modal-content {
    position: fixed;
    bottom: 0;
    box-shadow: none;
    border-radius: 30px 30px 0 0;
    transform: translateY(0);
    transition: transform 0.3s ease-out;
  }

  .modal-content.swiping-down {
    animation: swipeOut 0.3s ease-out forwards;
  }

  .discount-box {
    margin-bottom: 15px;
  }

  .modal-footer-text {
    margin-bottom: 15px;
  }
}