* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #000;
  color: #fff;
  overflow: hidden;
}

@media (max-width: 768px) {
  body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

.header {
  padding: 1rem;
  background-color: #111;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.header h1 {
  font-size: 1.5rem;
  color: #fff;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 350px; /* Space for controls panel */
  z-index: 1;
  min-height: 0; /* Allow flexbox to shrink */
  flex-shrink: 1;
}

.rsvp-display {
  text-align: center;
  user-select: none;
  cursor: default;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rsvp-word {
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1.5;
  transition: opacity 0.1s ease-in-out;
}

.rsvp-words-container {
  display: flex;
  flex-direction: row;
  gap: 0.5em;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.rsvp-word-item {
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1.5;
  transition: opacity 0.1s ease-in-out;
}

.rsvp-word-item .char {
  color: #fff;
  transition: color 0.1s;
}

.rsvp-word-item .char.orp {
  color: #ff0000;
  font-weight: 600;
}

.rsvp-word .char {
  color: #fff;
  transition: color 0.1s;
}

.rsvp-word .char.orp {
  color: #ff0000;
  font-weight: 600;
}

.controls-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.98), rgba(0, 0, 0, 0.85));
  border-top: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 100;
  max-height: 50vh;
  overflow-y: auto;
}

.controls-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 150px;
}

.control-group label {
  font-size: 0.875rem;
  color: #aaa;
  text-align: center;
}

.control-group input[type="range"] {
  width: 100%;
  cursor: pointer;
}

.control-group input[type="number"] {
  width: 100%;
  padding: 0.5rem;
  background-color: #222;
  border: 1px solid #444;
  color: #fff;
  border-radius: 4px;
  text-align: center;
}

.control-group select {
  width: 100%;
  padding: 0.5rem;
  background-color: #222;
  border: 1px solid #444;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

.button {
  padding: 0.75rem 1.5rem;
  background-color: #333;
  border: 1px solid #555;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.button:hover {
  background-color: #444;
  border-color: #666;
}

.button:active {
  background-color: #222;
}

.button.primary {
  background-color: #0066cc;
  border-color: #0088ff;
}

.button.primary:hover {
  background-color: #0088ff;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.file-upload-section {
  padding: 2rem;
  text-align: center;
  background-color: #111;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.file-upload-section h2 {
  margin-bottom: 1rem;
  color: #fff;
}

.source-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.source-separator {
  color: #666;
  font-size: 0.875rem;
}

.url-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.url-input {
  flex: 1;
  min-width: 180px;
  padding: 0.75rem 1rem;
  background-color: #222;
  border: 1px solid #444;
  color: #fff;
  border-radius: 6px;
  font-size: 1rem;
}

.url-input::placeholder {
  color: #666;
}

.url-input:focus {
  outline: none;
  border-color: #0066cc;
}

.file-input-wrapper {
  display: inline-block;
  position: relative;
  overflow: hidden;
  margin: 0.5rem;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  left: -9999px;
}

.file-input-label {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: #333;
  border: 1px solid #555;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.file-input-label:hover {
  background-color: #444;
  border-color: #666;
}

.file-name-display {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  color: #aaa;
  font-size: 0.875rem;
  text-align: center;
  word-break: break-word;
}

.music-player {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #333;
}

.music-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.music-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.music-input-group input[type="text"],
.music-input-group input[type="file"] {
  padding: 0.5rem;
  background-color: #222;
  border: 1px solid #444;
  color: #fff;
  border-radius: 4px;
  font-size: 0.875rem;
}

.music-input-group input[type="text"] {
  min-width: 200px;
}

.stats {
  padding: 0.5rem 1rem;
  background-color: rgba(0, 0, 0, 0.7);
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #aaa;
}

.error-message {
  padding: 1rem;
  background-color: #330000;
  border: 1px solid #ff0000;
  color: #ff6666;
  border-radius: 6px;
  margin: 1rem;
  text-align: center;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #aaa;
}

.hidden {
  display: none;
}

/* Screen reader only class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus indicators for keyboard navigation */
button:focus,
input:focus,
select:focus {
  outline: 2px solid #0088ff;
  outline-offset: 2px;
}

/* Ensure buttons are keyboard accessible */
button:disabled {
  cursor: not-allowed;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .app-container {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }

  .header {
    flex-shrink: 0;
    padding: 0.75rem;
  }

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

  .file-upload-section {
    flex-shrink: 0;
    padding: 1rem;
  }

  .file-upload-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .main-content {
    padding: 1rem;
    min-height: 350px;
    margin-bottom: 0;
    flex: 1 1 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
  }

  .rsvp-display {
    min-height: 250px;
    height: 250px;
    padding: 1rem;
    width: 100%;
    max-width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 250px;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .controls-panel {
    max-height: none;
    padding: 1rem;
    position: relative;
    border-top: 1px solid #333;
    flex-shrink: 0;
  }

  .control-group {
    min-width: 120px;
  }

  .button {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
  }

  .music-input-group input[type="text"] {
    min-width: 150px;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0.5rem;
    min-height: 280px;
    flex: 1 1 280px;
  }

  .rsvp-display {
    min-height: 220px;
    height: 220px;
    padding: 0.5rem;
    width: 100%;
    max-width: 100%;
    flex: 0 0 220px;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .controls-panel {
    max-height: none;
    padding: 0.75rem;
    gap: 0.75rem;
    position: relative;
  }

  .controls-row {
    gap: 0.5rem;
  }

  .control-group {
    min-width: 100px;
  }

  .control-group label {
    font-size: 0.75rem;
  }

  .control-group input[type="number"],
  .control-group select {
    padding: 0.375rem;
    font-size: 0.875rem;
  }

  .button {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
  }

  .file-upload-section {
    padding: 0.75rem;
  }

  .file-upload-section h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }

  .file-input-label {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
  }

  .music-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .music-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .music-input-group input[type="text"] {
    min-width: 100%;
    width: 100%;
  }
}
