/* Light mode */
:root {
    --md-sys-color-primary: rgb(143 75 57);
    --md-sys-color-surface-tint: rgb(143 75 57);
    --md-sys-color-on-primary: rgb(255 255 255);
    --md-sys-color-primary-container: rgb(255 219 209);
    --md-sys-color-on-primary-container: rgb(114 53 36);
    --md-sys-color-secondary: rgb(119 87 78);
    --md-sys-color-on-secondary: rgb(255 255 255);
    --md-sys-color-secondary-container: rgb(255 219 209);
    --md-sys-color-on-secondary-container: rgb(93 64 56);
    --md-sys-color-tertiary: rgb(108 93 46);
    --md-sys-color-on-tertiary: rgb(255 255 255);
    --md-sys-color-tertiary-container: rgb(246 225 166);
    --md-sys-color-on-tertiary-container: rgb(83 70 25);
    --md-sys-color-error: rgb(186 26 26);
    --md-sys-color-on-error: rgb(255 255 255);
    --md-sys-color-error-container: rgb(255 218 214);
    --md-sys-color-on-error-container: rgb(147 0 10);
    --md-sys-color-background: rgb(255 248 246);
    --md-sys-color-on-background: rgb(35 25 23);
    --md-sys-color-surface: rgb(255 248 246);
    --md-sys-color-on-surface: rgb(35 25 23);
    --md-sys-color-surface-variant: rgb(245 221 216);
    --md-sys-color-on-surface-variant: rgb(83 67 63);
    --md-sys-color-outline: rgb(133 115 110);
    --md-sys-color-outline-variant: rgb(216 194 188);
    --md-sys-color-shadow: rgb(0 0 0);
    --md-sys-color-scrim: rgb(0 0 0);
    --md-sys-color-inverse-surface: rgb(57 46 43);
    --md-sys-color-inverse-on-surface: rgb(255 237 233);
    --md-sys-color-inverse-primary: rgb(255 181 161);
    --md-sys-color-primary-fixed: rgb(255 219 209);
    --md-sys-color-on-primary-fixed: rgb(58 10 1);
    --md-sys-color-primary-fixed-dim: rgb(255 181 161);
    --md-sys-color-on-primary-fixed-variant: rgb(114 53 36);
    --md-sys-color-secondary-fixed: rgb(255 219 209);
    --md-sys-color-on-secondary-fixed: rgb(44 21 15);
    --md-sys-color-secondary-fixed-dim: rgb(231 189 178);
    --md-sys-color-on-secondary-fixed-variant: rgb(93 64 56);
    --md-sys-color-tertiary-fixed: rgb(246 225 166);
    --md-sys-color-on-tertiary-fixed: rgb(35 27 0);
    --md-sys-color-tertiary-fixed-dim: rgb(217 197 141);
    --md-sys-color-on-tertiary-fixed-variant: rgb(83 70 25);
    --md-sys-color-surface-dim: rgb(232 214 210);
    --md-sys-color-surface-bright: rgb(255 248 246);
    --md-sys-color-surface-container-lowest: rgb(255 255 255);
    --md-sys-color-surface-container-low: rgb(255 241 237);
    --md-sys-color-surface-container: rgb(252 234 230);
    --md-sys-color-surface-container-high: rgb(247 228 224);
    --md-sys-color-surface-container-highest: rgb(241 223 218);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --md-sys-color-primary: rgb(255 181 161);
    --md-sys-color-surface-tint: rgb(255 181 161);
    --md-sys-color-on-primary: rgb(86 31 16);
    --md-sys-color-primary-container: rgb(114 53 36);
    --md-sys-color-on-primary-container: rgb(255 219 209);
    --md-sys-color-secondary: rgb(231 189 178);
    --md-sys-color-on-secondary: rgb(68 42 35);
    --md-sys-color-secondary-container: rgb(93 64 56);
    --md-sys-color-on-secondary-container: rgb(255 219 209);
    --md-sys-color-tertiary: rgb(217 197 141);
    --md-sys-color-on-tertiary: rgb(59 47 5);
    --md-sys-color-tertiary-container: rgb(83 70 25);
    --md-sys-color-on-tertiary-container: rgb(246 225 166);
    --md-sys-color-error: rgb(255 180 171);
    --md-sys-color-on-error: rgb(105 0 5);
    --md-sys-color-error-container: rgb(147 0 10);
    --md-sys-color-on-error-container: rgb(255 218 214);
    --md-sys-color-background: rgb(26 17 15);
    --md-sys-color-on-background: rgb(241 223 218);
    --md-sys-color-surface: rgb(26 17 15);
    --md-sys-color-on-surface: rgb(241 223 218);
    --md-sys-color-surface-variant: rgb(83 67 63);
    --md-sys-color-on-surface-variant: rgb(216 194 188);
    --md-sys-color-outline: rgb(160 140 136);
    --md-sys-color-outline-variant: rgb(83 67 63);
    --md-sys-color-shadow: rgb(0 0 0);
    --md-sys-color-scrim: rgb(0 0 0);
    --md-sys-color-inverse-surface: rgb(241 223 218);
    --md-sys-color-inverse-on-surface: rgb(57 46 43);
    --md-sys-color-inverse-primary: rgb(143 75 57);
    --md-sys-color-primary-fixed: rgb(255 219 209);
    --md-sys-color-on-primary-fixed: rgb(58 10 1);
    --md-sys-color-primary-fixed-dim: rgb(255 181 161);
    --md-sys-color-on-primary-fixed-variant: rgb(114 53 36);
    --md-sys-color-secondary-fixed: rgb(255 219 209);
    --md-sys-color-on-secondary-fixed: rgb(44 21 15);
    --md-sys-color-secondary-fixed-dim: rgb(231 189 178);
    --md-sys-color-on-secondary-fixed-variant: rgb(93 64 56);
    --md-sys-color-tertiary-fixed: rgb(246 225 166);
    --md-sys-color-on-tertiary-fixed: rgb(35 27 0);
    --md-sys-color-tertiary-fixed-dim: rgb(217 197 141);
    --md-sys-color-on-tertiary-fixed-variant: rgb(83 70 25);
    --md-sys-color-surface-dim: rgb(26 17 15);
    --md-sys-color-surface-bright: rgb(66 55 52);
    --md-sys-color-surface-container-lowest: rgb(20 12 10);
    --md-sys-color-surface-container-low: rgb(35 25 23);
    --md-sys-color-surface-container: rgb(39 29 27);
    --md-sys-color-surface-container-high: rgb(50 40 37);
    --md-sys-color-surface-container-highest: rgb(61 50 48);
  }
}

/* Global styles */
body {
  font-family: 'Roboto', sans-serif;
  padding: 24px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  transition: background 0.3s ease, color 0.3s ease;
}

h1 {
  text-align: center;
  margin-bottom: 32px;
}

/* Card layout */
.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  max-width: 1000px;
  margin: 0 auto;
}

.card {
  background: var(--md-sys-color-surface-container);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.card-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}

.card h2 {
  font-size: 1.25rem;
  margin: 8px 0 16px 0;
  color: var(--md-sys-color-on-surface);
}

/* Button style */
md-filled-button {
  --md-filled-button-container-color: var(--md-sys-color-primary);
  --md-filled-button-label-text-color: var(--md-sys-color-on-primary);
}

/* Dialog theme (Material 3 native) */
#linksDialog {
  --md-dialog-container-color: var(--md-sys-color-surface-container);
  --md-dialog-headline-color: var(--md-sys-color-on-surface);
  --md-dialog-supporting-text-color: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-on-surface);
}

/* Dialog content formatting */
#dialogContent {
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
  max-height: 400px;
  padding-right: 8px;
}

#dialogContent a {
  color: #1a73e8;
  text-decoration: underline;
}

#dialogContent h1, 
#dialogContent h2, 
#dialogContent h3 {
  margin: 12px 0 8px 0;
}

#dialogContent strong {
  font-weight: 600;
}
/* --- Desktop optimization --- */
md-dialog#linksDialog {
  --md-dialog-container-max-width: 900px;
  --md-dialog-container-min-width: 600px;
  width: 80vw;
  max-width: 900px;
}
#dialogContent {
  padding: 16px 24px;
}
/* --- 404 Error icon --- */
.error-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px auto 16px;
}

.error-icon img {
  width: 48px;
  height: 48px;
  filter: brightness(0) invert(1);
}
.site-footer {
  margin-top: 48px;
  padding: 16px;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.6;
}