/* ===========================
   Design System & Layout
   =========================== */

:root {
  /* Base - Retro Light */
  --bg-primary: #f0e6d3;
  --bg-secondary: #fff8ee;
  --bg-surface: rgba(0, 0, 0, 0.03);

  /* Retro Accents */
  --neon-green: #e74c3c;       /* retro red (main accent) */
  --neon-blue: #2980b9;        /* retro blue */
  --neon-purple: #8e44ad;      /* retro purple */
  --neon-pink: #c0392b;        /* deep red */
  --neon-yellow: #e67e22;      /* retro orange */

  /* Text */
  --text-primary: #2a2a3a;
  --text-secondary: #5a5a6a;
  --text-dim: #8a8a9a;

  /* Stat Bar Colors */
  --hp-red: #e74c3c;
  --mp-blue: #2980b9;
  --exp-yellow: #e67e22;

  /* Borders & Effects */
  --border-glow: rgba(231, 76, 60, 0.15);
  --glass-border: rgba(0, 0, 0, 0.1);

  /* RPG Theme */
  --rpg-wood-dark: #5a3a1a;
  --rpg-wood-mid: #8b6914;
  --rpg-wood-light: #b8860b;
  --rpg-parchment: #f5e6c8;
  --rpg-header-bg: #6b4226;
  --rpg-header-text: #f0e0c0;

  /* Spacing */
  --section-padding: 80px 16px;
  --content-max-width: 960px;
}

/* ===========================
   Reset & Base
   =========================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 60px;
}

body {
  position: relative;
  font-family: 'Noto Sans JP', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul {
  list-style: none;
}

.pixel-font {
  font-family: 'DotGothic16', cursive;
}

.neon-green { color: var(--neon-green); }
.neon-blue { color: var(--neon-blue); }
.neon-yellow { color: var(--neon-yellow); }

/* ===========================
   Particles Background (hidden in RPG mode)
   =========================== */

#particles-bg {
  display: none;
}

/* ===========================
   RPG Map Background
   =========================== */

.rpg-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.rpg-bg__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===========================
   RPG Viewport (Grid Container)
   =========================== */

.rpg-viewport {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "nav      nav"
    "profile  ."
    "heading  heading"
    "apps     apps"
    "footer   footer";
  gap: 12px;
  padding: 0 16px 16px;
  pointer-events: none;
}

.rpg-viewport > * {
  pointer-events: auto;
}

/* ===========================
   Opening Overlay
   =========================== */

.opening {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 10vh;
  background: var(--bg-primary);
  cursor: pointer;
}

.opening.is-hidden {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.opening__blur-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, #e8dcc8 0%, var(--bg-primary) 70%);
}

.opening__blur-layer--strong {
  filter: blur(12px);
}

.opening__blur-layer--weak {
  filter: blur(4px);
  opacity: 0;
}

.opening__bg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  z-index: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0;
}

/* Gradient overlay for text readability on top of image */
.opening__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: linear-gradient(
    to bottom,
    rgba(240, 230, 211, 0.95) 0%,
    rgba(240, 230, 211, 0.85) 40%,
    rgba(240, 230, 211, 0.3) 65%,
    transparent 80%
  );
}

.opening__content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.opening__title {
  font-size: clamp(40px, 10vw, 72px);
  color: var(--neon-green);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: 0.1em;
}

.opening__subtitle {
  font-size: clamp(14px, 3vw, 20px);
  color: var(--text-secondary);
  margin-top: 8px;
  letter-spacing: 0.15em;
}

.opening__start {
  font-size: clamp(14px, 3vw, 18px);
  color: var(--neon-green);
  margin-top: 28px;
  letter-spacing: 0.2em;
  text-shadow:
    0 0 8px rgba(240, 230, 211, 1),
    0 0 16px rgba(240, 230, 211, 0.8),
    0 0 24px rgba(240, 230, 211, 0.5);
}

/* ===========================
   Navigation (RPG Header Bar)
   =========================== */

.nav {
  grid-area: nav;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--rpg-parchment);
  border: 4px solid var(--rpg-wood-dark);
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow:
    inset 0 0 0 2px var(--rpg-wood-light),
    0 4px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.nav.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.nav__inner {
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__logo {
  font-size: 18px;
  color: var(--rpg-wood-dark);
  text-shadow: none;
  transition: opacity 0.3s ease;
}

.nav__logo:hover {
  opacity: 0.7;
}

.nav__hamburger {
  display: none;
}

.nav__menu {
  position: static;
  width: auto;
  height: auto;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
  border-left: none;
}

.nav__link {
  font-size: 14px;
  color: var(--rpg-wood-dark);
  letter-spacing: 0.15em;
  transition: color 0.3s ease;
  position: relative;
  padding-left: 20px;
}

.nav__link::before {
  content: '▶';
  position: absolute;
  left: 0;
  font-size: 10px;
  color: var(--neon-green);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav__link:hover {
  color: var(--neon-green);
}

.nav__link:hover::before {
  opacity: 1;
  transform: translateX(0);
}

/* ===========================
   Hero Section
   =========================== */

.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.02) 2px,
      rgba(0, 0, 0, 0.02) 4px
    );
  pointer-events: none;
  z-index: 1;
}

.hero__content {
  position: relative;
  z-index: 2;
}

.hero__title {
  font-size: clamp(48px, 12vw, 88px);
  color: var(--neon-green);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.hero__subtitle {
  font-size: clamp(16px, 3vw, 22px);
  color: var(--neon-blue);
  margin-top: 12px;
  letter-spacing: 0.12em;
  font-weight: 500;
}

.hero__desc {
  font-size: clamp(14px, 2.5vw, 17px);
  color: var(--text-secondary);
  margin-top: 20px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.hero__scroll-indicator {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.2em;
}

.hero__scroll-arrow {
  margin-top: 8px;
  font-size: 14px;
  color: var(--neon-green);
}

/* ===========================
   Section Common (RPG panels)
   =========================== */

.section {
  position: relative;
  z-index: 1;
}

.section__title {
  font-size: clamp(24px, 5vw, 36px);
  text-align: center;
  margin-bottom: 48px;
  color: var(--text-primary);
  letter-spacing: 0.1em;
}

.section__title-icon {
  margin-right: 8px;
}

/* ===========================
   Game Window Component (RPG style)
   =========================== */

.game-window {
  background: var(--rpg-parchment);
  border: 4px solid var(--rpg-wood-dark);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px var(--rpg-wood-light),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

.game-window__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--rpg-header-bg);
  border-bottom: 3px solid var(--rpg-wood-dark);
}

.game-window__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.game-window__dot:nth-child(1) { background: #e74c3c; }
.game-window__dot:nth-child(2) { background: #e67e22; }
.game-window__dot:nth-child(3) { background: #27ae60; }

.game-window__header-title {
  margin-left: 8px;
  font-size: 12px;
  color: var(--rpg-header-text);
  letter-spacing: 0.15em;
}

.game-window__body {
  padding: 20px;
}

/* ===========================
   About / Player Profile (RPG panel)
   =========================== */

.about {
  grid-area: profile;
  align-self: start;
  max-width: 380px;
}

.about__container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile__avatar {
  flex-shrink: 0;
}

.profile__avatar-placeholder {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--neon-green), var(--neon-blue));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25);
  overflow: hidden;
}

.profile__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.profile__info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile__name {
  font-size: 22px;
  color: var(--text-primary);
}

.profile__bio {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.profile__level,
.profile__exp {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile__label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  min-width: 90px;
}

.profile__value {
  font-size: 14px;
}

/* ===========================
   Stat Bars
   =========================== */

.stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-bar__label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 80px;
  letter-spacing: 0.05em;
}

.stat-bar__track {
  flex: 1;
  height: 16px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.stat-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  position: relative;
  transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.stat-bar__fill--hp {
  background: linear-gradient(90deg, var(--hp-red), #f07070);
  box-shadow: none;
}

.stat-bar__fill--mp {
  background: linear-gradient(90deg, var(--mp-blue), #5dade2);
  box-shadow: none;
}

.stat-bar__fill--exp {
  background: linear-gradient(90deg, var(--exp-yellow), #f0a040);
  box-shadow: none;
}

.stat-bar__fill.is-filled::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 2s ease-in-out infinite;
}

.stat-bar__value {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
}

/* ===========================
   Apps Heading
   =========================== */

.apps-heading {
  grid-area: heading;
  font-size: 20px;
  color: var(--rpg-header-text);
  background: var(--rpg-header-bg);
  border: 4px solid var(--rpg-wood-dark);
  box-shadow: inset 0 0 0 2px var(--rpg-wood-light);
  border-radius: 4px;
  padding: 6px 16px;
  text-align: center;
  margin: 0;
}

/* ===========================
   App Cards
   =========================== */

.apps {
  grid-area: apps;
  align-self: end;
}

.apps__container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.app-card {
  background: var(--rpg-parchment);
  border: 4px solid var(--rpg-wood-dark);
  border-radius: 4px;
  padding: 20px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px var(--rpg-wood-light),
    0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.app-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, rgba(231, 76, 60, 0.05), transparent 60%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow:
    inset 0 0 0 2px var(--rpg-wood-light),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

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

.app-card__badge {
  display: inline-block;
  font-size: 10px;
  color: var(--rpg-header-text);
  background: var(--rpg-header-bg);
  border: 2px solid var(--rpg-wood-dark);
  padding: 3px 10px;
  border-radius: 2px;
  margin-bottom: 10px;
  letter-spacing: 0.1em;
}

.app-card__icon-wrapper {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.app-card__icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-card__icon-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e74c3c, #2980b9);
  font-size: 40px;
}

.app-card__title {
  font-size: 18px;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.app-card__subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.app-card__desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-card__tags {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.app-card__tag {
  font-size: 11px;
  color: var(--neon-blue);
  background: rgba(41, 128, 185, 0.08);
  border: 1px solid rgba(41, 128, 185, 0.2);
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.app-card__links {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.app-card__link {
  font-size: 12px;
  color: #fff;
  background: var(--neon-green);
  padding: 6px 16px;
  border: 2px solid var(--rpg-wood-dark);
  border-radius: 2px;
  transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.app-card__link:hover {
  background: #c0392b;
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
  transform: scale(1.05);
}

/* ===========================
   Contact (RPG Modal)
   =========================== */

.contact {
  display: none;
}

.contact.is-open {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  pointer-events: auto;
}

.contact__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.contact__container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 400px;
  width: 90%;
  z-index: 1;
}

.contact__menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact__link {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  color: var(--rpg-wood-dark);
  padding: 10px 16px;
  border-radius: 2px;
  transition: color 0.3s ease, background 0.3s ease;
}

.contact__link:hover {
  color: var(--neon-green);
  background: rgba(231, 76, 60, 0.08);
}

.contact__cursor {
  font-size: 12px;
  color: var(--neon-green);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.contact__link:hover .contact__cursor {
  opacity: 1;
  transform: translateX(0);
}

.contact__note {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* ===========================
   Footer (hidden in RPG mode - DOM kept for shooting.js)
   =========================== */

.footer {
  grid-area: footer;
  position: relative;
  z-index: 1;
  margin-top: 24px;
  padding: 16px;
  background: var(--rpg-header-bg);
  border: 4px solid var(--rpg-wood-dark);
  box-shadow: inset 0 0 0 2px var(--rpg-wood-light);
  border-radius: 4px;
  pointer-events: auto;
}

.footer__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.footer__copy {
  font-size: 12px;
  color: var(--rpg-header-text);
  letter-spacing: 0.1em;
}

.footer__links {
  display: flex;
  gap: 20px;
}

.footer__link {
  font-size: 13px;
  color: var(--rpg-parchment);
  transition: color 0.3s ease;
  position: relative;
}

.footer__link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--neon-blue);
  transition: width 0.3s ease;
}

.footer__link:hover {
  color: var(--neon-blue);
}

.footer__link:hover::after {
  width: 100%;
}

/* ===========================
   Responsive - Mobile (< 768px)
   =========================== */

@media (max-width: 767px) {
  .rpg-viewport {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      "nav"
      "profile"
      "heading"
      "apps"
      "footer";
    min-height: auto;
    gap: 10px;
    padding: 0 8px 8px;
  }

  .about {
    max-width: 100%;
  }

  .apps__container {
    grid-template-columns: 1fr;
  }

  .app-card {
    padding: 16px 12px;
  }

  .app-card__icon-wrapper {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
  }

  .app-card__title {
    font-size: 18px;
  }

  .app-card__desc {
    font-size: 13px;
    margin-bottom: 12px;
    -webkit-line-clamp: 3;
  }

  .nav__menu {
    gap: 16px;
  }

  .nav__link {
    font-size: 12px;
    padding-left: 16px;
  }

  .opening {
    padding-top: 8vh;
  }

  .opening__content {
    padding: 24px 32px;
  }

  .opening__title {
    font-size: clamp(24px, 8vw, 56px);
    white-space: nowrap;
  }
}

/* ===========================
   Reduced Motion
   =========================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}
