:root {
  --paper-cream: #F5F5DC;
  --tan: #D2B48C;
  --dark-brown: #8B4513;
  --charcoal: #2C2C2C;
  --black: #1A1A1A;
  --sepia: #704214;
  
  --font-heading: 'Cinzel', serif;
  --font-body: 'Crimson Text', serif;

  --bg: #0d0a08;
  --panel: #1a1410;
  --panel-alt: #0f0c0a;
  --line: #2d2420;
  --text: #f5e6d3;
  --text-dim: #c4b5a0;
  --accent: #d4af37;
  --accent-700: #a0826d;
  --accent-glow: rgba(212, 175, 55, .18);
  --container: min(1200px, 92%);
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 500px at 80% -10%, var(--accent-glow), transparent 60%), var(--bg);
  color: var(--text);
  font-family: 'Crimson Text', serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex; 
  flex-direction: column; 
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
.container { width: var(--container); margin: 0 auto; }

/* Header Styles - Match main RedM page */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: blur(10px);
  z-index: 1000;
  padding: 1rem 0;
  border-bottom: 2px solid var(--dark-brown);
}

.header__inner { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 16px; 
  padding: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.brand { 
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--tan);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

.brand:hover {
  color: var(--paper-cream);
  text-decoration: none;
}

.brand__logo { 
  width: 50px;
  height: 50px;
  object-fit: contain; 
}

.brand__name { 
  font-weight: 600;
  letter-spacing: .2px; 
  font-family: 'Cinzel', serif;
}

.nav__list { 
  display: flex; 
  gap: 18px; 
  list-style: none; 
  margin: 0; 
  padding: 0; 
}

.nav__link { 
  color: var(--tan);
  font-family: var(--font-heading);
  font-weight: 500;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.nav__link:hover { 
  background: var(--dark-brown);
  color: var(--paper-cream);
  text-decoration: none;
}

/* Main Layout */
.site-main {
  flex: 1;
  padding: 0;
  padding-top: 73px;
}

.rules-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 120px);
  max-width: 1400px;
  margin: 0 auto;
}

/* Sidebar Styles */
.rules-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 73px;
  height: calc(100vh - 73px);
  overflow-y: auto;
}

.sidebar-content {
  padding: 1.5rem 0;
}

.search-container {
  position: relative;
  margin: 0 1rem 1.5rem 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: 'Crimson Text', serif;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input::placeholder {
  color: var(--text-dim);
}

.search-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.sidebar-nav {
  padding: 0;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list li {
  margin: 0;
}

.nav-item {
  display: block;
  padding: 0.75rem 1.5rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  outline: none;
}

.nav-item:hover {
  background: var(--panel-alt);
  color: var(--text);
  border-left-color: var(--accent);
}

.nav-item.active {
  background: var(--panel-alt);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item.filtered-out {
  display: none;
}

/* Content Styles */
.rules-content {
  padding: 2rem;
  background: var(--bg);
}

.rules-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}

.rules-header h1 {
  margin: 0 0 1rem 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0.02em;
  font-family: 'Cinzel', serif;
}

.rules-subtitle {
  font-size: 1.125rem;
  color: var(--text-dim);
  margin: 0 0 1rem 0;
  max-width: 65ch;
  line-height: 1.6;
}

.last-updated {
  font-size: 0.875rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Rule Sections */
.rule-section {
  margin-bottom: 3rem;
  scroll-margin-top: 100px;
}

.rule-section h2 {
  margin: 0 0 1.5rem 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--accent);
  font-family: 'Cinzel', serif;
}

.rule-list {
  display: grid;
  gap: 1.5rem;
}

.rule-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rule-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.rule-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.rule-number {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 50px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}

.rule-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Cinzel', serif;
}

.rule-description {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.rule-description p {
  margin: 0 0 1rem 0;
}

.rule-description p:last-child {
  margin-bottom: 0;
}

.rule-description ul,
.rule-description ol {
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.rule-description li {
  margin-bottom: 0.5rem;
}

.rule-description strong {
  color: var(--accent);
  font-weight: 600;
}

.rule-description em {
  color: var(--accent-700);
}

.rule-description img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1rem 0;
  border: 2px solid var(--line);
}

.rule-item.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

/* Search Highlighting */
.search-highlight {
  background: var(--accent);
  color: #0d0a08;
  padding: 0.1em 0.2em;
  border-radius: 3px;
  font-weight: 600;
}

/* Loading/Error States */
.loading-message,
.error-message {
  text-align: center;
  padding: 3rem;
  font-size: 1.2rem;
  color: var(--text-dim);
  font-style: italic;
}

.error-message {
  color: #d97706;
}

/* Quill Font Size Classes */
.ql-size-small {
  font-size: 0.75em;
}

.ql-size-large {
  font-size: 1.5em;
}

.ql-size-huge {
  font-size: 2.5em;
}

/* Apply font sizes in rule content */
.rule-item .ql-size-small,
.rules-content .ql-size-small {
  font-size: 0.75em;
}

.rule-item .ql-size-large,
.rules-content .ql-size-large {
  font-size: 1.5em;
}

.rule-item .ql-size-huge,
.rules-content .ql-size-huge {
  font-size: 2.5em;
}

/* Footer - Match main RedM page */
.site-footer {
  background: var(--black);
  color: var(--tan);
  padding: 2rem 0;
  border-top: 2px solid var(--dark-brown);
  margin-top: auto;
}

.footer__inner { 
  padding: 0;
  display: flex; 
  flex-direction: column;
  align-items: center; 
  justify-content: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.footer__inner p {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  margin: 0;
  color: var(--tan);
}

.footer__socials { 
  display: flex;
  align-items: center; 
  gap: 1rem;
}

.social-btn { 
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--dark-brown);
  color: var(--paper-cream);
  border-radius: 50%;
  transition: all 0.3s ease;
  text-decoration: none;
}

.social-btn:hover { 
  background: var(--tan);
  color: var(--black);
  text-decoration: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--dark-brown);
  color: var(--paper-cream);
  padding: 1rem 1.5rem;
  border-radius: 6px;
  font-family: var(--font-heading);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 3000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Scrollbar Styling */
.rules-sidebar::-webkit-scrollbar {
  width: 6px;
}

.rules-sidebar::-webkit-scrollbar-track {
  background: var(--panel-alt);
}

.rules-sidebar::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.rules-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .rules-container {
    grid-template-columns: 250px 1fr;
  }
  
  .rules-content {
    padding: 1.5rem;
  }
  
  .nav-item {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 768px) {
  .header__inner,
  .footer__inner {
    padding: 0 1rem;
  }

  .rules-container {
    grid-template-columns: 1fr;
  }
  
  .rules-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  
  .sidebar-content {
    padding: 1rem;
  }
  
  .search-container {
    margin: 0 0 1rem 0;
  }
  
  .nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .nav-item {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border-left: none;
    background: var(--panel-alt);
    font-size: 0.8rem;
    white-space: nowrap;
  }
  
  .nav-item:hover,
  .nav-item.active {
    background: var(--accent);
    color: #0d0a08;
    border-left: none;
  }
  
  .rules-content {
    padding: 1rem;
  }
  
  .rules-header h1 {
    font-size: 1.75rem;
  }
  
  .rule-section {
    margin-bottom: 2rem;
  }
  
  .rule-section h2 {
    font-size: 1.5rem;
  }
  
  .rule-item {
    padding: 1rem;
  }
  
  .rule-title {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .brand {
    font-size: 1rem;
  }

  .brand__logo {
    width: 40px;
    height: 40px;
  }

  .brand__name {
    font-size: 0.9rem;
  }
  
  .nav__list {
    gap: 12px;
  }
  
  .nav__link {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }
  
  .rules-content {
    padding: 0.75rem;
  }
  
  .rules-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }
  
  .rules-subtitle {
    font-size: 1rem;
  }
  
  .nav-item {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
}

/* Print styles */
@media print {
  .rules-sidebar,
  .site-header,
  .site-footer {
    display: none;
  }
  
  .rules-container {
    grid-template-columns: 1fr;
  }
  
  .rules-content {
    padding: 0;
  }
  
  .rule-item {
    break-inside: avoid;
    background: white;
    color: black;
    border: 1px solid #ccc;
  }
}
