:root {
  --theme-bg: linear-gradient(135deg, #1a1d2e, #1f2338, #252841);
  --theme-card: #3d3740;
  --theme-accent: #e67e22;
  --theme-text: #f0ebe5;
  --theme-secondary: #b8b0a8;
  --theme-link-hover: #ff9966;
  
  /* Common dimensions */
  --container-max-width: 1200px;
  --container-padding: 0 24px;
  
  /* Common transitions */
  --transition-fast: all 0.2s ease;
  --transition-normal: all 0.3s ease;
}

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

html, body {
  font-family: 'SF Pro Display', 'Inter', 'Hiragino Sans', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--theme-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  overflow-x: hidden;
  position: relative;
  letter-spacing: 0.01em;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--theme-bg);
  z-index: -2;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 60'%3E%3Cdefs%3E%3CradialGradient id='grad' cx='50%25' cy='50%25' r='50%25' fx='50%25' fy='50%25'%3E%3Cstop offset='9%25' stop-color='%23453842' /%3E%3Cstop offset='10%25' stop-color='%23221e1a' /%3E%3Cstop offset='19%25' stop-color='%23221e1a' /%3E%3Cstop offset='20%25' stop-color='%23453842' /%3E%3Cstop offset='29%25' stop-color='%23453842' /%3E%3Cstop offset='30%25' stop-color='%23221e1a' /%3E%3Cstop offset='39%25' stop-color='%23221e1a' /%3E%3Cstop offset='40%25' stop-color='%23453842' /%3E%3Cstop offset='49%25' stop-color='%23453842' /%3E%3Cstop offset='50%25' stop-color='%23221e1a' /%3E%3Cstop offset='59%25' stop-color='%23221e1a' /%3E%3Cstop offset='60%25' stop-color='%23453842' /%3E%3Cstop offset='69%25' stop-color='%23453842' /%3E%3Cstop offset='70%25' stop-color='%23221e1a' /%3E%3Cstop offset='79%25' stop-color='%23221e1a' /%3E%3Cstop offset='80%25' stop-color='%23453842' /%3E%3Cstop offset='89%25' stop-color='%23453842' /%3E%3Cstop offset='90%25' stop-color='%23221e1a' /%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle fill='url(%23grad)' cy='27' r='57' /%3E%3Ccircle fill='url(%23grad)' cx='100' cy='27' r='57' /%3E%3Ccircle fill='url(%23grad)' cx='50' cy='57' r='57' /%3E%3Ccircle fill='url(%23grad)' cy='87' r='57' /%3E%3Ccircle fill='url(%23grad)' cx='100' cy='87' r='57' /%3E%3C/svg%3E") center center / 42rem auto;
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}

/* Base mixins and utilities */
.container, .language-nav {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--container-padding);
}

/* Header and Navigation */
header {
  padding: 24px 0 12px 0;
  position: relative;
  z-index: 100;
}

.language-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: flex-end;
}

.lang-selector {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
}

.lang-btn, .nav-link {
  background: none;
  border: none;
  color: var(--theme-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition-fast);
  font-family: inherit;
  text-decoration: none;
  position: relative;
}

.lang-btn::after, .nav-link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--theme-accent), var(--theme-link-hover));
  transition: var(--transition-normal);
  transform: translateX(-50%);
}

.lang-btn:hover, .nav-link:hover {
  color: var(--theme-text);
  background: rgba(255, 255, 255, 0.05);
}

.lang-btn:hover::after, .nav-link:hover::after {
  width: 70%;
}

.lang-btn.active {
  color: var(--theme-accent);
  font-weight: 600;
}

.lang-btn.active::after {
  width: 70%;
}

.nav-dot {
  color: var(--theme-secondary);
  opacity: 0.5;
  font-size: 12px;
}

@media (max-width: 768px) {
  .language-nav {
    justify-content: center;
    padding: 0 16px;
  }
  
  .lang-selector {
    gap: 12px;
  }
  
  /* Main content adjustments */
  h1, .main-title {
    font-size: 40px;
  }
  
  h2 {
    font-size: 28px;
  }
  
  .projects-grid {
    grid-template-columns: 1fr;
  }
  
  .project-images-gallery {
    grid-template-columns: 1fr;
  }
  
  .project-app-icon {
    width: 60px;
    height: 60px;
  }
}

/* Common hover effects */
.hover-slide {
  transition: var(--transition-normal);
}

.hover-slide:hover {
  transform: translateX(4px);
}

.hover-3d {
  transition: var(--transition-normal);
}

.hover-3d:hover {
  transform: scale(1.02) rotateY(5deg) rotateX(2deg);
  filter: brightness(1.1) saturate(1.2);
}

.project-link, .project-link.secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  padding: 12px 24px;
  margin: 6px 8px 6px 0;
  border-radius: 20px;
  text-decoration: none;
  color: var(--theme-text);
  border: 1px solid rgba(230, 126, 34, 0.4);
  background: linear-gradient(135deg, rgba(230, 126, 34, 0.08), rgba(230, 126, 34, 0.15));
  cursor: pointer;
  font-size: 15px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-normal);
}

.project-link:hover, .project-link.secondary:hover {
  color: white;
  border-color: var(--theme-accent);
  background: var(--theme-accent);
  box-shadow: 2px 0 12px rgba(230, 126, 34, 0.3);
}

/* Loading state */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Content styling */
#content {
  padding: 0 0 40px 0;
}

/* Portfolio header styling */
h1 {
  font-size: 56px;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

  .main-title {
    font-size: 50px;
    font-weight: 700;
    margin: 40px 0 12px 0;
    letter-spacing: -0.02em;
    line-height: 1.0;
    text-align: left;
    color: #e67e22;
    user-select: none;
    cursor: default;
    display: inline-block;
    width: fit-content;
  }

  .main-title:hover {
    color: #e67e22;
    text-shadow: 2px 0 0 rgba(230, 126, 34, 0.3),
                 4px 0 0 rgba(230, 126, 34, 0.15);
    opacity: 0.9;
  }

  .main-title ruby {
    position: relative;
  }

  .main-title rt {
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 2px;
    opacity: 0.9;
    color: var(--theme-text);
    user-select: none;
  }

  .main-title:hover rt {
    opacity: 0.7;
    color: var(--theme-secondary);
  }

h2 {
  font-size: 32px;
  font-weight: 600;
  margin: 40px 0 24px;
  letter-spacing: -0.01em;
}

p {
  font-size: 17px;
  line-height: 1.5;
  color: var(--secondary-text);
  margin-bottom: 24px;
}

/* Projects grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 32px;
  margin: 40px 0;
}

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--theme-card);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), 
              inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
}

.project-card:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6), 0 0 20px rgba(230, 126, 34, 0.15);
  border-color: var(--theme-accent);
}

/* Project header with app icon and title */
.project-header {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.project-app-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.project-title-section {
  flex-grow: 1;
}

.project-title {
  margin: 0 0 4px 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tech-tag {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 3px 8px;
  color: var(--theme-secondary);
}

.project-date {
  font-size: 1rem;
  color: var(--theme-secondary);
  font-weight: 600;
  opacity: 0.8;
  white-space: nowrap;
}

/* Project images gallery */
.project-media {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  perspective: 1000px;
}

.project-images-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  width: 100%;
  perspective: 1000px;
}

.project-screenshot {
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  aspect-ratio: 16/9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.project-screenshot:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-color: var(--theme-accent);
}

/* Single image handling */
.project-media > .project-screenshot {
  max-height: 350px;
  width: 100%;
  object-fit: contain;
  margin: 0 auto;
  display: block;
}

/* Project content area */
.project-content {
  padding: 18px 20px;
}

.project-description {
  color: var(--theme-text);
  line-height: 1.6;
  margin: 0 0 16px 0;
}

/* Platform icon styling */
.platform-icon {
  font-size: 20px;
  flex-shrink: 0;
  transition: var(--transition-normal);
  opacity: 0.8;
  filter: brightness(0.9);
}

.project-link:hover .platform-icon,
.project-link.secondary:hover .platform-icon {
  opacity: 1;
  transform: scale(1.2);
  filter: brightness(1.2);
}

/* Ensure consistent spacing between icon and text */
.project-link .platform-icon + *,
.project-link.secondary .platform-icon + * {
  margin-left: 0;
}

/* Lightbox styles */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  padding-top: 50px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  display: block;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  margin: auto;
  padding: 0;
  width: 90%;
  max-width: var(--container-max-width);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  color: white;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
}

.lightbox-controls {
  display: flex;
  justify-content: space-between;
  width: 100%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.lightbox-nav {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s;
  pointer-events: auto;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}

.lightbox-caption {
  color: white;
  margin-top: 16px;
  text-align: center;
  font-size: 16px;
  padding: 10px 0;
}

/* Link styling for markdown content */
a {
  color: var(--theme-accent);
  text-decoration: none;
  position: relative;
  font-weight: 500;
}

a:hover {
  color: var(--theme-link-hover);
}

/* Underline effect for content links */
a:not(.project-link):not(.lang-button):not(.nav-link)::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--theme-accent), var(--theme-link-hover));
  transition: width 0.3s ease;
}

a:not(.project-link):not(.lang-button):not(.nav-link):hover::after {
  width: 100%;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  h1, .main-title {
    font-size: 32px;
  }
  
  .container {
    padding: 0 16px;
  }
  
  .project-content {
    padding: 16px;
  }
}

.site-footer {
  width: 100%;
  color: var(--theme-secondary);
  text-align: center;
  padding: 10px 0 25px;
  z-index: 2;
  user-select: none;
  font-weight: 300;
}

body.is-loading {
  overflow: hidden;
}

body.is-loading header,
body.is-loading .main-title,
body.is-loading .site-footer {
  opacity: 0;
}