/* Layout and screen management */

#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: white;
  border-bottom: 2px solid #e0e0e0;
  padding: 0.5rem 1rem;
  height: 3.5rem;
  /* display: flex !important; */
  /* justify-content: space-between; */
  /* flex-direction: row; */
}

.header-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.header-container h1 {
  font-size: 1.25rem;
  margin: 0;
}

.header-container .btn-secondary {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  min-height: auto;
  width: auto;
}

#app {
  min-height: 100vh;
  position: relative;
}

.screen {
  display: none;
  min-height: 100vh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 100dvh;
  overflow-y: auto;
  padding: 0;
  animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
  display: block;
}

.screen.with-header {
  padding-top: 3.5rem; /* Account for fixed header */
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Screen-specific layouts */
#setup-screen .container,
#names-screen .container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 2rem);
}

#ready-screen .container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: calc(100vh - 2rem);
}

#game-screen .container {
  max-width: 600px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 4rem); /* Account for header */
}

#game-screen.with-header .container {
  height: calc(100vh - 3.5rem); /* Account for header when visible */
  height: calc(100dvh - 3.5rem); /* Account for header when visible */
}

/* Names form layout */
#names-form {
  margin-bottom: 2rem;
}

#names-form .form-group {
  margin-bottom: 1rem;
}

/* Game screen layout */
.game-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #f5f5f5;
  margin: -1rem -1rem 1rem -1rem;
  padding: 1rem;
}

.playbar {
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: #f5f5f5;
  margin: -1rem;
  padding: 1rem;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  margin-bottom: -0.5rem;
}

/* Responsive adjustments */
@media (min-width: 768px) {
  .container {
    padding: 3rem 2rem;
  }

  #game-screen .container {
    padding: 2rem;
  }

  .game-header {
    position: static;
    margin: 0 0 1.5rem 0;
    border-radius: 12px;
  }

  .playbar {
    position: static;
    margin: 1.5rem 0;
    border-radius: 16px;
    border: 2px solid #e0e0e0;
  }

  #timeline-container {
    max-height: 50vh;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 700px;
  }

  #game-screen .container {
    max-width: 800px;
  }
}

/* Landscape mobile adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  .container {
    padding: 1rem;
  }

  #timeline-container {
    max-height: 40vh;
  }

  .screen {
    padding: 0.5rem;
  }
}

/* Safe area support for devices with notches */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .game-header {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .playbar {
    padding-bottom: max(0.2rem, env(safe-area-inset-bottom));
  }
}
