.language-switcher {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 20px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  z-index: 10020;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(142, 232, 216, 0.36);
  border-radius: 999px;
  background: rgba(5, 8, 18, 0.72);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.26), inset 0 0 18px rgba(142, 232, 216, 0.08);
  backdrop-filter: blur(14px);
}

body.has-main-menu .language-switcher {
  right: calc(env(safe-area-inset-right, 0px) + 92px);
}

body.has-paper-menu .language-switcher {
  right: calc(env(safe-area-inset-right, 0px) + 92px);
}

#header nav a.menu-toggle,
.paper-menu-button {
  width: 54px;
  height: 42px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0;
  line-height: 1;
  letter-spacing: 0;
}

.paper-menu-button {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 20px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  z-index: 10021;
  border: 1px solid rgba(142, 232, 216, 0.36);
  border-radius: 10px;
  color: #f4f3ee;
  background: rgba(5, 8, 18, 0.72);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.26), inset 0 0 18px rgba(142, 232, 216, 0.08);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

#header nav a.menu-toggle::before,
#header nav a.menu-toggle::after {
  display: none;
}

.menu-toggle-lines {
  width: 22px;
  height: 15px;
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
}

.menu-toggle-lines span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 10px rgba(142, 232, 216, 0.28);
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

#header nav a.menu-toggle:hover .menu-toggle-lines span,
#header nav a.menu-toggle:focus-visible .menu-toggle-lines span,
.paper-menu-button:hover .menu-toggle-lines span,
.paper-menu-button:focus-visible .menu-toggle-lines span {
  background: #8ee8d8;
}

.paper-menu-button:focus-visible {
  outline: 2px solid rgba(142, 232, 216, 0.6);
  outline-offset: 3px;
}

.language-switcher a {
  width: 34px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #f4f3ee;
  text-decoration: none;
  border: 1px solid transparent;
  opacity: 0.62;
  transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.language-switcher a:hover,
.language-switcher a:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(142, 232, 216, 0.46);
  outline: none;
}

.language-switcher a[aria-current="true"] {
  opacity: 1;
  background: linear-gradient(135deg, rgba(96, 242, 225, 0.2), rgba(130, 92, 255, 0.2));
  border-color: rgba(142, 232, 216, 0.64);
}

.language-switcher .flag {
  position: relative;
  width: 21px;
  height: 14px;
  display: block;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.language-switcher .flag-jp {
  background: #ffffff;
}

.language-switcher .flag-jp::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #bc002d;
}

.language-switcher .flag-us {
  background: repeating-linear-gradient(
    to bottom,
    #b22234 0,
    #b22234 1.08px,
    #ffffff 1.08px,
    #ffffff 2.16px
  );
}

.language-switcher .flag-us::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 7.6px;
  background: #3c3b6e;
}

.paper-global-menu {
  position: fixed;
  inset: 0;
  z-index: 10030;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
}

.paper-global-menu.is-open {
  display: flex;
}

.paper-global-menu__panel {
  position: relative;
  width: min(920px, 92vw);
  max-height: min(760px, 88vh);
  overflow: auto;
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid rgba(142, 232, 216, 0.34);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(10, 12, 18, 0.98), rgba(18, 24, 32, 0.96)),
    linear-gradient(90deg, rgba(142, 232, 216, 0.08), rgba(108, 60, 255, 0.08));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
}

.paper-global-menu__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.paper-global-menu h2 {
  margin: 0 52px 12px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(142, 232, 216, 0.28);
  color: #fff;
  font: 700 1.12rem/1.25 "Space Grotesk", system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paper-global-menu p {
  margin: 0 52px 18px 0;
  color: rgba(244, 243, 238, 0.76);
  font: 500 0.95rem/1.7 "Noto Sans JP", system-ui, sans-serif;
}

.paper-global-menu__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.paper-global-menu__grid a {
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f4f3ee;
  background: rgba(255, 255, 255, 0.045);
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.paper-global-menu__grid a:hover,
.paper-global-menu__grid a:focus-visible {
  background: rgba(142, 232, 216, 0.1);
  border-color: rgba(142, 232, 216, 0.38);
  transform: translateY(-1px);
  outline: none;
}

.paper-global-menu__grid span {
  color: #8ee8d8;
  font: 700 0.95rem/1.35 "Space Grotesk", system-ui, sans-serif;
}

.paper-global-menu__grid small {
  margin-top: 6px;
  color: rgba(244, 243, 238, 0.7);
  font: 500 0.84rem/1.45 "Noto Sans JP", system-ui, sans-serif;
}

@media (max-width: 760px) {
  .language-switcher {
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    right: calc(env(safe-area-inset-right, 0px) + 12px);
    padding: 4px;
  }

  body.has-main-menu .language-switcher,
  body.has-paper-menu .language-switcher {
    right: calc(env(safe-area-inset-right, 0px) + 72px);
  }

  #header nav a.menu-toggle,
  .paper-menu-button {
    width: 48px;
    height: 38px;
  }

  .paper-menu-button {
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    right: calc(env(safe-area-inset-right, 0px) + 12px);
  }

  .language-switcher a {
    width: 32px;
    height: 28px;
    font-size: 1rem;
  }

  .paper-global-menu {
    padding: 16px;
  }

  .paper-global-menu__panel {
    width: min(100%, 94vw);
    max-height: 88dvh;
    padding: 18px;
  }

  .paper-global-menu h2,
  .paper-global-menu p {
    margin-right: 42px;
  }

  .paper-global-menu__grid {
    grid-template-columns: 1fr;
  }

  .paper-global-menu__grid a {
    min-height: 78px;
  }
}
