* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", Arial, sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(circle at 25% 20%, rgba(236, 72, 153, 0.2), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(34, 211, 238, 0.2), transparent 30%),
    linear-gradient(180deg, #160328 0%, #0a1124 100%);
  color: #f9f6ff;
}

.container {
  width: min(980px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-left)) 1.75rem max(1rem, env(safe-area-inset-right));
  padding-bottom: max(1.75rem, env(safe-area-inset-bottom));
}

.header h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.35rem, 4.2vw + 0.85rem, 2rem);
  line-height: 1.2;
}

.header p {
  margin: 0 0 1.25rem;
  color: #d9c8ff;
}

.ad-region {
  margin: 0 0 1rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  background: rgba(8, 12, 28, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.ad-region:last-of-type {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.ad-region__label {
  display: block;
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.38);
  margin-bottom: 0.32rem;
}

.ad-region__frame {
  max-width: 100%;
  overflow: hidden;
  text-align: center;
}

.ad-region__frame .adsbygoogle {
  display: block !important;
  margin-left: auto;
  margin-right: auto;
  opacity: 0.94;
}

.controls {
  display: block;
  margin-bottom: 1rem;
}

.calendar {
  width: min(320px, 100%);
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.04) 0px,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 10px
    ),
    linear-gradient(180deg, rgba(88, 28, 135, 0.85), rgba(49, 46, 129, 0.8));
  border: 1px solid rgba(236, 72, 153, 0.7);
  border-radius: 10px;
  padding: 0.42rem;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.25);
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.nav-group {
  display: flex;
  gap: 0.2rem;
}

.calendar-head h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fdf4ff;
}

.calendar-head button {
  border: 1px solid rgba(34, 211, 238, 0.7);
  background: rgba(8, 47, 73, 0.6);
  color: #67e8f9;
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
  font-size: 0.72rem;
  cursor: pointer;
  touch-action: manipulation;
}

.calendar-head button:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.85);
  outline-offset: 2px;
}

.calendar-head button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.calendar-hint {
  margin: 0.3rem 0 0.4rem;
  color: #e9d5ff;
  font-size: 0.64rem;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.weekday-row {
  margin-bottom: 0.2rem;
}

.weekday-row span {
  text-align: center;
  font-size: 0.56rem;
  color: #a5b4fc;
  text-transform: uppercase;
}

.day {
  min-height: 1.15rem;
  font-size: 0.6rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #7c8ab8;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(34, 211, 238, 0.25);
}

.day.available {
  border-color: rgba(34, 211, 238, 0.9);
  background: rgba(8, 145, 178, 0.28);
  color: #e0f2fe;
  cursor: pointer;
  box-shadow: inset 0 0 6px rgba(34, 211, 238, 0.25);
}

.day.available:hover,
.day.available:active {
  background: rgba(14, 165, 233, 0.45);
}

.day:focus-visible {
  outline: 2px solid rgba(244, 114, 182, 0.9);
  outline-offset: 1px;
}

.day.selected {
  border-color: rgba(244, 114, 182, 0.95);
  background: linear-gradient(180deg, #ec4899, #db2777);
  color: #ffffff;
  box-shadow: 0 0 8px rgba(236, 72, 153, 0.6);
}

.status {
  min-height: 1.25rem;
  margin-bottom: 0.8rem;
  color: #d8b4fe;
}

.status.error {
  color: #fda4af;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  background: rgba(10, 17, 36, 0.8);
  border: 1px solid rgba(167, 139, 250, 0.45);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 18rem;
  border-collapse: collapse;
}

thead {
  background: rgba(76, 29, 149, 0.55);
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.35);
}

th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  word-break: break-word;
  hyphens: auto;
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.12);
}

tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 639px) {
  .container {
    padding-top: max(0.85rem, env(safe-area-inset-top));
  }

  .calendar {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem 0.45rem;
  }

  .calendar-head {
    gap: 0.25rem;
  }

  .calendar-head button {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
  }

  .calendar-head h2 {
    font-size: 0.68rem;
    line-height: 1.25;
  }

  .weekday-row,
  .calendar-grid {
    gap: 0.28rem;
  }

  .weekday-row span {
    font-size: 0.5rem;
  }

  .day {
    min-height: 2.6rem;
    font-size: 0.72rem;
    border-radius: 5px;
  }

  .calendar-hint {
    font-size: 0.62rem;
  }

  .status {
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .table-wrap {
    border-radius: 6px;
  }

  table {
    font-size: 0.8125rem;
  }

  th,
  td {
    padding: 0.45rem 0.4rem;
    vertical-align: top;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 2.5rem;
    white-space: nowrap;
  }

  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5) {
    white-space: nowrap;
  }

  thead th:first-child,
  tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 4px 0 10px -6px rgba(0, 0, 0, 0.65);
  }

  thead th:first-child {
    z-index: 3;
    background: rgba(76, 29, 149, 0.98);
  }

  tbody td:first-child {
    background: rgba(10, 17, 36, 0.99);
  }

  tbody tr:hover td:first-child {
    background: rgba(20, 35, 55, 0.99);
  }
}
