@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f8f0e3;
  --bg-alt: #efe4d0;
  --bg-card: #fffdf7;
  --text: #3a2e22;
  --text-bright: #251c12;
  --text-muted: #8a7660;
  --accent: #b8442a;
  --accent-hover: #9a3520;
  --accent-light: #f5e0d0;
  --accent-glow: rgba(184, 68, 42, 0.15);
  --gold: #c49a2a;
  --gold-muted: #a68430;
  --border: #d9ccba;
  --border-dark: #baa88e;
  --shadow: rgba(60, 40, 20, 0.1);
  --shadow-lg: rgba(60, 40, 20, 0.15);
  --radius: 6px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
  --max-width: 960px;
  --font-display: 'MedievalSharp', cursive;
  --font-body: 'Inter', system-ui, sans-serif;
  --parchment: linear-gradient(135deg, #f8f0e3 0%, #f2e8d5 50%, #ede0c8 100%);
}

[data-theme="dark"] {
  --bg: #18120e;
  --bg-alt: #221a14;
  --bg-card: #2c221a;
  --text: #e2d5c3;
  --text-bright: #f0e6d8;
  --text-muted: #9a8872;
  --accent: #d65a3a;
  --accent-hover: #e87050;
  --accent-light: #3a2018;
  --accent-glow: rgba(214, 90, 58, 0.2);
  --gold: #dba830;
  --gold-muted: #c4982a;
  --border: #3e3024;
  --border-dark: #50402e;
  --shadow: rgba(0, 0, 0, 0.35);
  --shadow-lg: rgba(0, 0, 0, 0.45);
  --parchment: linear-gradient(135deg, #18120e 0%, #1e1610 50%, #201812 100%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg: #18120e;
    --bg-alt: #221a14;
    --bg-card: #2c221a;
    --text: #e2d5c3;
    --text-bright: #f0e6d8;
    --text-muted: #9a8872;
    --accent: #d65a3a;
    --accent-hover: #e87050;
    --accent-light: #3a2018;
    --accent-glow: rgba(214, 90, 58, 0.2);
    --gold: #dba830;
    --gold-muted: #c4982a;
    --border: #3e3024;
    --border-dark: #50402e;
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-lg: rgba(0, 0, 0, 0.45);
    --parchment: linear-gradient(135deg, #18120e 0%, #1e1610 50%, #201812 100%);
    color-scheme: dark;
  }
}

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

html {
  scrollbar-color: var(--border-dark) var(--bg);
  scrollbar-width: thin;
}

body {
  font-family: var(--font-body);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 20% 80%, var(--accent-glow) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, var(--accent-glow) 0%, transparent 50%);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

h1, h2, h3 {
  color: var(--text-bright);
  line-height: 1.2;
}

h1 { font-family: var(--font-display); font-size: 2.6rem; font-weight: 400; letter-spacing: 0.02em; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }

hr {
  border: none;
  border-top: 1px dashed var(--border-dark);
  margin: 2.5rem 0;
}

.site-header {
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border-dark);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px var(--shadow);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--text-bright);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: 0.02em;
  transition: color var(--transition);
}

.site-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-logo .logo-dice {
  display: inline-block;
  font-size: 1.4rem;
  transform: rotate(-12deg);
  transition: transform 0.3s ease;
}

.site-logo:hover .logo-dice {
  transform: rotate(0deg) scale(1.15);
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.site-nav a {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: color var(--transition);
  position: relative;
  padding-bottom: 2px;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.site-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav a:hover::after {
  width: 100%;
}

.hero {
  text-align: center;
  padding: 5rem 1.5rem 3.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: var(--gold);
  border-radius: 2px;
  opacity: 0.6;
}

.hero h1 {
  margin-bottom: 1rem;
  font-size: 3.2rem;
  color: var(--text-bright);
}

.hero h1 .subtitle-tag {
  display: block;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}

.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.section {
  margin-bottom: 3.5rem;
  position: relative;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-bright);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.section-title .icon {
  font-size: 1.2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
}

.card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.4rem 1.6rem;
  text-decoration: none;
  color: var(--text);
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px var(--shadow-lg);
  border-color: var(--accent);
  text-decoration: none;
  color: var(--text);
}

.card:hover::before {
  opacity: 1;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text-bright);
  margin-bottom: 0.4rem;
}

.card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.card-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: var(--accent-light);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.6rem;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 2px 6px var(--shadow);
}

.icon-link:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
  box-shadow: 0 3px 10px var(--shadow-lg);
  transform: translateY(-1px);
}

.icon-link .link-emoji {
  font-size: 1.15rem;
}

.inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  list-style: none;
}

.site-footer {
  border-top: 2px solid var(--border-dark);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  position: relative;
}

.site-footer::before {
  content: '';
  display: block;
  width: 30px;
  height: 3px;
  background: var(--gold);
  margin: 0 auto 1rem;
  border-radius: 2px;
  opacity: 0.5;
}

.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color var(--transition);
}

.page-back:hover {
  color: var(--accent);
  text-decoration: none;
}

.error-page {
  text-align: center;
  padding: 6rem 1.5rem;
}

.error-page h1 {
  font-family: var(--font-display);
  font-size: 6rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.error-page p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.divider-ornament {
  text-align: center;
  margin: 2.5rem 0;
  color: var(--border-dark);
  font-size: 1.1rem;
  letter-spacing: 0.5em;
  user-select: none;
  opacity: 0.5;
}

.theme-switcher {
  display: flex;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.theme-switcher button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.theme-switcher button + button {
  border-left: 1px solid var(--border-dark);
}

.theme-switcher button.active {
  background: var(--accent-light);
  color: var(--accent);
}

.theme-switcher button:hover:not(.active) {
  background: var(--bg-alt);
  color: var(--text-bright);
}

@media (max-width: 640px) {
  .hero h1 { font-size: 2.1rem; }
  .hero { padding: 3rem 1rem 2rem; }
  .content { padding: 0 1rem 3rem; }
  .card-grid { grid-template-columns: 1fr; }
  .site-header-inner { padding: 0 1rem; }
  .site-nav { gap: 1rem; }
  h1 { font-size: 2rem; }
  body { background-image: none; }
}