:root {
  --sepia: #F5F0E6;
  --cream: #FDF8EF;
  --parchment: #E8DFD0;
  --brown-dark: #3D2914;
  --brown-medium: #5C4033;
  --brown-light: #8B7355;
  --burgundy: #8B2942;
  --burgundy-dark: #6B1F35;
  --gold: #C9A227;
  --gold-light: #D4B94E;
  --ink: #1A1A1A;
}

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

body {
  font-family: 'Libre Baskerville', Georgia, serif;
  background: 
    radial-gradient(ellipse at top, var(--cream) 0%, var(--sepia) 50%, var(--parchment) 100%);
  min-height: 100vh;
  color: var(--brown-dark);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* Header Styles */
.header-container {
  padding: 1.5rem 1rem;
  background: linear-gradient(180deg, var(--brown-dark) 0%, var(--brown-medium) 100%);
  border-bottom: 4px solid var(--gold);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.header-plaque {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.plaque-ornament {
  width: 40px;
  height: 60px;
  background: var(--gold);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  opacity: 0.8;
}

.plaque-content {
  text-align: center;
  padding: 0.5rem 2rem;
  background: linear-gradient(135deg, var(--cream) 0%, var(--parchment) 100%);
  border: 3px solid var(--gold);
  border-radius: 4px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}

.address-number {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 900;
  color: var(--burgundy);
  letter-spacing: 0.2em;
  text-shadow: 1px 1px 0 var(--gold);
}

.main-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brown-dark);
  letter-spacing: 0.15em;
  margin: 0.25rem 0;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--brown-medium);
  font-style: italic;
}

.hat-bread-icon {
  font-size: 1.5rem;
  margin-top: 0.5rem;
  filter: grayscale(30%);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Home Screen */
.home-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.case-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
  max-width: 500px;
}

@media (min-width: 640px) {
  .case-cards {
    grid-template-columns: 1fr 1fr;
    max-width: 700px;
  }
}

.case-card {
  background: linear-gradient(145deg, var(--cream) 0%, var(--parchment) 100%);
  border: 2px solid var(--brown-light);
  border-radius: 8px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

.case-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--burgundy), var(--gold), var(--burgundy));
}

.case-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  border-color: var(--gold);
}

.card-seal {
  font-size: 3rem;
  margin-bottom: 1rem;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.2));
}

.case-card h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--brown-dark);
  margin-bottom: 0.75rem;
}

.case-card p {
  font-size: 0.9rem;
  color: var(--brown-medium);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.card-footer {
  font-size: 0.8rem;
  color: var(--burgundy);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.history-toggle {
  background: var(--brown-dark);
  color: var(--cream);
  border: none;
  padding: 0.75rem 1.5rem;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.history-toggle:hover {
  background: var(--burgundy);
}

/* Categories */
.categories-container {
  text-align: center;
}

.gazette-header {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 900;
  color: var(--brown-dark);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.gazette-subtitle {
  font-style: italic;
  color: var(--brown-medium);
  margin-bottom: 2rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.category-card {
  background: linear-gradient(135deg, var(--cream) 0%, var(--parchment) 100%);
  border: 2px solid var(--brown-light);
  border-radius: 8px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Libre Baskerville', serif;
}

.category-card:hover {
  border-color: var(--gold);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.category-icon {
  font-size: 2rem;
}

.category-name {
  font-size: 0.85rem;
  color: var(--brown-dark);
  font-weight: 600;
}

.back-btn {
  background: transparent;
  border: 2px solid var(--brown-light);
  color: var(--brown-medium);
  padding: 0.75rem 1.5rem;
  font-family: 'Libre Baskerville', serif;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.back-btn:hover {
  border-color: var(--burgundy);
  color: var(--burgundy);
}

/* Investigation */
.investigation-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 400px;
}

.dialogue-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--cream);
  border: 2px solid var(--brown-light);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.dialogue-message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  animation: fadeSlideIn 0.4s ease forwards;
  opacity: 0;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avatar {
  width: 40px;
  height: 40px;
  background: var(--parchment);
  border: 2px solid var(--brown-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.holmes .avatar {
  border-color: var(--burgundy);
}

.watson .avatar {
  border-color: var(--gold);
}

.message-content {
  background: var(--parchment);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--brown-light);
  max-width: calc(100% - 60px);
  position: relative;
}

.holmes .message-content {
  border-left: 3px solid var(--burgundy);
}

.watson .message-content {
  border-left: 3px solid var(--gold);
}

.speaker-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brown-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

.message-content p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--brown-dark);
}

.question-panel {
  background: linear-gradient(135deg, var(--cream) 0%, var(--parchment) 100%);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 1.25rem;
}

.question-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--brown-dark);
  margin-bottom: 1rem;
  text-align: center;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-btn {
  background: var(--cream);
  border: 2px solid var(--brown-light);
  color: var(--brown-dark);
  padding: 0.75rem 1rem;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  text-align: left;
}

.option-btn:hover {
  border-color: var(--burgundy);
  background: var(--parchment);
  transform: translateX(4px);
}

.typing-indicator {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  padding: 1rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--brown-medium);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Solved Screen */
.solved-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.solved-gazette {
  background: var(--cream);
  border: 3px double var(--brown-dark);
  padding: 1.5rem;
  text-align: center;
}

.gazette-masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--brown-dark);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.gazette-date, .gazette-price {
  font-size: 0.7rem;
  color: var(--brown-medium);
  font-style: italic;
}

.gazette-masthead h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.case-headline {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--burgundy);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.case-summary {
  text-align: left;
  border-top: 1px solid var(--brown-light);
  padding-top: 1rem;
}

.diagnosis-text {
  margin-bottom: 1rem;
  line-height: 1.6;
}

.solution-text {
  background: var(--parchment);
  padding: 1rem;
  border-left: 3px solid var(--gold);
  line-height: 1.6;
}

.solved-dialogue {
  max-height: 250px;
}

.new-case-btn {
  background: var(--burgundy);
  color: var(--cream);
  border: none;
  padding: 1rem 2rem;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
  margin: 0 auto;
  display: block;
}

.new-case-btn:hover {
  background: var(--burgundy-dark);
  transform: scale(1.05);
}

/* Recipe */
.recipe-container {
  text-align: center;
}

.recipe-steps {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 2rem 0;
  text-align: left;
}

.recipe-step {
  display: flex;
  gap: 1rem;
  background: var(--cream);
  border: 2px solid var(--brown-light);
  border-radius: 8px;
  padding: 1.25rem;
}

.step-number {
  width: 36px;
  height: 36px;
  background: var(--burgundy);
  color: var(--cream);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  flex-shrink: 0;
}

.step-content h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--brown-dark);
  margin-bottom: 0.5rem;
}

.step-content p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--brown-medium);
  margin-bottom: 0.75rem;
}

.step-quote {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--parchment);
  border-radius: 4px;
  font-size: 0.85rem;
}

.step-quote.holmes {
  border-left: 2px solid var(--burgundy);
}

.step-quote.watson {
  border-left: 2px solid var(--gold);
}

.quote-avatar {
  font-size: 1rem;
}

/* History Panel */
.history-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.history-panel {
  background: var(--cream);
  border: 3px solid var(--gold);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.history-panel h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  color: var(--brown-dark);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  border-bottom: 1px solid var(--brown-light);
  padding-bottom: 1rem;
}

.history-date {
  font-size: 0.75rem;
  color: var(--brown-medium);
}

.history-item h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--burgundy);
  margin: 0.25rem 0;
}

.history-item p {
  font-size: 0.85rem;
  color: var(--brown-medium);
  line-height: 1.4;
}

.close-history {
  background: var(--brown-dark);
  color: var(--cream);
  border: none;
  padding: 0.75rem 1.5rem;
  font-family: 'Libre Baskerville', serif;
  cursor: pointer;
  border-radius: 4px;
  margin-top: 1rem;
  width: 100%;
}

/* Footer */
.footer {
  background: var(--brown-dark);
  padding: 1rem;
  border-top: 3px solid var(--gold);
}

.footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

.footer-date {
  color: var(--parchment);
  font-size: 0.8rem;
  font-style: italic;
}

.footer-quill {
  color: var(--gold);
  font-size: 1.25rem;
}

.footer-link {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.3s ease;
}

.footer-link:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
  .header-plaque {
    flex-direction: column;
    gap: 0;
  }
  
  .plaque-ornament {
    display: none;
  }
  
  .address-number {
    font-size: 1.5rem;
  }
  
  .main-title {
    font-size: 1.25rem;
  }
  
  .gazette-header {
    font-size: 1.5rem;
  }
  
  .case-headline {
    font-size: 1.25rem;
  }
  
  .category-grid {
    grid-template-columns: 1fr 1fr;
  }
}