* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background: #f4f4f4;
  color: #333;
}

header {
  background: #e46c87;
  color: #fff;
  text-align: center;
  position: relative;
  padding: 2rem 1rem 4rem;
}

.header-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.title-image {
  height: 40px;
  width: auto;
  vertical-align: middle;
}

header h1 {
  margin: 0;
  position: relative;
  z-index: 1;
}

.header-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  z-index: 0;
}

main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

#story-init,
#story-view {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#story-init textarea,
#user-option textarea {
  width: 100%;
  min-height: 100px;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.settings-group textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  resize: vertical;
}

button {
  background: #e46c87;
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #c23c5c;
}

.hidden {
  display: none;
}

#story-path p {
  background: #f7e1e5;
  padding: 0.8rem;
  border-left: 4px solid #e46c87;
  margin: 0.5rem 0;
  border-radius: 4px;
}

.ai-option {
  background: #faf0f2;
  border: 1px solid #e46c87;
  border-radius: 4px;
  margin: 0.5rem 0;
  padding: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.5s ease-in;
}

.ai-option p {
  margin: 0;
  flex-grow: 1;
  padding-right: 1rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Simple spinner */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #e46c87;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* New styles for AI settings */
#ai-settings {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#ai-settings h3 {
  margin-top: 0;
  color: #e46c87;
}

.settings-group {
  margin-bottom: 1rem;
}

.settings-group.label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: bold;
}

.settings-group select, 
.settings-group input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
}

.settings-toggle {
  background: #f7e1e5;
  color: #e46c87;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  cursor: pointer;
  font-weight: bold;
}

.settings-toggle:hover {
  background: #f0c9d0;
}

.settings-group.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.advanced-settings {
  border-top: 2px solid #eee;
  padding-top: 1rem;
  margin-top: 1rem;
}

.custom-option {
  display: none;
  margin-top: 0.5rem;
  animation: fadeIn 0.3s ease-out;
}

select:has(option[value="custom"]:checked) + .custom-option {
  display: block;
}

.story-ending {
  background: #f7e1e5;
  border: 2px solid #e46c87;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  animation: fadeIn 0.5s ease-in;
}

.story-ending h3 {
  color: #e46c87;
  margin-top: 0;
  text-align: center;
  font-size: 1.2rem;
}

.story-ending p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

#end-story-btn {
  background: #8b1338;
  margin-top: 1rem;
  margin-bottom: 1rem;
  transition: background 0.3s;
}

#end-story-btn:hover {
  background: #6a0f2a;
}

#end-story-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Tab navigation */
nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 2;
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
}

nav li {
  margin: 0 10px;
}

.tab-btn {
  background: #c23c5c;
  padding: 0.5rem 1rem;
  border-radius: 4px 4px 0 0;
  border: none;
  color: white;
  cursor: pointer;
}

.tab-btn.active {
  background: #fff;
  color: #e46c87;
  font-weight: bold;
}

.tab-content {
  display: block;
}

.tab-content.hidden {
  display: none;
}

/* Community tab styles */
#community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.community-story-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  transition: transform 0.2s;
}

.community-story-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.community-story-card h3 {
  color: #e46c87;
  margin-top: 0;
}

.community-story-card p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: #666;
}

.community-story-card .story-preview {
  height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1rem;
}

.community-story-card button {
  width: 100%;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

#submit-to-community {
  margin-top: 1rem;
  text-align: center;
}

#submit-story-btn {
  background: #2ecc71;
}

#submit-story-btn:hover {
  background: #27ae60;
}

.comment-bubble {
  background: #fff;
  border-radius: 15px;
  padding: 1rem;
  margin: 0.5rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.comment-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.comment-author img {
  width: 25px;
  height: 25px;
  border-radius: 50%;
}

.comment-content {
  margin-left: 35px;
  color: #444;
}

.like-button {
  background: none;
  border: 2px solid #e46c87;
  padding: 0.3rem 1rem;
  transition: all 0.3s;
}

.like-button:disabled {
  background: #e46c87;
  color: white;
  opacity: 0.7;
}

.story-node {
  margin: 1rem 0;
  padding: 0;
}

.story-image-container {
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.story-image {
  width: 100%;
  height: auto;
  display: block;
}

.add-image-btn {
  background: #3498db;
  margin-left: 0.5rem;
}

.add-image-btn:hover {
  background: #2980b9;
}

#save-story-btn:hover {
  background: #2980b9;
}

/* Add music player styles */
.music-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  backdrop-filter: blur(5px);
  z-index: 1000;
}

.music-player .track-info {
  font-size: 0.7em;
  color: #666;
  margin-bottom: 8px;
  text-align: center;
  font-style: italic;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.progress-container, .progress-bar {
  display: none;
}

.time-display {
  font-size: 0.8em;
  color: #666;
  display: flex;
  justify-content: space-between;
}

.volume-container {
  display: flex;
  align-items: center;
  gap: 5px;
}

#volume-slider {
  width: 80px;
}

canvas.visualizer {
  width: 200px;
  height: 60px;
  margin-top: 10px;
  border-radius: 4px;
}