/* Global styles */
:root {
  --color-bg: #f5f5f5;
  --color-text: #333333;
  --color-primary: #2196f3;
  --color-surface: #ffffff;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.25);
}

html {
  --font-size: 16px;
  overscroll-behavior: none;
}

body {
  font-family: 'Roboto', Arial, sans-serif;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--font-size);
  line-height: 1.6;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Home page */
.app-header {
  background: var(--color-primary);
  color: #fff;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.app-header .logo {
  height: 32px;
  margin: 0;
  display: block;
}
.site-title {
  font-size: 1.125rem;
  line-height: 1;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(200px,1fr));
  gap: 1.5rem;
  padding: 1rem;
}
.category-card {
  position: relative;
  display: block;
  aspect-ratio: 1;
  background: var(--color-surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .3s;
  min-width: 44px;
  min-height: 44px;
}
.category-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.category-card span {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  padding: .5rem;
  font-weight: bold;
  text-align: center;
}
.category-card:hover {
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}
.category-card:active {
  box-shadow: var(--shadow-sm);
}

/* Content page header */
.section-header {
  color: #fff;
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.section-header .back-arrow {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: inherit;
  padding: 0;
  line-height: 1;
  -webkit-appearance: none;
}

.section-header .icon {
  font-size: 1.5rem;
  margin: 0;
}

.section-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.section-header p {
  margin: 0.25rem 0 0;
}

.section-title {
  text-align: center;
  margin: 1rem 0;
 }

.section-card {
  background: var(--color-surface);
  margin: 1.5rem;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.section-card h3 {
  color: inherit;
  margin-top: 0;
}
.section-card h4 {
  margin-top: 1rem;
  font-size: 1.1rem;
}
.section-card h5 {
  margin-top: 0.75rem;
  font-size: 1rem;
}
.section-card ul {
  margin: 0.5rem 0 1rem 1.25rem;
  padding-left: 1rem;
}
.section-card ul li {
  margin-bottom: 0.5rem;
}
.image-card {
  margin: 1.5rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.image-card img {
  width: 100%;
  height: auto;
  display: block;
}

.font-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 56px;
  height: 56px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.font-popup {
  position: fixed;
  bottom: 4.5rem;
  right: 1rem;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
  display: flex;
  overflow: hidden;
}
.font-popup.hidden { display: none; }
.font-popup button {
  background: none;
  border: none;
  padding: .75rem 1rem;
  font-size: 1.25rem;
  cursor: pointer;
  min-width: 50px;
  min-height: 50px;
}

.font-popup span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  padding: 0 .5rem;
  min-width: 2ch;
}

/* Footer */
.page-footer {
  text-align: center;
  font-size: 0.875rem;
  margin: 2rem 0;
  color: #555;
}

@media (max-width:768px) {
  html { --font-size: 15px; }
  .category-grid { grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); padding: .75rem; gap: 1.25rem; }
  .section-card { margin: 1.25rem; padding: .75rem; }
  .image-card { margin: 1.25rem; }
}

@media (max-width:480px) {
  html { --font-size: 14px; }
  .app-header { padding: 0.675rem 0.75rem; }
  .category-grid { grid-template-columns: repeat(2,1fr); padding: .5rem; gap: 1rem; }
  .category-card { transform: scale(0.9); }
  .category-card span { font-size:0.85rem; }
  .section-card { margin: 1rem; padding: .5rem; }
  .image-card { margin: 1rem; }
}
