:root {
  --bg: #f5f3ea;
  --card: #fffaf0;
  --card-strong: #ffffff;
  --text: #171717;
  --muted: #666666;
  --border: #d9d2c2;
  --border-strong: #b9ad97;
  --accent: #2563eb;
  --danger: #ef4444;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.07);

  --hour-width: 64px;
  --resource-label-width: 74px;
  --week-row-height: 76px;
  --day-hour-height: 54px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.7), transparent 35%),
    var(--bg);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px max(12px, env(safe-area-inset-left)) 10px max(12px, env(safe-area-inset-right));
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: rgba(245, 243, 234, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  font-size: 24px;
}

.main-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 650;
}

.nav-link.active {
  border-color: var(--text);
  background: var(--card-strong);
}

.nav-link-primary {
  background: #202020;
  color: #ffffff;
}

.nav-link-primary:visited {
  color: #ffffff;
}

.nav-link-primary.active,
.nav-link-primary:active,
.nav-link-primary:hover {
  border-color: #202020;
  background: #202020;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px #ffffff;
}

.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 14px 12px 24px;
}

.content-card,
.calendar-page {
  border-radius: 20px;
}

.content-card {
  padding: 18px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.08;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

p {
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--card-strong);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn.active,
.btn:active {
  border-color: #111;
  box-shadow: inset 0 0 0 1px #111;
}

.btn-dark {
  border-color: #202020;
  background: #202020;
  color: #ffffff;
}

.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 4px 0 14px;
}

.toolbar-row {
  display: inline-flex;
  gap: 8px;
}

.calendar-title-block {
  margin: 8px 0 12px;
  text-align: center;
}

.calendar-title-block p {
  margin: 0;
}

.floor-tabs {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.floor-tab {
  min-height: 42px;
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  background: var(--card-strong);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  transform: scale(1);
  transition:
    background-color 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease,
    border-radius 180ms ease;
}

.floor-tab.active {
  border-color: #111;
  border-radius: 999px;
  background: #202020;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
  transform: scale(1.035);
}

.floor-tab.pulse {
  animation: floor-tab-pulse 220ms ease;
}

@keyframes floor-tab-pulse {
  0% { transform: scale(0.98); }
  100% { transform: scale(1.035); }
}

.loading-card,
.empty-card {
  padding: 18px;
  border-radius: 16px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
}

.week-calendar {
  display: grid;
  gap: 14px;
}

.week-day-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.week-day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.68);
}

.week-day-date {
  color: var(--muted);
  font-weight: 700;
}

.week-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.week-grid {
  position: relative;
  min-width: calc(var(--resource-label-width) + var(--hour-width) * 24);
}

.week-hours,
.week-resource-row {
  display: grid;
  grid-template-columns: var(--resource-label-width) repeat(24, var(--hour-width));
}

.corner-cell,
.hour-cell,
.resource-label {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.corner-cell,
.hour-cell {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
  background: rgba(255,255,255,0.65);
}

.corner-cell {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #fff8df;
}

.resource-label {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--week-row-height);
  padding: 6px;
  background: #fff8df;
  font-weight: 900;
  text-align: center;
}

.week-timeline {
  position: relative;
  grid-column: 2 / span 24;
  min-height: var(--week-row-height);
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(
      to right,
      rgba(0,0,0,0.09) 0,
      rgba(0,0,0,0.09) 1px,
      transparent 1px,
      transparent var(--hour-width)
    );
}

.week-event {
  position: absolute;
  top: 6px;
  height: calc(var(--week-row-height) - 12px);
  min-width: 34px;
  border-radius: 12px;
  padding: 7px 8px;
  overflow: hidden;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.15;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.event-time {
  font-weight: 900;
  white-space: nowrap;
}

.event-title {
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  opacity: 0.96;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-calendar {
  position: relative;
}

.day-desktop-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 12px;
}

.day-floor-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.day-floor-title {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.7);
  text-align: center;
  font-weight: 900;
  font-size: 20px;
}

.day-grid {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
}

.day-time-axis {
  display: grid;
  grid-template-rows: repeat(24, var(--day-hour-height));
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.65);
}

.day-time-label {
  display: flex;
  justify-content: center;
  align-items: start;
  padding-top: 4px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.day-timeline {
  position: relative;
  min-height: calc(var(--day-hour-height) * 24);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--day-hour-height) - 1px),
      rgba(0,0,0,0.13) calc(var(--day-hour-height) - 1px),
      rgba(0,0,0,0.13) var(--day-hour-height)
    );
}

.day-event {
  position: absolute;
  left: 6px;
  right: 6px;
  min-height: 42px;
  border-radius: 13px;
  padding: 8px;
  color: #ffffff;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.day-event .event-title {
  white-space: normal;
}

.now-line {
  position: absolute;
  left: 48px;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 20;
  pointer-events: none;
}

.now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.now-line-label {
  position: absolute;
  right: 4px;
  top: -17px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 800;
}

.day-desktop-now-label {
  position: absolute;
  top: -10px;
  left: 50%;
  z-index: 50;
  transform: translate(-50%, -100%);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  pointer-events: none;
}

@media (min-width: 761px) {
  .day-timeline .now-line-label {
    display: none;
  }
}

.open-games-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.open-game-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 18px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
}

.meta-grid {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  line-height: 1.35;
}

.open-game-description {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  white-space: pre-line;
  line-height: 1.4;
}

.card-actions {
  margin-top: auto;
  padding-top: 14px;
}

@media (max-width: 760px) {
  :root {
    --hour-width: 58px;
    --resource-label-width: 68px;
    --week-row-height: 82px;
    --day-hour-height: 52px;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-text {
    display: none;
  }

  .main-nav {
    width: 100%;
  }

  .nav-link {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 14px;
  }

  .page {
    padding-left: 8px;
    padding-right: 8px;
  }

  .calendar-toolbar {
    position: sticky;
    top: 88px;
    z-index: 80;
    padding: 8px 0;
    background: rgba(245, 243, 234, 0.9);
    backdrop-filter: blur(12px);
  }

  .btn {
    min-height: 38px;
    padding: 8px 11px;
  }

  .floor-tabs {
    display: grid;
    position: sticky;
    top: 150px;
    z-index: 70;
    padding: 8px 0;
    background: rgba(245, 243, 234, 0.9);
    backdrop-filter: blur(12px);
  }

  .day-desktop-grid {
    grid-template-columns: 1fr;
  }

  .day-floor-card:not(.mobile-active) {
    display: none;
  }

  .week-event {
    font-size: 11px;
  }

  .open-games-grid {
    grid-template-columns: 1fr;
  }
}


/* v3 fixes */

.calendar-title-block p {
  display: none;
}

.week-day-header {
  justify-content: flex-start;
}

.day-mobile-slider {
  display: none;
}

.day-mobile-track {
  display: flex;
  width: 100%;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.day-mobile-panel {
  flex: 0 0 100%;
  min-width: 100%;
}

.day-desktop-now-overlay {
  position: absolute;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 35;
  pointer-events: none;
}

.day-desktop-now-overlay::before {
  content: "";
  position: absolute;
  left: -6px;
  top: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
}

.day-desktop-now-overlay .day-desktop-now-label {
  position: absolute;
  left: 50%;
  top: -28px;
  transform: translateX(-50%);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .day-desktop-grid {
    display: none !important;
  }

  .day-mobile-slider {
    display: block;
    overflow: hidden;
  }

  .day-mobile-panel .day-floor-card {
    box-shadow: none;
  }

  .day-mobile-panel .day-floor-title {
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }
}


/* v4 fixes */

@media (max-width: 760px) {
  .brand-text {
    display: inline;
  }

  .day-mobile-panel .day-floor-card {
    display: block !important;
  }

  .day-mobile-panel .day-floor-card:not(.mobile-active) {
    display: block !important;
  }
}


/* v5 fixes */

:root {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --card: #1d1d1d;
  --card-strong: #242424;
  --text: #f4f4f4;
  --muted: #b9b9b9;
  --border: #3a3a3a;
  --border-strong: #666666;
  --accent: #60a5fa;
  --danger: #f87171;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.36);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.06), transparent 35%),
    var(--bg);
}

:root[data-theme="dark"] .site-header,
:root[data-theme="dark"] .calendar-sticky-controls,
:root[data-theme="dark"] .calendar-toolbar,
:root[data-theme="dark"] .floor-tabs {
  background: rgba(18, 18, 18, 0.94);
}

:root[data-theme="dark"] .resource-label,
:root[data-theme="dark"] .corner-cell {
  background: #25210f;
}

:root[data-theme="dark"] .hour-cell,
:root[data-theme="dark"] .day-time-axis,
:root[data-theme="dark"] .week-day-header,
:root[data-theme="dark"] .day-floor-title {
  background: rgba(255,255,255,0.04);
}

.calendar-sticky-controls {
  border-radius: 18px;
}

.calendar-toolbar {
  background: var(--bg);
  border-radius: 18px;
  padding: 8px;
  margin: 4px 0 8px;
}

.calendar-title-block p {
  display: none;
}

.week-calendar-merged {
  display: block;
}

.week-calendar-merged .week-scroll {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.week-calendar-merged .week-grid {
  overflow: hidden;
  border-radius: 18px;
}

.week-calendar-merged .week-hours {
  position: sticky;
  top: 0;
  z-index: 8;
}

.week-day-section {
  margin: 0;
  padding: 0;
}

.week-day-title-row {
  display: grid;
  grid-template-columns: var(--resource-label-width) calc(var(--hour-width) * 24);
}

.week-day-title-cell {
  position: sticky;
  left: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

.week-day-title-fill {
  min-height: 42px;
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
}

.week-calendar-merged .week-resource-row,
.week-calendar-merged .week-hours {
  grid-template-columns: var(--resource-label-width) repeat(24, var(--hour-width));
}

.week-calendar-merged .week-timeline {
  background-position-x: 0;
}

.theme-toggle {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 200;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 22px;
  cursor: pointer;
  opacity: 0.88;
  transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle:hover {
  opacity: 1;
}

@media (max-width: 760px) {
  .calendar-sticky-controls {
    position: sticky;
    top: 0;
    z-index: 80;
    margin: 0 -8px 10px;
    padding: 8px 8px 10px;
    background: rgba(245, 243, 234, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
  }

  .calendar-toolbar {
    position: static;
    top: auto;
    z-index: auto;
    background: var(--bg);
    border-radius: 18px;
    padding: 8px;
    margin: 0 0 8px;
  }

  .calendar-title-block {
    margin: 8px 0 10px;
  }

  .calendar-title-block p {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.25;
  }

  .floor-tabs {
    position: static;
    top: auto;
    z-index: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .theme-toggle {
    width: 44px;
    height: 44px;
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 18px);
    opacity: 0.72;
    font-size: 20px;
  }
}


/* v6 fixes */

/* Smooth theme switching */
body,
.site-header,
.calendar-sticky-controls,
.calendar-toolbar,
.floor-tabs,
.content-card,
.loading-card,
.empty-card,
.week-calendar-merged .week-scroll,
.week-day-title-cell,
.week-day-title-fill,
.week-day-card,
.week-day-header,
.corner-cell,
.hour-cell,
.resource-label,
.week-timeline,
.day-floor-card,
.day-floor-title,
.day-time-axis,
.day-timeline,
.open-game-card,
.btn,
.nav-link,
.floor-tab,
.theme-toggle {
  transition:
    background-color 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    opacity 220ms ease;
}

.theme-toggle-spin {
  animation: theme-toggle-spin 260ms ease;
}

@keyframes theme-toggle-spin {
  from { transform: rotate(-20deg) scale(0.92); }
  to { transform: rotate(0deg) scale(1); }
}

/* Telegram-like dark palette */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17212b;
  --card: #1f2c3a;
  --card-strong: #242f3d;
  --text: #f5f7fa;
  --muted: #93a4b5;
  --border: #344253;
  --border-strong: #4b5f73;
  --accent: #5288c1;
  --danger: #ff6b6b;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(82,136,193,0.16), transparent 34%),
    var(--bg);
}

:root[data-theme="dark"] .site-header,
:root[data-theme="dark"] .calendar-sticky-controls,
:root[data-theme="dark"] .calendar-toolbar,
:root[data-theme="dark"] .floor-tabs {
  background: rgba(23, 33, 43, 0.94);
}

:root[data-theme="dark"] .resource-label,
:root[data-theme="dark"] .corner-cell {
  background: #1b2836;
}

:root[data-theme="dark"] .hour-cell,
:root[data-theme="dark"] .week-day-title-cell,
:root[data-theme="dark"] .week-day-title-fill,
:root[data-theme="dark"] .day-time-axis,
:root[data-theme="dark"] .day-floor-title {
  background: #242f3d;
}

:root[data-theme="dark"] .btn,
:root[data-theme="dark"] .floor-tab,
:root[data-theme="dark"] .nav-link.active,
:root[data-theme="dark"] .theme-toggle {
  background: #242f3d;
  color: var(--text);
}

:root[data-theme="dark"] .floor-tab.active,
:root[data-theme="dark"] .nav-link-primary,
:root[data-theme="dark"] .nav-link-primary.active {
  background: #5288c1;
  border-color: #6aa1d8;
  color: #ffffff;
}

/* Week view v6:
   one horizontal scroll for the whole week,
   repeated time row under every day,
   sticky day labels and sticky floor labels. */
.week-calendar-merged .week-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}

.week-calendar-merged .week-grid {
  min-width: calc(var(--resource-label-width) + var(--hour-width) * 24);
}

.week-day-section {
  display: block;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.week-day-section:last-child {
  border-bottom: 0;
}

.week-day-title-row {
  display: grid;
  grid-template-columns: var(--resource-label-width) calc(var(--hour-width) * 24);
}

.week-day-title-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 48px;
  width: var(--resource-label-width);
  padding: 9px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
  white-space: normal;
}

.week-day-title-fill {
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
}

.week-calendar-merged .week-hours,
.week-calendar-merged .week-resource-row {
  display: grid;
  grid-template-columns: var(--resource-label-width) repeat(24, var(--hour-width));
}

.week-calendar-merged .week-hours {
  position: relative;
  top: auto;
  z-index: 7;
}

.week-calendar-merged .corner-cell {
  position: sticky;
  left: 0;
  z-index: 9;
  width: var(--resource-label-width);
  background: #fff8df;
}

.week-calendar-merged .resource-label {
  position: sticky;
  left: 0;
  z-index: 8;
  width: var(--resource-label-width);
}

.week-calendar-merged .hour-cell,
.week-calendar-merged .corner-cell {
  min-height: 34px;
}

.week-calendar-merged .week-timeline {
  grid-column: 2 / span 24;
  background-position-x: 0;
}

@media (max-width: 760px) {
  :root {
    --resource-label-width: 86px;
  }

  .week-day-title-cell {
    width: var(--resource-label-width);
    font-size: 14px;
  }
}


/* v7 fixes */

/* The toolbar itself should not have its own animated background:
   the shared sticky controls block owns the background. */
.calendar-toolbar {
  background: transparent !important;
}

:root[data-theme="dark"] .calendar-toolbar {
  background: transparent !important;
}

/* Make CTA buttons visible inside dark signup cards. */
:root[data-theme="dark"] .btn-dark,
:root[data-theme="dark"] .open-game-card .btn-dark {
  background: #5288c1;
  border-color: #6aa1d8;
  color: #ffffff;
}

:root[data-theme="dark"] .btn-dark:hover,
:root[data-theme="dark"] .open-game-card .btn-dark:hover {
  background: #64a1d7;
}

/* Week view v7:
   - no vertical grid line through day titles;
   - sticky left day title row and floor labels;
   - hour row and game rows use the same two-column structure,
     so they align exactly. */
.week-calendar-merged .week-grid {
  overflow: visible !important;
}

.week-day-title-row {
  position: sticky;
  left: 0;
  z-index: 14;
  display: block !important;
  width: calc(100vw - 24px);
  max-width: 100%;
}

.week-day-title-cell {
  width: 100% !important;
  min-height: 48px;
  border-right: 0 !important;
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-day-title-fill {
  display: none !important;
}

.week-calendar-merged .week-hours {
  display: grid;
  grid-template-columns: var(--resource-label-width) calc(var(--hour-width) * 24) !important;
  position: relative;
  top: auto;
  z-index: 7;
}

.week-hour-strip {
  display: grid;
  grid-template-columns: repeat(24, var(--hour-width));
  min-width: calc(var(--hour-width) * 24);
}

.week-calendar-merged .week-resource-row {
  display: grid;
  grid-template-columns: var(--resource-label-width) calc(var(--hour-width) * 24) !important;
}

.week-calendar-merged .corner-cell,
.week-calendar-merged .resource-label {
  position: sticky !important;
  left: 0 !important;
}

.week-calendar-merged .corner-cell {
  z-index: 13;
}

.week-calendar-merged .resource-label {
  z-index: 12;
}

.week-calendar-merged .week-timeline {
  grid-column: 2;
  width: calc(var(--hour-width) * 24);
  min-width: calc(var(--hour-width) * 24);
  background-size: var(--hour-width) 100%;
}

.week-calendar-merged .hour-cell {
  width: var(--hour-width);
}

@media (max-width: 760px) {
  .week-day-title-row {
    width: calc(100vw - 16px);
  }
}


/* v8 fixes */

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

.signup-title {
  text-align: center;
}

/* Week title rows: keep the day label fixed and prevent the visible
   grid columns from passing through the title area. */
.week-day-title-row {
  position: sticky !important;
  left: 0 !important;
  z-index: 30 !important;
  display: block !important;
  width: 100% !important;
  min-width: 100% !important;
  background: var(--card-strong);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.week-day-title-row::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--card-strong);
}

.week-day-title-cell {
  position: relative !important;
  left: auto !important;
  z-index: 1 !important;
  width: auto !important;
  max-width: calc(100vw - 32px);
  min-height: 48px;
  border-right: 0 !important;
  border-bottom: 0 !important;
  background: transparent !important;
  padding-left: 12px;
}

.week-day-title-fill {
  display: none !important;
}

/* The sticky left cells should stay above the scrolling time/game grid. */
.week-calendar-merged .corner-cell {
  z-index: 24 !important;
}

.week-calendar-merged .resource-label {
  z-index: 23 !important;
}

:root[data-theme="dark"] .week-day-title-row::after,
:root[data-theme="dark"] .week-day-title-row {
  background: var(--card-strong);
}

@media (max-width: 760px) {
  .brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .brand-text {
    font-size: 18px;
  }

  .week-day-title-cell {
    max-width: calc(100vw - 20px);
  }
}


/* v9 week split layout */

:root {
  --week-left-width: 132px;
  --week-day-title-height: 48px;
  --week-hour-row-height: 34px;
}

/* New week architecture:
   fixed left labels column + one shared scrollable timeline column. */
.week-calendar-split {
  display: grid;
  grid-template-columns: var(--week-left-width) minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.week-calendar-split .week-left-column {
  position: relative;
  z-index: 10;
  background: var(--card);
  border-right: 1px solid var(--border);
}

.week-calendar-split .week-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--card);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.week-calendar-split .week-right-grid {
  width: calc(var(--hour-width) * 24);
  min-width: calc(var(--hour-width) * 24);
}

.week-left-day,
.week-right-day {
  display: grid;
  grid-template-rows:
    var(--week-day-title-height)
    var(--week-hour-row-height)
    repeat(3, var(--week-row-height));
  border-bottom: 1px solid var(--border);
}

.week-left-day:last-child,
.week-right-day:last-child {
  border-bottom: 0;
}

.week-left-day-title {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.12;
  overflow: hidden;
}

.week-day-full {
  white-space: normal;
}

.week-day-compact,
.floor-compact {
  display: none;
}

.week-left-hour-spacer {
  min-height: var(--week-hour-row-height);
  border-bottom: 1px solid var(--border);
  background: #fff8df;
}

.week-left-floor-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--week-row-height);
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: #fff8df;
  font-weight: 900;
  text-align: center;
}

.week-left-floor-label:last-child {
  border-bottom: 0;
}

.week-right-day-title-spacer {
  min-height: var(--week-day-title-height);
  border-bottom: 1px solid var(--border);
  background: var(--card-strong);
}

.week-calendar-split .week-hour-strip {
  display: grid;
  grid-template-columns: repeat(24, var(--hour-width));
  min-height: var(--week-hour-row-height);
  border-bottom: 1px solid var(--border);
}

.week-calendar-split .hour-cell {
  width: var(--hour-width);
  min-height: var(--week-hour-row-height);
}

.week-calendar-split .week-timeline {
  position: relative;
  width: calc(var(--hour-width) * 24);
  min-width: calc(var(--hour-width) * 24);
  min-height: var(--week-row-height);
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(
      to right,
      rgba(0,0,0,0.09) 0,
      rgba(0,0,0,0.09) 1px,
      transparent 1px,
      transparent var(--hour-width)
    );
}

.week-calendar-split .week-timeline:last-child {
  border-bottom: 0;
}

:root[data-theme="dark"] .week-left-hour-spacer,
:root[data-theme="dark"] .week-left-floor-label {
  background: #1b2836;
}

:root[data-theme="dark"] .week-right-day-title-spacer,
:root[data-theme="dark"] .week-left-day-title {
  background: var(--card-strong);
}

:root[data-theme="dark"] .week-calendar-split .week-timeline {
  background:
    repeating-linear-gradient(
      to right,
      rgba(255,255,255,0.10) 0,
      rgba(255,255,255,0.10) 1px,
      transparent 1px,
      transparent var(--hour-width)
    );
}

/* Disable older merged-week sticky/grid rules for the new layout. */
.week-calendar-split .week-day-title-row,
.week-calendar-split .week-resource-row,
.week-calendar-split .corner-cell,
.week-calendar-split .resource-label {
  display: none !important;
}

@media (max-width: 760px) {
  :root {
    --week-left-width: 64px;
    --hour-width: 48px;
    --week-day-title-height: 48px;
    --week-hour-row-height: 34px;
    --week-row-height: 76px;
  }

  .week-left-day-title {
    justify-content: center;
    padding: 6px 4px;
    font-size: 13px;
    text-align: center;
  }

  .week-day-full,
  .floor-full {
    display: none;
  }

  .week-day-compact,
  .floor-compact {
    display: inline;
  }

  .week-left-floor-label {
    padding: 4px 2px;
    font-size: 13px;
  }

  .week-calendar-split {
    border-radius: 14px;
  }
}


/* v10 week split layout fixes */

/* v10: hard-reset old week-grid assumptions for the split layout.
   The old .week-timeline rule had grid-column: 2 / span 24, which created
   an implicit empty column in the new right-side grid. That caused the
   visible gap, broken vertical grid, wrong row heights and event overlaps. */
.week-calendar-split .week-left-day,
.week-calendar-split .week-right-day {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows:
    var(--week-day-title-height)
    var(--week-hour-row-height)
    repeat(3, var(--week-row-height)) !important;
  align-items: stretch;
}

.week-calendar-split .week-left-day-title {
  grid-row: 1;
}

.week-calendar-split .week-left-hour-spacer {
  grid-row: 2;
}

.week-calendar-split .week-left-floor-label:nth-of-type(1) {
  grid-row: 3;
}

.week-calendar-split .week-left-floor-label:nth-of-type(2) {
  grid-row: 4;
}

.week-calendar-split .week-left-floor-label:nth-of-type(3) {
  grid-row: 5;
}

.week-calendar-split .week-right-day-title-spacer {
  grid-row: 1;
  grid-column: 1 !important;
}

.week-calendar-split .week-hour-strip {
  grid-row: 2;
  grid-column: 1 !important;
  align-self: stretch;
}

.week-calendar-split .week-timeline {
  grid-column: 1 !important;
  align-self: stretch;
  height: var(--week-row-height);
  min-height: var(--week-row-height);
  max-height: var(--week-row-height);
  margin: 0 !important;
}

.week-calendar-split .week-timeline:nth-of-type(1) {
  grid-row: 3;
}

.week-calendar-split .week-timeline:nth-of-type(2) {
  grid-row: 4;
}

.week-calendar-split .week-timeline:nth-of-type(3) {
  grid-row: 5;
}

.week-calendar-split .week-left-column,
.week-calendar-split .week-scroll,
.week-calendar-split .week-right-grid,
.week-calendar-split .week-left-day,
.week-calendar-split .week-right-day,
.week-calendar-split .week-left-day-title,
.week-calendar-split .week-left-hour-spacer,
.week-calendar-split .week-left-floor-label,
.week-calendar-split .week-right-day-title-spacer,
.week-calendar-split .week-hour-strip,
.week-calendar-split .week-timeline {
  box-sizing: border-box;
}

.week-calendar-split .week-scroll {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

.week-calendar-split .week-right-grid {
  display: block;
  margin-left: 0 !important;
  padding-left: 0 !important;
}

.week-calendar-split .week-timeline {
  overflow: hidden;
}

/* The right-side day-title spacer exists only to keep row heights aligned.
   It should not show hour grid lines or any extra visual content. */
.week-calendar-split .week-right-day-title-spacer {
  background: var(--card-strong);
}

/* Avoid double-thick borders between the left fixed column and right timeline. */
.week-calendar-split .week-left-column {
  border-right: 1px solid var(--border);
}

.week-calendar-split .week-hour-strip,
.week-calendar-split .week-timeline,
.week-calendar-split .week-right-day-title-spacer {
  border-left: 0 !important;
}

/* Make sure event blocks stay inside their own floor row. */
.week-calendar-split .week-event {
  top: 6px;
  height: calc(var(--week-row-height) - 12px);
}


/* v11 week split layout fixes */

/* v11:
   Use explicit row classes instead of nth-of-type. nth-of-type counted the
   title spacer and the hour row too, so floor rows could be auto-placed and
   borders/heights became inconsistent. */
.week-calendar-split .week-floor-row-0 {
  grid-row: 3 !important;
}

.week-calendar-split .week-floor-row-1 {
  grid-row: 4 !important;
}

.week-calendar-split .week-floor-row-2 {
  grid-row: 5 !important;
}

/* Force all week floor rows to draw their separator. */
.week-calendar-split .week-left-floor-label,
.week-calendar-split .week-timeline {
  border-bottom: 1px solid var(--border) !important;
}

.week-calendar-split .week-left-floor-label:last-child,
.week-calendar-split .week-floor-row-2 {
  border-bottom: 0 !important;
}

/* Remove the visual seam/gap between fixed left column and the scroll area.
   The scrollable grid starts under the fixed column border by 1px so there is
   no background strip between them. */
.week-calendar-split {
  column-gap: 0 !important;
}

.week-calendar-split .week-left-column {
  border-right: 1px solid var(--border);
}

.week-calendar-split .week-scroll {
  margin-left: -1px !important;
  padding-left: 0 !important;
  border-left: 0 !important;
}

.week-calendar-split .week-right-grid {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

/* Make the first visible vertical grid line sit exactly at the left edge of
   the scrollable content. */
.week-calendar-split .week-hour-strip {
  border-left: 1px solid var(--border);
}

.week-calendar-split .week-timeline {
  border-left: 1px solid var(--border);
  background-position-x: -1px;
}

/* Keep right and left rows exactly the same height, including borders. */
.week-calendar-split .week-left-day,
.week-calendar-split .week-right-day {
  grid-template-rows:
    var(--week-day-title-height)
    var(--week-hour-row-height)
    repeat(3, var(--week-row-height)) !important;
}


/* v12 left floor order fix */

/* v12:
   Left-side floor labels must not use nth-of-type because the day title and
   hour spacer are also div elements. nth-of-type counted them too, causing
   the visible order 2-4-1 instead of 1-2-4. */
.week-calendar-split .week-left-floor-label {
  grid-row: auto !important;
}

.week-calendar-split .week-left-floor-row-0 {
  grid-row: 3 !important;
}

.week-calendar-split .week-left-floor-row-1 {
  grid-row: 4 !important;
}

.week-calendar-split .week-left-floor-row-2 {
  grid-row: 5 !important;
}


/* v13 cards view and card contrast */

/* Slightly separate signup cards from the parent page/card background. */
.open-game-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.45)),
    var(--card-strong);
  border: 1px solid rgba(0,0,0,0.06);
}

:root[data-theme="dark"] .open-game-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025)),
    #1b2836;
  border-color: rgba(255,255,255,0.08);
}

/* Full floor labels fit in the compact mobile week column. */
@media (max-width: 760px) {
  .week-day-full {
    display: none;
  }

  .floor-full {
    display: inline;
  }

  .floor-compact {
    display: none;
  }
}

/* Calendar cards/list view */
.cards-calendar {
  display: grid;
  gap: 18px;
}

.cards-day-section {
  display: grid;
  gap: 10px;
}

.cards-day-title {
  text-align: center;
  font-size: clamp(20px, 4vw, 30px);
}

.event-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.schedule-card {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  overflow: hidden;
  min-height: 128px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
}

.schedule-card-accent {
  position: absolute;
  inset: 0 0 auto 0;
  height: 8px;
  background: var(--event-color, var(--accent));
}

.schedule-card-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px 8px 10px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-weight: 800;
  text-transform: capitalize;
}

.schedule-card-date strong {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.schedule-card-body {
  min-width: 0;
  padding: 18px 14px 14px;
  line-height: 1.22;
}

.schedule-card-time {
  font-weight: 900;
}

.schedule-card-title {
  margin-top: 4px;
  color: var(--event-color, var(--accent));
  font-weight: 900;
  overflow-wrap: anywhere;
}

.schedule-card-system {
  margin-top: 4px;
  font-weight: 800;
}

.schedule-card-meta {
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

:root[data-theme="dark"] .schedule-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)),
    var(--card-strong);
  border-color: rgba(255,255,255,0.08);
}

@media (max-width: 760px) {
  .event-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .event-cards-grid .schedule-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 10px) / 2);
    min-width: 0;
  }

  .schedule-card {
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 128px;
    border-radius: 15px;
  }

  .schedule-card-date {
    padding: 12px 4px 8px;
    font-size: 11px;
  }

  .schedule-card-date strong {
    font-size: 22px;
  }

  .schedule-card-body {
    padding: 16px 9px 10px;
    font-size: 12px;
  }

  .schedule-card-title {
    font-size: 13px;
  }
}


/* v14 mobile full floor labels */

/* Mobile week view: use full floor labels: `1 этаж`, `2 этаж`, `4 этаж`.
   Keep the left column width unchanged; only reduce font slightly and prevent wrapping. */
@media (max-width: 760px) {
  .week-calendar-split .floor-full {
    display: inline !important;
  }

  .week-calendar-split .floor-compact {
    display: none !important;
  }

  .week-calendar-split .week-left-floor-label {
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
  }
}


/* v15 cards view desktop layout */

/* Calendar `Игры` view:
   desktop uses fixed-width cards, max 4 per row, centered if fewer;
   mobile keeps the previous 2-column compact layout. */
@media (min-width: 761px) {
  .cards-calendar .event-cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 300px));
    justify-content: center;
    align-items: stretch;
  }

  .cards-calendar .schedule-card {
    width: 100%;
  }
}


/* v16 language toggle */

.lang-toggle {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 58px);
  z-index: 200;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 22px;
  cursor: pointer;
  opacity: 0.88;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.lang-toggle:active {
  transform: scale(0.94);
}

.lang-toggle:hover {
  opacity: 1;
}

.lang-toggle-pop {
  animation: lang-toggle-pop 220ms ease;
}

@keyframes lang-toggle-pop {
  0% { transform: scale(0.92); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (max-width: 760px) {
  .lang-toggle {
    width: 44px;
    height: 44px;
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 74px);
    opacity: 0.72;
    font-size: 20px;
  }
}


/* v17 language toggle in navigation */

/* The language switcher now lives in the navbar instead of floating above the
   theme button. The desktop placement is before Calendar with a larger gap. */
.lang-toggle.nav-lang-toggle {
  position: static;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin-right: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card-strong);
  color: var(--text);
  box-shadow: none;
  font-size: 21px;
  cursor: pointer;
  opacity: 0.92;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.lang-toggle.nav-lang-toggle:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.lang-toggle.nav-lang-toggle:active {
  transform: scale(0.94);
}

/* Reset old floating mobile override from v16. */
@media (max-width: 760px) {
  .lang-toggle.nav-lang-toggle {
    position: absolute;
    top: 50%;
    right: 16px;
    bottom: auto;
    width: 42px;
    height: 42px;
    margin-right: 0;
    transform: translateY(-50%);
    opacity: 0.92;
    font-size: 20px;
  }

  .lang-toggle.nav-lang-toggle:hover {
    transform: translateY(-50%);
  }

  .lang-toggle.nav-lang-toggle:active {
    transform: translateY(-50%) scale(0.94);
  }

  .site-header {
    position: relative;
  }

  .main-nav {
    padding-right: 58px;
  }
}


/* v18 navbar language button alignment */

/* Desktop: keep the language button inside the nav, before Calendar.
   The nav itself should remain visually centered; only the gap after the
   language button is enlarged. */
@media (min-width: 761px) {
  .main-nav {
    justify-content: center;
  }

  .lang-toggle.nav-lang-toggle {
    position: static !important;
    margin-right: 28px;
  }
}

/* Mobile: the header has two visual rows:
   1) brand/logo row;
   2) nav buttons row.
   The language button must sit in row 1, aligned with the brand, not between
   the brand and nav. */
@media (max-width: 760px) {
  .site-header {
    position: relative;
  }

  .brand {
    padding-right: 58px;
  }

  .main-nav {
    position: static;
    padding-right: 0;
    justify-content: center;
  }

  .lang-toggle.nav-lang-toggle {
    position: absolute !important;
    top: 16px;
    right: 18px;
    bottom: auto !important;
    width: 42px;
    height: 42px;
    margin: 0;
    transform: none !important;
    opacity: 0.92;
    font-size: 20px;
  }

  .lang-toggle.nav-lang-toggle:hover {
    transform: none !important;
  }

  .lang-toggle.nav-lang-toggle:active {
    transform: scale(0.94) !important;
  }
}


/* v19 mobile language button exact brand-row alignment */

/* v19:
   On mobile the language button is still a child of .main-nav in markup,
   but visually it belongs to the brand row. Anchor it by the brand row height
   instead of by a fixed top offset, and reserve enough space on the right so
   it cannot touch the last nav button in Russian. */
@media (max-width: 760px) {
  .site-header {
    position: relative;
  }

  .brand {
    min-height: 58px;
    padding-right: 66px;
    align-items: center;
  }

  .main-nav {
    position: static;
    display: flex;
    justify-content: center;
    padding-right: 0;
    gap: 10px;
  }

  .lang-toggle.nav-lang-toggle {
    position: absolute !important;
    top: 29px;
    right: 20px;
    bottom: auto !important;
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
    transform: translateY(-50%) !important;
    opacity: 0.94;
    font-size: 18px;
    line-height: 1;
  }

  .lang-toggle.nav-lang-toggle:hover {
    transform: translateY(-50%) !important;
  }

  .lang-toggle.nav-lang-toggle:active {
    transform: translateY(-50%) scale(0.94) !important;
  }
}

@media (max-width: 380px) {
  .main-nav {
    gap: 8px;
  }

  .nav-link {
    padding-left: 14px;
    padding-right: 14px;
  }
}


/* v20 mobile language button final navbar alignment */

/* v20:
   Restore the mobile nav sizing from v18 and make the language button match
   the logo size/alignment. The language button is visually placed in the
   brand row, symmetric to the logo: same size, rounded corners, centered on
   the same vertical axis. */
@media (max-width: 760px) {
  .site-header {
    position: relative;
  }

  .brand {
    min-height: 52px;
    padding-right: 64px;
    align-items: center;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
  }

  .main-nav {
    position: static;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-right: 0;
  }

  .lang-toggle.nav-lang-toggle {
    position: absolute !important;
    top: 26px;
    right: 20px;
    bottom: auto !important;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    border-radius: 14px;
    transform: translateY(-50%) !important;
    opacity: 0.94;
    font-size: 22px;
    line-height: 1;
  }

  .lang-toggle.nav-lang-toggle:hover {
    transform: translateY(-50%) !important;
  }

  .lang-toggle.nav-lang-toggle:active {
    transform: translateY(-50%) scale(0.96) !important;
  }
}

/* Undo the v19 narrow-screen nav compression: it made the total button row
   wider/less predictable on some Telegram WebView widths. */
@media (max-width: 380px) {
  .main-nav {
    gap: 12px;
  }

  .nav-link {
    padding-left: 16px;
    padding-right: 16px;
  }
}


/* v21 language button belongs to brand row on mobile */

/* v21:
   The language button is now placed inside the brand/logo row in HTML.
   This removes the mobile positioning hacks where the button lived in .main-nav
   but was visually pulled into the row above. */
.brand {
  position: relative;
}

.lang-toggle.brand-lang-toggle {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin-left: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card-strong);
  color: var(--text);
  box-shadow: none;
  font-size: 21px;
  cursor: pointer;
  opacity: 0.92;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.lang-toggle.brand-lang-toggle:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.lang-toggle.brand-lang-toggle:active {
  transform: scale(0.94);
}

/* Desktop: keep the language button visually before Calendar, with a larger
   gap than between regular nav links. Because the button is in the brand row,
   move it to the nav line only on desktop via absolute positioning inside the
   header. */
@media (min-width: 761px) {
  .site-header {
    position: relative;
  }

  .lang-toggle.brand-lang-toggle {
    position: absolute;
    left: calc(50% - 275px);
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
  }

  .lang-toggle.brand-lang-toggle:hover {
    transform: translateY(-50%);
  }

  .lang-toggle.brand-lang-toggle:active {
    transform: translateY(-50%) scale(0.94);
  }

  .main-nav {
    justify-content: center;
    padding-left: 72px;
  }
}

/* Mobile: brand row is a real flex row: logo + title on the left, language
   button on the right. The button is exactly the logo size and has rounded
   corners, not a circle. Nav row spacing is restored to the pre-v19 layout. */
@media (max-width: 760px) {
  .site-header {
    position: relative;
  }

  .brand {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding-right: 0;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
  }

  .brand-text {
    min-width: 0;
    flex: 1 1 auto;
  }

  .lang-toggle.brand-lang-toggle {
    position: static !important;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    margin-left: auto;
    border-radius: 14px;
    transform: none !important;
    opacity: 0.94;
    font-size: 22px;
    line-height: 1;
  }

  .lang-toggle.brand-lang-toggle:hover {
    transform: none !important;
  }

  .lang-toggle.brand-lang-toggle:active {
    transform: scale(0.96) !important;
  }

  .main-nav {
    position: static;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-right: 0;
    padding-left: 0;
  }
}

/* Neutralize old v17-v20 rules that targeted the language button while it was
   inside .main-nav. They should not affect the new brand button. */
.lang-toggle.nav-lang-toggle {
  display: none;
}


/* v22 language layout cleanup */

/* v22:
   Mobile and desktop now use separate real buttons:
   - mobile: button in the brand/logo row;
   - desktop: button in the nav row before Calendar.
   This removes the fragile mobile absolute-positioning hacks. */

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row .brand {
  min-width: 0;
}

.lang-toggle {
  border: 1px solid var(--border-strong);
  background: var(--card-strong);
  color: var(--text);
  cursor: pointer;
  opacity: 0.92;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.lang-toggle:hover {
  opacity: 1;
}

.lang-toggle:active {
  transform: scale(0.96);
}

/* Desktop: show language button in the nav row. */
@media (min-width: 761px) {
  .brand-row {
    display: contents;
  }

  .lang-toggle.brand-lang-toggle {
    display: none !important;
  }

  .lang-toggle.nav-lang-toggle {
    display: inline-flex !important;
    position: static !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    margin: 0 22px 0 0;
    padding: 0;
    border-radius: 999px;
    box-shadow: none;
    font-size: 21px;
    line-height: 1;
    transform: none !important;
  }

  .lang-toggle.nav-lang-toggle:hover {
    transform: translateY(-1px) !important;
  }

  .lang-toggle.nav-lang-toggle:active {
    transform: scale(0.96) !important;
  }

  .main-nav {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
}

/* Mobile: show only the brand-row language button.
   It sits at the far right as a normal flex item, same size as the logo. */
@media (max-width: 760px) {
  .site-header {
    position: relative;
  }

  .brand-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .brand-row .brand {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 0;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
  }

  .brand-text {
    min-width: 0;
  }

  .lang-toggle.nav-lang-toggle {
    display: none !important;
  }

  .lang-toggle.brand-lang-toggle {
    display: inline-flex !important;
    position: static !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    margin-left: auto;
    margin-right: 0;
    padding: 0;
    border-radius: 14px;
    box-shadow: none;
    font-size: 22px;
    line-height: 1;
    transform: none !important;
  }

  .lang-toggle.brand-lang-toggle:hover {
    transform: none !important;
  }

  .lang-toggle.brand-lang-toggle:active {
    transform: scale(0.96) !important;
  }

  .main-nav {
    position: static;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding-left: 0;
    padding-right: 0;
  }
}


/* v23 language button text labels */

/* Language switcher now uses bold EN/RU labels instead of flag emoji. */
.lang-toggle.brand-lang-toggle,
.lang-toggle.nav-lang-toggle {
  font-family: inherit;
  font-weight: 900;
  letter-spacing: 0.02em;
}

@media (min-width: 761px) {
  .lang-toggle.nav-lang-toggle {
    font-size: 14px;
  }
}

@media (max-width: 760px) {
  .lang-toggle.brand-lang-toggle {
    font-size: 16px;
  }
}


/* v24 desktop language button rounded rectangle */

/* Desktop language switcher should match the mobile shape:
   rounded rectangle instead of a full circle. */
@media (min-width: 761px) {
  .lang-toggle.nav-lang-toggle {
    border-radius: 14px !important;
  }
}


/* v25 reviews page and signup review links */

.card-actions {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
}

.card-actions .btn,
.card-actions .muted,
.signup-action-btn {
  width: 100%;
}

.signup-review-button {
  margin-bottom: 0;
}

.reviews-page-header-card {
  margin-bottom: 14px;
}

.reviews-intro {
  margin: 0;
}

.reviews-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.review-master-card {
  position: relative;
  scroll-margin-top: 92px;
  overflow: hidden;
}

.review-master-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.review-master-header h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
}

.review-master-username {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 750;
}

.review-list-wrapper {
  position: relative;
  overflow: hidden;
  max-height: 230px;
  transition: max-height 320ms ease;
}

.review-master-card.is-expanded .review-list-wrapper {
  overflow: visible;
}

.review-list {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.review-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 112px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 220ms ease;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0),
    rgba(255,255,255,0.72) 44%,
    var(--card-strong) 92%
  );
}

.review-master-card.is-expanded .review-fade {
  opacity: 0;
}

.review-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.review-item-author {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.review-item-text {
  white-space: pre-line;
  line-height: 1.52;
}

.review-expand-panel {
  position: relative;
  z-index: 2;
  padding-top: 12px;
}

.review-expand-button {
  width: 100%;
  gap: 8px;
}

.review-expand-arrow {
  font-size: 18px;
  line-height: 1;
}

:root[data-theme="dark"] .review-fade {
  background: linear-gradient(
    to bottom,
    rgba(27,40,54,0),
    rgba(27,40,54,0.74) 44%,
    #1b2836 92%
  );
}

@media (min-width: 761px) {
  .review-list-wrapper {
    max-height: 250px;
  }
}

@media (max-width: 760px) {
  .reviews-grid {
    grid-template-columns: 1fr;
  }

  .review-list-wrapper {
    max-height: 220px;
  }
}
