body,
html {
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height for better mobile support */
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height for better mobile support */
  flex-direction: column;
  overflow: hidden;
  /* Handle iOS safe areas */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: border-box;
}

.header {
  font-family: "Linux Libertine", "Times New Roman", serif;
}

.header-row {
  padding: 10px;
  border-bottom: 1px solid rgb(167, 215, 249);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: baseline;
}

.date {
  font-size: 1.5rem;
  width: 33%;
}

.logo {
  font-size: 2rem;
  width: 33%;
  text-align: center;
}

.logo a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.logo a:hover {
  color: inherit;
  text-decoration: none;
}

.logo-blue {
  color: blue;
  text-decoration: underline;
}

#clicks-left {
  font-size: 1.5rem;
  width: 33%;
  text-align: right;
}

#breadcrumbs {
  display: block;
  width: 100%;
  text-align: center;
  font-family: sans-serif;
}

#breadcrumbs a {
  color: blue;
}

iframe {
  flex-grow: 1;
  border: none;
  margin: 0;
  padding: 0;
}

#loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(255, 255, 255, 0.5);
  z-index: 9999;
}

#overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.7);
}

.results {
  background: white;
  border-radius: 5px;
  width: 45vw;
  margin: 20vh auto;
  padding: 2rem;
}

.results h2 {
  font-weight: 400;
  text-align: center;
  font-size: 2rem;
  margin: 0;
  padding: 0;
}

#click-stats {
  display: flex;
  gap: 0.5rem;
}

#click-order,
#shortest-click-order {
  flex: 1 1 0;
}

.click-order-item {
  display: block;
}

.click-order-item a {
  color: blue;
}

#shortest-click-order {
  text-align: right;
}

#bottom-hr {
  margin: 1.5rem 0 1rem;
}

#share-and-countdown {
  display: grid;
  grid-template-columns: 50% 50%;
}

#countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#live-countdown {
  font-size: 2rem;
}

#share-button {
  display: block;
  text-align: center;
  background: #dfdfdf;
  font-size: 2rem;
  padding: 1rem;
  border-radius: 5px;
  text-decoration: none;
  color: black;
  cursor: pointer;
}

/* Preview modal styles */
#preview-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  padding: 2rem;
  box-sizing: border-box;
}

.preview-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  text-align: center;
}

.preview-header {
  background: white;
  padding: 8px 16px;
  font-size: 1rem;
  font-family: "Linux Libertine", "Times New Roman", serif;
  color: #000000;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#preview-modal-close {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  line-height: 0.5rem;
  cursor: pointer;
  color: #000000;
  padding: 0;
  width: auto;
  height: auto;
}

#preview-modal-close:hover {
  color: #333;
}

#preview-frame {
  width: 100%;
  flex-grow: 1;
  border: none;
}

/* Date change modal styles */
#date-change-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.7);
  z-index: 20000;
  align-items: center;
  justify-content: center;
}

.date-change-content {
  background: white;
  border-radius: 5px;
  width: 45vw;
  margin: 20vh auto;
  padding: 2rem;
  text-align: center;
}

.date-change-content h2 {
  font-weight: 400;
  text-align: center;
  font-size: 2.5rem;
  font-weight: bold;
  margin: 0 0 1rem 0;
  padding: 0;
}

.date-change-content p {
  font-size: 2rem;
  margin: 0.5rem 0;
}

.date-change-buttons {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
  margin-top: 1.5rem;
  flex-direction: row;
}

.date-change-buttons button {
  display: block;
  font-family: "Linux Libertine", "Times New Roman", serif;
  text-align: center;
  background: #dfdfdf;
  font-size: 1.5rem;
  padding: 1rem;
  border-radius: 5px;
  text-decoration: none;
  color: black;
  cursor: pointer;
  border: none;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .date {
    display: none;
  }

  .logo {
    width: auto;
    text-align: left;
  }

  #clicks-left {
    width: auto;
  }

  /* Win/Lose modal adjustments */
  .results {
    width: calc(90vw - 3rem);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    margin: 7.5vh auto;
    padding: 1rem;
  }

  .results h2 {
    flex-shrink: 0;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
  }

  .results hr {
    flex-shrink: 0;
    margin: 0.5rem 0;
  }

  #click-stats {
    flex-direction: column;
    gap: 1rem;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

  #shortest-click-order {
    text-align: left;
  }

  #share-and-countdown {
    grid-template-columns: 1fr;
    gap: 1rem;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: white;
    padding-top: 0.5rem;
  }

  #countdown {
    order: 2;
    font-size: 0.9rem;
  }

  #share-button {
    order: 1;
    font-size: 1.3rem;
    padding: 0.75rem;
  }

  #live-countdown {
    font-size: 1.2rem;
  }

  /* Preview modal adjustments */
  #preview-modal {
    padding: 1rem;
  }

  .preview-header {
    font-size: 0.9rem;
    padding: 6px 12px;
  }

  /* Date change modal adjustments */
  .date-change-content {
    width: calc(90vw - 3rem);
    margin: 10vh auto;
    padding: 1.5rem;
  }

  .date-change-content h2 {
    font-size: 1.8rem;
  }

  .date-change-content p {
    font-size: 1.2rem;
  }

  .date-change-buttons {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .date-change-buttons button {
    font-size: 1.2rem;
    padding: 0.75rem;
  }

  #click-order h3,
  #shortest-click-order h3 {
    font-size: 1rem;
    margin: 0.5rem 0;
  }

  .click-order-item {
    font-size: 0.9rem;
    margin: 0.25rem 0;
  }

  #bottom-hr {
    margin: 0.5rem 0;
  }
}
