body {
  font-family: 'Inter', 'Segoe UI', 'Roboto', Arial, sans-serif;
  background: linear-gradient(135deg, #f0f4ff 0%, #f9fafb 100%);
  margin: 0;
  padding: 0;
}

#container {
  max-width: 1500px;
  margin: 32px auto;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 8px 32px #6366f133, 0 1.5px 8px #6366f11a;
  padding: 0 0 32px 0;
}

.top-bar {
  padding: 24px 32px 0 32px;
  background: #f3f4f6cc;
}

.top-bar-label {
  font-weight: 600;
  color: #3730a3;
  margin-right: 12px;
}

.sticky-bar {
  position: sticky;
  top: 0;
  background: #f3f6fdcc;
  z-index: 10;
  padding: 20px 32px 12px 32px;
  border-bottom: 1.5px solid #e0e7ff;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.sticky-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  flex-wrap: wrap;
}

.sticky-bar .game-title {
  cursor:pointer;
}

.sticky-bar h9,
.sticky-bar .game-title {
  margin: 0;
  font-size: 1.6rem;
  color: #3730a3;
  letter-spacing: 1px;
  font-weight: 800;
  flex: 0 0 auto;
  white-space: nowrap;
}

.sticky-bar h9,
.sticky-bar .game-title a:hover {
  text-decoration: none !important;
}

body.dark-mode .sticky-bar h9, .sticky-bar .game-title {
  color: #fbbf24 !important;
}

.sticky-bar h9, .sticky-bar .game-title {
  color: #3730a3 !important;
}


.info-group {
  display: flex;
  align-items: flex-start;
  /* Change from flex-end to flex-start */
  justify-content: space-between;
  gap: 12px;
  font-size: 1.13rem;
  margin-bottom: 0;
  width: 100%;
  flex: 2 1 0;
  /* flex-wrap: wrap; */
}

.info-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Keep horizontal centering */
  justify-content: flex-start;
  /* Add this for vertical top alignment */
  min-width: 70px;
  flex: 1 1 0;
  max-width: 300px;
  word-break: break-word;
  position: relative;
}

.info-label {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 5px;
}

.info-arrow {
  font-size: 1.1rem;
  color: #6366f1;
  margin-bottom: 2px;
  line-height: 1;
  text-align: center;
}

#startPage,
#targetPage,
#currentPage,
#clicks {
  margin-top: 2px;
}

#startPage,
#targetPage {
  color: #3730a3;
  font-weight: 600;
  background: #e0e7ff;
  padding: 2px 10px;
  border-radius: 8px;
  font-size: 1.08em;
}

#currentPage {
  color: #0e2a66;
  font-weight: 600;
  background: #dbeafe;
  padding: 2px 10px;
  border-radius: 8px;
  font-size: 1.08em;
  box-shadow: 0 2px 8px #2563eb11;
}

#clicks {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  /* Match min width of goBack button */
  height: 40px;
  /* Match height of goBack button */
  font-weight: bold;
  color: #059669;
  background: #e0f7ef;
  padding: 0 14px;
  /* Match horizontal padding of goBack */
  border-radius: 8px;
  font-size: 1.05rem;
  box-sizing: border-box;
  box-shadow: 0 2px 8px #05966911;
  margin-right: 8px;
  transition: background 0.2s, box-shadow 0.2s;
}

#startPage,
#targetPage,
#currentPage {
  display: block;
  max-width: 300px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  white-space: normal;
  /* Allow wrapping */
  overflow-wrap: break-word;
  font-size: clamp(0.75em, 1.08em, 1.08em);
  transition: font-size 0.15s;
}

.clicks-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  background: linear-gradient(90deg, #e0f7ef 60%, #dbeafe 100%);
  color: #059669;
  border-radius: 999px;
  padding: 0.35em 1.1em 0.35em 0.9em;
  font-weight: 700;
  font-size: 1.08rem;
  box-shadow: 0 2px 8px #05966911;
  border: 1.5px solid #a7f3d0;
  min-width: 80px;
  transition: background 0.18s, color 0.18s, border 0.18s;
  margin-right: 8px;
}

.clicks-label {
  font-size: 0.98em;
  color: #2563eb;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-right: 0.3em;
  display: flex;
  align-items: center;
  gap: 0.2em;
}

.clicks-label::before {
  content: "👆";
  font-size: 1.1em;
  margin-right: 0.18em;
  vertical-align: middle;
}

.clicks-count {
  font-size: 1.13em;
  color: #059669;
  font-weight: 800;
  margin-left: 0.1em;
}

@media (max-width: 900px) {
  .info-group {
    gap: 16px;
  }

  .info-col {
    min-width: 50px;
  }
}

@media (max-width: 700px) {
  .info-group {
    display: flex;
    align-items: stretch;
    /* All columns same height */
    gap: 6px;
    font-size: 0.98rem;
  }

  .info-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    /* Stretch child to fill height */
    min-width: 0;
    max-width: 100vw;
    flex: 1 1 100%;
  }

  #startPage,
  #targetPage,
  #currentPage {
    display: flex;
    /* Use flex for vertical centering */
    align-items: center;
    /* Vertically center text */
    justify-content: center;
    /* Horizontally center text */
    width: 100%;
    min-height: 48px;
    max-width: 98vw;
    font-size: clamp(0.7em, 0.98em, 0.98em);
    white-space: normal;
    overflow-wrap: break-word;
    text-overflow: ellipsis;
    padding-left: 2px;
    padding-right: 2px;
    box-sizing: border-box;
    height: 100%;
    /* Fill parent .info-col */
  }

  .gamedate {
    font-size: 0.98rem;
    padding: 4px 8px;
    min-width: 90px;
    gap: 4px;
  }

  .gamedate svg {
    width: 16px;
    height: 16px;
  }

  .nav-button {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    padding: 0;
  }

  .nav-actions {
    gap: 6px;
    margin-top: 4px;
  }

  .date-picker-container {
    max-width: 98vw;
    padding: 0.5rem;
    font-size: 0.98rem;
  }

  .date-picker-header h3 {
    font-size: 1rem;
  }

  .month-nav {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
  }

  .calendar-grid {
    gap: 3px;
  }

  .date-cell {
    font-size: 0.95rem;
    padding: 0.25rem 0;
  }
}

#goBack {
  background: #f3f4f6;
  color: #3730a3;
  border: 1.5px solid #c7d2fe;
  border-radius: 7px;
  padding: 8px 22px;
  font-size: 1.05rem;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 1.5px 6px #6366f111;
  transition: background 0.18s, box-shadow 0.18s, border 0.18s, color 0.18s;
  display: flex;
  align-items: center;
  gap: 8px;
}

#goBack:hover:not(:disabled) {
  background: #e0e7ff;
  border-color: #6366f1;
  color: #2563eb;
  box-shadow: 0 3px 12px #6366f122;
}

#goBack:active:not(:disabled) {
  background: #dbeafe;
  border-color: #2563eb;
  color: #3730a3;
}

#goBack:disabled {
  background: #f1f5f9;
  color: #bdbdbd;
  border-color: #e5e7eb;
  cursor: not-allowed;
  box-shadow: none;
}

#resetGame {
  background: linear-gradient(90deg, #f87171 60%, #f43f5e 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 1.05rem;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 2px 8px #f8717111;
  transition: background 0.2s, box-shadow 0.2s;
}

#resetGame:hover {
  background: linear-gradient(90deg, #f43f5e 60%, #f87171 100%);
}

#goBack,
#resetGame {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  min-width: 0;
}

#goBack svg,
#resetGame svg {
  display: block;
}

#goBack:disabled {
  background: #d1d5db;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
}

#playAgainBtn {
  background: linear-gradient(90deg, #f87171 60%, #f43f5e 100%) !important;
  color: #fff !important;
  border: none;
  border-radius: 10px;
  padding: 14px 36px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 8px #f8717111;
  margin-top: 2em;
  transition: background 0.2s, box-shadow 0.2s;
}

#playAgainBtn:hover {
  background: linear-gradient(90deg, #f43f5e 60%, #f87171 100%) !important;
}

#message {
  margin: 8px 0 0 0;
  color: #059669;
  font-weight: 600;
  flex: 1 1 100%;
  font-size: 1.13rem;
  letter-spacing: 0.01em;
}

#article {
  margin: 0 auto;
  padding: 36px 36px 0 36px;
  max-width: 1400px;
  font-size: 1rem;
  /* Changed from 1.15rem to 1rem */
  line-height: 1.7;
  color: #22223b;
  background: #f8fafc;
  border-radius: 14px;
  box-shadow: 0 2px 12px #6366f11a;
  overflow: scroll;
}

#article h1,
#article h2,
#article h3 {
  color: #3730a3;
  margin-top: 1.5em;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#article a {
  color: #2563eb;
  text-decoration: underline;
  transition: color 0.2s;
  font-weight: 500;
}

#article a:hover {
  color: #7c3aed;
  background: #e0e7ff;
  border-radius: 4px;
}

input[type="date"],
#gameDate {
  font-size: 1.08rem;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid #c7d2fe;
  background: #f1f5ff;
  color: #3730a3;
  font-weight: 500;
  margin-right: 8px;
  transition: border 0.2s;
}

input[type="date"]:focus,
#gameDate:focus {
  border: 1.5px solid #6366f1;
  outline: none;
}

.flatpickr-day.selected,
.flatpickr-day.today.selected {
  background: linear-gradient(90deg, #6366f1 60%, #2563eb 100%) !important;
  color: #fff !important;
  border-radius: 50% !important;
}

.flatpickr-day.today {
  border: 2px solid #6366f1 !important;
  border-radius: 50% !important;
}

.wt-datepicker-cell.selected {
  border: 2.5px solid #6366f1;
  box-sizing: border-box;
  z-index: 2;
}
body.dark-mode .wt-datepicker-cell.selected {
  border: 2.5px solid #fbbf24;
}

@media (max-width: 700px) {
  #container {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .sticky-bar {
    padding: 10px 4px 8px 4px;
    gap: 8px;
  }

  .sticky-bar-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
  }

  .sticky-bar h2,
  .sticky-bar .game-title {
    font-size: 1.1rem;
    padding-right: 4px;
    max-width: 50vw;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 15px;
  }

  .sticky-bar .game-title h2 {
    border-bottom: none !important;
    text-decoration: none !important;
  }

  .info-group {
    /* flex-direction: row;
    flex-wrap: wrap; */
    gap: 6px;
    font-size: 0.98rem;
  }

  .info-col {
    min-width: 50px;
    font-size: 0.95rem;
  }

  .nav-container {
    gap: 4px;
    min-width: 0;
    flex-shrink: 1;
  }

  .gamedate {
    font-size: 0.98rem;
    min-width: 80px;
    padding: 4px 8px;
  }

  .nav-button {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
  }

  .nav-actions {
    justify-content: flex-start;
    gap: 8px;
    margin-top: 4px;
  }

  .nav-container {
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 4px;
  }

  .sticky-bar h2 {
    font-size: 1.3rem;
    margin-bottom: 2px;
  }

  #article {
    font-size: 1rem;
    padding: 25px;
  }
}

/* --- Wikipedia Sidebar Table Styling --- */
.sidebar {
  float: right;
  clear: right;
  margin: 0 0 1em 1.5em;
  background: #fff;
  border: 1px solid #8888aa;
  border-radius: 8px;
  font-size: 0.98em;
  max-width: 320px;
  min-width: 180px;
  box-shadow: 0 2px 8px #6366f11a;
  overflow: hidden;
  padding: 0;
  border-spacing: 0;
}

.sidebar td,
.sidebar th {
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
  border: none;
}

.sidebar .sidebar-pretitle,
.sidebar .sidebar-title-with-pretitle,
.sidebar .sidebar-heading {
  font-weight: bold;
  background: #c5c5dd;
  color: #22223b;
  padding: 6px 8px;
  border-top: 1px solid #8888aa;
  border-bottom: 1px solid #8888aa;
  text-align: left;
}

.sidebar .sidebar-title-with-pretitle {
  background: #e9e9f6;
  font-size: 1.08em;
  border-top: none;
}

.sidebar .sidebar-image {
  text-align: center;
  padding: 8px;
  background: none;
}

.sidebar .sidebar-image img {
  display: block;
  margin: 0 auto;
  max-width: 90%;
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 4px #0001;
}

.sidebar .sidebar-content {
  padding: 6px 8px;
  background: none;
  font-size: 0.97em;
}

.sidebar .sidebar-navbar {
  padding: 4px 8px;
  background: #f8f8ff;
  font-size: 0.92em;
  text-align: right;
  border-top: 1px solid #e0e7ff;
}

.sidebar dl,
.sidebar dd,
.sidebar dt {
  margin: 0;
  padding: 0;
}

.sidebar dl {
  margin-top: 4px;
  margin-bottom: 4px;
}

.sidebar dt {
  font-style: italic;
  margin-top: 4px;
}

.sidebar dd {
  margin-left: 0;
  margin-bottom: 2px;
}

@media (max-width: 700px) {
  .sidebar {
    float: none;
    margin: 1em auto;
    max-width: 98vw;
    min-width: 0;
    width: 100%;
  }
}

body.dark-mode .sidebar {
  background: #232323;
  border-color: #444466;
  color: #e5e7eb;
}

body.dark-mode .sidebar .sidebar-pretitle,
body.dark-mode .sidebar .sidebar-title-with-pretitle,
body.dark-mode .sidebar .sidebar-heading {
  background: #23223a;
  color: #fafafa;
  border-color: #444466;
}

body.dark-mode .sidebar .sidebar-navbar {
  background: #18181b;
  color: #bdbdbd;
  border-top: 1px solid #23223a;
}

body.dark-mode {
  background: linear-gradient(135deg, #232323 0%, #18181b 100%) !important;
  color: #e5e7eb !important;
}

body.dark-mode #container {
  background: #232323 !important;
  box-shadow: 0 8px 32px #0008, 0 1.5px 8px #0004;
}

body.dark-mode .top-bar {
  background: #232323cc !important;
}

body.dark-mode .top-bar-label {
  color: #fafafa !important;
}

body.dark-mode .sticky-bar {
  background: #232323cc !important;
  border-bottom: 1.5px solid #2d2d2d !important;
}

body.dark-mode .sticky-bar h9 {
  text-shadow: 0 2px 8px #23232344;
}

body.dark-mode .info-label {
  color: #bdbdbd !important;
}

body.dark-mode .info-arrow {
  color: #fbbf24 !important;
}

body.dark-mode #startPage,
body.dark-mode #targetPage,
body.dark-mode #currentPage {
  color: #fafafa !important;
  background: #2d2d2d !important;
}

body.dark-mode #currentPage {
  color: #fbbf24 !important;
}

body.dark-mode #clicks {
  color: #a3e635 !important;
  background: #232a1a !important;
}

body.dark-mode #clicks .clicks-label {
  color: #FFFFFF;
}

body.dark-mode input[type="date"],
body.dark-mode #gameDate {
  background: #232323 !important;
  color: #fafafa !important;
  border: 1.5px solid #444 !important;
}

body.dark-mode input[type="date"]:focus,
body.dark-mode #gameDate:focus {
  border: 1.5px solid #fbbf24 !important;
}

body.dark-mode .flatpickr-calendar {
  background: #232323 !important;
  color: #e5e7eb !important;
  border: 1px solid #444 !important;
}

body.dark-mode .flatpickr-day {
  background: #232323 !important;
  color: #e5e7eb !important;
  border-radius: 50% !important;
}

body.dark-mode .flatpickr-day.flatpickr-disabled,
body.dark_mode .flatpickr-day.nextMonthDay,
body.dark_mode .flatpickr-day.prevMonthDay {
  color: #444 !important;
  background: #18181b !important;
  opacity: 0.7 !important;
}

body.dark-mode .flatpickr-day.selected,
body.dark-mode .flatpickr-day.today.selected {
  background: #444 !important;
  color: #fff !important;
}

body.dark-mode .flatpickr-day.today {
  border: 2px solid #fbbf24 !important;
}

body.dark-mode .flatpickr-months,
body.dark-mode .flatpickr-month,
body.dark-mode .flatpickr-current-month,
body.dark-mode .flatpickr-weekdays {
  background: #232323 !important;
  color: #fafafa !important;
}

body.dark-mode .flatpickr-monthDropdown-months,
body.dark-mode .flatpickr-current-month input.cur-year {
  background: #232323 !important;
  color: #fafafa !important;
  border: none !important;
}

.settings-modal-content {
  background: #fff;
  color: #222;
  max-width: 440px;
  min-width: 320px;
  padding: 38px 38px 28px 38px;
  border-radius: 20px;
  box-shadow: 0 8px 32px #0003;
  position: relative;
  font-size: 1.13rem;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

body.dark-mode .settings-modal-content {
  background: #232323 !important;
  color: #e5e7eb !important;
}

.settings-modal-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.5rem;
  color: #3730a3;
  font-weight: 800;
  letter-spacing: 1px;
}

body.dark-mode .settings-modal-content h2 {
  color: #fafafa !important;
}

.settings-option-row {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 0;
  padding: 12px 0;
  border-bottom: 1px solid #e0e7ff;
}

.settings-option-row:last-child {
  border-bottom: none;
}

.settings-label-group {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-label {
  font-weight: 600;
  color: #3730a3;
  font-size: 1.08rem;
  margin-bottom: 2px;
}

body.dark-mode .settings-label {
  color: #fafafa !important;
}

.settings-desc {
  color: #64748b;
  font-size: 0.98em;
  margin-top: 2px;
  margin-bottom: 0;
  line-height: 1.5;
}

body.dark-mode .settings-desc {
  color: #bdbdbd !important;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #e0e7ff;
  transition: background 0.2s;
  border-radius: 16px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #6366f1;
  transition: transform 0.2s, background 0.2s;
  border-radius: 50%;
  box-shadow: 0 2px 8px #6366f133;
}

.toggle-switch input:checked+.slider {
  background: #6366f1;
}

.toggle-switch input:checked+.slider:before {
  transform: translateX(22px);
  background: #fff;
}

.toggle-switch input:disabled+.slider {
  background: #d1d5db;
  cursor: not-allowed;
}

.toggle-switch input:disabled+.slider:before {
  background: #bdbdbd;
}

body.dark-mode .slider {
  background: #232323;
}

body.dark-mode .toggle-switch input:checked+.slider {
  background: #fbbf24;
}

body.dark-mode .toggle-switch input:checked+.slider:before {
  background: #232323;
}

.settings-close-btn {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 1.08rem;
  cursor: pointer;
  float: right;
  margin-top: 16px;
  align-self: flex-end;
  font-weight: 600;
  box-shadow: 0 2px 8px #6366f133;
  transition: background 0.2s;
}

body.dark-mode .settings-close-btn {
  background: #444 !important;
  color: #fafafa !important;
}

@media (max-width: 600px) {
  .settings-modal-content {
    max-width: 98vw;
    min-width: 0;
    padding: 18px 8vw 18px 8vw;
  }

  .wt-datepicker-container {
    left: 30% !important;
  }
}

.nav-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.nav-button {
  background: none;
  border: none;
  font-size: 1.6rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.game-date {
  font-size: 1.13rem;
  font-weight: 600;
  color: #2563eb;
  background: #e0e7ff;
  border-radius: 8px;
  padding: 6px 18px;
  min-width: 140px;
  text-align: center;
  user-select: none;
}

.gamedate {
  font-size: 1.13rem;
  font-weight: 600;
  color: #2563eb;
  background: #e0e7ff;
  border-radius: 8px;
  padding: 6px 18px;
  min-width: 140px;
  text-align: center;
  user-select: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: box-shadow 0.15s, background 0.15s, border 0.15s, transform 0.1s;
  border: 2px solid transparent;
}

.gamedate:hover,
.gamedate:focus {
  background: #dbeafe;
  box-shadow: 0 2px 8px #2563eb22;
  border: 2px solid #2563eb;
  outline: none;
  transform: scale(1.03);
}

body.dark-mode .gamedate {
  background: #232323;
  color: #fbbf24;
  border: 2px solid #444;
}

body.dark-mode .gamedate:hover,
body.dark-mode .gamedate:focus {
  background: #18181b;
  border: 2px solid #fbbf24;
  box-shadow: 0 2px 8px #fbbf2422;
}

.gamedate svg rect {
  transition: fill 0.2s, stroke 0.2s;
}

body.dark-mode .gamedate svg rect {
  fill: #18181b;
  stroke: #fbbf24;
}

.date-picker-container {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 0.5rem;
  max-width: 340px;
  width: 100%;
  box-sizing: border-box;
}

body.dark-mode .date-picker-container {
  background: #232323;
  color: #fafafa;
}

.date-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.month-nav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  user-select: none;
  touch-action: manipulation;
  color: inherit;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  width: 100%;
}

.date-cell {
  padding: 0.4rem 0px;
  border-radius: 0.375rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  margin: 1px;
  position: relative;
  font-weight: 500;
}

.date-cell.has-game[data-status="completed"] {
  background-color: #c6f6d5;
  color: #22543d;
  border: 1px solid #9ae6b4;
}

.date-cell.has-game[data-status="started"] {
  background-color: #fefcbf;
  color: #92400e;
  border: 1px solid #f6e05e;
}

.date-cell.has-game[data-status="unsolved"] {
  background-color: #e9f5f9;
  color: #2c5282;
  border: 1px solid #bee3f8;
}

.date-cell.selected {
  border: 2px solid #4a5568;
  box-shadow: 0 0 0 2px #4299e1;
  font-weight: bold;
}

.date-cell.no-game,
.date-cell[disabled] {
  background-color: #f9f9f9;
  color: #a0aec0;
  border: 1px solid #edf2f7;
  cursor: default;
  opacity: 0.5;
}

body.dark-mode .date-cell.has-game[data-status="completed"] {
  background-color: #14532d;
  color: #bbf7d0;
  border: 1px solid #22c55e;
}

body.dark-mode .date-cell.has-game[data-status="started"] {
  background-color: #78350f;
  color: #fde68a;
  border: 1px solid #fbbf24;
}

body.dark-mode .date-cell.has-game[data-status="unsolved"] {
  background-color: #232323;
  color: #60a5fa;
  border: 1px solid #444;
}

body.dark-mode .date-cell.selected {
  border: 2px solid #fbbf24;
  box-shadow: 0 0 0 2px #fbbf24;
}

body.dark-mode .date-cell.no-game,
body.dark-mode .date-cell[disabled] {
  background-color: #18181b;
  color: #444;
  border: 1px solid #232323;
}

.calendar-footer {
  margin-top: 1rem;
  font-size: 0.8rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.calendar-footer span {
  display: flex;
  align-items: center;
}

.calendar-footer .legend-box {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  border-radius: 2px;
  border: 1px solid #ccc;
}

body.dark-mode .nav-button {
  color: #fafafa !important;
  background: #232323 !important;
  border: 1px solid #444 !important;
}

body.dark-mode .nav-button:disabled {
  color: #444 !important;
  background: #18181b !important;
  border: 1px solid #232323 !important;
  opacity: 0.3;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 15px;
  margin-bottom: 0;
  flex: 1 1 0;
  flex-wrap: wrap;
}

@media (max-width: 700px) {
  .nav-actions {
    /* justify-content: flex-start; */
    gap: 8px;
    margin-top: 4px;
    justify-content: center;
    margin-top: 15px;
  }
}

.top-row-flex {
  display: inline;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .top-row-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}

#collapseStickyBarWrapper {
  position: relative;
  z-index: 11;
}

#collapseStickyBar {
  background: #e0e7ff;
  border-radius: 50%;
  margin: 0 auto;
  margin-bottom: 2px;
  transition: color 0.2s, background 0.2s;
}

#collapseStickyBar:hover {
  color: #6366f1;
  background: #dbeafe;
}

.sticky-bar.collapsed .top-row-flex,
.sticky-bar.collapsed #message {
  display: none !important;
}

.sticky-bar.collapsed {
  padding-bottom: 0 !important;
}

@media (max-width: 700px) {
  .top-row-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 20px;
  }

  .info-group {
    /* flex-wrap: wrap; */
    gap: 6px;
  }

  .info-col {
    min-width: 0;
    max-width: 100vw;
    flex: 1 1 100%;
  }

  #startPage,
  #targetPage,
  #currentPage {
    max-width: 98vw;
    font-size: clamp(0.7em, 0.98em, 0.98em);
    white-space: normal;
    /* Allow wrapping */
    overflow-wrap: break-word;
    /* Break long words */
    text-overflow: ellipsis;
    padding-left: 2px;
    padding-right: 2px;
  }
}

.infobox,
.sidebar,
.vertical-navbox,
.navbox {
  float: right;
  margin: 0 0 1em 1.5em;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.98em;
  max-width: 320px;
  box-shadow: 0 2px 8px #6366f11a;
  overflow: auto;
}

/* --- Custom Date Picker --- */
.wt-datepicker-container {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: #fff;
  box-shadow: 0 4px 16px #0002;
  border-radius: 0.75em;
  padding: 1.2em 1em 1em 1em;
  margin-top: 0.5em;
  min-width: 320px;
  max-width: 98vw;
  width: 340px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 1rem;
  color: #22223b;
  display: none;
}

body.dark-mode .wt-datepicker-container {
  background: #232323;
  color: #fafafa;
  box-shadow: 0 4px 16px #0008;
}

.wt-datepicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1em;
}

.wt-datepicker-month {
  font-weight: 700;
  font-size: 1.15em;
  letter-spacing: 0.01em;
}

.wt-datepicker-nav {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 1.5em;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wt-datepicker-nav:focus {
  outline: 2px solid #6366f1;
}
body.dark-mode .wt-datepicker-nav {
  color: #fbbf24;
  background: #232323;
}
.wt-datepicker-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.wt-datepicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.3em;
  font-size: 0.98em;
}
body.dark-mode .wt-datepicker-weekdays {
  color: #bdbdbd;
}

.wt-datepicker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25em;
}

.wt-datepicker-cell {
  position: relative;
  font-size: 1.08em;
  font-weight: 600;
  border: none;
  outline: none;
  background: #e0e7ff;
  color: #2563eb;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border-radius: 0.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.3em;
  width: 2.3em;
  margin: 0 auto;
  user-select: none;
}

.wt-datepicker-cell.available {
  background: #e0e7ff;
  color: #2563eb;
}
.wt-datepicker-cell.started {
  background: #fbbf24;
  color: #fff;
}
.wt-datepicker-cell.completed {
  background: #22c55e;
  color: #fff;
}
.wt-datepicker-cell.unavailable,
.wt-datepicker-cell[disabled] {
  background: #f3f4f6;
  color: #bdbdbd;
  cursor: default;
  opacity: 0.6;
  pointer-events: none;
}

body.dark-mode .wt-datepicker-cell.available {
  background: #232323;
  color: #fbbf24;
}
body.dark-mode .wt-datepicker-cell.started {
  background: #fbbf24;
  color: #232323;
}
body.dark-mode .wt-datepicker-cell.completed {
  background: #22c55e;
  color: #232323;
}
body.dark-mode .wt-datepicker-cell.unavailable,
body.dark-mode .wt-datepicker-cell[disabled] {
  background: #18181b;
  color: #444;
}

.wt-datepicker-footer {
  margin-top: 1em;
  font-size: 0.95em;
  color: #64748b;
  text-align: center;
  display: flex;
  gap: 1.5em;
  justify-content: center;
}
body.dark-mode .wt-datepicker-footer {
  color: #bdbdbd;
}
.wt-datepicker-legend {
  display: flex;
  align-items: center;
  gap: 0.3em;
}
.wt-legend-swatch {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border-radius: 0.25em;
  margin-right: 0.3em;
  border: 1.5px solid #ddd;
  vertical-align: middle;
}
.wt-legend-swatch.available { background: #e0e7ff; border-color: #a5b4fc; }
.wt-legend-swatch.started { background: #fbbf24; border-color: #f59e42; }
.wt-legend-swatch.completed { background: #22c55e; border-color: #16a34a; }


  .top-row-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 20px;
  }

  .info-group {
    /* flex-wrap: wrap; */
    gap: 6px;
  }

  .info-col {
    min-width: 0;
    max-width: 100vw;
    flex: 1 1 100%;
  }

  .info-group {
    display: flex;
    align-items: stretch;
    /* All columns same height */
    gap: 6px;
    font-size: 0.98rem;
  }

  .info-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    /* Stretch child to fill height */
    min-width: 0;
    max-width: 100vw;
    flex: 1 1 100%;
  }

  #startPage,
  #targetPage,
  #currentPage {
    display: flex;
    /* Use flex for vertical centering */
    align-items: center;
    /* Vertically center text */
    justify-content: center;
    /* Horizontally center text */
    width: 100%;
    min-height: 48px;
    max-width: 98vw;
    font-size: clamp(0.7em, 0.98em, 0.98em);
    white-space: normal;
    overflow-wrap: break-word;
    text-overflow: ellipsis;
    padding-left: 2px;
    padding-right: 2px;
    box-sizing: border-box;
    height: 100%;
    padding: 10px;
    /* Fill parent .info-col */
  }
#targetHint {
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
}
#targetHint:hover {
  opacity: 1;
}