/* Mobile-specific styles */
@media (max-width: 768px) {

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  #game-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
  }

  .screen {
    height: 100vh;
    overflow: hidden;
  }

  /* Remove this to prevent screen-level scrolling conflicts */
  /* .screen.active {
    overflow-y: auto;
  } */

  /* Backstory screen specific fix */
  #backstory-screen {
    overflow: hidden;
    height: 100vh;
  }

  #backstory-screen .story-container {
    min-height: 80vh;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-top: 5vh;
    box-sizing: border-box;
  }

  /* Title screen adjustments */
  .title-layout {
    flex-direction: column;
  }

  .logo-container {
    width: 80%;
    height: 40%;
  }

  .title-content {
    width: 100%;
    height: 60%;
    padding: 20px;
  }

  #title-screen h1 {
    font-size: 36px;
    margin-bottom: 10px;
  }

  #title-screen h2 {
    font-size: 20px;
    margin-bottom: 30px;
  }

  #title-screen .button-container {
    width: 80%;
  }

  /* Game area adjustments */
  .game-area {
    flex-direction: column;
  }

  .story-container {
    margin-right: 0;
    margin-bottom: 20px;
    border-right: none;
    border-bottom: 1px solid var(--warm-dark);
    max-height: 150px;
  }

  .grid-container {
    margin-right: 0;
    margin-bottom: 20px;
  }

  .words-container {
    display: none;
    /* Hide desktop word list */
  }

  /* Mobile word list */
  .mobile-word-list {
    display: block;
    max-height: 150px;
    overflow-y: auto;
    background-color: var(--warm-medium);
    border-radius: 8px;
    padding: 8px;
    margin: 10px 0;
    list-style-type: none;
    border: 1px solid var(--primary-light);
  }

  .mobile-word-list li {
    padding: 6px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--warm-dark);
    color: #333;
    font-weight: 500;
  }

  .mobile-word-list li.found {
    text-decoration: line-through;
    color: var(--accent-dark);
    opacity: 0.7;
  }

  /* Book container adjustments */
  .book-container {
    width: 90%;
    height: 75vh;
    max-height: 500px;
  }

  /* Mobile timer */
  .mobile-timer-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background-color: var(--warm-light);
    z-index: 100;
  }

  .mobile-timer-bar {
    height: 100%;
    width: 100%;
    background-color: var(--primary-light);
    transition: width 1s linear;
  }

  /* Collapsible story toggle */
  .story-toggle {
    display: block;
    width: 100%;
    text-align: center;
    background-color: var(--primary-lighter);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px;
    margin-top: 5px;
    font-size: 12px;
  }

  .story-container.expanded {
    max-height: 300px;
  }

  /* Grid cell size adjustment */
  .grid-cell {
    font-size: 16px;
  }

  /* Button size adjustments */
  button {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  #title-screen h1 {
    font-size: 28px;
  }

  #title-screen h2 {
    font-size: 16px;
  }

  #title-screen button {
    padding: 8px 16px;
    font-size: 12px;
  }

  .grid-cell {
    font-size: 14px;
  }

  .story-container {
    max-height: 100px;
  }

  .book-title {
    font-size: 22px;
  }

  button {
    padding: 8px 16px;
    font-size: 12px;
  }
}