/* Global Reset */
* {
  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: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #e0e0e0;
  min-height: 100vh;
}

/* Main App Container - Simple centered approach */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  text-align: center;
  padding: 30px;
  margin-bottom: 40px;
  background: rgba(168, 85, 247, 0.05);
  border-bottom: 3px solid #a855f7;
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.app-header h1 {
  font-size: 3rem;
  background: linear-gradient(135deg, #a855f7 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: -1px;
}

.passage-id {
  color: #888;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

/* Story Content Container */
.story-content {
  flex: 1;
}

/* Passage Card */
.passage {
  background: linear-gradient(135deg, rgba(37, 37, 37, 0.8) 0%, rgba(30, 30, 30, 0.9) 100%);
  padding: 50px;
  border-radius: 16px;
  margin-bottom: 30px;
  line-height: 1.8;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(168, 85, 247, 0.1);
  backdrop-filter: blur(10px);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
}

.passage p {
  margin-bottom: 20px;
}

.passage p:last-child {
  margin-bottom: 0;
}

/* Choices Card */
.choices {
  background: linear-gradient(135deg, rgba(37, 37, 37, 0.8) 0%, rgba(30, 30, 30, 0.9) 100%);
  padding: 50px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(168, 85, 247, 0.1);
  backdrop-filter: blur(10px);
}

.choices h3 {
  margin-bottom: 25px;
  color: #a855f7;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.choice-button {
  display: block;
  width: 100%;
  padding: 18px 24px;
  margin-bottom: 15px;
  background: linear-gradient(135deg, rgba(51, 51, 51, 0.8) 0%, rgba(40, 40, 40, 0.9) 100%);
  color: #e0e0e0;
  border: 2px solid #a855f7;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  position: relative;
}

.choice-button::before {
  content: '→';
  position: absolute;
  right: 20px;
  opacity: 0;
  transition: all 0.3s ease;
}

.choice-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
  color: #ffffff;
  transform: translateX(8px);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}

.choice-button:hover:not(:disabled)::before {
  opacity: 1;
}

.choice-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #555;
}

.choice-button:last-child {
  margin-bottom: 0;
}

/* Ending Card */
.ending {
  text-align: center;
  padding: 60px 40px;
  background: linear-gradient(135deg, rgba(37, 37, 37, 0.8) 0%, rgba(30, 30, 30, 0.9) 100%);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 2px solid #a855f7;
}

.ending h2 {
  color: #a855f7;
  margin-bottom: 30px;
  font-size: 2.5rem;
  font-weight: 700;
}

/* Buttons */
.restart-button,
.small-button {
  padding: 15px 32px;
  background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

.restart-button:hover,
.small-button:hover {
  background: linear-gradient(135deg, #d8b4fe 0%, #a855f7 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.5);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 30px 0;
  margin-top: 40px;
  border-top: 2px solid rgba(168, 85, 247, 0.2);
}

/* Loading & Error States */
.loading,
.error {
  text-align: center;
  padding: 60px 40px;
  background: linear-gradient(135deg, rgba(37, 37, 37, 0.8) 0%, rgba(30, 30, 30, 0.9) 100%);
  border-radius: 16px;
  margin-top: 40px;
  border: 1px solid rgba(168, 85, 247, 0.1);
}

.loading {
  color: #a855f7;
  font-size: 1.5rem;
  font-weight: 500;
}

.error {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.3);
}

.error h2 {
  margin-bottom: 20px;
  font-size: 2rem;
}

.error button {
  margin-top: 20px;
}

/* Story Selection */
.story-select {
  background: linear-gradient(135deg, rgba(37, 37, 37, 0.8) 0%, rgba(30, 30, 30, 0.9) 100%);
  padding: 50px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(168, 85, 247, 0.1);
}

.story-select h2 {
  color: #a855f7;
  margin-bottom: 40px;
  text-align: center;
  font-size: 2rem;
  font-weight: 600;
}

.story-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.story-button {
  padding: 24px;
  background: linear-gradient(135deg, rgba(51, 51, 51, 0.8) 0%, rgba(40, 40, 40, 0.9) 100%);
  color: #e0e0e0;
  border: 2px solid #444;
  border-radius: 12px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.story-button:hover {
  background: linear-gradient(135deg, rgba(58, 58, 58, 0.9) 0%, rgba(48, 48, 48, 1) 100%);
  border-color: #a855f7;
  transform: translateY(-4px);
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.3);
}

.story-button.selected {
  background: linear-gradient(135deg, rgba(42, 74, 106, 0.9) 0%, rgba(32, 64, 96, 1) 100%);
  border-color: #a855f7;
  color: #fff;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}

.start-button {
  display: block;
  width: 100%;
  padding: 20px;
  background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

.start-button:hover {
  background: linear-gradient(135deg, #d8b4fe 0%, #a855f7 100%);
  transform: scale(1.02);
  box-shadow: 0 6px 28px rgba(168, 85, 247, 0.5);
}

/* Markdown Styling */
.passage h1,
.passage h2,
.passage h3,
.passage h4,
.passage h5,
.passage h6 {
  color: #a855f7;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

.passage h1 {
  font-size: 2.2rem;
  border-bottom: 3px solid #a855f7;
  padding-bottom: 0.3em;
}

.passage h2 {
  font-size: 1.8rem;
  border-bottom: 2px solid #444;
  padding-bottom: 0.3em;
}

.passage h3 {
  font-size: 1.5rem;
}

.passage h4 {
  font-size: 1.3rem;
}

.passage strong {
  color: #d8b4fe;
  font-weight: 600;
}

.passage em {
  color: #c084fc;
  font-style: italic;
}

.passage a {
  color: #a855f7;
  text-decoration: none;
  border-bottom: 1px solid #a855f7;
  transition: all 0.2s ease;
}

.passage a:hover {
  color: #c084fc;
  border-bottom-color: #c084fc;
}

.passage code {
  background: rgba(26, 26, 26, 0.6);
  color: #ff6b6b;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.9em;
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.passage pre {
  background: rgba(26, 26, 26, 0.8);
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  border-left: 4px solid #a855f7;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.passage pre code {
  background: none;
  color: #e0e0e0;
  padding: 0;
  border: none;
}

.passage blockquote {
  border-left: 4px solid #a855f7;
  padding-left: 20px;
  margin-left: 0;
  color: #aaa;
  font-style: italic;
  background: rgba(168, 85, 247, 0.05);
  padding: 15px 20px;
  border-radius: 4px;
}

.passage ul,
.passage ol {
  padding-left: 30px;
  margin: 1em 0;
}

.passage li {
  margin: 0.5em 0;
}

.passage hr {
  border: none;
  border-top: 2px solid rgba(168, 85, 247, 0.3);
  margin: 2em 0;
}

.passage img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.5em 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.passage table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.passage th,
.passage td {
  border: 1px solid #444;
  padding: 12px 16px;
  text-align: left;
}

.passage th {
  background: linear-gradient(135deg, rgba(42, 74, 106, 0.9) 0%, rgba(32, 64, 96, 1) 100%);
  color: #c084fc;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.passage td {
  background: rgba(37, 37, 37, 0.5);
}

.passage tr:hover td {
  background: rgba(168, 85, 247, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
  .app {
    padding: 20px 15px;
  }

  .app-header h1 {
    font-size: 2rem;
  }

  .passage,
  .choices,
  .story-select {
    padding: 25px;
  }

  .story-list {
    grid-template-columns: 1fr;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.passage,
.choices,
.ending {
  animation: fadeIn 0.5s ease-out;
}
